diff --git a/ops/work/web/app.py b/ops/work/web/app.py index ea6b43e..87a0bc2 100644 --- a/ops/work/web/app.py +++ b/ops/work/web/app.py @@ -1235,6 +1235,35 @@ def _features(d): return sorted(fs) +def draft_devices(): + out = [] + seen = set() + for p in sorted(glob.glob("/root/buryan-infra/ops/combine/staging/*/models.yaml")): + try: + d = yaml.safe_load(open(p, encoding="utf-8")) or {} + except Exception: + continue + for x in d.get("models") or []: + name = x.get("model") + if not name: + continue + key = norm(name) + if key in seen: + continue + seen.add(key) + spec = x.get("specs") or {} + proto = spec.get("protocols") or x.get("protocols") or [] + out.append({ + "name": name, "vendor": x.get("vendor"), "domain": "vcs", + "solution_class": x.get("solution_class") or "vcs.other", + "role": x.get("role") or "other", "form_factor": x.get("form_factor"), + "market": x.get("market"), "markets": x.get("markets") or [], + "protocols": proto, "specs": spec, "draft": True, + "source": x.get("source") or {}, "review": x.get("review"), + }) + return out + + def search_catalog(params): q = (params.get("q", [""])[0] or "").strip() vendor = (params.get("vendor", [""])[0] or "all").lower() @@ -1245,6 +1274,7 @@ def search_catalog(params): feature = (params.get("feature", [""])[0] or "").strip() arch_mode = (params.get("archived", ["all"])[0] or "all").lower() market = (params.get("market", ["all"])[0] or "all").lower() + drafts = (params.get("drafts", ["0"])[0] or "0") in ("1", "true", "yes") low = q.lower() interpreted = [] if not cls: @@ -1299,6 +1329,25 @@ def search_catalog(params): continue items.append(d) + if drafts: + known = {norm(_dev_name(d)) for d in D.analog_devices} + for d in draft_devices(): + if norm(_dev_name(d)) in known: + continue + if vendor not in ("", "all") and d.get("vendor") != vendor: + continue + if domain not in ("", "all") and d.get("domain") != domain: + continue + if cls and d.get("solution_class") != cls: + continue + if role and d.get("role") != role: + continue + text = " ".join([_dev_name(d), str(d.get("vendor")), str(d.get("role")), + " ".join(str(x) for x in (d.get("protocols") or []))]).lower() + if apply_text and low not in text: + continue + items.append(d) + note = "" # протокол/4K — мягкие фильтры: если подтверждённых данных нет, # не обнуляем выдачу, а показываем кандидатов и предупреждение @@ -1333,7 +1382,7 @@ def search_catalog(params): "form_factor": d.get("form_factor"), "protocols": d.get("protocols") or [], "sales_scope": d.get("sales_scope"), "deployment": d.get("deployment"), "features": _features(d)[:8], - "archived": is_archived(d), "specs": specs(d)} + "archived": is_archived(d), "specs": specs(d), "draft": bool(d.get("draft"))} for d in items[:100]] return {"query": q, "vendor": vendor, "domain": domain, "interpreted": interpreted, "total": len(items), "items": out, @@ -1351,6 +1400,9 @@ def find_device(key): for d in D.analog_devices: if k and k in _dev_name(d).lower(): return d + for d in draft_devices(): + if k and k in _dev_name(d).lower(): + return d return None @@ -1368,7 +1420,9 @@ def product_info(key): "protocols": d.get("protocols") or [], "sales_scope": d.get("sales_scope"), "deployment": d.get("deployment"), "components": d.get("components") or [], "features": _features(d), "archived": is_archived(d), - "specs": specs(d), + "specs": d.get("specs") or specs(d), + "draft": bool(d.get("draft")), + "source": d.get("source") or {}, "attributes": D.attrs.get(norm(_dev_name(d)), {}), "compatibility": [{"to": e.get("to"), "kind": e.get("kind"), "supported": e.get("supported"), diff --git a/ops/work/web/studio.html b/ops/work/web/studio.html index a1c929c..1e8ac8f 100644 --- a/ops/work/web/studio.html +++ b/ops/work/web/studio.html @@ -76,6 +76,7 @@ main{max-width:1560px;margin:0 auto;padding:22px 26px 70px}.view{display:none}.v +
@@ -270,6 +271,7 @@ function query(){ if(S.cls) p.set('class',S.cls); if(S.protocol) p.set('protocol',S.protocol); if(S.feature) p.set('feature','4K'); if(!$('#showArchived').checked) p.set('archived','active'); + if($('#showDrafts')?.checked) p.set('drafts','1'); return p.toString(); } async function search(){ @@ -298,7 +300,7 @@ function renderResults(items){ if(!items.length){$('#results').innerHTML='
Ничего не найдено. Уберите фильтр или проверьте, есть ли подтверждённые данные.
';return;} $('#results').innerHTML = items.map(x=>`
${esc(x.vendor)}
${esc(x.name)}
-
${esc(cl(x.solution_class))} · ${esc(rl(x.role))}${x.form_factor?' · '+esc(x.form_factor):''} ${x.market?'· '+esc(x.market_label||x.market)+'':''}
+
${esc(cl(x.solution_class))} · ${esc(rl(x.role))}${x.form_factor?' · '+esc(x.form_factor):''} ${x.market?'· '+esc(x.market_label||x.market)+'':''} ${x.draft?'· черновик':''}
${x.archived?'снято · купить нельзя':''}
${esc(x.sales_scope||'')}
${esc((x.protocols||[]).slice(0,3).join(', '))}
`).join(''); @@ -487,6 +489,7 @@ async function boot(){ $('#protocol').onchange=e=>{S.protocol=e.target.value;search()}; $('#f4k').onchange=e=>{S.feature=e.target.checked;search()}; $('#showArchived').onchange=()=>search(); + $('#showDrafts').onchange=()=>search(); $('#q').addEventListener('input',()=>{clearTimeout(window._t);window._t=setTimeout(()=>{S.q=$('#q').value;search()},250)}); document.querySelectorAll('.nav').forEach(b=>b.onclick=()=>setView(b.dataset.v)); await search();