[PRISM] Draft search toggle: staging models visible without prod publish
lint / hygiene (push) Failing after 23s
lint / hygiene (push) Failing after 23s
This commit is contained in:
1 parent
73cc6c98f7
commit
fcc0c9f2d1
2 files changed
+60
-3
No files matched your search
+56
-2
@@ -1235,6 +1235,35 @@ def _features(d):
|
|||||||
return sorted(fs)
|
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):
|
def search_catalog(params):
|
||||||
q = (params.get("q", [""])[0] or "").strip()
|
q = (params.get("q", [""])[0] or "").strip()
|
||||||
vendor = (params.get("vendor", [""])[0] or "all").lower()
|
vendor = (params.get("vendor", [""])[0] or "all").lower()
|
||||||
@@ -1245,6 +1274,7 @@ def search_catalog(params):
|
|||||||
feature = (params.get("feature", [""])[0] or "").strip()
|
feature = (params.get("feature", [""])[0] or "").strip()
|
||||||
arch_mode = (params.get("archived", ["all"])[0] or "all").lower()
|
arch_mode = (params.get("archived", ["all"])[0] or "all").lower()
|
||||||
market = (params.get("market", ["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()
|
low = q.lower()
|
||||||
interpreted = []
|
interpreted = []
|
||||||
if not cls:
|
if not cls:
|
||||||
@@ -1299,6 +1329,25 @@ def search_catalog(params):
|
|||||||
continue
|
continue
|
||||||
items.append(d)
|
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 = ""
|
note = ""
|
||||||
# протокол/4K — мягкие фильтры: если подтверждённых данных нет,
|
# протокол/4K — мягкие фильтры: если подтверждённых данных нет,
|
||||||
# не обнуляем выдачу, а показываем кандидатов и предупреждение
|
# не обнуляем выдачу, а показываем кандидатов и предупреждение
|
||||||
@@ -1333,7 +1382,7 @@ def search_catalog(params):
|
|||||||
"form_factor": d.get("form_factor"),
|
"form_factor": d.get("form_factor"),
|
||||||
"protocols": d.get("protocols") or [], "sales_scope": d.get("sales_scope"),
|
"protocols": d.get("protocols") or [], "sales_scope": d.get("sales_scope"),
|
||||||
"deployment": d.get("deployment"), "features": _features(d)[:8],
|
"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]]
|
for d in items[:100]]
|
||||||
return {"query": q, "vendor": vendor, "domain": domain,
|
return {"query": q, "vendor": vendor, "domain": domain,
|
||||||
"interpreted": interpreted, "total": len(items), "items": out,
|
"interpreted": interpreted, "total": len(items), "items": out,
|
||||||
@@ -1351,6 +1400,9 @@ def find_device(key):
|
|||||||
for d in D.analog_devices:
|
for d in D.analog_devices:
|
||||||
if k and k in _dev_name(d).lower():
|
if k and k in _dev_name(d).lower():
|
||||||
return d
|
return d
|
||||||
|
for d in draft_devices():
|
||||||
|
if k and k in _dev_name(d).lower():
|
||||||
|
return d
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -1368,7 +1420,9 @@ def product_info(key):
|
|||||||
"protocols": d.get("protocols") or [], "sales_scope": d.get("sales_scope"),
|
"protocols": d.get("protocols") or [], "sales_scope": d.get("sales_scope"),
|
||||||
"deployment": d.get("deployment"), "components": d.get("components") or [],
|
"deployment": d.get("deployment"), "components": d.get("components") or [],
|
||||||
"features": _features(d), "archived": is_archived(d),
|
"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)), {}),
|
"attributes": D.attrs.get(norm(_dev_name(d)), {}),
|
||||||
"compatibility": [{"to": e.get("to"), "kind": e.get("kind"),
|
"compatibility": [{"to": e.get("to"), "kind": e.get("kind"),
|
||||||
"supported": e.get("supported"),
|
"supported": e.get("supported"),
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ main{max-width:1560px;margin:0 auto;padding:22px 26px 70px}.view{display:none}.v
|
|||||||
<select id="protocol"><option value="">Протокол</option><option>SIP</option><option>H.323</option></select>
|
<select id="protocol"><option value="">Протокол</option><option>SIP</option><option>H.323</option></select>
|
||||||
<label class="tiny"><input type="checkbox" id="f4k"> 4K</label>
|
<label class="tiny"><input type="checkbox" id="f4k"> 4K</label>
|
||||||
<label class="tiny"><input type="checkbox" id="showArchived" checked> показывать снятые</label>
|
<label class="tiny"><input type="checkbox" id="showArchived" checked> показывать снятые</label>
|
||||||
|
<label class="tiny"><input type="checkbox" id="showDrafts"> черновики</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="layout">
|
<div class="layout">
|
||||||
<aside class="card facets"><h3>Фасеты</h3><div id="facets"><span class="muted">—</span></div></aside>
|
<aside class="card facets"><h3>Фасеты</h3><div id="facets"><span class="muted">—</span></div></aside>
|
||||||
@@ -270,6 +271,7 @@ function query(){
|
|||||||
if(S.cls) p.set('class',S.cls); if(S.protocol) p.set('protocol',S.protocol);
|
if(S.cls) p.set('class',S.cls); if(S.protocol) p.set('protocol',S.protocol);
|
||||||
if(S.feature) p.set('feature','4K');
|
if(S.feature) p.set('feature','4K');
|
||||||
if(!$('#showArchived').checked) p.set('archived','active');
|
if(!$('#showArchived').checked) p.set('archived','active');
|
||||||
|
if($('#showDrafts')?.checked) p.set('drafts','1');
|
||||||
return p.toString();
|
return p.toString();
|
||||||
}
|
}
|
||||||
async function search(){
|
async function search(){
|
||||||
@@ -298,7 +300,7 @@ function renderResults(items){
|
|||||||
if(!items.length){$('#results').innerHTML='<div class="card muted">Ничего не найдено. Уберите фильтр или проверьте, есть ли подтверждённые данные.</div>';return;}
|
if(!items.length){$('#results').innerHTML='<div class="card muted">Ничего не найдено. Уберите фильтр или проверьте, есть ли подтверждённые данные.</div>';return;}
|
||||||
$('#results').innerHTML = items.map(x=>`<div class="item ${x.archived?'archived':''}" onclick="openProduct('${esc(x.key)}')">
|
$('#results').innerHTML = items.map(x=>`<div class="item ${x.archived?'archived':''}" onclick="openProduct('${esc(x.key)}')">
|
||||||
<div style="flex:1"><div class="vendor">${esc(x.vendor)}</div><div class="name">${esc(x.name)}</div>
|
<div style="flex:1"><div class="vendor">${esc(x.vendor)}</div><div class="name">${esc(x.name)}</div>
|
||||||
<div class="meta">${esc(cl(x.solution_class))} · ${esc(rl(x.role))}${x.form_factor?' · '+esc(x.form_factor):''} ${x.market?'· <span class="pill">'+esc(x.market_label||x.market)+'</span>':''}</div>
|
<div class="meta">${esc(cl(x.solution_class))} · ${esc(rl(x.role))}${x.form_factor?' · '+esc(x.form_factor):''} ${x.market?'· <span class="pill">'+esc(x.market_label||x.market)+'</span>':''} ${x.draft?'· <span class="pill">черновик</span>':''}</div>
|
||||||
${x.archived?'<span class="badge-archive">снято · купить нельзя</span>':''}</div>
|
${x.archived?'<span class="badge-archive">снято · купить нельзя</span>':''}</div>
|
||||||
<div class="tiny muted" style="text-align:right">${esc(x.sales_scope||'')}<br>${esc((x.protocols||[]).slice(0,3).join(', '))}</div>
|
<div class="tiny muted" style="text-align:right">${esc(x.sales_scope||'')}<br>${esc((x.protocols||[]).slice(0,3).join(', '))}</div>
|
||||||
<label class="tiny" style="align-self:center" onclick="event.stopPropagation()"><input type="checkbox" ${isComp(x.key)?'checked':''} onchange="toggleCompare('${esc(x.key)}',this.checked)"> сравнить</label></div>`).join('');
|
<label class="tiny" style="align-self:center" onclick="event.stopPropagation()"><input type="checkbox" ${isComp(x.key)?'checked':''} onchange="toggleCompare('${esc(x.key)}',this.checked)"> сравнить</label></div>`).join('');
|
||||||
@@ -487,6 +489,7 @@ async function boot(){
|
|||||||
$('#protocol').onchange=e=>{S.protocol=e.target.value;search()};
|
$('#protocol').onchange=e=>{S.protocol=e.target.value;search()};
|
||||||
$('#f4k').onchange=e=>{S.feature=e.target.checked;search()};
|
$('#f4k').onchange=e=>{S.feature=e.target.checked;search()};
|
||||||
$('#showArchived').onchange=()=>search();
|
$('#showArchived').onchange=()=>search();
|
||||||
|
$('#showDrafts').onchange=()=>search();
|
||||||
$('#q').addEventListener('input',()=>{clearTimeout(window._t);window._t=setTimeout(()=>{S.q=$('#q').value;search()},250)});
|
$('#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));
|
document.querySelectorAll('.nav').forEach(b=>b.onclick=()=>setView(b.dataset.v));
|
||||||
await search();
|
await search();
|
||||||
|
|||||||
Reference in new issue
Block a user