Group instances by service type, collapsible lists

This commit is contained in:
2026-07-23 17:59:59 +04:00
parent 8e2387f91c
commit aa738474e4
2 changed files with 16 additions and 11 deletions
+10 -5
View File
@@ -57,9 +57,16 @@ def index():
raw_inst = get_instances(client) raw_inst = get_instances(client)
instances = [i for i in raw_inst instances = [i for i in raw_inst
if i.get("explainedStatus") not in ("deleted", "not created") if i.get("explainedStatus") not in ("deleted", "not created")
and i.get("serviceId") not in (109, 110, 111)] # DNS — не показываем and i.get("serviceId") not in (109, 110, 111)]
# org first, then rest
instances.sort(key=lambda i: (0 if i.get("serviceId") == 19 else 1, i.get("displayName", ""))) 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() config = load_config()
except Exception as e: except Exception as e:
error = str(e) error = str(e)
@@ -68,9 +75,7 @@ def index():
organization=org, error=error, organization=org, error=error,
env_token_masked=_mask(env_token), env_token_masked=_mask(env_token),
has_user_token=bool(user_token), has_user_token=bool(user_token),
services=services, instance_groups=instance_groups)
instances=instances,
config=config)
@bp.route("/api/operations/<int:svc_id>") @bp.route("/api/operations/<int:svc_id>")
+6 -6
View File
@@ -36,18 +36,18 @@
</div> </div>
</div> </div>
{% endif %} {% endif %}
{% if instances %} {% for svc_name, items in instance_groups.items() %}
<div class="card" style="margin-top:8px;"> <div class="card" style="margin-top:8px;">
<div class="card-header" style="cursor:pointer;" onclick="this.nextElementSibling.style.display=this.nextElementSibling.style.display==='none'?'block':'none'">Инстансы ({{ instances|length }})</div> <div class="card-header" style="cursor:pointer;font-size:13px;" onclick="this.nextElementSibling.style.display=this.nextElementSibling.style.display==='none'?'block':'none'">{{ svc_name }} ({{ items|length }})</div>
<div class="card-body" style="padding:0;max-height:60vh;overflow-y:auto;"> <div class="card-body" style="padding:0;max-height:200px;overflow-y:auto;">
<table> <table>
{% for i in instances %} {% for i in items %}
<tr><td style="font-size:12px;">{{ i.displayName }}</td><td style="font-size:11px;color:var(--muted);">{{ i.svc }}</td><td><span class="badge badge-success" style="font-size:10px;">{{ i.explainedStatus or "?" }}</span></td></tr> <tr><td style="font-size:12px;">{{ i.displayName }}</td><td><span class="badge badge-success" style="font-size:10px;">{{ i.explainedStatus or "?" }}</span></td></tr>
{% endfor %} {% endfor %}
</table> </table>
</div> </div>
</div> </div>
{% endif %} {% endfor %}
</div> </div>
<div class="right"> <div class="right">
<p>Скоро здесь будут тесты.</p> <p>Скоро здесь будут тесты.</p>