84 lines
4.2 KiB
HTML
84 lines
4.2 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="ru">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title>Файлы — Morozovka Portal</title>
|
||
<style>
|
||
body { background: #0d1117; color: #e6edf3; font-family: sans-serif; padding: 40px; }
|
||
.container { max-width: 1000px; margin: 0 auto; }
|
||
h1 { color: #58a6ff; margin-top: 0; }
|
||
|
||
.upload-box { background: #161b22; border: 1px dashed #30363d; border-radius: 8px; padding: 30px; text-align: center; margin-bottom: 30px; }
|
||
.upload-box input[type="file"] { display: none; }
|
||
.upload-label { display: inline-block; padding: 10px 20px; background: #21262d; border: 1px solid #30363d; border-radius: 5px; cursor: pointer; font-weight: bold; margin-bottom: 15px; }
|
||
.upload-label:hover { background: #30363d; }
|
||
.upload-btn { background: #238636; color: white; border: none; padding: 10px 20px; border-radius: 5px; font-weight: bold; cursor: pointer; }
|
||
.upload-btn:hover { background: #2ea043; }
|
||
#file-name-display { margin-left: 15px; color: #8b949e; font-size: 0.9rem; }
|
||
|
||
table { width: 100%; border-collapse: collapse; background: #161b22; border-radius: 8px; overflow: hidden; }
|
||
th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #30363d; }
|
||
th { background: #21262d; color: #8b949e; font-size: 0.85rem; text-transform: uppercase; }
|
||
tr:hover { background: #21262d; }
|
||
|
||
.btn-download { color: #58a6ff; text-decoration: none; font-weight: bold; }
|
||
.btn-download:hover { text-decoration: underline; }
|
||
.btn-delete { background: none; border: none; color: #da3633; cursor: pointer; font-weight: bold; }
|
||
.btn-delete:hover { text-decoration: underline; }
|
||
|
||
.back-link { display: block; margin-bottom: 20px; color: #8b949e; text-decoration: none; }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="container">
|
||
<a href="/" class="back-link">← На главную</a>
|
||
<h1>Файлохранилище</h1>
|
||
|
||
<div class="upload-box">
|
||
<form action="/files/upload" method="POST" enctype="multipart/form-data">
|
||
<label for="file-upload" class="upload-label">Выбрать файл</label>
|
||
<input id="file-upload" type="file" name="file" required onchange="document.getElementById('file-name-display').textContent = this.files[0].name">
|
||
<span id="file-name-display">Файл не выбран</span>
|
||
<br><br>
|
||
<button type="submit" class="upload-btn">Загрузить (макс 100 МБ)</button>
|
||
</form>
|
||
</div>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Имя файла</th>
|
||
<th>Размер</th>
|
||
<th>Загрузил</th>
|
||
<th>Дата</th>
|
||
<th>Действия</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for db_file, uploader_name in files %}
|
||
<tr>
|
||
<td><strong>{{ db_file.original_name }}</strong></td>
|
||
<td>{{ (db_file.size_bytes / 1024 / 1024) | round(2) }} МБ</td>
|
||
<td>{{ uploader_name }}</td>
|
||
<td>{{ db_file.uploaded_at|msk_strftime('%d.%m.%Y %H:%M') }}</td>
|
||
<td style="display: flex; gap: 15px;">
|
||
<a href="/files/download/{{ db_file.id }}" class="btn-download">Скачать</a>
|
||
|
||
{% if session.get('role') == 'admin' or db_file.uploaded_by == session.get('user_id') %}
|
||
<form action="/files/{{ db_file.id }}/delete" method="POST" onsubmit="return confirm('Удалить файл?');">
|
||
<button type="submit" class="btn-delete">Удалить</button>
|
||
</form>
|
||
{% endif %}
|
||
</td>
|
||
</tr>
|
||
{% else %}
|
||
<tr>
|
||
<td colspan="5" style="text-align: center; color: #8b949e;">Файлов пока нет. Загрузите первый!</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</body>
|
||
</html>
|