first commit

This commit is contained in:
2026-04-20 11:56:11 +03:00
commit 8d80fadb56
103 changed files with 19756 additions and 0 deletions

View File

@@ -0,0 +1,154 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Редактирование тренера</title>
<style>
:root {
--bg: #0f1115;
--panel: #171a21;
--panel-2: #1d222b;
--border: #2b3240;
--text: #e8ecf3;
--muted: #9aa4b2;
--accent: #4f8cff;
--shadow: 0 10px 30px rgba(0, 0, 0, .35);
--radius: 16px;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
background: var(--bg);
color: var(--text);
font-family: Arial, sans-serif;
}
.page {
max-width: 900px;
margin: 0 auto;
padding: 24px;
}
.panel {
background: var(--panel);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
padding: 20px;
}
.title {
font-size: 24px;
font-weight: 700;
margin-bottom: 18px;
}
.small-meta {
margin-bottom: 16px;
color: var(--muted);
font-size: 13px;
}
.form-grid {
display: grid;
grid-template-columns: 1fr;
gap: 16px;
}
.form-group {
display: flex;
flex-direction: column;
gap: 6px;
}
label {
color: var(--muted);
font-size: 13px;
font-weight: 600;
}
input[type="text"] {
min-height: 42px;
padding: 0 12px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--panel-2);
color: var(--text);
}
.actions {
margin-top: 20px;
display: flex;
gap: 10px;
}
.btn {
min-height: 42px;
padding: 0 14px;
border: none;
border-radius: 10px;
cursor: pointer;
font-weight: 600;
text-decoration: none;
display: inline-flex;
align-items: center;
}
.btn-primary {
background: var(--accent);
color: white;
}
.btn-secondary {
background: transparent;
color: var(--text);
border: 1px solid var(--border);
}
</style>
</head>
<body>
<div class="page">
<div class="panel">
<div class="title">Редактирование тренера</div>
<div class="small-meta">ID: {{ coach.id }}</div>
<form method="post" action="/admin/db/coaches/{{ coach.id }}/edit">
<div class="form-grid">
<div class="form-group">
<label>ФИО</label>
<input type="text" name="full_name" value="{{ coach.full_name }}">
</div>
<div class="form-group">
<label>External ID</label>
<input type="text" name="external_id" value="{{ coach.external_id }}">
</div>
<div class="form-group full">
<label>Амплуа</label>
<input type="text" name="role" value="{{ coach.role }}">
</div>
<div class="form-group full">
<label>Команда</label>
<input type="text" value="{{ coach.team_name or 'Не привязан' }}" disabled>
</div>
</div>
<div class="actions">
<button type="submit" class="btn btn-primary">Сохранить</button>
<a href="/admin/db/coaches" class="btn btn-secondary">К списку</a>
<a href="/admin/db" class="btn btn-secondary">Разделы</a>
</div>
</form>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,178 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Тренеры</title>
<style>
:root {
--bg: #0f1115;
--panel: #171a21;
--panel-2: #1d222b;
--border: #2b3240;
--text: #e8ecf3;
--muted: #9aa4b2;
--accent: #4f8cff;
--shadow: 0 10px 30px rgba(0, 0, 0, .35);
--radius: 16px;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
background: var(--bg);
color: var(--text);
font-family: Arial, sans-serif;
}
.page {
max-width: 1400px;
margin: 0 auto;
padding: 24px;
}
.panel {
background: var(--panel);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
padding: 20px;
}
.topbar {
display: flex;
gap: 12px;
justify-content: space-between;
align-items: center;
margin-bottom: 18px;
flex-wrap: wrap;
}
.title {
font-size: 24px;
font-weight: 700;
}
.search-form {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
input[type="text"] {
min-width: 280px;
min-height: 42px;
padding: 0 12px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--panel-2);
color: var(--text);
}
.btn {
min-height: 42px;
padding: 0 14px;
border: none;
border-radius: 10px;
cursor: pointer;
font-weight: 600;
text-decoration: none;
display: inline-flex;
align-items: center;
}
.btn-primary {
background: var(--accent);
color: white;
}
.btn-secondary {
background: transparent;
color: var(--text);
border: 1px solid var(--border);
}
table {
width: 100%;
border-collapse: collapse;
background: var(--panel-2);
border-radius: 12px;
overflow: hidden;
}
th,
td {
padding: 10px 12px;
border-bottom: 1px solid var(--border);
text-align: left;
font-size: 14px;
}
th {
color: var(--muted);
font-weight: 600;
}
tr:last-child td {
border-bottom: none;
}
.id-col {
width: 70px;
}
.action-col {
width: 140px;
text-align: right;
}
.empty-box {
padding: 18px;
border-radius: 12px;
background: var(--panel-2);
color: var(--muted);
border: 1px dashed var(--border);
}
</style>
</head>
<body>
<div class="page">
<div class="panel">
<div class="topbar">
<div class="title">Тренеры</div>
<form method="get" action="/admin/db/coaches" class="search-form">
<input type="text" name="q" value="{{ q }}" placeholder="Поиск по ФИО или external_id">
<button type="submit" class="btn btn-primary">Найти</button>
<a href="/admin/db" class="btn btn-secondary">Назад</a>
</form>
</div>
{% if coaches %}
<table>
<thead>
{% for c in coaches %}
<tr>
<td>{{ c.id }}</td>
<td>{{ c.full_name }}</td>
<td>{{ c.team_name or "—" }}</td>
<td>{{ c.role or "—" }}</td>
<td>{{ c.external_id }}</td>
<td class="action-col">
<a href="/admin/db/coaches/{{ c.id }}/edit" class="btn btn-secondary">Редактировать</a>
</td>
</tr>
{% endfor %}
</thead>
</table>
{% else %}
<div class="empty-box">Тренеры не найдены.</div>
{% endif %}
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,92 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>База</title>
<style>
:root {
--bg: #0f1115;
--panel: #171a21;
--panel-2: #1d222b;
--border: #2b3240;
--text: #e8ecf3;
--muted: #9aa4b2;
--accent: #4f8cff;
--accent-hover: #3e78e6;
--shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
--radius: 16px;
}
* { box-sizing: border-box; }
body {
margin: 0;
background: var(--bg);
color: var(--text);
font-family: Arial, sans-serif;
}
.page {
max-width: 1200px;
margin: 0 auto;
padding: 24px;
}
.panel {
background: var(--panel);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
padding: 20px;
}
.title {
font-size: 24px;
font-weight: 700;
margin-bottom: 18px;
}
.tabs {
display: flex;
gap: 12px;
flex-wrap: wrap;
}
.tab-link {
display: inline-flex;
align-items: center;
min-height: 42px;
padding: 0 16px;
border-radius: 999px;
background: var(--panel-2);
border: 1px solid var(--border);
color: var(--text);
text-decoration: none;
font-weight: 600;
}
.tab-link:hover {
background: var(--accent);
border-color: var(--accent);
color: white;
}
</style>
</head>
<body>
<div class="page">
<div class="panel">
<div class="title">Редактирование базы</div>
<div class="tabs">
<a class="tab-link" href="/admin/db/players">Игроки</a>
<a class="tab-link" href="/admin/db/referees">Судьи</a>
<a class="tab-link" href="/admin/db/teams">Команды</a>
<a class="tab-link" href="/admin/db/coaches">Тренеры</a>
<a class="tab-link" href="/admin/db/stadiums">Стадионы</a>
<a class="tab-link" href="/admin/matches">Назад к матчам</a>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,226 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Редактирование игрока</title>
<style>
:root {
--bg: #0f1115;
--panel: #171a21;
--panel-2: #1d222b;
--border: #2b3240;
--text: #e8ecf3;
--muted: #9aa4b2;
--accent: #4f8cff;
--accent-hover: #3e78e6;
--shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
--radius: 16px;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
background: var(--bg);
color: var(--text);
font-family: Arial, sans-serif;
}
.page {
max-width: 900px;
margin: 0 auto;
padding: 24px;
}
.panel {
background: var(--panel);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
padding: 20px;
}
.title {
font-size: 24px;
font-weight: 700;
margin-bottom: 18px;
}
.form-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
}
.form-group {
display: flex;
flex-direction: column;
gap: 6px;
}
.form-group.full {
grid-column: 1 / -1;
}
label {
color: var(--muted);
font-size: 13px;
font-weight: 600;
}
input[type="text"],
input[type="date"] {
min-height: 42px;
padding: 0 12px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--panel-2);
color: var(--text);
}
.actions {
margin-top: 20px;
display: flex;
gap: 10px;
}
.btn {
min-height: 42px;
padding: 0 14px;
border: none;
border-radius: 10px;
cursor: pointer;
font-weight: 600;
text-decoration: none;
display: inline-flex;
align-items: center;
}
.btn-primary {
background: var(--accent);
color: white;
}
.btn-secondary {
background: transparent;
color: var(--text);
border: 1px solid var(--border);
}
.small-meta {
margin-bottom: 16px;
color: var(--muted);
font-size: 13px;
}
select,
input[type="text"],
input[type="date"] {
min-height: 42px;
padding: 0 12px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--panel-2);
color: var(--text);
}
.media-preview-box {
margin-top: 10px;
padding: 12px;
border-radius: 12px;
border: 1px dashed var(--border);
background: var(--panel-2);
}
.media-preview-image {
max-width: 180px;
max-height: 180px;
object-fit: contain;
display: block;
}
</style>
</head>
<body>
<div class="page">
<div class="panel">
<div class="title">Редактирование игрока</div>
<div class="small-meta">ID: {{ player.id }}</div>
<form method="post" action="/admin/db/players/{{ player.id }}/edit">
{% set positions = [
"",
"Вратарь",
"Защитник",
"Полузащитник",
"Нападающий",
] %}
<div class="form-grid">
<div class="form-group full">
<label>Полное имя</label>
<input type="text" name="full_name" value="{{ player.full_name }}">
</div>
<div class="form-group">
<label>Имя</label>
<input type="text" name="first_name" value="{{ player.first_name }}">
</div>
<div class="form-group">
<label>Фамилия</label>
<input type="text" name="last_name" value="{{ player.last_name }}">
</div>
<div class="form-group">
<label>External ID</label>
<input type="text" name="external_id" value="{{ player.external_id }}">
</div>
<div class="form-group">
<label>Амплуа</label>
<select name="position">
{% for pos in positions %}
<option value="{{ pos }}" {% if player.position==pos %}selected{% endif %}>
{{ pos if pos else "Не выбрано" }}
</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label>Дата рождения</label>
<input type="date" name="birth_date" value="{{ player.birth_date or '' }}">
</div>
<div class="form-group full">
<label>Фото игрока</label>
<input type="text" name="photo" value="{{ player.photo }}">
{% if player.photo %}
<div class="media-preview-box">
<img src="{{ player.photo }}" alt="{{ player.full_name }}" class="media-preview-image">
</div>
{% endif %}
</div>
<div class="form-group full">
<label>Видео игрока</label>
<input type="text" name="video" value="{{ player.video }}">
</div>
</div>
<div class="actions">
<button type="submit" class="btn btn-primary">Сохранить</button>
<a href="/admin/db/players" class="btn btn-secondary">К списку</a>
<a href="/admin/db" class="btn btn-secondary">Разделы</a>
</div>
</form>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,186 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Игроки</title>
<style>
:root {
--bg: #0f1115;
--panel: #171a21;
--panel-2: #1d222b;
--border: #2b3240;
--text: #e8ecf3;
--muted: #9aa4b2;
--accent: #4f8cff;
--accent-hover: #3e78e6;
--shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
--radius: 16px;
}
* { box-sizing: border-box; }
body {
margin: 0;
background: var(--bg);
color: var(--text);
font-family: Arial, sans-serif;
}
.page {
max-width: 1400px;
margin: 0 auto;
padding: 24px;
}
.panel {
background: var(--panel);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
padding: 20px;
}
.topbar {
display: flex;
gap: 12px;
justify-content: space-between;
align-items: center;
margin-bottom: 18px;
flex-wrap: wrap;
}
.title {
font-size: 24px;
font-weight: 700;
}
.search-form {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
input[type="text"] {
min-width: 280px;
min-height: 42px;
padding: 0 12px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--panel-2);
color: var(--text);
}
.btn {
min-height: 42px;
padding: 0 14px;
border: none;
border-radius: 10px;
cursor: pointer;
font-weight: 600;
text-decoration: none;
display: inline-flex;
align-items: center;
}
.btn-primary {
background: var(--accent);
color: white;
}
.btn-secondary {
background: transparent;
color: var(--text);
border: 1px solid var(--border);
}
table {
width: 100%;
border-collapse: collapse;
background: var(--panel-2);
border-radius: 12px;
overflow: hidden;
}
th, td {
padding: 10px 12px;
border-bottom: 1px solid var(--border);
text-align: left;
font-size: 14px;
}
th {
color: var(--muted);
font-weight: 600;
}
tr:last-child td {
border-bottom: none;
}
.id-col {
width: 70px;
}
.action-col {
width: 140px;
text-align: right;
}
.empty-box {
padding: 18px;
border-radius: 12px;
background: var(--panel-2);
color: var(--muted);
border: 1px dashed var(--border);
}
</style>
</head>
<body>
<div class="page">
<div class="panel">
<div class="topbar">
<div class="title">Игроки</div>
<form method="get" action="/admin/db/players" class="search-form">
<input type="text" name="q" value="{{ q }}" placeholder="Поиск по ФИО или external_id">
<button type="submit" class="btn btn-primary">Найти</button>
<a href="/admin/db" class="btn btn-secondary">Назад</a>
</form>
</div>
{% if players %}
<table>
<thead>
<tr>
<th class="id-col">ID</th>
<th>ФИО</th>
<th>Имя</th>
<th>Фамилия</th>
<th>External ID</th>
<th>Амплуа</th>
<th class="action-col"></th>
</tr>
</thead>
<tbody>
{% for p in players %}
<tr>
<td>{{ p.id }}</td>
<td>{{ p.full_name }}</td>
<td>{{ p.first_name }}</td>
<td>{{ p.last_name }}</td>
<td>{{ p.external_id }}</td>
<td>{{ p.position }}</td>
<td class="action-col">
<a href="/admin/db/players/{{ p.id }}/edit" class="btn btn-secondary">Редактировать</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="empty-box">Игроки не найдены.</div>
{% endif %}
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Редактирование судьи</title>
<style>
:root {
--bg: #0f1115; --panel: #171a21; --panel-2: #1d222b; --border: #2b3240;
--text: #e8ecf3; --muted: #9aa4b2; --accent: #4f8cff; --shadow: 0 10px 30px rgba(0,0,0,.35); --radius: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Arial, sans-serif; }
.page { max-width: 900px; margin: 0 auto; padding: 24px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.title { font-size: 24px; font-weight: 700; margin-bottom: 18px; }
.small-meta { margin-bottom: 16px; color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
label { color: var(--muted); font-size: 13px; font-weight: 600; }
input[type="text"] { min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
.actions { margin-top: 20px; display: flex; gap: 10px; }
.btn { min-height: 42px; padding: 0 14px; border: none; border-radius: 10px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
</style>
</head>
<body>
<div class="page">
<div class="panel">
<div class="title">Редактирование судьи</div>
<div class="small-meta">ID: {{ referee.id }}</div>
<form method="post" action="/admin/db/referees/{{ referee.id }}/edit">
<div class="form-grid">
<div class="form-group">
<label>ФИО</label>
<input type="text" name="full_name" value="{{ referee.full_name }}">
</div>
<div class="form-group">
<label>External ID</label>
<input type="text" name="external_id" value="{{ referee.external_id }}">
</div>
</div>
<div class="actions">
<button type="submit" class="btn btn-primary">Сохранить</button>
<a href="/admin/db/referees" class="btn btn-secondary">К списку</a>
<a href="/admin/db" class="btn btn-secondary">Разделы</a>
</div>
</form>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,72 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Судьи</title>
<style>
:root {
--bg: #0f1115; --panel: #171a21; --panel-2: #1d222b; --border: #2b3240;
--text: #e8ecf3; --muted: #9aa4b2; --accent: #4f8cff; --shadow: 0 10px 30px rgba(0,0,0,.35); --radius: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Arial, sans-serif; }
.page { max-width: 1400px; margin: 0 auto; padding: 24px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.topbar { display: flex; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.title { font-size: 24px; font-weight: 700; }
.search-form { display: flex; gap: 10px; flex-wrap: wrap; }
input[type="text"] { min-width: 280px; min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
.btn { min-height: 42px; padding: 0 14px; border: none; border-radius: 10px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--panel-2); border-radius: 12px; overflow: hidden; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
th { color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.id-col { width: 70px; }
.action-col { width: 140px; text-align: right; }
.empty-box { padding: 18px; border-radius: 12px; background: var(--panel-2); color: var(--muted); border: 1px dashed var(--border); }
</style>
</head>
<body>
<div class="page">
<div class="panel">
<div class="topbar">
<div class="title">Судьи</div>
<form method="get" action="/admin/db/referees" class="search-form">
<input type="text" name="q" value="{{ q }}" placeholder="Поиск по ФИО или external_id">
<button type="submit" class="btn btn-primary">Найти</button>
<a href="/admin/db" class="btn btn-secondary">Назад</a>
</form>
</div>
{% if referees %}
<table>
<thead>
<tr>
<th class="id-col">ID</th>
<th>ФИО</th>
<th>External ID</th>
<th class="action-col"></th>
</tr>
</thead>
<tbody>
{% for r in referees %}
<tr>
<td>{{ r.id }}</td>
<td>{{ r.full_name }}</td>
<td>{{ r.external_id }}</td>
<td class="action-col">
<a href="/admin/db/referees/{{ r.id }}/edit" class="btn btn-secondary">Редактировать</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="empty-box">Судьи не найдены.</div>
{% endif %}
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,163 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Редактирование стадиона</title>
<style>
:root {
--bg: #0f1115;
--panel: #171a21;
--panel-2: #1d222b;
--border: #2b3240;
--text: #e8ecf3;
--muted: #9aa4b2;
--accent: #4f8cff;
--shadow: 0 10px 30px rgba(0, 0, 0, .35);
--radius: 16px;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
background: var(--bg);
color: var(--text);
font-family: Arial, sans-serif;
}
.page {
max-width: 900px;
margin: 0 auto;
padding: 24px;
}
.panel {
background: var(--panel);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
padding: 20px;
}
.title {
font-size: 24px;
font-weight: 700;
margin-bottom: 18px;
}
.small-meta {
margin-bottom: 16px;
color: var(--muted);
font-size: 13px;
}
.form-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
}
.form-group {
display: flex;
flex-direction: column;
gap: 6px;
}
.form-group.full {
grid-column: 1 / -1;
}
label {
color: var(--muted);
font-size: 13px;
font-weight: 600;
}
input[type="text"] {
min-height: 42px;
padding: 0 12px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--panel-2);
color: var(--text);
}
.actions {
margin-top: 20px;
display: flex;
gap: 10px;
}
.btn {
min-height: 42px;
padding: 0 14px;
border: none;
border-radius: 10px;
cursor: pointer;
font-weight: 600;
text-decoration: none;
display: inline-flex;
align-items: center;
}
.btn-primary {
background: var(--accent);
color: white;
}
.btn-secondary {
background: transparent;
color: var(--text);
border: 1px solid var(--border);
}
</style>
</head>
<body>
<div class="page">
<div class="panel">
<div class="title">Редактирование стадиона</div>
<div class="small-meta">ID: {{ stadium.id }}</div>
<form method="post" action="/admin/db/stadiums/{{ stadium.id }}/edit">
<div class="form-grid">
<div class="form-group full">
<label>Старое название стадиона</label>
<input type="text" value="{{ stadium.name }}" readonly>
</div>
<div class="form-group full">
<label>Название для графики</label>
<input type="text" name="stadium_gfx" value="{{ stadium.stadium_gfx }}">
</div>
<div class="form-group">
<label>Город</label>
<input type="text" name="city" value="{{ stadium.city }}">
</div>
<div class="form-group">
<label>External ID</label>
<input type="text" name="external_id" value="{{ stadium.external_id }}">
</div>
<div class="form-group full">
<label>Адрес</label>
<input type="text" name="address" value="{{ stadium.address }}">
</div>
</div>
<div class="actions">
<button type="submit" class="btn btn-primary">Сохранить</button>
<a href="/admin/db/stadiums" class="btn btn-secondary">К списку</a>
<a href="/admin/db" class="btn btn-secondary">Разделы</a>
</div>
</form>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Стадионы</title>
<style>
:root {
--bg: #0f1115; --panel: #171a21; --panel-2: #1d222b; --border: #2b3240;
--text: #e8ecf3; --muted: #9aa4b2; --accent: #4f8cff; --shadow: 0 10px 30px rgba(0,0,0,.35); --radius: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Arial, sans-serif; }
.page { max-width: 1400px; margin: 0 auto; padding: 24px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.topbar { display: flex; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.title { font-size: 24px; font-weight: 700; }
.search-form { display: flex; gap: 10px; flex-wrap: wrap; }
input[type="text"] { min-width: 280px; min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
.btn { min-height: 42px; padding: 0 14px; border: none; border-radius: 10px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--panel-2); border-radius: 12px; overflow: hidden; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
th { color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.id-col { width: 70px; }
.action-col { width: 140px; text-align: right; }
.empty-box { padding: 18px; border-radius: 12px; background: var(--panel-2); color: var(--muted); border: 1px dashed var(--border); }
</style>
</head>
<body>
<div class="page">
<div class="panel">
<div class="topbar">
<div class="title">Стадионы</div>
<form method="get" action="/admin/db/stadiums" class="search-form">
<input type="text" name="q" value="{{ q }}" placeholder="Поиск по названию, городу, адресу, external_id">
<button type="submit" class="btn btn-primary">Найти</button>
<a href="/admin/db" class="btn btn-secondary">Назад</a>
</form>
</div>
{% if stadiums %}
<table>
<thead>
<tr>
<th class="id-col">ID</th>
<th>Название</th>
<th>Название GFX</th>
<th>Город</th>
<th>Адрес</th>
<th>External ID</th>
<th class="action-col"></th>
</tr>
</thead>
<tbody>
{% for s in stadiums %}
<tr>
<td>{{ s.id }}</td>
<td>{{ s.name }}</td>
<td>{{ s.stadium_gfx }}</td>
<td>{{ s.city }}</td>
<td>{{ s.address }}</td>
<td>{{ s.external_id }}</td>
<td class="action-col">
<a href="/admin/db/stadiums/{{ s.id }}/edit" class="btn btn-secondary">Редактировать</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="empty-box">Стадионы не найдены.</div>
{% endif %}
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,103 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Редактирование команды</title>
<style>
:root {
--bg: #0f1115; --panel: #171a21; --panel-2: #1d222b; --border: #2b3240;
--text: #e8ecf3; --muted: #9aa4b2; --accent: #4f8cff; --shadow: 0 10px 30px rgba(0,0,0,.35); --radius: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Arial, sans-serif; }
.page { max-width: 1000px; margin: 0 auto; padding: 24px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.title { font-size: 24px; font-weight: 700; margin-bottom: 18px; }
.small-meta { margin-bottom: 16px; color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { color: var(--muted); font-size: 13px; font-weight: 600; }
input[type="text"] {
min-height: 42px;
padding: 0 12px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--panel-2);
color: var(--text);
}
.logo-box {
margin-top: 8px;
padding: 12px;
border: 1px dashed var(--border);
border-radius: 12px;
background: var(--panel-2);
}
.logo-preview {
max-width: 120px;
max-height: 120px;
object-fit: contain;
display: block;
}
.actions { margin-top: 20px; display: flex; gap: 10px; }
.btn { min-height: 42px; padding: 0 14px; border: none; border-radius: 10px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
</style>
</head>
<body>
<div class="page">
<div class="panel">
<div class="title">Редактирование команды</div>
<div class="small-meta">ID: {{ team.id }}</div>
<form method="post" action="/admin/db/teams/{{ team.id }}/edit">
<div class="form-grid">
<div class="form-group">
<label>Название</label>
<input type="text" name="name" value="{{ team.name }}">
</div>
<div class="form-group">
<label>External ID</label>
<input type="text" name="external_id" value="{{ team.external_id }}">
</div>
<div class="form-group full">
<label>Полное название</label>
<input type="text" name="full_name" value="{{ team.full_name }}">
</div>
<div class="form-group">
<label>Город</label>
<input type="text" name="city" value="{{ team.city }}">
</div>
<div class="form-group">
<label>Трёхбуквенное название</label>
<input type="text" name="short_name_3" value="{{ team.short_name_3 }}">
</div>
<div class="form-group full">
<label>Путь к логотипу</label>
<input type="text" name="logo_path" value="{{ team.logo_path }}">
<div class="logo-box">
{% if team.logo_path %}
<img src="{{ team.logo_path }}" alt="{{ team.name }}" class="logo-preview">
{% else %}
Логотип не задан.
{% endif %}
</div>
</div>
</div>
<div class="actions">
<button type="submit" class="btn btn-primary">Сохранить</button>
<a href="/admin/db/teams" class="btn btn-secondary">К списку</a>
<a href="/admin/db" class="btn btn-secondary">Разделы</a>
</div>
</form>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,93 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Команды</title>
<style>
:root {
--bg: #0f1115; --panel: #171a21; --panel-2: #1d222b; --border: #2b3240;
--text: #e8ecf3; --muted: #9aa4b2; --accent: #4f8cff; --shadow: 0 10px 30px rgba(0,0,0,.35); --radius: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Arial, sans-serif; }
.page { max-width: 1500px; margin: 0 auto; padding: 24px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.topbar { display: flex; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.title { font-size: 24px; font-weight: 700; }
.search-form { display: flex; gap: 10px; flex-wrap: wrap; }
input[type="text"] { min-width: 280px; min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
.btn { min-height: 42px; padding: 0 14px; border: none; border-radius: 10px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--panel-2); border-radius: 12px; overflow: hidden; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
th { color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.id-col { width: 70px; }
.action-col { width: 140px; text-align: right; }
.logo-preview {
width: 28px;
height: 28px;
object-fit: contain;
display: inline-block;
vertical-align: middle;
}
.empty-box { padding: 18px; border-radius: 12px; background: var(--panel-2); color: var(--muted); border: 1px dashed var(--border); }
</style>
</head>
<body>
<div class="page">
<div class="panel">
<div class="topbar">
<div class="title">Команды</div>
<form method="get" action="/admin/db/teams" class="search-form">
<input type="text" name="q" value="{{ q }}" placeholder="Поиск по названию, short, external_id">
<button type="submit" class="btn btn-primary">Найти</button>
<a href="/admin/db" class="btn btn-secondary">Назад</a>
</form>
</div>
{% if teams %}
<table>
<thead>
<tr>
<th class="id-col">ID</th>
<th>Название</th>
<th>Полное название</th>
<th>Город</th>
<th>3 буквы</th>
<th>Логотип</th>
<th>External ID</th>
<th class="action-col"></th>
</tr>
</thead>
<tbody>
{% for t in teams %}
<tr>
<td>{{ t.id }}</td>
<td>{{ t.name }}</td>
<td>{{ t.full_name or "—" }}</td>
<td>{{ t.city or "—" }}</td>
<td>{{ t.short_name_3 or "—" }}</td>
<td>
{% if t.logo_path %}
<img src="{{ t.logo_path }}" alt="{{ t.name }}" class="logo-preview">
{% else %}
{% endif %}
</td>
<td>{{ t.external_id }}</td>
<td class="action-col">
<a href="/admin/db/teams/{{ t.id }}/edit" class="btn btn-secondary">Редактировать</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="empty-box">Команды не найдены.</div>
{% endif %}
</div>
</div>
</body>
</html>

110
templates/login.html Normal file
View File

@@ -0,0 +1,110 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>WFL Admin Login</title>
<style>
:root {
--bg: #0f1115;
--panel: #171a21;
--panel-2: #1d222b;
--border: #2b3240;
--text: #e8ecf3;
--muted: #9aa4b2;
--accent: #4f8cff;
--accent-hover: #3e78e6;
--danger-bg: rgba(220, 53, 69, 0.14);
--danger-border: rgba(220, 53, 69, 0.45);
--info-bg: rgba(79, 140, 255, 0.14);
--info-border: rgba(79, 140, 255, 0.4);
--shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
--radius: 16px;
}
* { box-sizing: border-box; }
body {
margin: 0;
min-height: 100vh;
display: grid;
place-items: center;
padding: 24px;
background: var(--bg);
color: var(--text);
font-family: Arial, sans-serif;
}
.card {
width: 100%;
max-width: 420px;
background: var(--panel);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
padding: 28px;
}
h1 { margin: 0 0 8px; font-size: 28px; }
.subtitle { color: var(--muted); margin-bottom: 22px; }
.alert {
border: 1px solid var(--border);
border-radius: 12px;
padding: 12px 14px;
margin-bottom: 16px;
font-size: 14px;
}
.alert-error { background: var(--danger-bg); border-color: var(--danger-border); }
.alert-info { background: var(--info-bg); border-color: var(--info-border); }
label { display: block; font-size: 14px; margin-bottom: 8px; }
input {
width: 100%;
min-height: 44px;
margin-bottom: 14px;
padding: 0 12px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--panel-2);
color: var(--text);
outline: none;
}
input:focus {
border-color: var(--accent);
box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}
button {
width: 100%;
min-height: 46px;
border: none;
border-radius: 10px;
background: var(--accent);
color: white;
font-weight: 700;
cursor: pointer;
}
button:hover { background: var(--accent-hover); }
.hint { color: var(--muted); font-size: 13px; margin-top: 12px; }
</style>
</head>
<body>
<div class="card">
<h1>WFL Admin</h1>
<div class="subtitle">Вход в административный интерфейс</div>
{% if message %}
<div class="alert alert-info">{{ message }}</div>
{% endif %}
{% if error %}
<div class="alert alert-error">{{ error }}</div>
{% endif %}
<form method="post" action="/login">
<label for="username">Логин</label>
<input id="username" name="username" type="text" autocomplete="username" required>
<label for="password">Пароль</label>
<input id="password" name="password" type="password" autocomplete="current-password" required>
<button type="submit">Войти</button>
</form>
<div class="hint">Сессия автоматически завершится после 2 часов без активности.</div>
</div>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

554
templates/matches.html Normal file
View File

@@ -0,0 +1,554 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate, max-age=0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<title>Выбор матча</title>
<style>
:root {
--bg: #0f1115;
--panel: #171a21;
--panel-2: #1d222b;
--border: #2b3240;
--text: #e8ecf3;
--muted: #9aa4b2;
--accent: #4f8cff;
--accent-hover: #3e78e6;
--success-bg: rgba(46, 160, 67, 0.16);
--success-border: rgba(46, 160, 67, 0.4);
--live-bg: rgba(245, 158, 11, 0.16);
--live-border: rgba(245, 158, 11, 0.4);
--scheduled-bg: transparent;
--input-bg: #11151c;
--shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
--radius: 14px;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 28px;
font-family: Arial, sans-serif;
background: var(--bg);
color: var(--text);
}
.page {
max-width: 1400px;
margin: 0 auto;
}
.page-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
margin-bottom: 20px;
}
h1 {
margin: 0;
font-size: 28px;
font-weight: 700;
letter-spacing: 0.2px;
}
.subtitle {
color: var(--muted);
font-size: 14px;
margin-top: 6px;
}
.panel {
background: var(--panel);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
}
.filters {
display: flex;
flex-wrap: wrap;
gap: 18px;
align-items: end;
padding: 18px;
margin-bottom: 18px;
}
.filter-group label {
display: block;
font-size: 13px;
color: var(--muted);
margin-bottom: 8px;
}
.check-line {
display: flex;
align-items: center;
gap: 8px;
min-height: 40px;
}
input[type="checkbox"] {
transform: scale(1.15);
accent-color: var(--accent);
}
select,
input[type="text"] {
min-height: 40px;
padding: 0 12px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--input-bg);
color: var(--text);
outline: none;
}
select:focus,
input[type="text"]:focus {
border-color: var(--accent);
box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}
a {
color: #8ab4ff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.table-wrap {
overflow-x: auto;
}
table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
}
thead th {
position: sticky;
top: 0;
background: var(--panel-2);
color: var(--muted);
font-size: 13px;
font-weight: 600;
text-align: left;
padding: 14px 12px;
border-bottom: 1px solid var(--border);
}
thead th:first-child {
border-top-left-radius: var(--radius);
}
thead th:last-child {
border-top-right-radius: var(--radius);
}
tbody td {
padding: 14px 12px;
border-bottom: 1px solid var(--border);
vertical-align: middle;
}
tbody tr:last-child td {
border-bottom: none;
}
tbody tr:hover {
background: rgba(255, 255, 255, 0.03);
}
tbody tr.finished {
background: var(--success-bg);
}
tbody tr.finished:hover {
background: rgba(46, 160, 67, 0.22);
}
tbody tr.live {
background: var(--live-bg);
}
tbody tr.live:hover {
background: rgba(245, 158, 11, 0.22);
}
.match-cell {
font-weight: 600;
}
.muted {
color: var(--muted);
font-size: 13px;
}
.status-badge {
display: inline-flex;
align-items: center;
gap: 6px;
min-height: 28px;
padding: 0 10px;
border-radius: 999px;
font-size: 12px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.4px;
border: 1px solid var(--border);
}
.status-finished {
background: var(--success-bg);
border-color: var(--success-border);
color: #8ee29b;
}
.status-live {
background: var(--live-bg);
border-color: var(--live-border);
color: #ffd27a;
}
.status-scheduled {
background: rgba(255,255,255,0.04);
color: #c8d1dc;
}
.select-form {
display: flex;
gap: 8px;
align-items: center;
}
.operator-input {
width: 170px;
}
.btn {
min-height: 40px;
padding: 0 14px;
border: none;
border-radius: 10px;
background: var(--accent);
color: white;
font-weight: 600;
cursor: pointer;
transition: background 0.15s ease, transform 0.05s ease;
}
.btn:hover {
background: var(--accent-hover);
}
.btn:active {
transform: translateY(1px);
}
.empty {
padding: 28px;
color: var(--muted);
}
.id-chip {
display: inline-block;
padding: 4px 8px;
border-radius: 999px;
background: rgba(255,255,255,0.05);
color: var(--muted);
font-size: 12px;
}
.page-actions {
display: flex;
align-items: center;
gap: 10px;
}
.logout-form {
margin: 0;
}
.btn-secondary {
background: rgba(255,255,255,0.08);
color: var(--text);
border: 1px solid var(--border);
}
.btn-secondary:hover {
background: rgba(255,255,255,0.12);
}
.session-banner {
display: none;
margin-bottom: 16px;
padding: 12px 14px;
border-radius: 10px;
border: 1px solid rgba(255, 193, 7, 0.35);
background: rgba(255, 193, 7, 0.08);
color: var(--text);
}
</style>
</head>
<body>
<div class="page">
<div class="page-header">
<div>
<h1>Выбор матча</h1>
<div class="subtitle">Рабочая панель оператора трансляции</div>
</div>
<div class="page-actions">
<form method="post" action="/logout" class="logout-form">
<button type="submit" class="btn btn-secondary">Выйти</button>
</form>
</div>
</div>
<div id="sessionStatusBanner" class="session-banner"></div>
<form method="get" action="/admin/matches" class="filters panel" id="filters-form">
<div class="filter-group">
<label>Фильтр по дате</label>
<div class="check-line">
<input
type="checkbox"
name="today_only"
value="true"
{% if today_only %}checked{% endif %}
onchange="document.getElementById('filters-form').submit();"
>
<span>Только сегодня</span>
</div>
</div>
<div class="filter-group">
<label for="tour">Тур</label>
<select
name="tour"
id="tour"
onchange="document.getElementById('filters-form').submit();"
>
<option value="">Все туры</option>
{% for t in tours %}
<option value="{{ t }}" {% if selected_tour == t %}selected{% endif %}>{{ t }}</option>
{% endfor %}
</select>
</div>
<div class="filter-group">
<label>&nbsp;</label>
<div class="check-line">
<a href="/admin/matches">Сбросить фильтры</a>
</div>
</div>
</form>
<div class="panel table-wrap">
{% if matches %}
<table>
<thead>
<tr>
<th>ID</th>
<th>Дата</th>
<th>Матч</th>
<th>Тур</th>
<th>Сезон</th>
<th>Статус</th>
<th>Оператор</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
{% for row in matches %}
{% set status = (row[3] or 'scheduled') %}
<tr class="{{ status }}">
<td><span class="id-chip">{{ row[0] }}</span></td>
<td>
<div>{{ row[2] or "" }}</div>
</td>
<td class="match-cell">
{{ row[6] }} — {{ row[7] }}
</td>
<td>{{ row[4] or "" }}</td>
<td>{{ row[5] or "" }}</td>
<td>
<span class="status-badge status-{{ status }}">
{{ status }}
</span>
</td>
<td colspan="2">
<form method="get" action="/admin/matches/{{ row[0] }}/select" class="select-form js-select-form">
<input
type="text"
name="operator_name"
placeholder="Имя оператора"
class="operator-input"
>
<button type="submit" class="btn">Выбрать матч</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="empty">Матчи не найдены.</div>
{% endif %}
</div>
</div>
<script>
(function () {
async function handleSelectSubmit(event) {
const form = event.target;
if (!form.classList.contains("js-select-form")) return;
event.preventDefault();
const submitButton = form.querySelector('button[type="submit"]');
const operatorInput = form.querySelector('input[name="operator_name"]');
const operatorName = operatorInput ? operatorInput.value : "";
if (submitButton) {
submitButton.disabled = true;
submitButton.textContent = "Подготовка...";
}
try {
const url = new URL(form.action, window.location.origin);
url.searchParams.set("operator_name", operatorName);
const response = await fetch(url.toString(), {
method: "GET",
headers: {
"X-Requested-With": "XMLHttpRequest",
"Accept": "application/json"
},
credentials: "same-origin"
});
const data = await response.json();
if (!response.ok || !data.success) {
throw new Error(data.error || data.vmix_error || "Не удалось выбрать матч");
}
if (data.download_url) {
const downloadResponse = await fetch(data.download_url, {
method: "GET",
credentials: "same-origin"
});
if (!downloadResponse.ok) {
let errText = "Не удалось скачать vMix проект";
try {
const errJson = await downloadResponse.json();
errText = errJson.error || errText;
} catch (_) {}
throw new Error(errText);
}
const blob = await downloadResponse.blob();
let filename = "project.vmix";
const disposition = downloadResponse.headers.get("Content-Disposition");
if (disposition) {
let match = disposition.match(/filename\*=UTF-8''([^;]+)/i);
if (match && match[1]) {
filename = decodeURIComponent(match[1]);
} else {
match = disposition.match(/filename="([^"]+)"/i);
if (match && match[1]) {
filename = match[1];
}
}
}
const blobUrl = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = blobUrl;
a.download = filename;
document.body.appendChild(a);
a.click();
a.remove();
window.URL.revokeObjectURL(blobUrl);
}
window.location.href = data.session_url;
} catch (error) {
alert(error.message || "Ошибка при подготовке матча");
if (submitButton) {
submitButton.disabled = false;
submitButton.textContent = "Выбрать матч";
}
}
}
document.addEventListener("submit", handleSelectSubmit);
})();
(function () {
const LOGIN_URL = "/login";
const IDLE_LIMIT_MS = 2 * 60 * 60 * 1000;
const WARNING_BEFORE_MS = 60 * 1000;
const ACTIVITY_EVENTS = ["mousemove", "mousedown", "keydown", "scroll", "touchstart", "click"];
const banner = document.getElementById("sessionStatusBanner");
let lastActivityAt = Date.now();
let warned = false;
let redirected = false;
function showBanner(message) {
if (!banner) return;
banner.textContent = message;
banner.style.display = "block";
}
function markActivity() {
lastActivityAt = Date.now();
warned = false;
if (banner) banner.style.display = "none";
}
function redirectToLogin(reason) {
if (redirected) return;
redirected = true;
const url = new URL(LOGIN_URL, window.location.origin);
if (reason) url.searchParams.set("reason", reason);
window.location.replace(url.toString());
}
ACTIVITY_EVENTS.forEach((eventName) => {
window.addEventListener(eventName, markActivity, { passive: true });
});
document.addEventListener("submit", markActivity, true);
setInterval(() => {
const idleFor = Date.now() - lastActivityAt;
const leftMs = IDLE_LIMIT_MS - idleFor;
if (!warned && leftMs <= WARNING_BEFORE_MS && leftMs > 0) {
warned = true;
const leftMinutes = Math.ceil(leftMs / 60000);
showBanner(`До выхода из системы из-за неактивности осталось около ${leftMinutes} мин.`);
}
if (idleFor >= IDLE_LIMIT_MS) {
showBanner("Сессия завершена из-за 2 часов неактивности.");
redirectToLogin("idle");
}
}, 15000);
})();
</script>
</body>
</html>