mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 11:50:44 +08:00
Cache biz-state discover CLI results and improve bind table UX.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b9be545a75
commit
908771baea
8 changed files with 316 additions and 63 deletions
|
|
@ -239,11 +239,14 @@ const en = {
|
|||
bindTitle: "Select bindings",
|
||||
unbound: "Not bound",
|
||||
bindHintRequired: "Bind params before collect",
|
||||
paramsDblClickHint: "Double-click to view all bindings",
|
||||
paramsDblClickHint: "Click to view all bindings",
|
||||
paramsClickHint: "Click to view all bindings",
|
||||
paramsDetailTitle: "Bound parameters",
|
||||
paramsDetailCount: "{{n}} binding(s)",
|
||||
discoverLoading: "Discovering…",
|
||||
discoverEmpty: "No candidates discovered",
|
||||
discoverCacheHit: "reused (no re-login)",
|
||||
discoverRefresh: "Refresh from device",
|
||||
selectAllVrfs: "Select all",
|
||||
deselectAllVrfs: "Deselect all",
|
||||
batches: "Batches",
|
||||
|
|
|
|||
|
|
@ -239,11 +239,14 @@ const zh = {
|
|||
bindTitle: "选择参数关联",
|
||||
unbound: "未关联",
|
||||
bindHintRequired: "需关联参数后才可采集",
|
||||
paramsDblClickHint: "双击查看全部关联明细",
|
||||
paramsDblClickHint: "单击查看全部关联明细",
|
||||
paramsClickHint: "单击查看全部关联明细",
|
||||
paramsDetailTitle: "参数关联明细",
|
||||
paramsDetailCount: "共 {{n}} 条",
|
||||
discoverLoading: "正在发现…",
|
||||
discoverEmpty: "未发现可用选项",
|
||||
discoverCacheHit: "已复用(未重新登录)",
|
||||
discoverRefresh: "重新从设备拉取",
|
||||
selectAllVrfs: "全选",
|
||||
deselectAllVrfs: "取消全选",
|
||||
batches: "采集批次",
|
||||
|
|
|
|||
|
|
@ -11292,28 +11292,44 @@ html.login-page--paused .login-page__flare {
|
|||
}
|
||||
|
||||
.bs-profiles-table {
|
||||
min-width: 1100px;
|
||||
min-width: 1280px;
|
||||
table-layout: fixed;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
.bs-profiles-table thead th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 3;
|
||||
background: rgba(15, 23, 42, 0.97);
|
||||
box-shadow: 0 1px 0 rgba(148, 163, 184, 0.25);
|
||||
}
|
||||
|
||||
.bs-profiles-table th:nth-child(1),
|
||||
.bs-profiles-table td:nth-child(1) {
|
||||
width: 56px;
|
||||
width: 52px;
|
||||
}
|
||||
|
||||
.bs-profiles-table th:nth-child(2),
|
||||
.bs-profiles-table td:nth-child(2) {
|
||||
width: 28%;
|
||||
width: 24%;
|
||||
}
|
||||
|
||||
.bs-profiles-table th:nth-child(3),
|
||||
.bs-profiles-table td:nth-child(3) {
|
||||
width: 180px;
|
||||
width: 34%;
|
||||
min-width: 320px;
|
||||
}
|
||||
|
||||
.bs-profiles-table th:nth-child(4),
|
||||
.bs-profiles-table td:nth-child(4) {
|
||||
width: 110px;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.bs-profiles-table th:nth-child(5),
|
||||
.bs-profiles-table td:nth-child(5) {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.bs-profiles-table .bs-cmd-cell {
|
||||
|
|
|
|||
|
|
@ -246,6 +246,7 @@ export function BizStatePage() {
|
|||
const [discoverCmd, setDiscoverCmd] = useState("");
|
||||
const [discoverLoading, setDiscoverLoading] = useState(false);
|
||||
const [discoverError, setDiscoverError] = useState("");
|
||||
const [discoverCacheHit, setDiscoverCacheHit] = useState(false);
|
||||
|
||||
// Bound-params detail modal (double-click params cell)
|
||||
const [paramsDetail, setParamsDetail] = useState<{
|
||||
|
|
@ -775,10 +776,11 @@ export function BizStatePage() {
|
|||
setSelectedVrfs([]);
|
||||
setDiscoverCmd("");
|
||||
setDiscoverError("");
|
||||
setDiscoverCacheHit(false);
|
||||
setDiscoverLoading(false);
|
||||
};
|
||||
|
||||
const startDiscover = async (item: any) => {
|
||||
const startDiscover = async (item: any, forceRefresh = false) => {
|
||||
if (!taskId) return;
|
||||
const prof = profiles.find((p) => p.profile_id === item.source_profile_id);
|
||||
const phs = prof?.placeholders || [];
|
||||
|
|
@ -792,6 +794,7 @@ export function BizStatePage() {
|
|||
setSelectedVrfs([]);
|
||||
setDiscoverCmd("");
|
||||
setDiscoverError("");
|
||||
setDiscoverCacheHit(false);
|
||||
setDiscoverLoading(true);
|
||||
setBusy(true);
|
||||
try {
|
||||
|
|
@ -801,6 +804,7 @@ export function BizStatePage() {
|
|||
task_id: taskId,
|
||||
collect_profile_id: item.source_profile_id,
|
||||
placeholder: sharedDisc ? "" : ph.name,
|
||||
force_refresh: forceRefresh,
|
||||
});
|
||||
if (!res.ok) {
|
||||
const err = res.error || t("bizState.discoverFailed");
|
||||
|
|
@ -809,6 +813,7 @@ export function BizStatePage() {
|
|||
return;
|
||||
}
|
||||
setDiscoverCmd(res.command || "");
|
||||
setDiscoverCacheHit(Boolean(res.cache_hit));
|
||||
const cand = (res.candidates || []) as Candidate[];
|
||||
setCandidates(cand);
|
||||
const existing = (item.bindings || []) as { placeholder?: string; value?: string }[];
|
||||
|
|
@ -1459,10 +1464,10 @@ export function BizStatePage() {
|
|||
}${bindLines.length ? " bs-params-scroll--clickable" : ""}`}
|
||||
title={
|
||||
bindLines.length
|
||||
? `${bindHint}\n${t("bizState.paramsDblClickHint")}`
|
||||
? `${bindHint}\n${t("bizState.paramsClickHint")}`
|
||||
: bindHint
|
||||
}
|
||||
onDoubleClick={() => {
|
||||
onClick={() => {
|
||||
if (!bindLines.length) return;
|
||||
setParamsDetail({
|
||||
title: prof.title,
|
||||
|
|
@ -1689,6 +1694,7 @@ export function BizStatePage() {
|
|||
<p className="muted">
|
||||
<code>{discoverCmd}</code>
|
||||
{candidates.length ? ` · ${selectedVrfs.length}/${candidates.length}` : null}
|
||||
{discoverCacheHit ? ` · ${t("bizState.discoverCacheHit")}` : null}
|
||||
</p>
|
||||
) : null}
|
||||
{discoverError ? <p className="bs-params-warn">{discoverError}</p> : null}
|
||||
|
|
@ -1711,6 +1717,19 @@ export function BizStatePage() {
|
|||
? t("bizState.deselectAllVrfs")
|
||||
: t("bizState.selectAllVrfs")}
|
||||
</Button>
|
||||
{bindItemId ? (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
isDisabled={busy || discoverLoading}
|
||||
onPress={() => {
|
||||
const item = (detail?.items || []).find((it: any) => it.id === bindItemId);
|
||||
if (item) void startDiscover(item, true);
|
||||
}}
|
||||
>
|
||||
{t("bizState.discoverRefresh")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="bs-bind-list bs-bind-list--modal">
|
||||
{candidates.map((c) => (
|
||||
|
|
|
|||
|
|
@ -1777,7 +1777,16 @@ export const bizStateDiscover = (body: Record<string, unknown>) =>
|
|||
ok: boolean;
|
||||
error?: string;
|
||||
command?: string;
|
||||
candidates?: Array<{ value: string; label: string; rd?: string; protocols?: string }>;
|
||||
cache_hit?: boolean;
|
||||
pair_mode?: boolean;
|
||||
discover_profile_id?: string;
|
||||
candidates?: Array<{
|
||||
value: string;
|
||||
label: string;
|
||||
rd?: string;
|
||||
protocols?: string;
|
||||
bindings?: Record<string, string>;
|
||||
}>;
|
||||
raw_preview?: string;
|
||||
}>("/v1/biz-state/discover", body);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue