[WORK] Вкладка «Матрица и порты» (25 хостов × 47 аксессуаров), комплектация и ограничения из даташитов; не дублировать кабели в BOM

This commit is contained in:
root committed 2026-11-06 16:06:39 +03:00
1 parent daffbe41dd
commit b234740dcc
6 files changed
+431

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
# Вкладка «Матрица и порты»
Дата: 06.11.2026. Отдельный экран: только матрица совместимости и порты.
## Что внутри
### 1. Матрица совместимости
- **25 хостов × 47 аксессуаров**
- в ячейке: `✓` (до 1) или число (максимум штук)
- показаны порты хоста (in / out)
- фильтр по модели + галочка «только с портами из даташита»
### 2. Порты, комплектация, ограничения
Таблица по **131 устройству**:
| Колонка | Что |
|---|---|
| входы / выходы | HDMI, USB, USB-C, VCH, LAN, 3.5mm, Phoenix |
| источник | **даташит** / извлечено / по роли |
| комплектация | что в коробке |
| ограничения | запреты из даташита |
## Про комплектацию (ваше замечание)
**Вы правы:** если кабель входит в комплект — не надо добавлять его в BOM.
Из даташитов извлечено (10 устройств):
| Устройство | В комплекте |
|---|---|
| **CP50** | DC-адаптер 48В/0.7А, Ethernet 7.5 м, USB-C 1.2 м, стяжки |
| **CPE40** | Ethernet 3 м, стяжки, крышка, винт, QSG |
| **MeetingBar A40** | пакет A40-031: CTP25 + PD-адаптер 2 м 65 Вт + сетевой 7.5 м |
| **MCore** | кронштейн в комплекте |
| **UVC40 E2** | VCR20 + 2 батарейки AAA, адаптер питания |
| **UVC85-BYOD** | VCR20 + батарейки, DC-адаптер 48В, кронштейн |
**Правило для BOM:** позиция из комплектации помечается «в комплекте» и не
дублируется.
## Ограничения, найденные в даташитах
| Устройство | Ограничение |
|---|---|
| **UVC86** | HDMI-выход совместим с VCS, но **НЕ с MVC**; зависит от версии ПО |
| **MeetingDisplay** | тележка **не подходит** для MeetingDisplay 55 + MCore 4 |
| **MB-FS-VESA** | **не подходит** для MeetingDisplay 55 + MVC S40 |
## Комплектация: качество данных
Извлечение пока грязное: теряются цифры (`7.5m` → `.5m`), склеиваются названия.
Поэтому:
- показываем как есть со словом «извлечено»
- в BOM не добавляем кабели автоматически, пока данные не выверены
## Что дальше
1. **Выверить комплектацию** для 10 устройств вручную (как порты: отдельный файл)
2. **Добавить ограничения** — их всего 2, на сайте Yealink их больше
3. **BOM: блок «в комплекте»** — чтобы не покупать лишнее
4. **Порты остальных ~100 устройств**
+11
View File
@@ -0,0 +1,11 @@
source: даташиты Yealink, ограничения
devices:
- device: MeetingDisplay
limits:
- 'Optional Accessories: The cart cannot be used to mount MeetingDisplay 55 + MCore 4; 2'
- nd Installation MB-FS-Lift / MB- FS-VESA[1] MD-AVBracket-S MCore bracket (Included in the package) 💡 [1] MB-FS- VESA is not suitable for MeetingDispla y 55 + MVC S40
- '💡: The cart cannot be used to mount MeetingDisplay 55 + MCore 4; 2'
- '💡: [1] MB-FS- VESA is not suitable for MeetingDispla y 55 + MVC S40'
- device: UVC86
limits:
- '💡: Please note that this HDMI output port is only compatible with a specific version and may limit some functions'
+135
View File
@@ -0,0 +1,135 @@
source: даташиты Yealink, разделы Package
devices:
- device: CP50
items:
- CP50
- DC power adapter(standard 48V/0.7A, optional 48V/2A)
- .5m Ethernet cable
- .2m dual
- head USB
- C cable
- Cable ties * 2
- Cable cover * 1;Screw * 2
- 'Quick Start Guide Package Features: Quantity:4 Package Features: N.W/CTN:6.1 kg Package Features: G.W/CTN:6.7 kg Package Features: Dimensions:665 *221 * 252 mm Package Features: Giftbox Size: 241 *
216 * 162 mm Package Features: Carton Size:665 * 221 * 252 mm 1: Codec Port Connect to a UVC Camera (such as UVC85) or VC Host (such as MeetingEye 500). 2: DC48V Connect to the power adapter. 3: Type'
- 'C Connect to PC. 4: Audi'
evidence: 'Package Features: Package includes: - CP50 - DC power adapter(standard 48V/0.7A, optional 48V/2A) - 7.5m Ethernet cable - 1.2m dual-head USB-C cable - Cable ties * 2 - Cable cover * 1;Screw
* 2 - Quick Start Guide Package Features: Quantity:4 Package Features:'
- device: CPE40
items:
- CPE40
- m Ethernet cable
- Cable ties * 1
- Cable cover * 1;Screw * 1
- 'Quick Start Guide Package Features: Quantity:4 Package Features: N.W/CTN:4.1 kg Package Features: G.W/CTN:4.8 kg Package Features: Dimensions:151.8 * 151.8 * 75.3 mm Package Features: Giftbox Size:
241 * 216 * 162 mm Package Features: Carton Size:665 * 221 * 252 mm 1: Codec Port Connect the previous omnidirectional microphone. 2: Type'
- 'C Connect to PC (for internal debugging, unavailable for external functionalities currently). 3: Audio Port Connect the next omnidirectional microphone CPE40. LLEEDD SStt'
evidence: 'Package Features: Package includes: - CPE40 - 3m Ethernet cable - Cable ties * 1 - Cable cover * 1;Screw * 1 - Quick Start Guide Package Features: Quantity:4 Package Features: N.W/CTN:4.1 kg
Package Features: G.W/CTN:4.8 kg Package Features: Dimensions:151.8 *'
- device: CT300
items:
- × CT300 1 × 3 m Cat5 cable 1 × 1.0 m USB 3.0 Type
- C to Type
- 'A Cable (for management port) 1 × Power adapter (12V / 2A) Environmental Factors: Operating humidity: 10% ~ 95% Operating temperature:'
- '°C ~ +45°C Storage temperature:'
- '°C ~ 70°C Dimensions and Weight (W × D × H): Giftbox size: 259 × 193 × 124 mm Carton size: 635 × 265 × 209 mm Dimensions: 216 × 160 × 36.7 mm G.W/CTN: 9.133 kg N.W/CTN: 8.485 kg Weight: 1.07 kg Quantity/carton:
5 pcs'
evidence: 'Package Contents: 1 × CT300 1 × 3 m Cat5 cable 1 × 1.0 m USB 3.0 Type-C to Type-A Cable (for management port) 1 × Power adapter (12V / 2A) Environmental Factors: Operating humidity: 10% ~ 95%
Operating temperature: -10°C ~ +45°C Storage temperature: -30°C ~ 70'
- device: MB-12X Pro
items:
- 'X Pro Quick Start Guide Screwdriver Mounting Screws Power consumption: Average: 8.8 W Peak: 13.3 W Standby: 8.4 W Physical Features: Carton Meas: 245 mm x 287 mm x 125 mm Weight:'
- 'N.W: 1 kg'
- G.W:1.35 kg
evidence: 'Package Contents: MB-12X Pro Quick Start Guide Screwdriver Mounting Screws Power consumption: Average: 8.8 W Peak: 13.3 W Standby: 8.4 W Physical Features: Carton Meas: 245 mm x 287 mm x 125
mm Weight: - N.W: 1 kg - G.W:1.35 kg'
- device: MTouch Plus
items:
- 'MTouch Plus Touch Panel Package Content: Mounting Bracket Package Content: Double'
- 'Coating Tape Package Content: USB Type'
- 'C Cable (with HDMI Adapter) Package Content: 7.5m Ethernet Cable Package Content: WPP30 (Optional) Package Content: 65W PD Power Supply (Optional) MTouch Plus: 1 MCore Pro Port VCH Port Logistic Information:
Weight: 0.967 kg Logistic Information: Qty/CTN: 3 PCS Logistic Information: N.W/CTN: 5.7 kg Logistic Information: G.W/CTN: 6.2 kg Logistic Information: Giftbox: 327 × 105 × 220 mm Logistic Information:
Carton Meas: 350 × 335 × 260 mm'
evidence: 'Package Content: MTouch Plus Touch Panel Package Content: Mounting Bracket Package Content: Double-Coating Tape Package Content: USB Type-C Cable (with HDMI Adapter) Package Content: 7.5m Ethernet
Cable Package Content: WPP30 (Optional) Package Content: 65W PD'
- device: MVC MCoreKit-C5U
items:
- MCore 4,Gen
- Mini
- PC MTouch Plus, Gen
- 'touch panel RoomSensor Preload: Windows 11 IoT enterprise X64 Windows 11 IoT enterprise license Package: content MCore: 4,Gen'
- 'Mini PC MCore: 4, Gen'
- 'Mini PC MTouch: Plus, Gen'
- 'touch panel MTouch: plus Windows: 11 IoT enterprise X64 Windows: 11 IoT enterprise license MCore 4, Gen'
- Mini
- 'PC: Processor: Intel Ultra5 125H Memory: 16GB(2*8GB) DDR5 Storage: 256GB SSD BIOS feature: 3x HDMI video output'
- CEC
- 'EDID TPM2.0 Kernel DMA Interfaces: 1 x HDMI'
- Out 2.1 port 2 x HDMI
evidence: 'Package content: MCore 4,Gen-4 Mini-PC MTouch Plus, Gen-3 touch panel RoomSensor Preload: Windows 11 IoT enterprise X64 Windows 11 IoT enterprise license Package: content MCore: 4,Gen-4 Mini
PC MCore: 4, Gen-4 Mini PC MTouch: Plus, Gen-3 touch panel MTouch: pl'
- device: MeetingEye 500
items:
- 'N.W/ CTN : 10.5kg G.W/: CTN : 11.2kg Giftbox s: ize: 455mm x 400mm x 2 55mm Audio Te: chnology Multi'
- 'c: hannel acoustic echo cancellation Multi'
- 'c: hannel'
evidence: 'Package Features: N.W/ CTN : 10.5kg G.W/: CTN : 11.2kg Giftbox s: ize: 455mm x 400mm x 2 55mm Audio Te: chnology Multi-c: hannel acoustic echo cancellation Multi-c: hannel'
- device: UVC40 E2
items:
- UVC40 E2 all
- 'one USB video bar Package Content: VCR20 Remote Control, 2 x AAA battery Package Content: Power adapter Package Content: Wall bracket and accessories Package Content: TV Mount Bracket and Accessories
Package Content: 7m USB cable Package Content: Desktop Stand (optional) Package Content: Velcro Package Content: Quick Start Guide Package Content: Silicone Pad Package Content: Cable Ties Camera: 8M
P Camera with SONY 1/1.8 inch CMOS 120: ° Ultra'
- 'Wi de Field of View 5x: e'
- 'PTZ cam Package: Conten Package: Feature UVC40: E2 all in'
- 'one USB v ideo b ar VCR20: Remot e Control, 2 x AAA'
evidence: 'Package Content: UVC40 E2 all-in-one USB video bar Package Content: VCR20 Remote Control, 2 x AAA battery Package Content: Power adapter Package Content: Wall bracket and accessories Package
Content: TV Mount Bracket and Accessories Package Content: 7m USB cab'
- device: UVC85-BYOD
items:
- UVC85
- VCR20 Remote Control and 2 AAA Batteries
- DC Power Adapter (48V/0.7A)
- Wall Mount Bracket and Accessories
- .5m USB Cable (USB
- A to USB
- .5m Gigabit Ethernet Cable
- Cable ties * 2
- Lens Cap
- 'UVC85 Quick Start Guide Package includes: CP50'
- DC power adapter (standard 48V/0.7A, optional 48V/2A)
- .5m Ethernet cable
evidence: 'Package includes: UVC85 - VCR20 Remote Control and 2 AAA Batteries - DC Power Adapter (48V/0.7A) - Wall Mount Bracket and Accessories - 2.5m USB Cable (USB-A to USB-B) - 7.5m Gigabit Ethernet
Cable - Cable ties * 2 - Lens Cap - UVC85 Quick Start Guide Package '
- device: UVC86
items:
- 'Package Content UVC86 Camera VCR20: Remote Control Power: Adapter Wall: Bracket and Accessories 7m: USB Cable (2.5m for MVC bundle) PTZ Camera: 8MP Sony Sensor Auto: Focus PTZ: Camera 90°: DFOV, 81°
HFOV, 50° VFOV 20.4x: HD z oom ( 12x optical, 1.7x digital) Pan:: ±100 °, Tilt: +40°, 90° Focal: length: 1m infinity 9: Camera Preset Panoramic Camera: 8MP Sony Senso r HFOV, 78° VFOV 120°: DFOV, 110°
HFOV, 78° VFOV Manual: Til t: ±9° AI Features: Auto Framing Speaker Tr: ackin Speaker Tr: PIP Multi: Focu Presenter: Tracking (Wide Area, Stage, and Segment Tracking) UVC86 Connections: 1 x USB3.0 Typ'
evidence: 'Package Content: Package Content UVC86 Camera VCR20: Remote Control Power: Adapter Wall: Bracket and Accessories 7m: USB Cable (2.5m for MVC bundle) PTZ Camera: 8MP Sony Sensor Auto: Focus
PTZ: Camera 90°: DFOV, 81° HFOV, 50° VFOV 20.4x: HD z oom ( 12x optical'
- device: UVC86 E2
items:
- 'UVC86 E2 Camera Package Content: VCR20 Remote Control Package Content: Power Adapter Package Content: Wall Bracket and Accessories Package Content: 2.5m USB Cable PTZ Camera: 8MP Sony Sensor Panoramic
Camera: 8MP Sony Sensor Panoramic Camera: 104° DFOV, 96° HFOV, 62° VFOV Panoramic Camera: Manual Tilt: ±10° AI Features: Auto Framing AI Features: Speaker Tracking AI Features: PIP AI Features: Multi
Focus AI Features: Presenter Tracking (Wide Area, Stage, and Segment Tracking) UVC86 E2 Connections: 1 x USB3.0 Type'
- 'B Port UVC86 E2 Connections: 1 x USB2.0 Type'
- 'A Port UVC86 E2 Connections: 1 x Yeal'
evidence: 'Package Content: UVC86 E2 Camera Package Content: VCR20 Remote Control Package Content: Power Adapter Package Content: Wall Bracket and Accessories Package Content: 2.5m USB Cable PTZ Camera:
8MP Sony Sensor Panoramic Camera: 8MP Sony Sensor Panoramic Camera: '
- device: VCM35
items:
- 'VCM35 Package Contents: RJ45 connector for Ethernet cable Package Contents: Double'
- 'sided tape Package Contents: Quick Start Guide Package Contents: Qty/CTN: 20 PCS Package Contents: N.W/CTN: 4.878 kg Package Contents: G.W/CTN: 5.612 kg Package Contents: Giftbox size: 148 x 135 x
45 mm Package Contents: Carton Meas: 464 x 282 x 165 mm RJ45: connector fo r Ethernet cable Double: sided tape Quick S: tart Qty/: CTN: 20 PCS N.W/: CTN: 4.878 kg G.W/: CTN: 5.612 kg Giftbox: size:
148 x 135 x 45 mm Carton: Meas: 464 x 282 x 165 mm LED: Status Description Solid red: Muting Solid: green The audio can be'
evidence: 'Package Contents: VCM35 Package Contents: RJ45 connector for Ethernet cable Package Contents: Double-sided tape Package Contents: Quick Start Guide Package Contents: Qty/CTN: 20 PCS Package
Contents: N.W/CTN: 4.878 kg Package Contents: G.W/CTN: 5.612 kg Packag'
- device: VCM36-W
items:
- x VCM36
- 'W Video Conference Microphone 1x: Charger Cr 1x: 1.2 m USB 1x: USB Adapt er (not included for the Thailand market) Double'
- 'sided: adhesiv Quick: Start G Package Features: Qty/ CTN: 20 P CS 68 kg 78 kg 184 x 112 x 60 mm 635 x 237 x 200 mm N.W/: CTN: 8.0 G.W/: CTN: 8.6 Giftbox size:: 184 x 112 x 6 0 mm Carton Meas:: 635
x 23 7 x 2 00 mm Wi: Fi Physical: Features Package: Contents Package: Features'
evidence: 'Package Contents: 1x VCM36-W Video Conference Microphone 1x: Charger Cr 1x: 1.2 m USB 1x: USB Adapt er (not included for the Thailand market) Double-sided: adhesiv Quick: Start G Package Features:
Qty/ CTN: 20 P CS 68 kg 78 kg 184 x 112 x 60 mm 635 x 237 x 200'
+93
View File
@@ -0,0 +1,93 @@
#!/usr/bin/env python3
"""Комплектация и ограничения из даташитов Yealink.
Ищет секции «Package includes», «Package Contents», «Optional package»
и ограничения вида «not suitable for», «is not compatible with».
"""
import glob
import os
import re
import sys
BASE = "/opt/work-hub/compat"
DEV = "/opt/work-hub/devices/yealink"
def clean(s):
s = re.sub(r"\s+", " ", str(s)).strip()
return s
def split_items(text):
"""' - CP50 - DC power adapter ... - 7.5m Ethernet cable' -> список."""
parts = re.split(r"\s*[-–—]\s*", text)
out = []
for p in parts:
p = clean(p)
p = re.sub(r"^\*?\s*\d*\s*", "", p)
if len(p) < 3:
continue
if re.search(r"package|includes|content", p, re.I) and len(p) < 30:
continue
out.append(p)
return out[:12]
def main():
import yaml
pkg, limits = {}, {}
for f in glob.glob(os.path.join(DEV, "*.yaml")):
try:
d = yaml.safe_load(open(f, encoding="utf-8"))["device"]
except Exception:
continue
model = re.sub(r"\s*\(\d+\)?\s*$", "", d.get("model") or "").strip()
lines = []
for k, vals in (d.get("specs") or {}).items():
for v in vals:
lines.append(clean("%s: %s" % (k, v)) if k else clean(v))
blob = "\n".join(lines)
# комплектация
m = re.search(r"(?:Package includes|Package Contents?|Package Features?)[:\s]*(.{10,600})",
blob, re.I | re.S)
if m:
items = split_items(m.group(1))
if items:
pkg[model] = {"items": items,
"evidence": clean(m.group(0))[:260]}
# ограничения
found = []
for pat in (r"[^.\n]{0,120}not suitable for[^.\n]{0,120}",
r"[^.\n]{0,120}(?:is not compatible with|are not compatible with)[^.\n]{0,120}",
r"[^.\n]{0,120}cannot be (?:used|connected)[^.\n]{0,120}",
r"[^.\n]{0,120}only compatible with[^.\n]{0,120}"):
for mm in re.finditer(pat, blob, re.I):
t = clean(mm.group(0))
if 15 < len(t) < 240:
found.append(t)
if found:
limits[model] = sorted(set(found))[:6]
with open(os.path.join(BASE, "package.yaml"), "w", encoding="utf-8") as f:
yaml.safe_dump({"source": "даташиты Yealink, разделы Package",
"devices": [{"device": k, **v} for k, v in sorted(pkg.items())]},
f, allow_unicode=True, sort_keys=False, width=200)
with open(os.path.join(BASE, "limitations.yaml"), "w", encoding="utf-8") as f:
yaml.safe_dump({"source": "даташиты Yealink, ограничения",
"devices": [{"device": k, "limits": v} for k, v in sorted(limits.items())]},
f, allow_unicode=True, sort_keys=False, width=200)
print("комплектация найдена у:", len(pkg))
for k, v in list(pkg.items())[:8]:
print(" %-20s %s" % (k[:20], "; ".join(v["items"][:5])[:110]))
print("\nограничения найдены у:", len(limits))
for k, v in list(limits.items())[:6]:
print(" %-20s %s" % (k[:20], v[0][:110]))
print("\nсохранено: package.yaml, limitations.yaml")
return 0
if __name__ == "__main__":
sys.exit(main())
+54
View File
@@ -58,6 +58,8 @@ class Data:
self.mounts = load_yaml("mounts.yaml")
self.iface = load_yaml("interfaces_verified.yaml")
self.iface_auto = load_yaml("interfaces.yaml")
self.pkg = load_yaml("package.yaml")
self.limits = load_yaml("limitations.yaml")
self.dante = load_yaml("dante.yaml")
self.devices = {norm(d["name"]): {"name": d["name"], "role": d.get("role", "unknown")}
for d in self.cat.get("devices") or []}
@@ -316,6 +318,54 @@ class Data:
return {"host": host, "host_ports": {"in": h_in, "out": h_out, "source": h_src},
"links": links}
# ── матрица: хосты × аксессуары + порты ──
def matrix(self):
hosts = [h for h in self.hosts()]
accs = {}
for hk in [h["key"] for h in hosts]:
for e in self.edges.get(hk, []):
if not e.get("supported") or not e.get("usable", True):
continue
accs[norm(e["to"])] = e["to"]
acc_list = sorted(accs.values())
rows = []
for h in hosts:
hk = h["key"]
cells = {}
for e in self.edges.get(hk, []):
if not e.get("supported") or not e.get("usable", True):
continue
k = norm(e["to"])
q = e.get("max_qty")
cells[k] = q if q else 1
ins, outs, src = self.device_ports(h["name"])
rows.append({"host": h["name"], "cells": cells,
"ports": {"in": ins, "out": outs, "source": src}})
return {"hosts": [r["host"] for r in rows],
"rows": rows,
"accessories": acc_list}
# ── порты всех устройств ──
def ports_table(self):
out = []
for k, v in sorted(self.devices.items(), key=lambda x: x[1]["name"]):
name = v["name"]
ins, outs, src = self.device_ports(name)
pkg = []
for x in (self.pkg.get("devices") or []):
if norm(x["device"]) == k:
pkg = x.get("items") or []
break
lim = []
for x in (self.limits.get("devices") or []):
if norm(x["device"]) == k:
lim = x.get("limits") or []
break
out.append({"device": name, "role": v["role"],
"in": ins, "out": outs, "source": src,
"package": pkg, "limits": lim})
return out
# ── проверка ёмкости хоста ──
def capacity(self, host_key, items):
"""items: [[model, qty], ...]. Проверяет порты VCH, лимиты, питание."""
@@ -577,6 +627,10 @@ class H(BaseHTTPRequestHandler):
if p == "/api/positions":
return self._out(D.positions(q.get("host", [""])[0],
[x for x in q.get("need", []) if x]))
if p == "/api/matrix":
return self._out(D.matrix())
if p == "/api/ports":
return self._out(D.ports_table())
if p == "/api/links":
items = [x for x in q.get("item", []) if x]
return self._out(D.link_plan(q.get("host", [""])[0], items))
+77
View File
@@ -72,6 +72,10 @@ svg{width:100%;height:460px;background:#0a0e13;border:1px solid var(--line);bord
</header>
<main>
<div class="crumb" id="crumb"><div class="c on">ВКС</div></div>
<div style="display:flex;gap:8px;margin-bottom:14px">
<div class="mtab on" data-m="work" id="mtab-work">Конструктор</div>
<div class="mtab" data-m="matrix" id="mtab-matrix">Матрица и порты</div>
</div>
<section id="pick">
<div class="card"><h3>Направление</h3><div class="dir" id="dirs"></div>
@@ -79,6 +83,25 @@ svg{width:100%;height:460px;background:#0a0e13;border:1px solid var(--line);bord
</div>
</section>
<section id="matrix" class="hidden">
<div class="card">
<h3>Матрица совместимости — хосты × аксессуары</h3>
<div style="display:flex;gap:10px;margin-bottom:10px;flex-wrap:wrap">
<input id="mq" placeholder="фильтр по модели…" style="max-width:240px" oninput="renderMatrix()">
<label style="display:flex;gap:6px;align-items:center;margin:0;font-size:12px">
<input type="checkbox" id="monly" onchange="renderMatrix()" style="width:auto"> только с портами из даташита
</label>
<span class="muted" id="mstat"></span>
</div>
<div id="matrixbox" style="overflow:auto;max-height:70vh"></div>
</div>
<div class="card" style="margin-top:14px">
<h3>Порты, комплектация и ограничения</h3>
<input id="pq" placeholder="поиск устройства…" style="max-width:280px;margin-bottom:10px" oninput="renderPorts()">
<div id="portsbox" style="overflow:auto;max-height:60vh"></div>
</div>
</section>
<section id="work" class="hidden">
<div class="lay">
<!-- комната -->
@@ -275,6 +298,60 @@ function drawLinks(lp, hostname){
});
svg.innerHTML=s;
}
let MATRIX=null, PORTS=null;
document.getElementById('mtab-matrix').onclick=async()=>{
document.querySelectorAll('.mtab').forEach(x=>x.classList.toggle('on',x.id==='mtab-matrix'));
$('#matrix').classList.remove('hidden'); $('#work').classList.add('hidden'); $('#pick').classList.add('hidden');
if(!MATRIX){ MATRIX=await J('/api/matrix'); PORTS=await J('/api/ports'); }
renderMatrix(); renderPorts();
};
document.getElementById('mtab-work').onclick=()=>{
document.querySelectorAll('.mtab').forEach(x=>x.classList.toggle('on',x.id==='mtab-work'));
$('#matrix').classList.add('hidden');
if($('#pick').classList.contains('hidden')) $('#work').classList.remove('hidden');
else $('#pick').classList.remove('hidden');
};
function renderMatrix(){
if(!MATRIX)return;
const q=($('#mq')?.value||'').toLowerCase(), only=$('#monly')?.checked;
const accs=MATRIX.accessories.filter(a=>a.toLowerCase().includes(q));
let rows=MATRIX.rows.filter(r=>r.host.toLowerCase().includes(q));
if(only) rows=rows.filter(r=>r.ports.source==='verified');
$('#mstat').textContent=`хостов ${rows.length} · аксессуаров ${accs.length} · связей ${rows.reduce((a,r)=>a+Object.keys(r.cells).length,0)}`;
let html='<table style="font-size:11.5px;border-collapse:separate;border-spacing:0">';
html+='<tr><th style="position:sticky;left:0;background:#161b22;z-index:2">Хост</th>';
html+='<th style="position:sticky;top:0;background:#161b22">порты in</th><th style="position:sticky;top:0;background:#161b22">порты out</th>';
accs.forEach(a=>{html+=`<th style="writing-mode:vertical-rl;transform:rotate(180deg);height:110px;background:#161b22">${esc(a).slice(0,26)}</th>`});
html+='</tr>';
rows.forEach(r=>{
html+=`<tr><td style="position:sticky;left:0;background:#161b22;font-weight:600;white-space:nowrap">${esc(r.host)}</td>`;
html+=`<td class="muted">${(r.ports.in||['—']).join(',')}</td>`;
html+=`<td class="muted">${(r.ports.out||['—']).join(',')}</td>`;
accs.forEach(a=>{
const v=r.cells[a.toLowerCase().replace(/[^a-z0-9]/g,'')];
html+=`<td style="text-align:center;color:${v?'#3fb950':'#30363d'}">${v?(v>1?v:'✓'):'·'}</td>`;
});
html+='</tr>';
});
html+='</table>';
$('#matrixbox').innerHTML=html;
}
function renderPorts(){
if(!PORTS)return;
const q=($('#pq')?.value||'').toLowerCase();
const list=PORTS.filter(p=>p.device.toLowerCase().includes(q));
let html='<table><tr><th>Устройство</th><th>роль</th><th>входы</th><th>выходы</th><th>источник</th><th>комплектация</th><th>ограничения</th></tr>';
list.forEach(p=>{
html+=`<tr><td><b>${esc(p.device)}</b></td><td class="muted">${p.role}</td>
<td>${(p.in||['—']).map(x=>`<span class="tag">${esc(x)}</span>`).join('')}</td>
<td>${(p.out||['—']).filter(x=>x!=='—').map(x=>`<span class="tag">${esc(x)}</span>`).join('')||'<span class="muted">—</span>'}</td>
<td class="muted">${p.source==='verified'?'даташит':p.source==='auto'?'извлечено':'по роли'}</td>
<td class="muted">${(p.package||[]).slice(0,3).map(x=>esc(x).slice(0,40)).join('; ')||'—'}</td>
<td class="muted">${(p.limits||[]).slice(0,2).map(x=>esc(x).slice(0,60)).join('; ')||'—'}</td></tr>`;
});
html+='</table>';
$('#portsbox').innerHTML=html;
}
function esc(s){return String(s).replace(/[<>&]/g,c=>({'<':'&lt;','>':'&gt;','&':'&amp;'}[c]))}
boot();
</script>