[WORK] Схема самодокументируемая: тип связи (wireless/power/video/net/data) в модели и отдельные стили + легенда. Проверено: 7 рёбер размечены (net 1, data 3, wireless 2, video 1), 5 стилей на странице

This commit is contained in:
root committed 2026-11-12 15:00:45 +03:00
1 parent 44daa09c75
commit 1d313ec07d
3 files changed
+86 -3

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
# Типы связей и легенда схемы (12.11.2026)
## Что добавлено
Рёбра схемы теперь несут **тип связи** (`kind`), рассчитанный из подписи:
| Тип | Как рисуется | Что означает |
|---|---|---|
| `wireless` | зелёный пунктир | Wi-Fi / WL |
| `power` | красный точечный | 220 В |
| `video` | синий | HDMI / DP |
| `net` | жёлтый | LAN / RJ45 |
| `data` | серый | USB / VCH / 3.5 мм |
| `other` | синий (по умолчанию) | не распознано |
Под холстом — **легенда**, чтобы схему можно было читать без пояснений.
## Проверка
```
рёбер: 7 | по типам: {net: 1, data: 3, wireless: 2, video: 1}
net LAN → LAN → RCH40 E2
data USB → USB → UVC86
data ? → VCH → MSpeaker Pro
wireless WL → WL → WPP30
легенда на странице: есть
стилей по типам: 5
```
Это делает схему **самодокументируемой**: видно, где кабель, где Wi-Fi,
где питание.
## Почему типы, а не только подписи
Раньше все линии выглядели одинаково, и приходилось читать каждую подпись.
Теперь тип виден сразу — важно, когда в комнате 10+ устройств.
## Что осталось
1. **Раскладка dagre** не учитывает тип связи при распределении (все рёбра
равнозначны). Можно задать вес: питание — в нижний ярус, Wi-Fi — ближе
к хабу.
2. **Беспроводные связи** в dagre не влияют на ранги — они могут идти
«вбок», хотя логически это подключение.
+5 -1
View File
@@ -60,7 +60,11 @@ def main():
hubs = rules.get("hubs") or []
# берём самые «богатые» хабы
targets = [h for h in hubs if h.get("count", 0) >= 3][:LIMIT]
have_llm = {str(n.get("device")) for n in (rules.get("notes") or [])
if n.get("note_llm")}
targets = [h for h in hubs
if h.get("count", 0) >= 3 and str(h.get("device")) not in have_llm][:LIMIT]
print("к обработке:", len(targets), "| уже с LLM:", len(have_llm))
if not targets:
print("нет целей")
return
+36 -2
View File
@@ -26,6 +26,24 @@ STATIC = "/root/buryan-infra/ops/work/web/static"
os.makedirs(LAY, exist_ok=True)
def edge_kind(label):
"""Тип связи по подписи: беспроводно / питание / видео / сеть / данные."""
t = str(label or "").lower()
if "wi-fi" in t or "wl" in t or "беспровод" in t:
return "wireless"
if "220" in t:
return "power"
if "hdmi" in t or "dp" in t:
return "video"
if "lan" in t or "rj45" in t:
return "net"
if "usb" in t or "vch" in t or "3.5" in t:
return "data"
return "other"
def items_of(q):
out = []
for raw in (q.get("item") or []):
@@ -113,7 +131,7 @@ def auto_model(q):
"y": via_node["y"] + 120,
"under": via_node["id"]})
edges.append({"source": via_node["id"], "target": rid,
"label": elabel})
"label": elabel, "kind": edge_kind(elabel)})
continue
col = i % per_row
@@ -122,7 +140,8 @@ def auto_model(q):
"role": role_of(r["device"]) or "",
"ok": bool(r["ok"]),
"x": start_x + col * step, "y": y + row * 90})
edges.append({"source": "host", "target": rid, "label": elabel})
edges.append({"source": "host", "target": rid, "label": elabel,
"kind": edge_kind(elabel)})
place(tiers["switch"], 60, per_row=3, start_x=420, step=300)
place(tiers["hub"], 170, per_row=4, start_x=140, step=280)
@@ -235,6 +254,14 @@ border-radius:6px;padding:5px 8px;font-size:13px}
<div id="list"></div>
</div>
<div id="cy"></div>
<div id="legend" style="position:absolute;left:270px;bottom:10px;font-size:11px;
color:#8b9cb0;background:#0d1117cc;border:1px solid #233040;border-radius:6px;padding:6px 10px">
<span style="color:#3fb950">— — Wi-Fi</span> ·
<span style="color:#2f81f7">— видео</span> ·
<span style="color:#d29922">— сеть</span> ·
<span style="color:#8b949e">— данные</span> ·
<span style="color:#f85149">···· 220 В</span>
</div>
</div>
<script src="/static/dagre.min.js"></script>
<script src="/static/cytoscape.min.js"></script>
@@ -268,6 +295,13 @@ function initCy(){
{selector:'edge',style:{'width':1.6,'line-color':'#2f81f7','target-arrow-color':'#2f81f7',
'target-arrow-shape':'triangle','curve-style':'bezier','label':'data(label)',
'font-size':9,'color':'#8b9cb0','text-rotation':'autorotate'}},
{selector:'edge[kind="wireless"]',style:{'line-style':'dashed','line-color':'#3fb950',
'target-arrow-color':'#3fb950','width':2}},
{selector:'edge[kind="power"]',style:{'line-style':'dotted','line-color':'#f85149',
'target-arrow-color':'#f85149','width':2}},
{selector:'edge[kind="video"]',style:{'line-color':'#2f81f7','target-arrow-color':'#2f81f7','width':2}},
{selector:'edge[kind="net"]',style:{'line-color':'#d29922','target-arrow-color':'#d29922'}},
{selector:'edge[kind="data"]',style:{'line-color':'#8b949e','target-arrow-color':'#8b949e'}},
{selector:':selected',style:{'border-color':'#f0883e','line-color':'#f0883e',
'target-arrow-color':'#f0883e'}}
]});