diff --git a/ops/work/web/app.py b/ops/work/web/app.py index a68ee91..8959240 100644 --- a/ops/work/web/app.py +++ b/ops/work/web/app.py @@ -334,6 +334,41 @@ class Data: return {"host": host, "host_ports": {"in": h_in, "out": h_out, "source": h_src}, "links": links} + # ── проверка одной пары: хост + устройство ── + def check_pair(self, host_key, accessory): + hk = norm(host_key) + ak = norm(accessory) + host = self.devices.get(hk, {}).get("name") + acc_name = self.devices.get(ak, {}).get("name") or accessory + if not host: + return {"error": "хост не найден"} + found = None + for e in self.edges.get(hk, []): + if norm(e["to"]) == ak: + found = e + break + if not found: + return {"host": host, "device": acc_name, "known": False, + "supported": False, "verdict": "нет в матрице для этого хоста", + "note": "устройство не описано как аксессуар этого хоста"} + supported = bool(found.get("supported")) + usable = found.get("usable", True) + if not usable: + verdict = "исключено: источники расходятся — требуется проверка у вендора" + elif supported: + q = found.get("max_qty") + verdict = "совместимо" + (" (до %s шт)" % q if q else "") + else: + verdict = "несовместимо" + cond = re.sub(r"^[\u221a\u2713\u2714\u00d7\u2717\u2718\u2022\s]+", "", + (found.get("condition") or "")).strip() # cond_clean + return {"host": host, "device": acc_name, "known": True, + "supported": supported, "usable": usable, + "max_qty": found.get("max_qty"), + "condition": cond, + "source": found.get("source") or "матрица", + "verdict": verdict} + # ── матрица: хосты × аксессуары + порты ── def matrix(self): hosts = [h for h in self.hosts()] @@ -673,6 +708,9 @@ class H(BaseHTTPRequestHandler): return self._out({"missing": D.extra.get("missing") or []}) if p == "/api/kits": return self._out(D.kits) + if p == "/api/check": + return self._out(D.check_pair(q.get("host", [""])[0], + q.get("device", [""])[0])) if p == "/api/matrix": return self._out(D.matrix()) if p == "/api/ports": diff --git a/ops/work/web/index.html b/ops/work/web/index.html index c0d26c5..6445b30 100644 --- a/ops/work/web/index.html +++ b/ops/work/web/index.html @@ -128,7 +128,16 @@ svg{width:100%;height:480px;background:#0a0e13;border:1px solid var(--line);bord -
+| Хост | in | out | '; accs.forEach(a=>{html+=`${esc(a).slice(0,26)} | `}); html+='|
|---|---|---|---|---|
| ${esc(r.host)} | + rows.forEach((r,ri)=>{ + html+=`||||
| ${esc(r.host)} | ${(r.ports.in||['—']).join(',')} | ${(r.ports.out||['—']).join(',')} | `; accs.forEach(a=>{ const v=r.cells[a.toLowerCase().replace(/[^a-z0-9]/g,'')]; - html+=`${v?(v>1?v:'✓'):'·'} | `; + html+=`${v?(v>1?v:'✓'):'·'} | `; }); html+='