Вопрос по модели
@@ -264,12 +282,13 @@ function roomOut(){const w=+$('#w').value,l=+$('#l').value,s=+$('#seats').value;
document.querySelectorAll('.tab').forEach(t=>t.onclick=()=>showTab(t.dataset.t));
function showTab(n){
document.querySelectorAll('.tab').forEach(t=>t.classList.toggle('on',t.dataset.t===n));
- ['build','cables','diagram','layout','heat','matrix','docs','ask'].forEach(x=>$('#sec-'+x).classList.toggle('hidden',x!==n));
+ ['build','cables','diagram','layout','heat','matrix','docs','issues','ask'].forEach(x=>$('#sec-'+x).classList.toggle('hidden',x!==n));
if(n==='diagram')renderDiagram();
if(n==='cables')renderCables();
if(n==='matrix')loadMatrix();
if(n==='layout')renderPlanDrag();
if(n==='heat')renderHeatmap();
+ if(n==='issues')renderIssues();
}
const DIRECTIONS=[
@@ -518,6 +537,27 @@ function pickVendor(id){
showTab('build');
reload();
}
+async function renderIssues(){
+ const ks=Object.keys(SEL);
+ if(!ks.length){$('#issuesbox').innerHTML='
соберите состав';return;}
+ const r=await J(`${SVC.engine}/issues?host=${$('#host').value}&${itemsQuery()}`);
+ if(r.error){$('#issuesbox').innerHTML=`
${esc(r.error)}
`;return;}
+ const icon={blocker:'⛔', warning:'⚠️', info:'ℹ️'};
+ $('#issuesbox').innerHTML=`
+ готов к закупке: ${r.ready?'да':'нет'} · блокеров ${r.blockers} · предупреждений ${r.warnings}
+ ${(r.issues||[]).map(i=>`
${icon[i.level]||'•'}
+
${esc(i.kind)} ${esc(i.text)}
`).join('')}`;
+}
+async function renderLineage(){
+ const dev=$('#lndev').value.trim(); if(!dev)return;
+ const r=await J(`${SVC.engine}/lineage?device=${encodeURIComponent(dev)}`);
+ if(r.error){$('#lineagebox').innerHTML=`
${esc(r.error)}
`;return;}
+ $('#lntrust').textContent=`выверено ${r.verified} из ${r.total} (${r.trust_pct}%)`;
+ $('#lineagebox').innerHTML=`
| Параметр | Значение | Источник |
+ ${(r.attributes||[]).map(a=>`| ${esc(a.attr)} | ${esc(String(a.value))} |
+ ${a.verified?'выверено':esc(a.source)} |
`).join('')}
+
файлы: ${(r.files||[]).map(f=>esc(f.file)+' ('+f.file_age_hours+' ч)').join(' · ')}
`;
+}
async function doAsk(){
const q=$('#askq').value.trim(); if(!q)return;
$('#askbox').innerHTML='
думаю…';
diff --git a/ops/work/web/services/svc_engine.py b/ops/work/web/services/svc_engine.py
index 44bc41c..9f2b5af 100644
--- a/ops/work/web/services/svc_engine.py
+++ b/ops/work/web/services/svc_engine.py
@@ -652,6 +652,14 @@ def pdf(q, body):
"content_type": "application/pdf"}
+def lineage(q, body):
+ return C.lineage((q.get("device") or [""])[0])
+
+
+def issues(q, body):
+ return C.issues((q.get("host") or [""])[0], _items(q), q.get("infra") or [])
+
+
serve({
"/groups": groups,
"/check": check,
@@ -671,5 +679,7 @@ serve({
"/override": override,
"/pack": pack,
"/pdf": pdf,
+ "/lineage": lineage,
+ "/issues": issues,
"/xlsx": xlsx,
}, int(sys.argv[1]) if len(sys.argv) > 1 else 8102, "engine", before=C.reload_if_changed)
diff --git a/ops/work/web/services/svc_project.py b/ops/work/web/services/svc_project.py
index 8060160..dd3f72f 100644
--- a/ops/work/web/services/svc_project.py
+++ b/ops/work/web/services/svc_project.py
@@ -10,6 +10,10 @@ sys.path.insert(0, "/root/buryan-infra/ops/work/web")
from svc_base import serve # noqa
DIR = "/opt/work-hub/compat/projects"
+
+
+def _ensure(d):
+ os.makedirs(d, exist_ok=True)
os.makedirs(DIR, exist_ok=True)
@@ -152,10 +156,60 @@ def import_project(q, body):
return res
+TPL_DIR = "/opt/work-hub/compat/templates"
+
+
+def templates(q, body):
+ """Список шаблонов комнат."""
+ _ensure(TPL_DIR)
+ out = []
+ for f in sorted(os.listdir(TPL_DIR)):
+ if f.endswith(".json"):
+ try:
+ d = json.load(open(os.path.join(TPL_DIR, f), encoding="utf-8"))
+ except Exception:
+ continue
+ out.append({"id": d.get("id"), "name": d.get("name"),
+ "host": d.get("host"),
+ "items": len(d.get("items") or [])})
+ return {"templates": out}
+
+
+def save_template(q, body):
+ """Сохранить текущий состав как шаблон комнаты."""
+ _ensure(TPL_DIR)
+ body = body or {}
+ name = (body.get("name") or "").strip()
+ items = body.get("items") or []
+ if not name or not items:
+ return {"error": "нужны name и items"}
+ tid = "t%d" % int(time.time())
+ payload = {"id": tid, "name": name, "host": body.get("host"),
+ "room": body.get("room") or {}, "need": body.get("need") or [],
+ "items": items, "created": time.strftime("%Y-%m-%dT%H:%M:%S")}
+ with open(os.path.join(TPL_DIR, tid + ".json"), "w", encoding="utf-8") as f:
+ json.dump(payload, f, ensure_ascii=False, indent=2)
+ return {"ok": True, "id": tid, "name": name}
+
+
+def get_template(q, body):
+ _ensure(TPL_DIR)
+ tid = (q.get("id") or [""])[0]
+ if not _ok(tid):
+ return {"error": "bad id"}
+ p = os.path.join(TPL_DIR, tid + ".json")
+ if not os.path.exists(p):
+ return {"error": "not found"}
+ return json.load(open(p, encoding="utf-8"))
+
+
serve({
"/list": lst,
"/get": get,
"/save": save,
"/delete": remove,
"/import": import_project,
+ "/templates": templates,
+ "/template": get_template,
+ "/save-template": save_template,
}, int(sys.argv[1]) if len(sys.argv) > 1 else 8103, "project")
diff --git a/ops/work/web/webui.html b/ops/work/web/webui.html
index 8063fd1..4cffbb9 100644
--- a/ops/work/web/webui.html
+++ b/ops/work/web/webui.html
@@ -83,6 +83,7 @@ svg{width:100%;height:520px;background:#0a0e13;border:1px solid var(--line);bord
Документы
План комнаты
Покрытие
+
Проблемы
Спросить
@@ -216,6 +217,23 @@ svg{width:100%;height:520px;background:#0a0e13;border:1px solid var(--line);bord