mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 03:10:46 +08:00
Align compare board toolbar and show device name with collect time.
Drop the batch-run label, resolve NE from job tasks, and slim left-nav badges to pass or non-zero fail counts only. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
182b65de2a
commit
d96cbf330a
3 changed files with 238 additions and 121 deletions
|
|
@ -10096,39 +10096,52 @@ html.login-page--paused .login-page__flare {
|
|||
|
||||
.bs-cmp-board__toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 12px;
|
||||
flex-wrap: nowrap;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
flex: 0 0 auto;
|
||||
min-height: 36px;
|
||||
}
|
||||
|
||||
.bs-cmp-board__run-select {
|
||||
flex: 0 1 280px;
|
||||
min-width: 160px;
|
||||
max-width: 320px;
|
||||
height: 32px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.bs-cmp-board__actions {
|
||||
margin-left: auto;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.bs-cmp-sides {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
gap: 6px 8px;
|
||||
min-width: 0;
|
||||
flex: 1 1 auto;
|
||||
padding: 4px 8px;
|
||||
height: 32px;
|
||||
padding: 0 8px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--bs-cmp-border, rgba(148, 163, 184, 0.22));
|
||||
background: rgba(15, 23, 42, 0.45);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bs-cmp-sides__side {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: 4px 8px;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
padding: 2px 6px;
|
||||
padding: 0 6px;
|
||||
border-radius: 6px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.bs-cmp-sides__side.is-before {
|
||||
|
|
@ -10158,14 +10171,14 @@ html.login-page--paused .login-page__flare {
|
|||
}
|
||||
|
||||
.bs-cmp-sides__name {
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #f1f5f9;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-width: 14rem;
|
||||
line-height: 1.3;
|
||||
max-width: 10rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.bs-cmp-sides__meta {
|
||||
|
|
@ -10175,19 +10188,22 @@ html.login-page--paused .login-page__flare {
|
|||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.bs-cmp-sides__vs {
|
||||
.bs-cmp-sides__arrow {
|
||||
flex: 0 0 auto;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
background: rgba(59, 130, 246, 0.18);
|
||||
border: 1px solid rgba(96, 165, 250, 0.35);
|
||||
color: #93c5fd;
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.02em;
|
||||
font-weight: 700;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.bs-cmp-sides__vs {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.bs-cmp-board__toolbar {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.bs-cmp-board__actions {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
|
@ -10195,10 +10211,9 @@ html.login-page--paused .login-page__flare {
|
|||
.bs-cmp-sides {
|
||||
flex: 1 1 100%;
|
||||
order: 3;
|
||||
}
|
||||
|
||||
.bs-cmp-board__actions {
|
||||
order: 2;
|
||||
height: auto;
|
||||
min-height: 32px;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -10370,6 +10385,16 @@ html.login-page--paused .login-page__flare {
|
|||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.bs-cmp-nav__badge--pass.is-hot {
|
||||
color: #bbf7d0;
|
||||
background: rgba(34, 197, 94, 0.14);
|
||||
border-color: rgba(74, 222, 128, 0.35);
|
||||
}
|
||||
|
||||
.bs-cmp-nav__badge--pass.is-hot b {
|
||||
color: #86efac;
|
||||
}
|
||||
|
||||
.bs-cmp-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
|
|||
|
|
@ -213,13 +213,41 @@ function sideDeviceName(side?: {
|
|||
batch_id?: string;
|
||||
} | null): string {
|
||||
if (!side) return "—";
|
||||
return (
|
||||
String(side.ne_name || "").trim() ||
|
||||
String(side.ne_ip || "").trim() ||
|
||||
String(side.label || "").trim() ||
|
||||
String(side.batch_id || "").slice(0, 8) ||
|
||||
"—"
|
||||
);
|
||||
const name = String(side.ne_name || "").trim();
|
||||
const ip = String(side.ne_ip || "").trim();
|
||||
const label = String(side.label || "").trim();
|
||||
// Prefer real device identity; ignore hex-ish fallbacks that look like batch ids
|
||||
if (name) return name;
|
||||
if (ip) return ip;
|
||||
if (label && !/^[a-f0-9]{8,32}$/i.test(label)) return label;
|
||||
return "—";
|
||||
}
|
||||
|
||||
function sideCollectTime(side?: { started_at?: string | null } | null): string {
|
||||
return fmtTime(side?.started_at);
|
||||
}
|
||||
|
||||
function enrichSideFromTask(
|
||||
side: Record<string, unknown> | null | undefined,
|
||||
taskId: string,
|
||||
tasks: TaskOpt[],
|
||||
): { ne_name?: string; ne_ip?: string; label?: string; batch_id?: string; started_at?: string | null } {
|
||||
const base = { ...(side || {}) } as {
|
||||
ne_name?: string;
|
||||
ne_ip?: string;
|
||||
label?: string;
|
||||
batch_id?: string;
|
||||
started_at?: string | null;
|
||||
};
|
||||
if (sideDeviceName(base) !== "—") return base;
|
||||
const task = tasks.find((t) => t.id === taskId);
|
||||
if (!task) return base;
|
||||
return {
|
||||
...base,
|
||||
ne_name: task.ne_name || base.ne_name,
|
||||
ne_ip: task.ne_ip || base.ne_ip,
|
||||
label: task.ne_name || task.ne_ip || base.label,
|
||||
};
|
||||
}
|
||||
|
||||
function taskLabel(row: TaskOpt) {
|
||||
|
|
@ -2074,8 +2102,9 @@ export function BizComparePage() {
|
|||
className={`bs-cmp-board${boardFs ? " is-fullscreen" : ""}`}
|
||||
>
|
||||
<div className="bs-cmp-board__toolbar">
|
||||
<FieldSelect
|
||||
label={t("bizCompare.pickBatchRun")}
|
||||
<select
|
||||
className="ui-field__select bs-cmp-board__run-select"
|
||||
aria-label={t("bizCompare.pickBatchRun")}
|
||||
value={runDetail?.id || ""}
|
||||
onChange={(e) => {
|
||||
const id = e.target.value;
|
||||
|
|
@ -2084,44 +2113,70 @@ export function BizComparePage() {
|
|||
>
|
||||
<option value="">{t("bizCompare.pickRun")}</option>
|
||||
{runs.map((r) => {
|
||||
const bl = sideDeviceName((r as any).before);
|
||||
const al = sideDeviceName((r as any).after);
|
||||
const sides =
|
||||
bl !== "—" || al !== "—" ? `${bl} → ${al} · ` : "";
|
||||
const before = enrichSideFromTask(
|
||||
(r as any).before,
|
||||
beforeTaskId,
|
||||
tasks,
|
||||
);
|
||||
const after = enrichSideFromTask(
|
||||
(r as any).after,
|
||||
afterTaskId || beforeTaskId,
|
||||
tasks,
|
||||
);
|
||||
const bl = sideDeviceName(before);
|
||||
const al = sideDeviceName(after);
|
||||
return (
|
||||
<option key={r.id} value={r.id}>
|
||||
{sides}
|
||||
{fmtTime(r.created_at)} · {t("bizCompare.failCount")}{" "}
|
||||
{(r.summary?.added ?? 0) +
|
||||
(r.summary?.removed ?? 0) +
|
||||
(r.summary?.changed ?? 0)}
|
||||
{bl} {sideCollectTime(before)} → {al} {sideCollectTime(after)}
|
||||
</option>
|
||||
);
|
||||
})}
|
||||
</FieldSelect>
|
||||
</select>
|
||||
{runDetail ? (
|
||||
<div className="bs-cmp-sides" aria-label={t("bizCompare.sidesTitle")}>
|
||||
<div className="bs-cmp-sides__side is-before">
|
||||
<span className="bs-cmp-sides__tag">{t("bizCompare.sideBefore")}</span>
|
||||
<strong className="bs-cmp-sides__name" title={sideDeviceName(runDetail.before)}>
|
||||
{sideDeviceName(runDetail.before)}
|
||||
</strong>
|
||||
<span className="bs-cmp-sides__meta muted">
|
||||
{fmtTime(runDetail.before?.started_at)}
|
||||
</span>
|
||||
</div>
|
||||
<span className="bs-cmp-sides__vs" aria-hidden>
|
||||
{t("bizCompare.sidesVs")}
|
||||
</span>
|
||||
<div className="bs-cmp-sides__side is-after">
|
||||
<span className="bs-cmp-sides__tag">{t("bizCompare.sideAfter")}</span>
|
||||
<strong className="bs-cmp-sides__name" title={sideDeviceName(runDetail.after)}>
|
||||
{sideDeviceName(runDetail.after)}
|
||||
</strong>
|
||||
<span className="bs-cmp-sides__meta muted">
|
||||
{fmtTime(runDetail.after?.started_at)}
|
||||
</span>
|
||||
</div>
|
||||
{(() => {
|
||||
const before = enrichSideFromTask(
|
||||
runDetail.before,
|
||||
beforeTaskId,
|
||||
tasks,
|
||||
);
|
||||
const after = enrichSideFromTask(
|
||||
runDetail.after,
|
||||
afterTaskId || beforeTaskId,
|
||||
tasks,
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<div className="bs-cmp-sides__side is-before">
|
||||
<span className="bs-cmp-sides__tag">{t("bizCompare.sideBefore")}</span>
|
||||
<strong
|
||||
className="bs-cmp-sides__name"
|
||||
title={sideDeviceName(before)}
|
||||
>
|
||||
{sideDeviceName(before)}
|
||||
</strong>
|
||||
<span className="bs-cmp-sides__meta muted">
|
||||
{sideCollectTime(before)}
|
||||
</span>
|
||||
</div>
|
||||
<span className="bs-cmp-sides__arrow" aria-hidden>
|
||||
→
|
||||
</span>
|
||||
<div className="bs-cmp-sides__side is-after">
|
||||
<span className="bs-cmp-sides__tag">{t("bizCompare.sideAfter")}</span>
|
||||
<strong
|
||||
className="bs-cmp-sides__name"
|
||||
title={sideDeviceName(after)}
|
||||
>
|
||||
{sideDeviceName(after)}
|
||||
</strong>
|
||||
<span className="bs-cmp-sides__meta muted">
|
||||
{sideCollectTime(after)}
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
) : null}
|
||||
<div className="btn-row bs-cmp-board__actions">
|
||||
|
|
@ -2193,31 +2248,39 @@ export function BizComparePage() {
|
|||
>
|
||||
<span className="bs-cmp-nav__dot" aria-hidden />
|
||||
<span className="bs-cmp-nav__name">{c.metric_id}</span>
|
||||
<span className="bs-cmp-nav__badges" aria-label={c.metric_id}>
|
||||
<span
|
||||
className={`bs-cmp-nav__badge bs-cmp-nav__badge--removed${
|
||||
Number(c.removed || 0) > 0 ? " is-hot" : ""
|
||||
}`}
|
||||
>
|
||||
{t("bizCompare.missCount")} <b>{Number(c.removed || 0)}</b>
|
||||
</span>
|
||||
<span
|
||||
className={`bs-cmp-nav__badge bs-cmp-nav__badge--added${
|
||||
Number(c.added || 0) > 0 ? " is-hot" : ""
|
||||
}`}
|
||||
>
|
||||
{t("bizCompare.extraCount")} <b>{Number(c.added || 0)}</b>
|
||||
</span>
|
||||
<span
|
||||
className={`bs-cmp-nav__badge bs-cmp-nav__badge--changed${
|
||||
Number(c.changed || 0) > 0 ? " is-hot" : ""
|
||||
}`}
|
||||
>
|
||||
{t("bizCompare.mismatchCount")} <b>{Number(c.changed || 0)}</b>
|
||||
</span>
|
||||
<span className="bs-cmp-nav__badge bs-cmp-nav__badge--unchanged">
|
||||
{t("bizCompare.matchCount")} <b>{Number(c.unchanged || 0)}</b>
|
||||
</span>
|
||||
<span className="bs-cmp-nav__badges">
|
||||
{dirty > 0 ? (
|
||||
<>
|
||||
{Number(c.removed || 0) > 0 ? (
|
||||
<span className="bs-cmp-nav__badge bs-cmp-nav__badge--removed is-hot">
|
||||
{t("bizCompare.missCount")}{" "}
|
||||
<b>{Number(c.removed || 0)}</b>
|
||||
</span>
|
||||
) : null}
|
||||
{Number(c.added || 0) > 0 ? (
|
||||
<span className="bs-cmp-nav__badge bs-cmp-nav__badge--added is-hot">
|
||||
{t("bizCompare.extraCount")}{" "}
|
||||
<b>{Number(c.added || 0)}</b>
|
||||
</span>
|
||||
) : null}
|
||||
{Number(c.changed || 0) > 0 ? (
|
||||
<span className="bs-cmp-nav__badge bs-cmp-nav__badge--changed is-hot">
|
||||
{t("bizCompare.mismatchCount")}{" "}
|
||||
<b>{Number(c.changed || 0)}</b>
|
||||
</span>
|
||||
) : null}
|
||||
</>
|
||||
) : (
|
||||
<span className="bs-cmp-nav__badge bs-cmp-nav__badge--pass is-hot">
|
||||
{t("bizCompare.kindPass")}
|
||||
{Number(c.unchanged || 0) > 0 ? (
|
||||
<>
|
||||
{" "}
|
||||
<b>{Number(c.unchanged || 0)}</b>
|
||||
</>
|
||||
) : null}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue