Имя устройства задаётся только при создании

Имя входит в ключи бэкапов в S3 (backups/<имя>/…), поэтому после создания
не меняется (docs/changes/015):
- API: PATCH с другим именем → 400 «Имя устройства нельзя изменить»,
  то же имя допустимо;
- UI: в окне изменения поле имени только для чтения, форма изменения
  присланное имя игнорирует;
- вёрстка: минимальная ширина таблиц устройств и файлов — в узком окне
  колонка с именем не схлопывается, включается горизонтальная прокрутка.

Тесты: 12 из 12.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5 committed 2026-09-19 15:53:08 +03:00
1 parent 0914209bf8
commit 1e5fb17755
10 files changed
+60 -17

No files matched your search

+9 -7
View File
@@ -320,18 +320,20 @@ async def device_edit(request: Request, device_id: int):
@router.post("/devices/{device_id}/edit", dependencies=[Depends(require_login)])
async def device_update(request: Request, device_id: int, name: str = Form(), host: str = Form(),
port: int = Form(443), username: str = Form(), password: str = Form(""),
verify_tls: bool = Form(False), use_tls: bool = Form(False),
group_id: str = Form(""), new_group: str = Form(""), note: str = Form("")):
v = dict(name=name, host=host, port=port, username=username, group_id=group_id, new_group=new_group,
async def device_update(request: Request, device_id: int, host: str = Form(), port: int = Form(443),
username: str = Form(), password: str = Form(""), verify_tls: bool = Form(False),
use_tls: bool = Form(False), group_id: str = Form(""), new_group: str = Form(""),
note: str = Form("")):
"""Имя устройства при изменении не принимается: оно задаётся только при создании."""
current = devices.get_device(device_id)
v = dict(name=current.name, host=host, port=port, username=username, group_id=group_id, new_group=new_group,
use_tls=use_tls, verify_tls=verify_tls, note=note)
try:
gid, ng = _group_choice(group_id, new_group)
devices.update_device(device_id, name=name, host=host, port=port, username=username, password=password,
devices.update_device(device_id, host=host, port=port, username=username, password=password,
verify_tls=verify_tls, use_tls=use_tls, group_id=gid, new_group=ng, note=note)
except ValueError as e:
return _device_form(request, devices.get_device(device_id), v, str(e))
return _device_form(request, current, v, str(e))
return _done(request)
+1 -1
View File
@@ -82,7 +82,7 @@
const modal = $("#modal");
if (e.detail.target.id === "modal-body") {
if (modal && !modal.open) modal.showModal();
$("#modal-body [autofocus], #modal-body input:not([type=hidden])")?.focus();
$("#modal-body [autofocus], #modal-body input:not([type=hidden]):not([readonly])")?.focus();
const sel = $("select[name=group_id][data-newgroup]"); if (sel) $("#new-group-field").hidden = sel.value !== "__new__";
}
syncSelection(); syncFilters();
+4
View File
@@ -87,6 +87,7 @@ summary.btn::-webkit-details-marker { display: none; }
/* ---------- Поля: та же форма, что у кнопок ---------- */
.field, .input { height: 36px; margin: 0; border-radius: 8px; border: 1px solid var(--line2); background-color: var(--surf); color: var(--text); font: 400 14px/1 var(--font); }
.input { width: 100%; padding: 0 12px; }
.input[readonly] { background: var(--head); color: var(--muted); cursor: not-allowed; }
textarea.input { height: 72px; padding: 10px 12px; font-family: var(--font); line-height: 1.4; resize: vertical; }
select.field { appearance: none; -webkit-appearance: none; padding: 0 36px 0 14px; font-weight: 500; cursor: pointer;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2358657a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
@@ -149,6 +150,9 @@ table.grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.empty { height: 88px; text-align: center; color: var(--muted); }
.table-wrap { overflow-x: auto; }
@media (min-width: 1360px) { .table-wrap { overflow: visible; } }
/* при узком окне таблица прокручивается по горизонтали, а колонка с именем не схлопывается */
table.grid.devices { min-width: 1240px; }
table.grid.files { min-width: 1000px; }
.grid.jobs td { height: 48px; }
.grid.files td { height: 52px; }
.grid.groups td { height: 56px; }
+3 -2
View File
@@ -9,8 +9,9 @@
</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>{% if edit %}задаётся при создании и не меняется — входит в ключи бэкапов{% else %}латиница, цифры, «.», «_», «-»; попадает в ключи бэкапов{% endif %}</small></span>
{% if edit %}<input class="input" value="{{ v.name }}" readonly aria-readonly="true" tabindex="-1">
{% else %}<input class="input" name="name" value="{{ v.name }}" maxlength="64" required autofocus>{% endif %}</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">
+1 -1
View File
@@ -1,7 +1,7 @@
{% 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">
<table class="grid devices">
<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>