From aa738474e432b111a25333826dffc23f52fa2288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Thu, 23 Jul 2026 17:59:59 +0400 Subject: [PATCH] Group instances by service type, collapsible lists --- site/routes/main.py | 15 ++++++++++----- site/templates/index.html | 12 ++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/site/routes/main.py b/site/routes/main.py index 1ebe9a1..db8db19 100644 --- a/site/routes/main.py +++ b/site/routes/main.py @@ -57,9 +57,16 @@ def index(): raw_inst = get_instances(client) instances = [i for i in raw_inst if i.get("explainedStatus") not in ("deleted", "not created") - and i.get("serviceId") not in (109, 110, 111)] # DNS — не показываем - # org first, then rest + and i.get("serviceId") not in (109, 110, 111)] instances.sort(key=lambda i: (0 if i.get("serviceId") == 19 else 1, i.get("displayName", ""))) + + # group non-org instances by service type + instance_groups = {} + for i in instances: + if i.get("serviceId") == 19: + continue + svc_name = i.get("svc", "Прочее") + instance_groups.setdefault(svc_name, []).append(i) config = load_config() except Exception as e: error = str(e) @@ -68,9 +75,7 @@ def index(): organization=org, error=error, env_token_masked=_mask(env_token), has_user_token=bool(user_token), - services=services, - instances=instances, - config=config) + instance_groups=instance_groups) @bp.route("/api/operations/") diff --git a/site/templates/index.html b/site/templates/index.html index a42a2d3..b621811 100644 --- a/site/templates/index.html +++ b/site/templates/index.html @@ -36,18 +36,18 @@ {% endif %} - {% if instances %} + {% for svc_name, items in instance_groups.items() %}
-
Инстансы ({{ instances|length }})
-
+
{{ svc_name }} ({{ items|length }})
+
- {% for i in instances %} - + {% for i in items %} + {% endfor %}
{{ i.displayName }}{{ i.svc }}{{ i.explainedStatus or "?" }}
{{ i.displayName }}{{ i.explainedStatus or "?" }}
- {% endif %} + {% endfor %}

Скоро здесь будут тесты.