ros_control: централизованное управление парком MikroTik RouterOS
Control Server (FastAPI) с WEB UI (Jinja2 + HTMX) и JSON API для группового администрирования устройств RouterOS 7 через REST. - Устройства: список, статус (модель, канал, версии ROS/FW, uptime, доступные обновления), примечания, пароли шифруются (Fernet); фоновый опрос каждые 30 с и быстрое обнаружение недоступности (таймаут соединения 4 с). - Группы устройств и фильтры (устройства, резервные копии). - Резервные копии: .backup и .rsc (show-sensitive) создаются через REST, скачиваются сервером и загружаются в S3 (Yandex Object Storage). - Обновление ROS/FW и выбор канала, групповые операции задачами. - Интерфейс по утверждённому макету: светлая/тёмная темы, окна, шрифты IBM Plex локально. Docker Compose, SQLite в томе, минимальный набор тестов. - Планы и итоги каждого изменения — в docs/changes/. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
commit
4c1841b61b
85 files changed
+3579
No files matched your search
@@ -0,0 +1 @@
|
||||
{{ stats.total }} {{ stats.total|plural("устройство", "устройства", "устройств") }} · {{ stats.online }} online · {{ stats.offline }} offline
|
||||
@@ -0,0 +1,51 @@
|
||||
{# Форма устройства: одна разметка для окна (in_modal) и запасной страницы. v — значения полей. #}
|
||||
{% import "_ui.html" as ui %}
|
||||
{% set edit = device is not none %}
|
||||
{% set action = ('/devices/' ~ device.id ~ '/edit') if edit else '/devices/new' %}
|
||||
<form method="post" action="{{ action }}" {% if in_modal %}hx-post="{{ action }}" hx-target="#modal-body"{% endif %}>
|
||||
<header class="modal-head">
|
||||
<h2 id="modal-title">{{ "Изменить устройство" if edit else "Новое устройство" }}</h2>
|
||||
{% if in_modal %}<button type="button" class="btn ghost-n icon" data-close aria-label="Закрыть">{{ ui.icon("x") }}</button>{% endif %}
|
||||
</header>
|
||||
<div class="modal-body">
|
||||
{% if error %}<div class="form-err" role="alert">{{ error }}</div>{% endif %}
|
||||
<label class="lbl"><span>Название <small>латиница, цифры, «.», «_», «-»; попадает в ключи бэкапов</small></span>
|
||||
<input class="input" name="name" value="{{ v.name }}" maxlength="64" required autofocus></label>
|
||||
<label class="lbl"><span>Примечание <small>необязательно</small></span>
|
||||
<textarea class="input" name="note" rows="3" maxlength="500" placeholder="Например: серверная, 2 этаж; ответственный — дежурный инженер">{{ v.note }}</textarea></label>
|
||||
<div class="form-row host">
|
||||
<label class="lbl">Адрес<input class="input" name="host" value="{{ v.host }}" required></label>
|
||||
<label class="lbl">Порт<input class="input" name="port" type="number" min="1" max="65535" value="{{ v.port }}" required></label>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label class="lbl">Пользователь<input class="input" name="username" value="{{ v.username }}" required></label>
|
||||
<label class="lbl"><span>Пароль {% if edit %}<small>пусто — не менять</small>{% endif %}</span>
|
||||
<input class="input" name="password" type="password" autocomplete="new-password" {{ "" if edit else "required" }}></label>
|
||||
</div>
|
||||
<label class="lbl">Группа
|
||||
<select class="field" name="group_id" data-newgroup style="width:100%">
|
||||
<option value="">— без группы —</option>
|
||||
{% for g in groups %}<option value="{{ g.id }}" {{ "selected" if v.group_id == g.id|string }}>{{ g.name }}</option>{% endfor %}
|
||||
<option value="__new__" {{ "selected" if v.group_id == "__new__" }}>+ Новая группа…</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="lbl" id="new-group-field" {{ "" if v.group_id == "__new__" else "hidden" }}>Название новой группы
|
||||
<input class="input" name="new_group" value="{{ v.new_group }}" maxlength="64"></label>
|
||||
<label class="check"><input name="use_tls" type="checkbox" {{ "checked" if v.use_tls }}>
|
||||
<span>HTTPS (сервис www-ssl)<small>Порт обычно 443; без HTTPS — сервис www, порт 80</small></span></label>
|
||||
<div class="note" id="http-note" {{ "hidden" if v.use_tls }}>Без HTTPS логин и пароль передаются по сети открытым текстом — только для доверенной сети.</div>
|
||||
<label class="check"><input name="verify_tls" type="checkbox" {{ "checked" if v.verify_tls }}>
|
||||
<span>Проверять TLS-сертификат<small>Отключите для самоподписанных сертификатов</small></span></label>
|
||||
</div>
|
||||
<footer class="modal-foot">
|
||||
{% if edit %}
|
||||
{% if in_modal %}<button type="button" class="btn danger" hx-post="/devices/{{ device.id }}/delete"
|
||||
hx-confirm="Удалить устройство {{ device.name }} из списка? Бэкапы в бакете сохранятся.">Удалить устройство</button>
|
||||
{% else %}<button class="btn danger" formaction="/devices/{{ device.id }}/delete" formnovalidate
|
||||
onclick="return confirm('Удалить устройство {{ device.name }} из списка? Бэкапы в бакете сохранятся.')">Удалить устройство</button>{% endif %}
|
||||
{% endif %}
|
||||
<span class="grow"></span>
|
||||
{% if in_modal %}<button type="button" class="btn ghost-n" data-close>Отмена</button>{% else %}<a class="btn ghost-n" href="/">Отмена</a>{% endif %}
|
||||
<button class="btn primary">{{ "Сохранить" if edit else "Добавить устройство" }}</button>
|
||||
</footer>
|
||||
</form>
|
||||
@@ -0,0 +1,75 @@
|
||||
{% import "_ui.html" as ui %}
|
||||
{% if oob %}<div class="sub" id="dev-sub" hx-swap-oob="true">{% include "_dev_sub.html" %}</div>{% endif %}
|
||||
<div class="table-wrap">
|
||||
<table class="grid">
|
||||
<colgroup><col style="width:44px"><col><col style="width:110px"><col style="width:110px"><col style="width:100px"><col style="width:120px"><col style="width:90px"><col style="width:120px"><col style="width:100px"><col style="width:150px"><col style="width:52px"></colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><input type="checkbox" id="check-all" aria-label="Выбрать все"></th>
|
||||
<th>Устройство</th><th>Группа</th><th>Канал</th><th>ROS</th><th>Upgrade ROS</th><th>FW</th><th>Upgrade FW</th><th>Uptime</th><th>Запрос бэкапа (UTC)</th><th><span class="sr-only">Действия</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for d in devices %}
|
||||
{% set st = d.status %}{% set down = d.online is false %}
|
||||
{% set ros_new = st.ros_latest and st.ros_installed and st.ros_latest != st.ros_installed %}
|
||||
{% set fw_new = st.fw_current and st.fw_upgrade and st.fw_upgrade != st.fw_current %}
|
||||
<tr>
|
||||
<td><input type="checkbox" name="device_ids" value="{{ d.id }}" form="move-form" aria-label="Выбрать {{ d.name }}"></td>
|
||||
<td>
|
||||
<div class="dev">
|
||||
<span class="dot {{ 'on' if d.online else ('off' if down else '') }}" title="{{ d.last_error or ('online, опрошено ' ~ (d.status_at|dt)) }}"></span>
|
||||
<div style="min-width:0">
|
||||
<div class="dev-name"><a class="dev-link" href="/devices/{{ d.id }}/edit" hx-get="/ui/dialog/device/{{ d.id }}" hx-target="#modal-body"
|
||||
title="{{ d.note or 'Изменить устройство' }}">{{ d.name }}</a></div>
|
||||
{% if down %}<div class="dev-sub bad" title="{{ d.last_error }}">Нет соединения</div>
|
||||
{% else %}<div class="dev-sub">{{ d.host }}:{{ d.port }}{% if st.model %} · {{ st.model }}{% endif %}</div>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="muted">{{ group_names.get(d.group_id) or "—" }}</td>
|
||||
<td>{% if down %}<span class="dash">—</span>{% else %}{{ st.channel or "—" }}{% endif %}</td>
|
||||
<td class="c-mono">{% if down %}<span class="dash">—</span>{% else %}{{ st.ros_installed or st.ros_version or "—" }}{% endif %}</td>
|
||||
<td>
|
||||
{% if down or not (st.ros_latest and st.ros_installed) %}<span class="dash" title="{{ st.ros_check_error or 'Проверка обновлений ещё не выполнялась' }}">—</span>
|
||||
{% elif ros_new %}<span class="badge warn" title="Доступно обновление ROS до {{ st.ros_latest }}">{{ ui.icon("up", 12, 2.2) }}{{ st.ros_latest }}</span>
|
||||
{% else %}<span class="okmark">{{ ui.icon("check", 14, 2.2) }}актуально</span>{% endif %}
|
||||
</td>
|
||||
<td class="c-mono">{% if down %}<span class="dash">—</span>{% else %}{{ st.fw_current or "—" }}{% endif %}</td>
|
||||
<td>
|
||||
{% if down or not (st.fw_current and st.fw_upgrade) %}<span class="dash" title="Нет RouterBOARD firmware (например, CHR) или устройство не опрошено">—</span>
|
||||
{% elif fw_new %}<span class="badge warn" title="Доступно обновление прошивки до {{ st.fw_upgrade }}">{{ ui.icon("up", 12, 2.2) }}{{ st.fw_upgrade }}</span>
|
||||
{% else %}<span class="okmark">{{ ui.icon("check", 14, 2.2) }}актуально</span>{% endif %}
|
||||
</td>
|
||||
<td class="c-small">{% if down %}<span class="dash">—</span>{% else %}{{ st.uptime or "—" }}{% endif %}</td>
|
||||
<td class="c-small">{{ d.last_backup_requested_at|dt }}</td>
|
||||
<td class="c-menu">
|
||||
<details class="menu right">
|
||||
<summary class="btn ghost-n icon" aria-label="Действия для {{ d.name }}" title="Действия">{{ ui.icon("more") }}</summary>
|
||||
<div class="menu-panel w270">
|
||||
<button type="button" class="mi" hx-post="/ui/devices/{{ d.id }}/refresh" hx-include="#dev-filters" hx-target="#devices">Обновить статус</button>
|
||||
<button type="button" class="mi" hx-post="/ui/devices/{{ d.id }}/backup" hx-target="#jobs">Создать бэкап</button>
|
||||
<hr>
|
||||
<button type="button" class="mi warn" hx-post="/ui/devices/{{ d.id }}/ros_update" hx-target="#jobs"
|
||||
hx-confirm="Обновить ROS на {{ d.name }}? Устройство перезагрузится после скачивания.">Обновить ROS<small>Перезагрузка после скачивания</small></button>
|
||||
<button type="button" class="mi warn" hx-post="/ui/devices/{{ d.id }}/fw_update" hx-target="#jobs"
|
||||
hx-confirm="Обновить прошивку на {{ d.name }}? Устройство перезагрузится сразу после обновления.">Обновить FW<small>Перезагрузка сразу после обновления</small></button>
|
||||
<hr>
|
||||
<details class="sub">
|
||||
<summary class="mi">Сменить канал…</summary>
|
||||
<div class="sub-list">
|
||||
{% for c in channels %}<button type="button" class="mi {{ 'on' if c == st.channel }}" hx-post="/ui/devices/{{ d.id }}/channel" hx-vals='{"channel": "{{ c }}"}' hx-include="#dev-filters" hx-target="#devices">{{ c }}</button>{% endfor %}
|
||||
</div>
|
||||
</details>
|
||||
<button type="button" class="mi" hx-get="/ui/dialog/device/{{ d.id }}" hx-target="#modal-body">Изменить устройство</button>
|
||||
</div>
|
||||
</details>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td colspan="11" class="empty">{{ "Нет устройств, подходящих под фильтр." if filtered else "Устройств пока нет. Добавьте первое." }}</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="tfoot">Показано {{ devices|length }} из {{ total }} {{ total|plural("устройства", "устройств", "устройств") }}</div>
|
||||
@@ -0,0 +1,18 @@
|
||||
{% import "_ui.html" as ui %}
|
||||
{% set edit = group is not none %}
|
||||
{% set action = ('/groups/' ~ group.id ~ '/rename') if edit else '/groups/new' %}
|
||||
<form method="post" action="{{ action }}" {% if in_modal %}hx-post="{{ action }}" hx-target="#modal-body"{% endif %}>
|
||||
<header class="modal-head">
|
||||
<h2 id="modal-title">{{ "Переименовать группу" if edit else "Новая группа" }}</h2>
|
||||
{% if in_modal %}<button type="button" class="btn ghost-n icon" data-close aria-label="Закрыть">{{ ui.icon("x") }}</button>{% endif %}
|
||||
</header>
|
||||
<div class="modal-body">
|
||||
{% if error %}<div class="form-err" role="alert">{{ error }}</div>{% endif %}
|
||||
<label class="lbl">Название<input class="input" name="name" value="{{ gname }}" maxlength="64" required autofocus></label>
|
||||
</div>
|
||||
<footer class="modal-foot">
|
||||
<span class="grow"></span>
|
||||
{% if in_modal %}<button type="button" class="btn ghost-n" data-close>Отмена</button>{% else %}<a class="btn ghost-n" href="/groups">Отмена</a>{% endif %}
|
||||
<button class="btn primary">{{ "Сохранить" if edit else "Создать группу" }}</button>
|
||||
</footer>
|
||||
</form>
|
||||
@@ -0,0 +1,31 @@
|
||||
{% import "_ui.html" as ui %}
|
||||
{% set running = jobs|selectattr("status", "in", ["pending", "running"])|list|length %}
|
||||
{% set done = jobs|selectattr("status", "equalto", "done")|list|length %}
|
||||
{% set failed = jobs|selectattr("status", "equalto", "failed")|list|length %}
|
||||
<div class="section-head">
|
||||
<h2>Задачи</h2>
|
||||
{% if running %}<span class="badge run">{{ running }} выполняется</span>{% endif %}
|
||||
{% if done %}<span class="badge">{{ done }} завершено</span>{% endif %}
|
||||
{% if failed %}<span class="badge bad">{{ failed }} с ошибкой</span>{% endif %}
|
||||
</div>
|
||||
{% if flash %}<p class="err">{{ flash }}</p>{% endif %}
|
||||
<div class="card">
|
||||
<table class="grid jobs">
|
||||
<colgroup><col style="width:56px"><col style="width:16%"><col style="width:16%"><col style="width:130px"><col><col style="width:150px"></colgroup>
|
||||
<thead><tr><th>#</th><th>Устройство</th><th>Операция</th><th>Статус</th><th>Сообщение</th><th>Создана (UTC)</th></tr></thead>
|
||||
<tbody>
|
||||
{% for j in jobs %}
|
||||
<tr>
|
||||
<td class="muted">{{ j.id }}</td>
|
||||
<td style="font-weight:500">{{ j.device_name }}</td>
|
||||
<td>{{ {"backup": "Бэкап", "ros_update": "Обновление ROS", "fw_update": "Обновление FW"}.get(j.type, j.type) }}</td>
|
||||
<td><span class="badge {{ {'running': 'run', 'done': 'ok', 'failed': 'bad'}.get(j.status, '') }}">{{ {"pending": "В очереди", "running": "Выполняется", "done": "Готово", "failed": "Ошибка"}.get(j.status, j.status) }}</span></td>
|
||||
<td class="msg">{{ j.message }}</td>
|
||||
<td class="c-small">{{ j.created_at|dt }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td colspan="6" class="empty">Задач пока нет.</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,4 @@
|
||||
{# Общие макросы: иконки (inline SVG, stroke) #}
|
||||
{% macro icon(name, size=16, sw=1.8) -%}
|
||||
<svg class="ico" width="{{ size }}" height="{{ size }}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="{{ sw }}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">{{ ICONS[name]|safe }}</svg>
|
||||
{%- endmacro %}
|
||||
@@ -0,0 +1,70 @@
|
||||
{% extends "base.html" %}
|
||||
{% import "_ui.html" as ui %}
|
||||
{% block content %}
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<h1>Резервные копии</h1>
|
||||
<div class="sub">Бакет {{ bucket }} · {{ stats.total }} {{ stats.total|plural("файл", "файла", "файлов") }} · {{ stats.size|size }}</div>
|
||||
</div>
|
||||
<div class="actions"><a class="btn secondary" href="/backups?{{ request.url.query }}">{{ ui.icon("refresh") }}Обновить список</a></div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="tools">
|
||||
<form method="get" action="/backups">
|
||||
<select class="field {{ 'on' if flt.group }}" name="group" onchange="this.form.submit()" aria-label="Группа" style="width:170px">
|
||||
<option value="">Группа: любая</option>
|
||||
<option value="none" {{ "selected" if flt.group == "none" }}>Группа: без группы</option>
|
||||
{% for g in groups %}<option value="{{ g.id }}" {{ "selected" if flt.group == g.id|string }}>Группа: {{ g.name }}</option>{% endfor %}
|
||||
</select>
|
||||
<select class="field {{ 'on' if flt.device }}" name="device" onchange="this.form.submit()" aria-label="Устройство" style="width:190px">
|
||||
<option value="">Устройство: любое</option>
|
||||
{% for d in devices %}<option value="{{ d.name }}" {{ "selected" if d.name == flt.device }}>Устройство: {{ d.name }}</option>{% endfor %}
|
||||
</select>
|
||||
<select class="field {{ 'on' if flt.kind }}" name="kind" onchange="this.form.submit()" aria-label="Тип файла" style="width:150px">
|
||||
<option value="">Тип: любой</option>
|
||||
<option value="backup" {{ "selected" if flt.kind == "backup" }}>Тип: .backup</option>
|
||||
<option value="rsc" {{ "selected" if flt.kind == "rsc" }}>Тип: .rsc</option>
|
||||
</select>
|
||||
<label class="datefield">с <input type="date" name="date_from" value="{{ flt.date_from }}" onchange="this.form.submit()" aria-label="Дата с"></label>
|
||||
<label class="datefield">по <input type="date" name="date_to" value="{{ flt.date_to }}" onchange="this.form.submit()" aria-label="Дата по"></label>
|
||||
<label class="search">{{ ui.icon("search") }}<input type="search" name="q" value="{{ flt.q }}" placeholder="Имя файла" aria-label="Поиск по имени файла" style="width:220px"></label>
|
||||
<span class="grow"></span>
|
||||
{% if flt_active %}<a class="btn ghost" href="/backups">Сбросить ({{ flt_active }})</a>{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
{% if error %}<div class="form-err" role="alert" style="margin:0 16px 16px">Ошибка S3: {{ error }}</div>{% endif %}
|
||||
<div class="table-wrap">
|
||||
<table class="grid files">
|
||||
<colgroup><col style="width:20%"><col style="width:140px"><col style="width:100px"><col><col style="width:100px"><col style="width:170px"><col style="width:104px"></colgroup>
|
||||
<thead><tr><th>Устройство</th><th>Группа</th><th>Тип</th><th>Файл</th><th>Размер</th><th>Изменён (UTC)</th><th><span class="sr-only">Действия</span></th></tr></thead>
|
||||
<tbody>
|
||||
{% for i in items %}
|
||||
<tr>
|
||||
<td style="font-weight:600">{{ i.device or "—" }}</td>
|
||||
<td class="muted">{{ i.group or "—" }}</td>
|
||||
<td><span class="badge">{{ {"backup": ".backup", "rsc": ".rsc"}.get(i.kind, "—") }}</span></td>
|
||||
<td class="c-mono" title="{{ i.key }}" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">{{ i.key.split("/")[-1] }}</td>
|
||||
<td class="c-small">{{ i.size|size }}</td>
|
||||
<td class="c-small">{{ i.last_modified|dt }}</td>
|
||||
<td class="c-menu">
|
||||
<a class="btn ghost-n icon" href="/backups/download?key={{ i.key|urlencode }}" aria-label="Скачать {{ i.key.split('/')[-1] }}" title="Скачать">{{ ui.icon("download") }}</a>
|
||||
<details class="menu right">
|
||||
<summary class="btn ghost-n icon" aria-label="Действия" title="Действия">{{ ui.icon("more") }}</summary>
|
||||
<div class="menu-panel w200">
|
||||
<form method="post" action="/backups/delete" onsubmit="return confirm('Удалить файл из бакета?')">
|
||||
<input type="hidden" name="key" value="{{ i.key }}"><button class="mi bad">Удалить файл</button>
|
||||
</form>
|
||||
</div>
|
||||
</details>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td colspan="7" class="empty">Файлов не найдено.</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="tfoot">Найдено {{ items|length }} из {{ stats.total }} {{ stats.total|plural("файла", "файлов", "файлов") }}</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,28 @@
|
||||
{% import "_ui.html" as ui %}
|
||||
<!doctype html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{% block title %}ros_control{% endblock %}</title>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
<script src="/static/htmx.min.js"></script>
|
||||
<script src="/static/app.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
{% if request.session.get("user") %}
|
||||
{% set nav = [("Устройства", "/", "devices"), ("Группы", "/groups", "groups"), ("Резервные копии", "/backups", "backups")] %}
|
||||
<header class="app-header">
|
||||
<a class="brand" href="/"><span class="brand-logo">{{ ui.icon("router") }}</span>ros_control</a>
|
||||
<nav class="nav" aria-label="Разделы">
|
||||
{% for title, href, key in nav %}<a href="{{ href }}" class="{{ 'on' if section == key }}">{{ title }}</a>{% endfor %}
|
||||
</nav>
|
||||
<span class="grow"></span>
|
||||
<span class="user">{{ request.session.get("user") }}</span>
|
||||
<form method="post" action="/logout"><button class="btn ghost-n">Выйти</button></form>
|
||||
</header>
|
||||
{% endif %}
|
||||
<main class="container">{% block content %}{% endblock %}</main>
|
||||
<dialog id="modal" class="modal" aria-labelledby="modal-title"><div id="modal-body"></div></dialog>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,85 @@
|
||||
{% extends "base.html" %}
|
||||
{% import "_ui.html" as ui %}
|
||||
{% block content %}
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<h1>Устройства</h1>
|
||||
<div class="sub" id="dev-sub">{% include "_dev_sub.html" %}</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button type="button" class="btn secondary" hx-post="/ui/refresh" hx-include="#dev-filters" hx-target="#devices" hx-indicator="#busy">{{ ui.icon("refresh") }}Обновить статус</button>
|
||||
<button type="button" class="btn primary" hx-get="/ui/dialog/device{{ '?group=' ~ flt.group if flt.group.isdigit() }}" hx-target="#modal-body">{{ ui.icon("plus") }}Добавить устройство</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav class="tabs" aria-label="Группы устройств">
|
||||
{% for t in tabs %}<a class="tab {{ 'on' if t.active }}" href="{{ t.href }}">{{ t.label }} <span class="count">{{ t.count }}</span></a>{% endfor %}
|
||||
<span class="grow"></span>
|
||||
<a class="tab-link" href="/groups">Управление группами {{ ui.icon("arrow", 14) }}</a>
|
||||
</nav>
|
||||
|
||||
<form id="move-form" method="post" action="/ui/move" hidden><input type="hidden" name="next" value="{{ page_url }}"></form>
|
||||
|
||||
<div class="card" id="dev-card">
|
||||
<div class="tools" id="tools-filters">
|
||||
<form id="dev-filters" hx-get="/ui/devices" hx-target="#devices" hx-trigger="input delay:300ms, change" onsubmit="return false">
|
||||
<input type="hidden" name="f_group" value="{{ flt.group }}">
|
||||
<label class="search">{{ ui.icon("search") }}<input type="search" name="f_q" value="{{ flt.q }}" placeholder="Поиск: имя, адрес, модель" aria-label="Поиск: имя, адрес, модель"></label>
|
||||
<select class="field {{ 'on' if flt.status }}" name="f_status" aria-label="Статус" style="width:150px">
|
||||
<option value="">Статус: любой</option>
|
||||
<option value="online" {{ 'selected' if flt.status == 'online' }}>Статус: online</option>
|
||||
<option value="offline" {{ 'selected' if flt.status == 'offline' }}>Статус: offline</option>
|
||||
</select>
|
||||
<select class="field {{ 'on' if flt.updates }}" name="f_updates" aria-label="Обновления" style="width:190px">
|
||||
<option value="">Обновления: любые</option>
|
||||
<option value="any" {{ 'selected' if flt.updates == 'any' }}>Есть обновление</option>
|
||||
<option value="ros" {{ 'selected' if flt.updates == 'ros' }}>Есть обновление ROS</option>
|
||||
<option value="fw" {{ 'selected' if flt.updates == 'fw' }}>Есть обновление FW</option>
|
||||
<option value="none" {{ 'selected' if flt.updates == 'none' }}>Всё актуально</option>
|
||||
</select>
|
||||
<select class="field {{ 'on' if flt.channel }}" name="f_channel" aria-label="Канал" style="width:150px">
|
||||
<option value="">Канал: любой</option>
|
||||
{% for c in channels %}<option value="{{ c }}" {{ 'selected' if flt.channel == c }}>Канал: {{ c }}</option>{% endfor %}
|
||||
</select>
|
||||
<span class="grow"></span>
|
||||
<a id="filters-reset" class="btn ghost" href="{{ '/?f_group=' ~ flt.group if flt.group else '/' }}" {{ 'hidden' if not flt_active }}>Сбросить ({{ flt_active }})</a>
|
||||
<span id="busy" class="busy htmx-indicator">…</span>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="tools bulk" id="tools-bulk" hidden>
|
||||
<span class="sel-count">Выбрано: <span id="sel-count">0</span></span>
|
||||
<button type="button" class="btn secondary" hx-post="/ui/batch/backup" hx-include="[name=device_ids]:checked" hx-target="#jobs">{{ ui.icon("archive") }}Создать бэкап</button>
|
||||
<button type="button" class="btn secondary" hx-post="/ui/refresh" hx-include="[name=device_ids]:checked, #dev-filters" hx-target="#devices">{{ ui.icon("refresh") }}Обновить статус</button>
|
||||
<details class="menu">
|
||||
<summary class="btn secondary">Обновление {{ ui.icon("chev", 14) }}</summary>
|
||||
<div class="menu-panel w330">
|
||||
<button type="button" class="mi warn" hx-post="/ui/batch/ros_update" hx-include="[name=device_ids]:checked" hx-target="#jobs"
|
||||
hx-confirm="Обновить ROS на выбранных устройствах? Они перезагрузятся после скачивания.">Обновить ROS до актуальной версии<small>Устройство перезагрузится после скачивания</small></button>
|
||||
<button type="button" class="mi warn" hx-post="/ui/batch/fw_update" hx-include="[name=device_ids]:checked" hx-target="#jobs"
|
||||
hx-confirm="Обновить прошивку на выбранных устройствах? Они перезагрузятся сразу после обновления.">Обновить прошивку (FW)<small>Устройство перезагрузится сразу после обновления</small></button>
|
||||
</div>
|
||||
</details>
|
||||
<details class="menu">
|
||||
<summary class="btn secondary">Канал {{ ui.icon("chev", 14) }}</summary>
|
||||
<div class="menu-panel w200">
|
||||
{% for c in channels %}<button type="button" class="mi" hx-post="/ui/batch/channel" hx-vals='{"channel": "{{ c }}"}' hx-include="[name=device_ids]:checked, #dev-filters" hx-target="#devices">{{ c }}</button>{% endfor %}
|
||||
</div>
|
||||
</details>
|
||||
<details class="menu">
|
||||
<summary class="btn secondary">В группу {{ ui.icon("chev", 14) }}</summary>
|
||||
<div class="menu-panel w200">
|
||||
{% for g in groups %}<button type="submit" form="move-form" name="group_id" value="{{ g.id }}" class="mi">{{ g.name }}</button>{% endfor %}
|
||||
{% if groups %}<hr>{% endif %}
|
||||
<button type="submit" form="move-form" name="group_id" value="" class="mi">Без группы</button>
|
||||
</div>
|
||||
</details>
|
||||
<span class="grow"></span>
|
||||
<button type="button" id="clear-sel" class="btn ghost-n">{{ ui.icon("x") }}Снять выбор</button>
|
||||
</div>
|
||||
|
||||
<div id="devices">{% include "_devices.html" %}</div>
|
||||
</div>
|
||||
|
||||
<div id="jobs" hx-get="/ui/jobs" hx-trigger="every 3s" hx-swap="innerHTML">{% include "_jobs.html" %}</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,4 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<div class="card page-card">{% include "_device_form.html" %}</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,45 @@
|
||||
{% extends "base.html" %}
|
||||
{% import "_ui.html" as ui %}
|
||||
{% block content %}
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<h1>Группы</h1>
|
||||
<div class="sub">{{ groups|length }} {{ groups|length|plural("группа", "группы", "групп") }} · {{ total }} {{ total|plural("устройство", "устройства", "устройств") }}</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button type="button" class="btn primary" hx-get="/ui/dialog/group" hx-target="#modal-body">{{ ui.icon("plus") }}Создать группу</button>
|
||||
</div>
|
||||
</div>
|
||||
{% if error %}<div class="form-err" role="alert" style="margin-bottom:16px">{{ error }}</div>{% endif %}
|
||||
<div class="card">
|
||||
<table class="grid groups">
|
||||
<colgroup><col><col style="width:200px"><col style="width:120px"></colgroup>
|
||||
<thead><tr><th>Название</th><th>Устройства</th><th><span class="sr-only">Действия</span></th></tr></thead>
|
||||
<tbody>
|
||||
{% for g in groups %}
|
||||
<tr>
|
||||
<td style="font-weight:600">{{ g.name }}</td>
|
||||
<td><a href="/?f_group={{ g.id }}" style="font-weight:500">{{ g.device_count }} {{ g.device_count|plural("устройство", "устройства", "устройств") }}</a></td>
|
||||
<td class="c-menu">
|
||||
<details class="menu right">
|
||||
<summary class="btn ghost-n icon" aria-label="Действия для группы {{ g.name }}" title="Действия">{{ ui.icon("more") }}</summary>
|
||||
<div class="menu-panel w200">
|
||||
<button type="button" class="mi" hx-get="/ui/dialog/group/{{ g.id }}" hx-target="#modal-body">Переименовать</button>
|
||||
<button type="button" class="mi bad" hx-post="/groups/{{ g.id }}/delete"
|
||||
hx-confirm="Удалить группу «{{ g.name }}»? Устройства останутся и станут «Без группы».">Удалить</button>
|
||||
</div>
|
||||
</details>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td colspan="3" class="empty">Групп пока нет. Создайте первую.</td></tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<td class="muted" style="font-weight:600">Без группы</td>
|
||||
<td><a href="/?f_group=none" style="font-weight:500">{{ ungrouped }} {{ ungrouped|plural("устройство", "устройства", "устройств") }}</a></td>
|
||||
<td class="c-menu c-small">системная</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,12 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<form method="post" action="/login" class="card login">
|
||||
<div class="modal-body">
|
||||
<h1>Вход</h1>
|
||||
{% if error %}<div class="form-err">{{ error }}</div>{% endif %}
|
||||
<label class="lbl">Логин <input class="input" name="username" autofocus required></label>
|
||||
<label class="lbl">Пароль <input class="input" name="password" type="password" required></label>
|
||||
<button class="btn primary">Войти</button>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
Reference in new issue
Block a user