From 48907772279bda00be7af982cf66c8269bff2895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Thu, 23 Jul 2026 12:00:52 +0400 Subject: [PATCH] Two-column layout: org+instances left, services right (collapsible) --- site/routes/main.py | 13 ++- site/templates/index.html | 215 ++++++++++++++++++++++---------------- 2 files changed, 135 insertions(+), 93 deletions(-) diff --git a/site/routes/main.py b/site/routes/main.py index 486da4c..813bfbf 100644 --- a/site/routes/main.py +++ b/site/routes/main.py @@ -1,7 +1,7 @@ from flask import Blueprint, current_app, render_template, request, make_response, jsonify from api.http_client import HttpClient -from operations.get_instances import get_organization +from operations.get_instances import get_organization, get_instances from operations.get_services import get_services, get_service_detail bp = Blueprint("main", __name__) @@ -42,6 +42,7 @@ def index(): return resp services = [] + instances = [] if active_token: try: client = HttpClient( @@ -49,8 +50,11 @@ def index(): active_token, ) org = get_organization(client) - raw = get_services(client) - services = sorted(raw, key=lambda s: (s.get("svcId", 0), s.get("svc", ""))) + raw_svc = get_services(client) + services = sorted(raw_svc, key=lambda s: (s.get("svcId", 0), s.get("svc", ""))) + instances = get_instances(client) + # org first, then rest + instances.sort(key=lambda i: (0 if i.get("serviceId") == 19 else 1, i.get("displayName", ""))) except Exception as e: error = str(e) @@ -58,7 +62,8 @@ def index(): organization=org, error=error, env_token_masked=_mask(env_token), has_user_token=bool(user_token), - services=services) + services=services, + instances=instances) @bp.route("/api/operations/") diff --git a/site/templates/index.html b/site/templates/index.html index 60de183..413e225 100644 --- a/site/templates/index.html +++ b/site/templates/index.html @@ -6,107 +6,144 @@ + -
-
- Организация -
- - - {% if has_user_token %} - - {% endif %} -
-
-
- {% if error %} -

{{ error }}

- {% elif organization %} -

{{ organization.displayName }} — {{ organization.explainedStatus or "OK" }}

- {% else %} -

Введите токен

- {% endif %} -
-
- {% if services %} -
-
Сервисы ({{ services|length }})
-
- - - - - - - - - - {% for s in services %} - - - - - - - + + + + {% if has_user_token %} + + {% endif %} + {% if error %}{{ error }}{% endif %} + + +
+ + +
+ {% if organization %} +
+
Организация
+
+
#СервисОперации
{{ s.svcId }}{{ s.svc }}{% if s.svcExtendedName %} — {{ s.svcExtendedName }}{% endif %} - ? -
+ + + +
Имя{{ organization.displayName }}
UID{{ organization.instanceUid }}
Статус{{ organization.explainedStatus or "OK" }}
+
+
+ {% endif %} + + {% if instances %} +
+
+ Инстансы ({{ instances|length }}) +
+
+ + {% for i in instances %} + + + + {% endfor %} - -
{{ i.displayName }}{{ i.svc }}{{ i.explainedStatus or "?" }}
+ +
+ {% endif %} - - {% endif %} + document.querySelectorAll('.ops-detail').forEach(d => d.style.display = 'none'); + document.querySelectorAll('.svc-row').forEach(r => r.style.background = ''); + row.style.background = 'var(--brand-grey-light)'; + detail.style.display = 'table-row'; + if (opsCache[svcId]) { + fillDetail(svcId, opsCache[svcId]); + return; + } + detail.cells[0].innerHTML = 'Загрузка...'; + try { + const r = await fetch('/api/operations/' + svcId); + const d = await r.json(); + opsCache[svcId] = d; + fillDetail(svcId, d); + } catch(e) { + detail.cells[0].innerHTML = 'Ошибка'; + } + }); +}); + +function fillDetail(svcId, data) { + const detail = document.getElementById('detail-' + svcId); + if (data.error) { + detail.cells[0].innerHTML = '' + data.error + ''; + return; + } + const ops = data.operations || []; + document.getElementById('ops-' + svcId).textContent = ops.length; + detail.cells[0].innerHTML = ops.map(o => + '' + o.operation + '' + ).join('') || 'Нет операций'; +} + -