morozovka-portal/app/templates/files_history.html

120 lines
5.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% extends "base.html" %}
{% block title %}История версий — {{ db_file.original_name }}{% endblock %}
{% block main_class %}container container-narrow{% endblock %}
{% block content %}
<div class="breadcrumbs-bar">
<a href="/files">Файлы</a>
{% if db_file.space_id %}
<span class="sep">/</span>
<a href="/files/space/{{ db_file.space_id }}">Пространство</a>
{% endif %}
{% if db_file.folder_id %}
<span class="sep">/</span>
<a href="/files/folder/{{ db_file.folder_id }}">Папка</a>
{% endif %}
<span class="sep">/</span>
<span class="current">История — {{ db_file.original_name }}</span>
</div>
<div class="files-hero">
<div class="files-hero-left">
<h1>🕘 История версий</h1>
<p class="subtitle">
{{ db_file.original_name }}
· <strong style="color:#58a6ff;">v{{ db_file.version }}</strong>
· {{ db_file.size_bytes|format_size }}
</p>
</div>
<div class="files-hero-actions">
<a href="/files/download/{{ db_file.id }}" class="btn btn-primary">⬇ Скачать текущую</a>
</div>
</div>
{% if perms.can_edit and db_file.space_id %}
<div class="form-card" style="margin-bottom:20px;">
<h3 style="margin-top:0;font-size:15px;">Загрузить новую версию</h3>
<form action="/files/{{ db_file.id }}/new_version" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label>Файл *</label>
<input type="file" name="file" required>
</div>
<div class="form-group">
<label>Комментарий к версии</label>
<input type="text" name="comment" placeholder="Например: обновил раздел 2.3" maxlength="200">
</div>
<div class="form-actions" style="margin-top:8px;padding-top:8px;">
<button type="submit" class="btn btn-primary">Загрузить v{{ (db_file.version or 1) + 1 }}</button>
</div>
</form>
</div>
{% endif %}
<div class="files-section">
<div class="files-section-head">
<h2>📚 Версии <span class="count">{{ versions|length }}</span></h2>
</div>
{% if versions %}
<table class="meta-table">
<thead>
<tr>
<th>Версия</th>
<th>Размер</th>
<th>Автор</th>
<th>Дата</th>
<th>Комментарий</th>
<th>Действия</th>
</tr>
</thead>
<tbody>
{% for v, u in versions %}
<tr {% if v.id == db_file.current_version_id %}style="background:rgba(88,166,255,0.08);"{% endif %}>
<td>
<span style="display:inline-block;padding:2px 8px;border-radius:8px;background:rgba(88,166,255,0.15);color:#58a6ff;border:1px solid rgba(88,166,255,0.3);font-weight:700;font-size:11px;">v{{ v.version_num }}</span>
{% if v.id == db_file.current_version_id %}
<small style="color:#3fb950;margin-left:6px;font-weight:600;">← текущая</small>
{% endif %}
</td>
<td>{{ v.size_bytes|format_size }}</td>
<td>
<div style="font-weight:500;">{{ u.full_name or u.username }}</div>
<div style="color:var(--text-muted);font-size:11px;">@{{ u.username }}</div>
</td>
<td>{{ v.uploaded_at|msk_strftime('%d.%m.%Y %H:%M') }}</td>
<td style="color:var(--text-muted);font-size:12px;">{{ v.comment or '—' }}</td>
<td>
<div style="display:flex;gap:6px;flex-wrap:wrap;">
<a href="/files/{{ db_file.id }}/version/{{ v.id }}/download" class="btn btn-default btn-sm">Скачать</a>
{% if perms.can_edit and v.id != db_file.current_version_id %}
<form action="/files/{{ db_file.id }}/revert/{{ v.id }}" method="POST" style="display:inline;" onsubmit="return confirm('Откатиться к v{{ v.version_num }}? Будет создана новая версия v{{ (db_file.version or 1) + 1 }} с содержимым v{{ v.version_num }}.');">
<button type="submit" class="btn btn-default btn-sm">↺ Откатить</button>
</form>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="files-empty">
<div class="icon">📚</div>
<h3>Версий нет</h3>
<p>Файл загружен в старой схеме (без пространства) — версий нет. Или это первый файл в пространстве, и запись о версии отсутствует.</p>
</div>
{% endif %}
</div>
<div style="margin-top:24px;">
{% if db_file.folder_id %}
<a href="/files/folder/{{ db_file.folder_id }}" class="btn btn-default">← К папке</a>
{% elif db_file.space_id %}
<a href="/files/space/{{ db_file.space_id }}" class="btn btn-default">← К пространству</a>
{% else %}
<a href="/files" class="btn btn-default">← Все файлы</a>
{% endif %}
</div>
{% endblock %}