fix(web): 收敛控制台列表主按钮、报警可读性与焦点环
按 UI 评审闭环 UI-02~UI-07(查询降权、对象/处理人可读化、筛选分层、数据源名映射、焦点外环);概览与登录壳按约定暂缓。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
c7a23837f4
commit
9dffeae667
25 files changed
+1057
-94
No files matched your search
@@ -35,7 +35,7 @@ import {
|
||||
} from "./actions";
|
||||
import { appendProgress, claimAlarm, closeAlarm, getAlarm, listEvidence, listHistory, listOccurrences } from "./client";
|
||||
import { describeAlarmError, isAlarmConflict, isAlarmForbidden, isAlarmNotFound } from "./errors";
|
||||
import { formatDateTime } from "./format";
|
||||
import { formatDateTime, formatHandlerLabel, formatIdentityLabel } from "./format";
|
||||
import type { AlarmRecord, ClosedBasis, EvidenceBundle, HistoryEvent, OccurrenceList } from "./types";
|
||||
|
||||
const { t, te } = useI18n();
|
||||
@@ -98,6 +98,19 @@ function textOrNone(value: string | null | undefined): string {
|
||||
return value;
|
||||
}
|
||||
|
||||
function objectLabel(identityKey: string): string {
|
||||
return formatIdentityLabel(identityKey) || t("alarm.detail.fields.none");
|
||||
}
|
||||
|
||||
function handlerDisplay(subject: string | null | undefined): { label: string; title?: string } {
|
||||
const short = formatHandlerLabel(subject);
|
||||
if (!short) {
|
||||
return { label: t("alarm.detail.fields.none") };
|
||||
}
|
||||
const full = subject?.trim() ?? short;
|
||||
return { label: short, title: full !== short ? full : undefined };
|
||||
}
|
||||
|
||||
function statusText(status: string): string {
|
||||
const key = `alarm.status.${status}`;
|
||||
return te(key) ? t(key) : status;
|
||||
@@ -393,76 +406,112 @@ onMounted(() => {
|
||||
<section class="wm-form-section" data-testid="alarm-summary">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("alarm.detail.summary") }}</h3>
|
||||
<dl class="grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-2">
|
||||
<div class="sm:col-span-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-surface-soft)] p-3">
|
||||
<div class="grid grid-cols-1 gap-3 sm:grid-cols-3">
|
||||
<div>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.status") }}</dt>
|
||||
<dd class="mt-1 font-semibold text-[var(--text-primary)]">
|
||||
<ElTag :type="statusTag(alarm.status)" effect="light" data-testid="alarm-detail-status">
|
||||
{{ statusText(alarm.status) }}
|
||||
</ElTag>
|
||||
<span v-if="alarm.close_result" class="ml-1 text-[13px] font-medium">
|
||||
{{ t("alarm.list.resultSep") }}{{ named("closeResult", alarm.close_result) }}
|
||||
</span>
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.scenario") }}</dt>
|
||||
<dd class="mt-1 text-[15px] font-semibold text-[var(--text-primary)]">{{ alarm.scenario_name }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.object") }}</dt>
|
||||
<dd
|
||||
class="mt-1 text-[15px] font-semibold text-[var(--text-primary)]"
|
||||
data-testid="alarm-identity"
|
||||
:title="alarm.identity_key"
|
||||
>
|
||||
{{ objectLabel(alarm.identity_key) }}
|
||||
</dd>
|
||||
<p
|
||||
v-if="objectLabel(alarm.identity_key) !== alarm.identity_key"
|
||||
class="mt-0.5 truncate text-[12px] text-[var(--text-muted)]"
|
||||
data-testid="alarm-identity-raw"
|
||||
:title="alarm.identity_key"
|
||||
>
|
||||
{{ alarm.identity_key }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.status") }}</dt>
|
||||
<dd>
|
||||
<ElTag :type="statusTag(alarm.status)" effect="light" data-testid="alarm-detail-status">
|
||||
{{ statusText(alarm.status) }}
|
||||
</ElTag>
|
||||
<span v-if="alarm.close_result">
|
||||
{{ t("alarm.list.resultSep") }}{{ named("closeResult", alarm.close_result) }}
|
||||
</span>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.module") }}</dt>
|
||||
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">{{ alarm.module_key }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.count") }}</dt>
|
||||
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">{{ alarm.occurrence_count }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.firstOccurred") }}</dt>
|
||||
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">
|
||||
{{ formatDateTime(alarm.first_occurred_at) || t("alarm.detail.fields.none") }}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.scenario") }}</dt>
|
||||
<dd>{{ alarm.scenario_name }}</dd>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.lastOccurred") }}</dt>
|
||||
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">
|
||||
{{ formatDateTime(alarm.last_occurred_at) || t("alarm.detail.fields.none") }}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.module") }}</dt>
|
||||
<dd>{{ alarm.module_key }}</dd>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.handler") }}</dt>
|
||||
<dd
|
||||
class="mt-0.5 font-medium text-[var(--text-primary)]"
|
||||
data-testid="alarm-handler"
|
||||
:title="handlerDisplay(alarm.current_handler).title"
|
||||
>
|
||||
{{ handlerDisplay(alarm.current_handler).label }}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.scenarioKey") }}</dt>
|
||||
<dd>{{ alarm.scenario_key }}</dd>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.claimedAt") }}</dt>
|
||||
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">
|
||||
{{ formatDateTime(alarm.claimed_at) || t("alarm.detail.fields.none") }}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.object") }}</dt>
|
||||
<dd data-testid="alarm-identity">{{ alarm.identity_key }}</dd>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.closedAt") }}</dt>
|
||||
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">
|
||||
{{ formatDateTime(alarm.closed_at) || t("alarm.detail.fields.none") }}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.count") }}</dt>
|
||||
<dd>{{ alarm.occurrence_count }}</dd>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.openedAt") }}</dt>
|
||||
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">
|
||||
{{ formatDateTime(alarm.opened_at) || t("alarm.detail.fields.none") }}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.firstOccurred") }}</dt>
|
||||
<dd>{{ formatDateTime(alarm.first_occurred_at) || t("alarm.detail.fields.none") }}</dd>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.updatedAt") }}</dt>
|
||||
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">
|
||||
{{ formatDateTime(alarm.updated_at) || t("alarm.detail.fields.none") }}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.lastOccurred") }}</dt>
|
||||
<dd>{{ formatDateTime(alarm.last_occurred_at) || t("alarm.detail.fields.none") }}</dd>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.scenarioKey") }}</dt>
|
||||
<dd class="mt-0.5 text-[var(--text-secondary)]">{{ alarm.scenario_key }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.handler") }}</dt>
|
||||
<dd data-testid="alarm-handler">{{ textOrNone(alarm.current_handler) }}</dd>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.cycle") }}</dt>
|
||||
<dd class="mt-0.5 text-[var(--text-secondary)]">{{ textOrNone(alarm.cycle_key) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.claimedAt") }}</dt>
|
||||
<dd>{{ formatDateTime(alarm.claimed_at) || t("alarm.detail.fields.none") }}</dd>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.event") }}</dt>
|
||||
<dd class="mt-0.5 text-[var(--text-secondary)]">{{ textOrNone(alarm.event_key) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.closedAt") }}</dt>
|
||||
<dd>{{ formatDateTime(alarm.closed_at) || t("alarm.detail.fields.none") }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.cycle") }}</dt>
|
||||
<dd>{{ textOrNone(alarm.cycle_key) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.event") }}</dt>
|
||||
<dd>{{ textOrNone(alarm.event_key) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.openedAt") }}</dt>
|
||||
<dd>{{ formatDateTime(alarm.opened_at) || t("alarm.detail.fields.none") }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.updatedAt") }}</dt>
|
||||
<dd>{{ formatDateTime(alarm.updated_at) || t("alarm.detail.fields.none") }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-[var(--text-muted)]">{{ t("alarm.detail.fields.previous") }}</dt>
|
||||
<dd>
|
||||
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.previous") }}</dt>
|
||||
<dd class="mt-0.5">
|
||||
<ElButton
|
||||
v-if="alarm.previous_alarm_id"
|
||||
link
|
||||
@@ -472,7 +521,7 @@ onMounted(() => {
|
||||
>
|
||||
{{ alarm.previous_alarm_id }}
|
||||
</ElButton>
|
||||
<span v-else>{{ t("alarm.detail.fields.none") }}</span>
|
||||
<span v-else class="text-[var(--text-secondary)]">{{ t("alarm.detail.fields.none") }}</span>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
emptyAlarmFilters,
|
||||
type AlarmFilterDraft,
|
||||
} from "./filters";
|
||||
import { formatDateTime } from "./format";
|
||||
import { formatDateTime, formatIdentityLabel } from "./format";
|
||||
import type { AlarmRecord } from "./types";
|
||||
|
||||
const { t, te } = useI18n();
|
||||
@@ -46,6 +46,8 @@ const total = ref(0);
|
||||
const phase = ref<"loading" | "ready" | "error" | "forbidden">("loading");
|
||||
const loadError = ref("");
|
||||
const filterIssue = ref<"object" | "time-order" | null>(null);
|
||||
/** Extra filters (module / object) stay collapsed until opened or they hold draft values. */
|
||||
const moreFiltersOpen = ref(false);
|
||||
|
||||
const draft = reactive<AlarmFilterDraft>(emptyAlarmFilters());
|
||||
const applied = reactive<AlarmFilterDraft>(emptyAlarmFilters());
|
||||
@@ -124,10 +126,19 @@ function resetFilters(): void {
|
||||
copyFilters(draft, blank);
|
||||
copyFilters(applied, blank);
|
||||
filterIssue.value = null;
|
||||
moreFiltersOpen.value = false;
|
||||
page.value = 1;
|
||||
void load();
|
||||
}
|
||||
|
||||
const moreFiltersActive = computed(
|
||||
() => draft.moduleKey.trim() !== "" || draft.objectId.trim() !== "",
|
||||
);
|
||||
|
||||
function toggleMoreFilters(): void {
|
||||
moreFiltersOpen.value = !moreFiltersOpen.value;
|
||||
}
|
||||
|
||||
function onSortChange(payload: { prop: string | null; order: string | null }): void {
|
||||
const sortable = new Set(["module_key", "scenario_name", "last_occurred_at", "status"]);
|
||||
if (!payload.prop || !payload.order || !sortable.has(payload.prop)) {
|
||||
@@ -189,15 +200,16 @@ onMounted(() => {
|
||||
<ListPageShell test-id="alarm-list">
|
||||
<template #filters>
|
||||
<div data-testid="alarm-list-toolbar" class="contents">
|
||||
<div class="w-[9rem]" data-testid="alarm-filter-module">
|
||||
<ElInput v-model="draft.moduleKey" clearable :placeholder="t('alarm.list.filterModule')" />
|
||||
<div class="w-[7.5rem]" data-testid="alarm-filter-status">
|
||||
<ElSelect v-model="draft.status" clearable class="w-full" :placeholder="t('alarm.list.filterStatus')">
|
||||
<ElOption :label="t('alarm.status.pending')" value="pending" />
|
||||
<ElOption :label="t('alarm.status.processing')" value="processing" />
|
||||
<ElOption :label="t('alarm.status.closed')" value="closed" />
|
||||
</ElSelect>
|
||||
</div>
|
||||
<div class="w-[12rem]" data-testid="alarm-filter-scenario">
|
||||
<ElInput v-model="draft.scenarioName" clearable :placeholder="t('alarm.list.filterScenario')" />
|
||||
</div>
|
||||
<div class="w-[14rem]" data-testid="alarm-filter-object">
|
||||
<ElInput v-model="draft.objectId" clearable :placeholder="t('alarm.list.filterObject')" />
|
||||
</div>
|
||||
<div class="w-[12.5rem]" data-testid="alarm-filter-from">
|
||||
<ElDatePicker
|
||||
v-model="draft.from"
|
||||
@@ -214,19 +226,24 @@ onMounted(() => {
|
||||
:placeholder="t('alarm.list.filterTo')"
|
||||
/>
|
||||
</div>
|
||||
<div class="w-[7.5rem]" data-testid="alarm-filter-status">
|
||||
<ElSelect v-model="draft.status" clearable class="w-full" :placeholder="t('alarm.list.filterStatus')">
|
||||
<ElOption :label="t('alarm.status.pending')" value="pending" />
|
||||
<ElOption :label="t('alarm.status.processing')" value="processing" />
|
||||
<ElOption :label="t('alarm.status.closed')" value="closed" />
|
||||
</ElSelect>
|
||||
</div>
|
||||
<template v-if="moreFiltersOpen">
|
||||
<div class="w-[9rem]" data-testid="alarm-filter-module">
|
||||
<ElInput v-model="draft.moduleKey" clearable :placeholder="t('alarm.list.filterModule')" />
|
||||
</div>
|
||||
<div class="w-[14rem]" data-testid="alarm-filter-object">
|
||||
<ElInput v-model="draft.objectId" clearable :placeholder="t('alarm.list.filterObject')" />
|
||||
</div>
|
||||
</template>
|
||||
<ElButton type="primary" data-testid="alarm-filter-search" @click="applyFilters">
|
||||
{{ t("alarm.list.filterSearch") }}
|
||||
</ElButton>
|
||||
<ElButton data-testid="alarm-filter-reset" @click="resetFilters">
|
||||
{{ t("alarm.list.filterReset") }}
|
||||
</ElButton>
|
||||
<ElButton data-testid="alarm-filter-more" @click="toggleMoreFilters">
|
||||
{{ moreFiltersOpen ? t("alarm.list.fewerFilters") : t("alarm.list.moreFilters") }}
|
||||
<span v-if="!moreFiltersOpen && moreFiltersActive" data-testid="alarm-filter-more-dot"> ·</span>
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -298,7 +315,13 @@ onMounted(() => {
|
||||
min-width="160"
|
||||
sortable="custom"
|
||||
/>
|
||||
<ElTableColumn prop="identity_key" :label="t('alarm.columns.object')" min-width="140" />
|
||||
<ElTableColumn prop="identity_key" :label="t('alarm.columns.object')" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<span :title="row.identity_key" data-testid="alarm-object-label">
|
||||
{{ formatIdentityLabel(row.identity_key) }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="last_occurred_at"
|
||||
:label="t('alarm.columns.lastOccurred')"
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { formatHandlerLabel, formatIdentityLabel } from "./format";
|
||||
|
||||
describe("formatIdentityLabel", () => {
|
||||
it("extracts serial from identity:v1 JSON", () => {
|
||||
expect(formatIdentityLabel('identity:v1:{"serial":"DEMO-298ce536"}')).toBe("DEMO-298ce536");
|
||||
});
|
||||
|
||||
it("falls back to the raw key when JSON is absent", () => {
|
||||
expect(formatIdentityLabel("plain-object-1")).toBe("plain-object-1");
|
||||
});
|
||||
|
||||
it("returns empty for blank input", () => {
|
||||
expect(formatIdentityLabel("")).toBe("");
|
||||
expect(formatIdentityLabel(null)).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatHandlerLabel", () => {
|
||||
it("keeps short subjects", () => {
|
||||
expect(formatHandlerLabel("26110002")).toBe("26110002");
|
||||
});
|
||||
|
||||
it("truncates UUID subjects", () => {
|
||||
expect(formatHandlerLabel("550e8400-e29b-41d4-a716-446655440000")).toBe("550e8400…");
|
||||
});
|
||||
|
||||
it("returns null for empty", () => {
|
||||
expect(formatHandlerLabel(null)).toBeNull();
|
||||
expect(formatHandlerLabel(" ")).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Alarm timestamps for tables. Empty or invalid values stay blank.
|
||||
* Boundary: display only. It does not parse filter input.
|
||||
* Depends on the browser time zone.
|
||||
* Alarm timestamps and display labels for tables/detail.
|
||||
* Boundary: display only. Does not parse filter input or call APIs.
|
||||
* Depends on the browser time zone for datetime formatting.
|
||||
*/
|
||||
|
||||
function pad(value: number): string {
|
||||
@@ -19,3 +19,58 @@ export function formatDateTime(iso: string | null | undefined): string {
|
||||
}
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
||||
}
|
||||
|
||||
const UUID_RE =
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
|
||||
/**
|
||||
* Prefer a short object id (e.g. serial) from identity keys like
|
||||
* `identity:v1:{"serial":"DEMO-1"}`. Falls back to the raw key when unknown.
|
||||
*/
|
||||
export function formatIdentityLabel(identityKey: string | null | undefined): string {
|
||||
if (!identityKey) {
|
||||
return "";
|
||||
}
|
||||
const raw = identityKey.trim();
|
||||
if (!raw) {
|
||||
return "";
|
||||
}
|
||||
const jsonStart = raw.indexOf("{");
|
||||
if (jsonStart >= 0) {
|
||||
try {
|
||||
const parsed = JSON.parse(raw.slice(jsonStart)) as unknown;
|
||||
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
||||
const record = parsed as Record<string, unknown>;
|
||||
for (const key of ["serial", "id", "code", "name"]) {
|
||||
const value = record[key];
|
||||
if (typeof value === "string" && value.trim()) {
|
||||
return value.trim();
|
||||
}
|
||||
}
|
||||
for (const value of Object.values(record)) {
|
||||
if (typeof value === "string" && value.trim()) {
|
||||
return value.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// keep raw
|
||||
}
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
|
||||
/** Short label for handler subjects; full value stays available via title. */
|
||||
export function formatHandlerLabel(subject: string | null | undefined): string | null {
|
||||
if (subject === null || subject === undefined) {
|
||||
return null;
|
||||
}
|
||||
const value = subject.trim();
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
if (UUID_RE.test(value)) {
|
||||
return `${value.slice(0, 8)}…`;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
Reference in new issue
Block a user