feat(web): 对齐和信后台页壳并落地工业 UI 评审与 Skills 盘点
统一控制台列表/表单页壳与 Hexin 样式,补充 industrial-ui-review、管理员评审证据,以及 Skills 资产盘点与 test-strategy 消歧。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
48d1735c17
commit
c7a23837f4
74 files changed
+3839
-601
No files matched your search
@@ -0,0 +1,216 @@
|
||||
/**
|
||||
* Shared helpers for console UI smoke / layout tests.
|
||||
* Auth is mocked; APIs return synthetic envelopes. Login page is out of scope.
|
||||
*/
|
||||
import { expect, type Locator, type Page } from "@playwright/test";
|
||||
|
||||
export function ok(data: unknown, requestId = "ui-smoke"): string {
|
||||
return JSON.stringify({ success: true, data, request_id: requestId });
|
||||
}
|
||||
|
||||
/** Signed-in watchman-admin via /auth/me mock. */
|
||||
export async function signedInAdmin(page: Page): Promise<void> {
|
||||
await page.route("**/auth/me", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: ok({
|
||||
subject: "admin-1",
|
||||
display_name: "Admin",
|
||||
roles: ["watchman-admin"],
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function mockHealth(page: Page): Promise<void> {
|
||||
await page.route("**/health", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: ok({ status: "ok", app: "watchman", version: "0.1.0" }),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function mockDatasourceList(page: Page): Promise<void> {
|
||||
await page.route("**/datasources?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: ok({
|
||||
items: [
|
||||
{
|
||||
id: "ds-1",
|
||||
name: "MES-PG",
|
||||
engine: "postgresql",
|
||||
host: "127.0.0.1",
|
||||
port: 5432,
|
||||
database_name: "mes",
|
||||
username: "ro",
|
||||
enabled: true,
|
||||
circuit_state: "closed",
|
||||
last_test_at: null,
|
||||
last_test_category: null,
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function mockQueryList(page: Page): Promise<void> {
|
||||
await page.route("**/datasources?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: ok({ items: [], total: 0, page: 1, page_size: 100 }),
|
||||
});
|
||||
});
|
||||
await page.route("**/queries?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: ok({
|
||||
items: [
|
||||
{
|
||||
id: "q-1",
|
||||
name: "炉温查询",
|
||||
datasource_id: "ds-1",
|
||||
enabled: true,
|
||||
current_version_no: 2,
|
||||
updated_at: "2024-11-18T10:00:00Z",
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function mockMappingList(page: Page): Promise<void> {
|
||||
await page.route("**/mappings**", async (route) => {
|
||||
const pathname = new URL(route.request().url()).pathname;
|
||||
if (!pathname.startsWith("/mappings") || route.request().method() !== "GET") {
|
||||
await route.continue();
|
||||
return;
|
||||
}
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: ok({
|
||||
items: [{ id: "m-1", name: "炉温映射", query: "炉温查询", current_version_no: 1 }],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function mockAlarmList(page: Page): Promise<void> {
|
||||
await page.route("**/alarms?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: ok({
|
||||
items: [
|
||||
{
|
||||
id: "a-1",
|
||||
module_key: "furnace",
|
||||
scenario_key: "temp",
|
||||
scenario_name: "炉温超限",
|
||||
identity_key: "F1",
|
||||
status: "pending",
|
||||
close_result: null,
|
||||
last_occurred_at: "2024-11-18T12:00:00Z",
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/** Read a CSS custom property from :root. */
|
||||
export async function cssVar(page: Page, name: string): Promise<string> {
|
||||
return page.locator(":root").evaluate((el, prop) => getComputedStyle(el).getPropertyValue(prop).trim(), name);
|
||||
}
|
||||
|
||||
export async function computed(locator: Locator, prop: keyof CSSStyleDeclaration): Promise<string> {
|
||||
return locator.evaluate((el, p) => {
|
||||
const style = getComputedStyle(el);
|
||||
return String(style[p as keyof CSSStyleDeclaration] ?? "");
|
||||
}, prop);
|
||||
}
|
||||
|
||||
/** Assert list page card skeleton (P1): surface card + 32px filter gutters + right pager. */
|
||||
export async function expectListPageLayout(page: Page, listTestId: string): Promise<void> {
|
||||
const card = page.getByTestId(listTestId);
|
||||
await expect(card).toBeVisible();
|
||||
await expect(card).toHaveClass(/wm-list-page/);
|
||||
|
||||
const radius = await computed(card, "borderRadius");
|
||||
expect(radius).toMatch(/16px/);
|
||||
|
||||
const filters = card.locator(".wm-list-page__filters");
|
||||
await expect(filters).toBeVisible();
|
||||
const padLeft = await computed(filters, "paddingLeft");
|
||||
const padRight = await computed(filters, "paddingRight");
|
||||
expect(padLeft).toBe("32px");
|
||||
expect(padRight).toBe("32px");
|
||||
|
||||
const pager = card.locator(".wm-list-page__pager");
|
||||
if ((await pager.count()) > 0) {
|
||||
await expect(pager).toBeVisible();
|
||||
// Chromium may serialize flex-end as flow-end.
|
||||
expect(await computed(pager, "justifyContent")).toMatch(/^(flex-end|end|flow-end)$/);
|
||||
expect(await computed(pager, "paddingLeft")).toBe("32px");
|
||||
expect(await computed(pager, "paddingRight")).toBe("32px");
|
||||
}
|
||||
}
|
||||
|
||||
/** Assert form/detail card: scroll body + centered sticky footer. */
|
||||
export async function expectFormPageLayout(
|
||||
page: Page,
|
||||
opts: { pageTestId: string; footerTestId: string; bodyTestId?: string },
|
||||
): Promise<void> {
|
||||
const card = page.getByTestId(opts.pageTestId);
|
||||
await expect(card).toBeVisible();
|
||||
await expect(card).toHaveClass(/wm-form-page/);
|
||||
expect(await computed(card, "borderRadius")).toMatch(/16px/);
|
||||
|
||||
if (opts.bodyTestId) {
|
||||
const body = page.getByTestId(opts.bodyTestId);
|
||||
await expect(body).toBeVisible();
|
||||
expect(await computed(body, "overflow")).toMatch(/auto|scroll/);
|
||||
expect(await computed(body, "paddingLeft")).toBe("32px");
|
||||
}
|
||||
|
||||
const footer = page.getByTestId(opts.footerTestId);
|
||||
await expect(footer).toBeVisible();
|
||||
expect(await computed(footer, "justifyContent")).toMatch(/^(center|flex-center)$/);
|
||||
expect(await computed(footer, "paddingLeft")).toBe("32px");
|
||||
}
|
||||
|
||||
/** Shell chrome: brand nav, breadcrumb bar, padded main stage. */
|
||||
export async function expectShellChrome(page: Page): Promise<void> {
|
||||
await expect(page.getByTestId("side-nav")).toBeVisible();
|
||||
await expect(page.getByTestId("side-brand")).toBeVisible();
|
||||
await expect(page.getByTestId("breadcrumb")).toBeVisible();
|
||||
await expect(page.getByTestId("side-user")).toBeVisible();
|
||||
await expect(page.getByTestId("logout")).toBeVisible();
|
||||
|
||||
// AppShell content column: header + main stage with page padding.
|
||||
const shellMain = page.locator("div.flex.min-w-0.flex-1.flex-col > main");
|
||||
await expect(shellMain).toBeVisible();
|
||||
expect(await computed(shellMain, "paddingTop")).toBe("16px");
|
||||
expect(await computed(shellMain, "paddingLeft")).toBe("16px");
|
||||
}
|
||||
@@ -0,0 +1,415 @@
|
||||
/**
|
||||
* Visual evidence for hexin UI alignment. Mocks auth + list APIs; does not cover login.
|
||||
*/
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const evidenceDir = path.resolve(
|
||||
path.dirname(fileURLToPath(import.meta.url)),
|
||||
"../../../../docs/evidence/ui-hexin",
|
||||
);
|
||||
|
||||
async function signedInAdmin(page: Page) {
|
||||
await page.route("**/auth/me", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { subject: "admin-1", display_name: "Admin", roles: ["watchman-admin"] },
|
||||
request_id: "ui-hexin-me",
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function shot(page: Page, name: string) {
|
||||
await page.setViewportSize({ width: 1440, height: 900 });
|
||||
await page.screenshot({ path: path.join(evidenceDir, name), fullPage: true });
|
||||
}
|
||||
|
||||
test.describe("ui hexin screenshots", () => {
|
||||
test("S0 shell + S1 home", async ({ page }) => {
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/health", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { status: "ok", app: "watchman", version: "0.1.0" },
|
||||
request_id: "ui-hexin-health",
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.goto("/");
|
||||
await expect(page.getByTestId("side-nav")).toBeVisible();
|
||||
await expect(page.getByTestId("home-page")).toBeVisible();
|
||||
await expect(page.getByTestId("health-success")).toBeVisible();
|
||||
await shot(page, "S0-shell-S1-home.png");
|
||||
});
|
||||
|
||||
test("S2 datasource list", async ({ page }) => {
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/datasources?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
id: "ds-1",
|
||||
name: "MES-PG",
|
||||
engine: "postgresql",
|
||||
host: "127.0.0.1",
|
||||
port: 5432,
|
||||
database_name: "mes",
|
||||
username: "ro",
|
||||
enabled: true,
|
||||
circuit_state: "closed",
|
||||
last_test_at: null,
|
||||
last_test_category: null,
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
},
|
||||
request_id: "ui-hexin-ds",
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.goto("/#/datasources");
|
||||
await expect(page.getByTestId("datasource-list")).toBeVisible();
|
||||
await expect(page.getByTestId("datasource-table")).toBeVisible();
|
||||
await shot(page, "S2-datasource-list.png");
|
||||
});
|
||||
|
||||
test("S3 datasource create", async ({ page }) => {
|
||||
await signedInAdmin(page);
|
||||
await page.goto("/#/datasources/new");
|
||||
await expect(page.getByTestId("datasource-edit")).toBeVisible();
|
||||
await expect(page.getByTestId("datasource-footer")).toBeVisible();
|
||||
await shot(page, "S3-datasource-create.png");
|
||||
});
|
||||
|
||||
test("S4 query list", async ({ page }) => {
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/datasources?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { items: [], total: 0, page: 1, page_size: 100 },
|
||||
request_id: "ui-hexin-ds-opt",
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.route("**/queries?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
id: "q-1",
|
||||
name: "炉温查询",
|
||||
datasource_id: "ds-1",
|
||||
enabled: true,
|
||||
current_version_no: 2,
|
||||
updated_at: "2024-11-18T10:00:00Z",
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
},
|
||||
request_id: "ui-hexin-q",
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.goto("/#/queries");
|
||||
await expect(page.getByTestId("query-list")).toBeVisible();
|
||||
await expect(page.getByTestId("query-table")).toBeVisible();
|
||||
await shot(page, "S4-query-list.png");
|
||||
});
|
||||
|
||||
test("S5 query create", async ({ page }) => {
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/datasources?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { items: [], total: 0, page: 1, page_size: 100 },
|
||||
request_id: "ui-hexin-ds-opt",
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.goto("/#/queries/new");
|
||||
await expect(page.getByTestId("query-edit")).toBeVisible();
|
||||
await expect(page.getByTestId("query-footer")).toBeVisible();
|
||||
await shot(page, "S5-query-create.png");
|
||||
});
|
||||
|
||||
test("S6 mapping list", async ({ page }) => {
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/health", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { status: "ok", app: "watchman", version: "0.1.0" },
|
||||
request_id: "ui-hexin-health",
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.route("**/mappings**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
if (!url.pathname.startsWith("/mappings") || route.request().method() !== "GET") {
|
||||
await route.continue();
|
||||
return;
|
||||
}
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: {
|
||||
items: [{ id: "m-1", name: "炉温映射", query: "炉温查询", current_version_no: 1 }],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
},
|
||||
request_id: "ui-hexin-m",
|
||||
}),
|
||||
});
|
||||
});
|
||||
page.on("pageerror", (err) => console.error("PAGEERROR", err.message));
|
||||
await page.goto("/#/mappings");
|
||||
await expect(page.getByTestId("nav-mappings")).toBeVisible();
|
||||
await expect(page.getByTestId("mapping-list")).toBeVisible({ timeout: 10_000 });
|
||||
await expect(page.getByTestId("mapping-table")).toBeVisible();
|
||||
await shot(page, "S6-mapping-list.png");
|
||||
});
|
||||
|
||||
test("S7 mapping edit", async ({ page }) => {
|
||||
const mapId = "44444444-4444-4444-8444-444444444444";
|
||||
const columns = [
|
||||
{
|
||||
source_column_name: "temperature",
|
||||
value_type: "number",
|
||||
is_identity: false,
|
||||
is_observation_time: false,
|
||||
numeric_multiply: null,
|
||||
numeric_offset: null,
|
||||
},
|
||||
];
|
||||
const tree = { column: "temperature", operator: "gt", value: 80 };
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/mappings**", async (route) => {
|
||||
const pathname = new URL(route.request().url()).pathname;
|
||||
if (!pathname.startsWith("/mappings")) {
|
||||
await route.continue();
|
||||
return;
|
||||
}
|
||||
if (route.request().method() === "GET" && pathname === `/mappings/${mapId}`) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { id: mapId, query_definition_id: "q1", current_version_no: 1 },
|
||||
request_id: "ui-hexin-m-get",
|
||||
}),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (route.request().method() === "GET" && pathname === `/mappings/${mapId}/versions`) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { items: [{ version_no: 1 }] },
|
||||
request_id: "ui-hexin-m-ver",
|
||||
}),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (route.request().method() === "GET" && pathname.startsWith(`/mappings/${mapId}/versions/`)) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { version_no: 1, columns, condition_tree: tree },
|
||||
request_id: "ui-hexin-m-v1",
|
||||
}),
|
||||
});
|
||||
return;
|
||||
}
|
||||
await route.fulfill({
|
||||
status: 404,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ success: true, data: {}, request_id: "ui-hexin-m-404" }),
|
||||
});
|
||||
});
|
||||
await page.route("**/queries/q1**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: {
|
||||
id: "q1",
|
||||
name: "炉温查询",
|
||||
description: null,
|
||||
datasource_id: "ds-1",
|
||||
enabled: true,
|
||||
current_version_no: 1,
|
||||
latest_version_no: 1,
|
||||
current: {
|
||||
sql_template: "select 1",
|
||||
param_schema: [],
|
||||
output_schema: [{ name: "temperature", type: "number" }],
|
||||
allowed_identifiers: [],
|
||||
timeout_ms: 5000,
|
||||
max_rows: 100,
|
||||
},
|
||||
},
|
||||
request_id: "ui-hexin-q-get",
|
||||
}),
|
||||
});
|
||||
});
|
||||
page.on("pageerror", (err) => console.error("PAGEERROR", err.message));
|
||||
await page.goto(`/#/mappings/${mapId}`);
|
||||
await expect(page.getByTestId("mapping-edit")).toBeVisible({ timeout: 10_000 });
|
||||
await expect(page.getByTestId("mapping-footer")).toBeVisible();
|
||||
await shot(page, "S7-mapping-edit.png");
|
||||
});
|
||||
|
||||
test("S8 alarm list", async ({ page }) => {
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/alarms?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
id: "a-1",
|
||||
module_key: "furnace",
|
||||
scenario_key: "temp",
|
||||
scenario_name: "炉温超限",
|
||||
identity_key: "F1",
|
||||
status: "pending",
|
||||
close_result: null,
|
||||
last_occurred_at: "2024-11-18T12:00:00Z",
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
},
|
||||
request_id: "ui-hexin-a",
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.goto("/#/alarms");
|
||||
await expect(page.getByTestId("alarm-list")).toBeVisible();
|
||||
await expect(page.getByTestId("alarm-table")).toBeVisible();
|
||||
await shot(page, "S8-alarm-list.png");
|
||||
});
|
||||
|
||||
test("S9 alarm detail", async ({ page }) => {
|
||||
const alarmId = "aaaaaaaa-aaaa-aaaa-8aaa-aaaaaaaaaaaa";
|
||||
const alarm = {
|
||||
id: alarmId,
|
||||
status: "pending",
|
||||
current_handler: null,
|
||||
claimed_at: null,
|
||||
closed_at: null,
|
||||
close_result: null,
|
||||
occurrence_count: 1,
|
||||
first_occurred_at: "2024-11-18T12:00:00Z",
|
||||
last_occurred_at: "2024-11-18T12:00:00Z",
|
||||
previous_alarm_id: null,
|
||||
mapped_input_id: "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb",
|
||||
identity_key: "F1",
|
||||
module_key: "furnace",
|
||||
scenario_key: "temp",
|
||||
scenario_name: "炉温超限",
|
||||
snapshot_id: "cccccccc-cccc-4ccc-8ccc-cccccccccccc",
|
||||
snapshot_version_no: 1,
|
||||
cycle_key: "c1",
|
||||
event_key: "e1",
|
||||
opened_at: "2024-11-18T12:00:00Z",
|
||||
updated_at: "2024-11-18T12:00:00Z",
|
||||
};
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/alarms/**", async (route) => {
|
||||
const path = new URL(route.request().url()).pathname;
|
||||
if (path === `/alarms/${alarmId}`) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ success: true, data: alarm, request_id: "ui-hexin-ad" }),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (path === `/alarms/${alarmId}/occurrences`) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { alarm_id: alarmId, items: [] },
|
||||
request_id: "ui-hexin-occ",
|
||||
}),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (path === `/alarms/${alarmId}/evidence`) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { alarm_id: alarmId, revision_evidence: [], closed_basis: [] },
|
||||
request_id: "ui-hexin-ev",
|
||||
}),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (path === `/alarms/${alarmId}/history`) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { alarm_id: alarmId, items: [] },
|
||||
request_id: "ui-hexin-hi",
|
||||
}),
|
||||
});
|
||||
return;
|
||||
}
|
||||
await route.continue();
|
||||
});
|
||||
await page.goto(`/#/alarms/${alarmId}`);
|
||||
await expect(page.getByTestId("alarm-detail")).toBeVisible();
|
||||
await expect(page.getByTestId("alarm-summary")).toBeVisible();
|
||||
await expect(page.getByTestId("alarm-footer")).toBeVisible();
|
||||
await shot(page, "S9-alarm-detail.png");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* UI smoke: shell chrome, list/form skeleton, design tokens, soft visual baselines.
|
||||
* Follows playwright-automation (user-facing locators + auto-wait) and visual-testing
|
||||
* (toHaveScreenshot with animations disabled). Login page is out of scope.
|
||||
*/
|
||||
import { expect, test } from "@playwright/test";
|
||||
import {
|
||||
cssVar,
|
||||
expectFormPageLayout,
|
||||
expectListPageLayout,
|
||||
expectShellChrome,
|
||||
mockAlarmList,
|
||||
mockDatasourceList,
|
||||
mockHealth,
|
||||
mockMappingList,
|
||||
mockQueryList,
|
||||
signedInAdmin,
|
||||
} from "./helpers/ui";
|
||||
|
||||
const DESKTOP = { width: 1440, height: 900 };
|
||||
|
||||
const shotOpts = {
|
||||
animations: "disabled" as const,
|
||||
caret: "hide" as const,
|
||||
maxDiffPixelRatio: 0.02,
|
||||
};
|
||||
|
||||
test.describe("UI smoke — tokens and shell", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.setViewportSize(DESKTOP);
|
||||
await signedInAdmin(page);
|
||||
await mockHealth(page);
|
||||
});
|
||||
|
||||
test("design tokens expose hexin primary and surface radius", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
await expect(page.getByTestId("home-page")).toBeVisible();
|
||||
|
||||
const primary = await cssVar(page, "--color-primary");
|
||||
const elPrimary = await cssVar(page, "--el-color-primary");
|
||||
const radius = await cssVar(page, "--radius-surface");
|
||||
const pageBg = await cssVar(page, "--bg-page");
|
||||
|
||||
expect(primary.toLowerCase()).toBe("#0284c7");
|
||||
expect(elPrimary.toLowerCase()).toBe("#0284c7");
|
||||
expect(radius).toBe("16px");
|
||||
expect(pageBg.toLowerCase()).toBe("#f8fafc");
|
||||
|
||||
// Guard against drifting back to company-doc purple baseline.
|
||||
expect(primary.toLowerCase()).not.toBe("#5e6ad2");
|
||||
});
|
||||
|
||||
test("shell shows brand nav, breadcrumb, and padded content stage", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
await expectShellChrome(page);
|
||||
await expect(page.getByTestId("nav-home")).toBeVisible();
|
||||
await expect(page.getByTestId("nav-datasources")).toBeVisible();
|
||||
await expect(page.getByTestId("nav-queries")).toBeVisible();
|
||||
await expect(page.getByTestId("nav-mappings")).toBeVisible();
|
||||
await expect(page.getByTestId("nav-alarms")).toBeVisible();
|
||||
await expect(page.getByTestId("health-success")).toBeVisible();
|
||||
|
||||
await expect(page).toHaveScreenshot("shell-home.png", shotOpts);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("UI smoke — list page layout", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.setViewportSize(DESKTOP);
|
||||
await signedInAdmin(page);
|
||||
});
|
||||
|
||||
test("datasource list uses single card, 32px gutters, and status tags", async ({ page }) => {
|
||||
await mockDatasourceList(page);
|
||||
await page.goto("/#/datasources");
|
||||
await expectShellChrome(page);
|
||||
await expectListPageLayout(page, "datasource-list");
|
||||
await expect(page.getByTestId("datasource-list-toolbar")).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "新建" })).toBeVisible();
|
||||
await expect(page.getByTestId("datasource-table")).toBeVisible();
|
||||
await expect(page.getByTestId("datasource-pagination")).toBeVisible();
|
||||
await expect(page.locator(".el-tag").first()).toBeVisible();
|
||||
|
||||
await expect(page.getByTestId("datasource-list")).toHaveScreenshot("list-datasources-card.png", shotOpts);
|
||||
});
|
||||
|
||||
test("query list uses the same list skeleton", async ({ page }) => {
|
||||
await mockQueryList(page);
|
||||
await page.goto("/#/queries");
|
||||
await expectListPageLayout(page, "query-list");
|
||||
await expect(page.getByTestId("query-table")).toBeVisible();
|
||||
await expect(page.getByTestId("query-pagination")).toBeVisible();
|
||||
await expect(page.getByTestId("row-status")).toBeVisible();
|
||||
});
|
||||
|
||||
test("mapping list uses the same list skeleton", async ({ page }) => {
|
||||
await mockMappingList(page);
|
||||
await page.goto("/#/mappings");
|
||||
await expectListPageLayout(page, "mapping-list");
|
||||
await expect(page.getByTestId("mapping-table")).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "新建" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("alarm list uses the same list skeleton", async ({ page }) => {
|
||||
await mockAlarmList(page);
|
||||
await page.goto("/#/alarms");
|
||||
await expectListPageLayout(page, "alarm-list");
|
||||
await expect(page.getByTestId("alarm-table")).toBeVisible();
|
||||
await expect(page.getByTestId("alarm-pagination")).toBeVisible();
|
||||
await expect(page.getByTestId("alarm-status")).toBeVisible();
|
||||
|
||||
await expect(page.getByTestId("alarm-list")).toHaveScreenshot("list-alarms-card.png", shotOpts);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("UI smoke — form page layout", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.setViewportSize(DESKTOP);
|
||||
await signedInAdmin(page);
|
||||
});
|
||||
|
||||
test("datasource create form keeps footer outside the scroll body", async ({ page }) => {
|
||||
await page.goto("/#/datasources/new");
|
||||
await expectFormPageLayout(page, {
|
||||
pageTestId: "datasource-edit",
|
||||
footerTestId: "datasource-footer",
|
||||
bodyTestId: "datasource-scroll",
|
||||
});
|
||||
await expect(page.getByTestId("footer-back")).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "测试连接" })).toBeVisible();
|
||||
|
||||
await expect(page.getByTestId("datasource-edit")).toHaveScreenshot("form-datasource-create.png", shotOpts);
|
||||
});
|
||||
|
||||
test("query create form uses form shell and centered footer", async ({ page }) => {
|
||||
await mockQueryList(page);
|
||||
await page.goto("/#/queries/new");
|
||||
await expectFormPageLayout(page, {
|
||||
pageTestId: "query-edit",
|
||||
footerTestId: "query-footer",
|
||||
bodyTestId: "query-scroll",
|
||||
});
|
||||
await expect(page.getByTestId("footer-back")).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("UI smoke — navigation routes", () => {
|
||||
test("admin can open every primary module without a blank main", async ({ page }) => {
|
||||
await page.setViewportSize(DESKTOP);
|
||||
await signedInAdmin(page);
|
||||
await mockHealth(page);
|
||||
await mockDatasourceList(page);
|
||||
await mockQueryList(page);
|
||||
await mockMappingList(page);
|
||||
await mockAlarmList(page);
|
||||
|
||||
const stops: { path: string; marker: string }[] = [
|
||||
{ path: "/", marker: "home-page" },
|
||||
{ path: "/#/datasources", marker: "datasource-list" },
|
||||
{ path: "/#/queries", marker: "query-list" },
|
||||
{ path: "/#/mappings", marker: "mapping-list" },
|
||||
{ path: "/#/alarms", marker: "alarm-list" },
|
||||
];
|
||||
|
||||
for (const stop of stops) {
|
||||
await page.goto(stop.path);
|
||||
await expect(page.getByTestId(stop.marker)).toBeVisible();
|
||||
await expect(page.getByTestId("side-nav")).toBeVisible();
|
||||
await expect(page.getByTestId("breadcrumb")).toBeVisible();
|
||||
}
|
||||
});
|
||||
});
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
@@ -27,6 +27,7 @@
|
||||
"welcome": "Signed in: {name}"
|
||||
},
|
||||
"health": {
|
||||
"cardTitle": "Service health",
|
||||
"loading": "Checking health",
|
||||
"success": "Health check succeeded",
|
||||
"failure": "Health check failed",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"welcome": "เข้าสู่ระบบแล้ว: {name}"
|
||||
},
|
||||
"health": {
|
||||
"cardTitle": "สุขภาพบริการ",
|
||||
"loading": "กำลังตรวจสอบสถานะ",
|
||||
"success": "ตรวจสอบสถานะสำเร็จ",
|
||||
"failure": "ตรวจสอบสถานะล้มเหลว",
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
"welcome": "已登录:{name}"
|
||||
},
|
||||
"health": {
|
||||
"cardTitle": "服务健康",
|
||||
"loading": "健康检查加载中",
|
||||
"success": "健康检查成功",
|
||||
"failure": "健康检查失败",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"welcome": "已登入:{name}"
|
||||
},
|
||||
"health": {
|
||||
"cardTitle": "服務健康",
|
||||
"loading": "健康檢查載入中",
|
||||
"success": "健康檢查成功",
|
||||
"failure": "健康檢查失敗",
|
||||
|
||||
@@ -61,7 +61,7 @@ const crumbs = computed(() => {
|
||||
});
|
||||
|
||||
const linkClass =
|
||||
"block rounded-md px-2.5 py-[7px] text-[var(--text-secondary)] no-underline hover:text-[var(--color-primary)]";
|
||||
"block rounded-lg px-2.5 py-2 text-[var(--text-secondary)] no-underline transition-colors hover:bg-[var(--bg-surface-soft)] hover:text-[var(--color-primary)]";
|
||||
const activeClass =
|
||||
"!bg-[var(--color-primary-soft)] !font-semibold !text-[var(--color-primary)]";
|
||||
</script>
|
||||
@@ -71,12 +71,14 @@ const activeClass =
|
||||
class="flex h-screen bg-[var(--bg-surface-soft)] text-[length:var(--font-size-base)] text-[var(--text-primary)]"
|
||||
>
|
||||
<aside
|
||||
class="flex w-48 shrink-0 flex-col border-r border-[var(--border-subtle)] bg-white px-2.5 py-3.5"
|
||||
class="flex w-52 shrink-0 flex-col border-r border-[var(--border-default)] bg-[var(--bg-surface)] px-3 py-4"
|
||||
data-testid="side-nav"
|
||||
>
|
||||
<div class="mb-3.5 flex items-center gap-2 px-2.5" data-testid="side-brand">
|
||||
<div class="mb-4 flex items-center gap-2.5 px-2.5" data-testid="side-brand">
|
||||
<img :src="logoUrl" alt="" class="h-7 w-7 shrink-0 object-contain" data-testid="side-logo" />
|
||||
<span class="text-base font-bold tracking-wide">{{ t("appName") }}</span>
|
||||
<span class="text-[length:var(--el-font-size-large)] font-semibold tracking-wide">{{
|
||||
t("appName")
|
||||
}}</span>
|
||||
</div>
|
||||
<nav class="flex flex-1 flex-col gap-1">
|
||||
<RouterLink to="/" :class="linkClass" :exact-active-class="activeClass" data-testid="nav-home">
|
||||
@@ -109,7 +111,7 @@ const activeClass =
|
||||
class="mt-3 border-t border-[var(--border-subtle)] px-2.5 pt-3"
|
||||
data-testid="side-user"
|
||||
>
|
||||
<div class="mb-2 text-[13px] text-[var(--text-secondary)]" data-testid="shell-welcome">
|
||||
<div class="mb-2 text-[length:var(--el-font-size-small)] text-[var(--text-secondary)]" data-testid="shell-welcome">
|
||||
{{ t("shell.welcome", { name: displayName }) }}
|
||||
</div>
|
||||
<ElButton class="w-full" data-testid="logout" @click="emit('logout')">
|
||||
@@ -119,7 +121,7 @@ const activeClass =
|
||||
</aside>
|
||||
<div class="flex min-w-0 flex-1 flex-col">
|
||||
<header
|
||||
class="flex h-12 shrink-0 items-center border-b border-[var(--border-subtle)] bg-white px-5"
|
||||
class="flex h-12 shrink-0 items-center border-b border-[var(--border-default)] bg-[var(--bg-surface)] px-8"
|
||||
>
|
||||
<ElBreadcrumb separator="/" data-testid="breadcrumb">
|
||||
<ElBreadcrumbItem v-for="item in crumbs" :key="item.label" :to="item.to">
|
||||
@@ -127,7 +129,7 @@ const activeClass =
|
||||
</ElBreadcrumbItem>
|
||||
</ElBreadcrumb>
|
||||
</header>
|
||||
<main class="min-h-0 flex-1 overflow-hidden">
|
||||
<main class="min-h-0 flex-1 overflow-hidden bg-[var(--bg-page)] p-4">
|
||||
<RouterView />
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -33,13 +33,16 @@ onMounted(loadHealth);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="h-full overflow-auto p-8">
|
||||
<ElCard>
|
||||
<div class="wm-home-page" data-testid="home-page">
|
||||
<ElCard shadow="never">
|
||||
<template #header>
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<span>{{ t("appName") }}</span>
|
||||
<span>{{ t("health.cardTitle") }}</span>
|
||||
<span data-testid="health-tag">
|
||||
<ElTag :type="state === 'loading' ? 'info' : state === 'success' ? 'success' : 'danger'">
|
||||
<ElTag
|
||||
:type="state === 'loading' ? 'info' : state === 'success' ? 'success' : 'danger'"
|
||||
effect="light"
|
||||
>
|
||||
{{
|
||||
state === "loading"
|
||||
? t("health.loading")
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
type FormInstance,
|
||||
type FormRules,
|
||||
} from "element-plus";
|
||||
import FormPageShell from "../shared/components/FormPageShell.vue";
|
||||
import { useAuthStore } from "../stores/auth";
|
||||
import {
|
||||
ALARM_PERMISSION,
|
||||
@@ -350,8 +351,7 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full min-h-0 flex-col" data-testid="alarm-detail">
|
||||
<div class="min-h-0 flex-1 overflow-y-auto p-5" data-testid="alarm-scroll">
|
||||
<FormPageShell test-id="alarm-detail" body-test-id="alarm-scroll" footer-test-id="alarm-footer">
|
||||
<p v-if="phase === 'loading'" data-testid="alarm-detail-loading">{{ t("alarm.detail.loading") }}</p>
|
||||
<ElAlert
|
||||
v-else-if="phase === 'missing'"
|
||||
@@ -390,7 +390,7 @@ onMounted(() => {
|
||||
:closable="false"
|
||||
/>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4" data-testid="alarm-summary">
|
||||
<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>
|
||||
@@ -478,7 +478,7 @@ onMounted(() => {
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4" data-testid="alarm-occurrences">
|
||||
<section class="wm-form-section" data-testid="alarm-occurrences">
|
||||
<h3 class="mb-1 text-[14.5px] font-semibold">{{ t("alarm.detail.occurrences") }}</h3>
|
||||
<p class="mb-2.5 text-[var(--text-muted)]">{{ t("alarm.detail.occurrencesHint") }}</p>
|
||||
<ElTable :data="occurrences" row-key="id" :empty-text="t('alarm.detail.occurrencesEmpty')">
|
||||
@@ -493,7 +493,7 @@ onMounted(() => {
|
||||
</ElTable>
|
||||
</section>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4" data-testid="alarm-evidence">
|
||||
<section class="wm-form-section" data-testid="alarm-evidence">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("alarm.detail.evidence") }}</h3>
|
||||
<h4 class="mb-2 font-semibold">{{ t("alarm.detail.revisionEvidence") }}</h4>
|
||||
<ElTable
|
||||
@@ -525,7 +525,7 @@ onMounted(() => {
|
||||
</ElTable>
|
||||
</section>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4" data-testid="alarm-history">
|
||||
<section class="wm-form-section" data-testid="alarm-history">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("alarm.detail.history") }}</h3>
|
||||
<ElTable :data="history" row-key="id" :empty-text="t('alarm.detail.historyEmpty')">
|
||||
<ElTableColumn prop="seq" :label="t('alarm.historyCols.seq')" width="72" />
|
||||
@@ -554,12 +554,8 @@ onMounted(() => {
|
||||
</ElTable>
|
||||
</section>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<footer
|
||||
data-testid="alarm-footer"
|
||||
class="flex shrink-0 flex-wrap items-center justify-center gap-2 border-t border-[var(--border-subtle)] bg-white px-5 py-3"
|
||||
>
|
||||
<template #footer>
|
||||
<ElButton data-testid="footer-back" :disabled="commandBusy" @click="backToList">
|
||||
{{ t("alarm.actions.back") }}
|
||||
</ElButton>
|
||||
@@ -591,7 +587,8 @@ onMounted(() => {
|
||||
{{ t("alarm.actions.close") }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</footer>
|
||||
</template>
|
||||
</FormPageShell>
|
||||
|
||||
<ElDialog
|
||||
v-model="progressOpen"
|
||||
@@ -702,5 +699,4 @@ onMounted(() => {
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
ElTag,
|
||||
vLoading,
|
||||
} from "element-plus";
|
||||
import ListPageShell from "../shared/components/ListPageShell.vue";
|
||||
import { LIST_DEFAULT_PAGE_SIZE, LIST_PAGE_SIZES, actionsColumnWidth } from "../tableLayout";
|
||||
import { useAuthStore } from "../stores/auth";
|
||||
import { ALARM_PERMISSION, alarmListEmptyKind, hasAlarmSubject } from "./actions";
|
||||
@@ -185,119 +186,106 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full min-h-0 flex-col overflow-hidden" data-testid="alarm-list">
|
||||
<div class="flex shrink-0 flex-wrap items-center gap-2 px-5 pb-3 pt-5" data-testid="alarm-list-toolbar">
|
||||
<div class="w-[140px]" data-testid="alarm-filter-module">
|
||||
<ElInput v-model="draft.moduleKey" clearable :placeholder="t('alarm.list.filterModule')" />
|
||||
<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>
|
||||
<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"
|
||||
style="width: 100%"
|
||||
type="datetime"
|
||||
:placeholder="t('alarm.list.filterFrom')"
|
||||
/>
|
||||
</div>
|
||||
<div class="w-[12.5rem]" data-testid="alarm-filter-to">
|
||||
<ElDatePicker
|
||||
v-model="draft.to"
|
||||
style="width: 100%"
|
||||
type="datetime"
|
||||
: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>
|
||||
<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>
|
||||
</div>
|
||||
<div class="w-[180px]" data-testid="alarm-filter-scenario">
|
||||
<ElInput v-model="draft.scenarioName" clearable :placeholder="t('alarm.list.filterScenario')" />
|
||||
</div>
|
||||
<div class="w-[220px]" data-testid="alarm-filter-object">
|
||||
<ElInput v-model="draft.objectId" clearable :placeholder="t('alarm.list.filterObject')" />
|
||||
</div>
|
||||
<div class="w-[200px]" data-testid="alarm-filter-from">
|
||||
<ElDatePicker
|
||||
v-model="draft.from"
|
||||
style="width: 100%"
|
||||
type="datetime"
|
||||
:placeholder="t('alarm.list.filterFrom')"
|
||||
/>
|
||||
</div>
|
||||
<div class="w-[200px]" data-testid="alarm-filter-to">
|
||||
<ElDatePicker
|
||||
v-model="draft.to"
|
||||
style="width: 100%"
|
||||
type="datetime"
|
||||
:placeholder="t('alarm.list.filterTo')"
|
||||
/>
|
||||
</div>
|
||||
<div class="w-[120px]" 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>
|
||||
<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>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="flex min-h-0 flex-1 flex-col px-5">
|
||||
<ElAlert
|
||||
v-if="filterIssue"
|
||||
class="mb-3"
|
||||
type="warning"
|
||||
data-testid="alarm-filter-issue"
|
||||
:title="filterIssue === 'object' ? t('alarm.list.objectInvalid') : t('alarm.list.timeOrder')"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<ElAlert
|
||||
v-if="phase === 'error'"
|
||||
type="error"
|
||||
data-testid="alarm-load-error"
|
||||
:title="loadError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div v-if="phase === 'error'" class="mt-3">
|
||||
<ElButton data-testid="alarm-retry" @click="load">{{ t("alarm.list.retry") }}</ElButton>
|
||||
<ElAlert
|
||||
v-if="filterIssue"
|
||||
class="mx-8 mt-4 mb-0"
|
||||
type="warning"
|
||||
data-testid="alarm-filter-issue"
|
||||
:title="filterIssue === 'object' ? t('alarm.list.objectInvalid') : t('alarm.list.timeOrder')"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<ElAlert
|
||||
v-if="phase === 'error'"
|
||||
class="m-4 mx-8"
|
||||
type="error"
|
||||
data-testid="alarm-load-error"
|
||||
:title="loadError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div v-if="phase === 'error'" class="mx-8 mb-4">
|
||||
<ElButton data-testid="alarm-retry" @click="load">{{ t("alarm.list.retry") }}</ElButton>
|
||||
</div>
|
||||
<div v-else-if="phase === 'forbidden'" data-testid="alarm-forbidden" class="wm-list-empty">
|
||||
<div>
|
||||
<h3 class="wm-list-empty__title">{{ t("alarm.list.forbidden") }}</h3>
|
||||
<p class="wm-list-empty__hint">{{ loadError }}</p>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="phase === 'forbidden'"
|
||||
data-testid="alarm-forbidden"
|
||||
class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
</div>
|
||||
<div v-else-if="emptyKind === 'no-scope'" data-testid="alarm-no-scope" class="wm-list-empty">
|
||||
<div>
|
||||
<h3 class="wm-list-empty__title">{{ t("alarm.list.noScope") }}</h3>
|
||||
<p class="wm-list-empty__hint">{{ t("alarm.list.noScopeHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="emptyKind === 'empty'" data-testid="alarm-empty" class="wm-list-empty">
|
||||
<div>
|
||||
<h3 class="wm-list-empty__title">{{ t("alarm.list.empty") }}</h3>
|
||||
<p class="wm-list-empty__hint">{{ t("alarm.list.emptyHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="emptyKind === 'no-match'" data-testid="alarm-no-match" class="wm-list-empty">
|
||||
<div>
|
||||
<h3 class="wm-list-empty__title">{{ t("alarm.list.noMatch") }}</h3>
|
||||
<p class="wm-list-empty__hint">{{ t("alarm.list.noMatchHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="showTable" class="min-h-0 flex-1" data-testid="alarm-table-wrap">
|
||||
<ElTable
|
||||
v-loading="phase === 'loading'"
|
||||
class="wm-admin-table"
|
||||
height="100%"
|
||||
:data="items"
|
||||
row-key="id"
|
||||
data-testid="alarm-table"
|
||||
:default-sort="{ prop: 'last_occurred_at', order: 'descending' }"
|
||||
@sort-change="onSortChange"
|
||||
>
|
||||
<div>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("alarm.list.forbidden") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ loadError }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="emptyKind === 'no-scope'"
|
||||
data-testid="alarm-no-scope"
|
||||
class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<div>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("alarm.list.noScope") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("alarm.list.noScopeHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="emptyKind === 'empty'"
|
||||
data-testid="alarm-empty"
|
||||
class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<div>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("alarm.list.empty") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("alarm.list.emptyHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="emptyKind === 'no-match'"
|
||||
data-testid="alarm-no-match"
|
||||
class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<div>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("alarm.list.noMatch") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("alarm.list.noMatchHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="showTable" class="min-h-0 flex-1" data-testid="alarm-table-wrap">
|
||||
<ElTable
|
||||
v-loading="phase === 'loading'"
|
||||
height="100%"
|
||||
:data="items"
|
||||
row-key="id"
|
||||
data-testid="alarm-table"
|
||||
:default-sort="{ prop: 'last_occurred_at', order: 'descending' }"
|
||||
@sort-change="onSortChange"
|
||||
>
|
||||
<ElTableColumn
|
||||
prop="module_key"
|
||||
:label="t('alarm.columns.module')"
|
||||
@@ -338,25 +326,22 @@ onMounted(() => {
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
</ElTable>
|
||||
</div>
|
||||
|
||||
<footer
|
||||
v-if="showPager"
|
||||
data-testid="alarm-pagination"
|
||||
class="flex shrink-0 items-center justify-end border-t border-[var(--border-subtle)] bg-white px-5 py-3"
|
||||
>
|
||||
<ElPagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[...LIST_PAGE_SIZES]"
|
||||
:current-page="page"
|
||||
@current-change="onPageChange"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</footer>
|
||||
</div>
|
||||
<template v-if="showPager" #pagination>
|
||||
<div data-testid="alarm-pagination">
|
||||
<ElPagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[...LIST_PAGE_SIZES]"
|
||||
:current-page="page"
|
||||
@current-change="onPageChange"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</ListPageShell>
|
||||
</template>
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
type FormRules,
|
||||
} from "element-plus";
|
||||
import { BusinessError } from "@watchman/api";
|
||||
import FormPageShell from "../shared/components/FormPageShell.vue";
|
||||
import {
|
||||
createDatasource,
|
||||
disableDatasource,
|
||||
@@ -320,8 +321,11 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full min-h-0 flex-col">
|
||||
<div class="min-h-0 flex-1 overflow-y-auto p-5" data-testid="datasource-scroll">
|
||||
<FormPageShell
|
||||
test-id="datasource-edit"
|
||||
body-test-id="datasource-scroll"
|
||||
footer-test-id="datasource-footer"
|
||||
>
|
||||
<ElAlert
|
||||
v-if="loadError"
|
||||
type="error"
|
||||
@@ -358,7 +362,7 @@ onMounted(async () => {
|
||||
data-testid="datasource-form"
|
||||
@submit.prevent
|
||||
>
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("datasource.form.connection") }}</h3>
|
||||
<div class="grid max-w-3xl grid-cols-1 gap-x-6 sm:grid-cols-2">
|
||||
<ElFormItem :label="t('datasource.form.name')" prop="name" data-testid="field-name">
|
||||
@@ -419,7 +423,7 @@ onMounted(async () => {
|
||||
|
||||
<section
|
||||
v-if="!isCreate"
|
||||
class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4"
|
||||
class="wm-form-section"
|
||||
data-testid="datasource-circuit"
|
||||
>
|
||||
<h3 class="mb-1 text-[14.5px] font-semibold">{{ t("datasource.circuit.title") }}</h3>
|
||||
@@ -478,7 +482,7 @@ onMounted(async () => {
|
||||
</section>
|
||||
</ElForm>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("datasource.test.title") }}</h3>
|
||||
<ElAlert
|
||||
v-if="testView.state === 'running'"
|
||||
@@ -543,7 +547,7 @@ onMounted(async () => {
|
||||
|
||||
<section
|
||||
v-if="!isCreate"
|
||||
class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4"
|
||||
class="wm-form-section"
|
||||
data-testid="datasource-references"
|
||||
>
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("datasource.refs.title") }}</h3>
|
||||
@@ -566,12 +570,8 @@ onMounted(async () => {
|
||||
</p>
|
||||
</section>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<footer
|
||||
data-testid="datasource-footer"
|
||||
class="flex shrink-0 items-center justify-center gap-2 border-t border-[var(--border-subtle)] bg-white px-5 py-3"
|
||||
>
|
||||
<template #footer>
|
||||
<ElButton
|
||||
v-if="loaded && !loadError"
|
||||
type="primary"
|
||||
@@ -601,6 +601,6 @@ onMounted(async () => {
|
||||
</ElButton>
|
||||
</template>
|
||||
<ElButton data-testid="footer-back" @click="backToList">{{ t("datasource.actions.backToList") }}</ElButton>
|
||||
</footer>
|
||||
</div>
|
||||
</template>
|
||||
</FormPageShell>
|
||||
</template>
|
||||
@@ -18,8 +18,10 @@ import {
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
vLoading,
|
||||
} from "element-plus";
|
||||
import ListPageShell from "../shared/components/ListPageShell.vue";
|
||||
import { LIST_DEFAULT_PAGE_SIZE, LIST_PAGE_SIZES, actionsColumnWidth } from "../tableLayout";
|
||||
import { disableDatasource, enableDatasource, listDatasources } from "./client";
|
||||
import { describeError } from "./errors";
|
||||
@@ -218,203 +220,191 @@ onMounted(load);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- Page itself does not scroll: toolbar + table body + pagination footer. -->
|
||||
<div class="flex h-full min-h-0 flex-col overflow-hidden" data-testid="datasource-list">
|
||||
<div
|
||||
class="flex shrink-0 flex-wrap items-center gap-2 px-5 pb-3 pt-5"
|
||||
data-testid="datasource-list-toolbar"
|
||||
>
|
||||
<div class="w-[200px]" data-testid="datasource-filter-name">
|
||||
<ElInput v-model="draft.name" clearable :placeholder="t('datasource.list.filterName')" />
|
||||
</div>
|
||||
<div class="w-[160px]" data-testid="datasource-filter-engine">
|
||||
<ElSelect
|
||||
v-model="draft.engine"
|
||||
clearable
|
||||
class="w-full"
|
||||
:placeholder="t('datasource.list.filterEngine')"
|
||||
>
|
||||
<ElOption label="PostgreSQL" value="postgresql" />
|
||||
<ElOption label="MySQL" value="mysql" />
|
||||
<ElOption label="SQL Server" value="sqlserver" />
|
||||
</ElSelect>
|
||||
</div>
|
||||
<div class="w-[140px]" data-testid="datasource-filter-status">
|
||||
<ElSelect
|
||||
v-model="draft.status"
|
||||
clearable
|
||||
class="w-full"
|
||||
:placeholder="t('datasource.list.filterStatus')"
|
||||
>
|
||||
<ElOption :label="t('datasource.status.enabled')" value="enabled" />
|
||||
<ElOption :label="t('datasource.status.disabled')" value="disabled" />
|
||||
</ElSelect>
|
||||
</div>
|
||||
<ElButton type="primary" data-testid="datasource-filter-search" @click="applyFilters">
|
||||
{{ t("datasource.list.filterSearch") }}
|
||||
</ElButton>
|
||||
<ElButton data-testid="datasource-filter-reset" @click="resetFilters">
|
||||
{{ t("datasource.list.filterReset") }}
|
||||
</ElButton>
|
||||
<div class="ml-auto">
|
||||
<ElButton type="primary" data-testid="datasource-create" @click="openCreate">
|
||||
{{ t("datasource.list.create") }}
|
||||
<ListPageShell test-id="datasource-list">
|
||||
<template #filters>
|
||||
<div data-testid="datasource-list-toolbar" class="contents">
|
||||
<div class="w-[16rem]" data-testid="datasource-filter-name">
|
||||
<ElInput v-model="draft.name" clearable :placeholder="t('datasource.list.filterName')" />
|
||||
</div>
|
||||
<div class="w-[11rem]" data-testid="datasource-filter-engine">
|
||||
<ElSelect
|
||||
v-model="draft.engine"
|
||||
clearable
|
||||
class="w-full"
|
||||
:placeholder="t('datasource.list.filterEngine')"
|
||||
>
|
||||
<ElOption label="PostgreSQL" value="postgresql" />
|
||||
<ElOption label="MySQL" value="mysql" />
|
||||
<ElOption label="SQL Server" value="sqlserver" />
|
||||
</ElSelect>
|
||||
</div>
|
||||
<div class="w-[9rem]" data-testid="datasource-filter-status">
|
||||
<ElSelect
|
||||
v-model="draft.status"
|
||||
clearable
|
||||
class="w-full"
|
||||
:placeholder="t('datasource.list.filterStatus')"
|
||||
>
|
||||
<ElOption :label="t('datasource.status.enabled')" value="enabled" />
|
||||
<ElOption :label="t('datasource.status.disabled')" value="disabled" />
|
||||
</ElSelect>
|
||||
</div>
|
||||
<ElButton type="primary" data-testid="datasource-filter-search" @click="applyFilters">
|
||||
{{ t("datasource.list.filterSearch") }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex min-h-0 flex-1 flex-col px-5">
|
||||
<ElAlert
|
||||
v-if="loadError"
|
||||
type="error"
|
||||
data-testid="datasource-load-error"
|
||||
:title="loadError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && !hasAppliedFilters"
|
||||
data-testid="datasource-empty"
|
||||
class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<div>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("datasource.list.empty") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("datasource.list.emptyHint") }}</p>
|
||||
<ElButton data-testid="datasource-filter-reset" @click="resetFilters">
|
||||
{{ t("datasource.list.filterReset") }}
|
||||
</ElButton>
|
||||
<div class="ml-auto">
|
||||
<ElButton type="primary" data-testid="datasource-create" @click="openCreate">
|
||||
{{ t("datasource.list.create") }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && hasAppliedFilters"
|
||||
data-testid="datasource-filter-empty"
|
||||
class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<div>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("datasource.list.filterEmpty") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("datasource.list.filterEmptyHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="min-h-0 flex-1" data-testid="datasource-table-wrap">
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
height="100%"
|
||||
:data="items"
|
||||
row-key="id"
|
||||
data-testid="datasource-table"
|
||||
:row-class-name="rowClass"
|
||||
@sort-change="onSortChange"
|
||||
>
|
||||
<ElTableColumn prop="name" :label="t('datasource.columns.name')" min-width="140" sortable="custom" />
|
||||
<ElTableColumn prop="engine" :label="t('datasource.columns.engine')" min-width="110" sortable="custom">
|
||||
<template #default="{ row }">{{ engineLabel(row.engine) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="host" :label="t('datasource.columns.host')" min-width="170" sortable="custom" />
|
||||
<ElTableColumn prop="port" :label="t('datasource.columns.port')" width="90" sortable="custom" />
|
||||
<ElTableColumn
|
||||
prop="database_name"
|
||||
:label="t('datasource.columns.database')"
|
||||
min-width="130"
|
||||
sortable="custom"
|
||||
/>
|
||||
<ElTableColumn
|
||||
prop="username"
|
||||
:label="t('datasource.columns.username')"
|
||||
min-width="130"
|
||||
sortable="custom"
|
||||
/>
|
||||
<ElTableColumn prop="status" :label="t('datasource.columns.status')" min-width="150" sortable="custom">
|
||||
<template #default="{ row }">
|
||||
<span class="inline-flex items-center gap-1.5">
|
||||
<span
|
||||
class="h-[7px] w-[7px] rounded-full"
|
||||
:class="row.enabled ? 'bg-[#1a7f37]' : 'bg-[var(--text-muted)]'"
|
||||
/>
|
||||
{{ row.enabled ? t("datasource.status.enabled") : t("datasource.status.disabled") }}
|
||||
<span
|
||||
v-if="row.circuit_state === 'open'"
|
||||
class="text-xs text-[#cf222e]"
|
||||
data-testid="row-circuit-open"
|
||||
>
|
||||
{{ t("datasource.status.circuitOpen") }}
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="last_test_at"
|
||||
:label="t('datasource.columns.lastTest')"
|
||||
min-width="190"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span
|
||||
:class="
|
||||
row.last_test_category === 'success'
|
||||
? 'text-[#1a7f37]'
|
||||
: row.last_test_category
|
||||
? 'text-[#cf222e]'
|
||||
: 'text-[var(--text-muted)]'
|
||||
"
|
||||
>
|
||||
{{ lastTestText(row) }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
:label="t('datasource.columns.actions')"
|
||||
:width="actionsWidth"
|
||||
align="right"
|
||||
fixed="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="whitespace-nowrap" :data-testid="`datasource-row-${row.id}`">
|
||||
<ElButton link type="primary" data-testid="row-edit" @click="openDetail(row)">
|
||||
{{ t("datasource.actions.edit") }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
data-testid="row-test"
|
||||
:disabled="testBlocked(row)"
|
||||
:title="testTitle(row)"
|
||||
@click="openTest(row)"
|
||||
>
|
||||
{{ t("datasource.actions.test") }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="row.enabled"
|
||||
link
|
||||
type="danger"
|
||||
data-testid="row-disable"
|
||||
@click="disable(row)"
|
||||
>
|
||||
{{ t("datasource.actions.disable") }}
|
||||
</ElButton>
|
||||
<ElButton v-else link type="success" data-testid="row-enable" @click="enable(row)">
|
||||
{{ t("datasource.actions.enable") }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</template>
|
||||
|
||||
<ElAlert
|
||||
v-if="loadError"
|
||||
class="m-4 mx-8"
|
||||
type="error"
|
||||
data-testid="datasource-load-error"
|
||||
:title="loadError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div v-else-if="!loading && total === 0 && !hasAppliedFilters" data-testid="datasource-empty" class="wm-list-empty">
|
||||
<div>
|
||||
<h3 class="wm-list-empty__title">{{ t("datasource.list.empty") }}</h3>
|
||||
<p class="wm-list-empty__hint">{{ t("datasource.list.emptyHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer
|
||||
v-if="!loadError && (loading || total > 0)"
|
||||
data-testid="datasource-pagination"
|
||||
class="flex shrink-0 items-center justify-end border-t border-[var(--border-subtle)] bg-white px-5 py-3"
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && hasAppliedFilters"
|
||||
data-testid="datasource-filter-empty"
|
||||
class="wm-list-empty"
|
||||
>
|
||||
<ElPagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[...LIST_PAGE_SIZES]"
|
||||
:current-page="page"
|
||||
@current-change="onPageChange"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</footer>
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="wm-list-empty__title">{{ t("datasource.list.filterEmpty") }}</h3>
|
||||
<p class="wm-list-empty__hint">{{ t("datasource.list.filterEmptyHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="min-h-0 flex-1" data-testid="datasource-table-wrap">
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
class="wm-admin-table"
|
||||
height="100%"
|
||||
:data="items"
|
||||
row-key="id"
|
||||
data-testid="datasource-table"
|
||||
:row-class-name="rowClass"
|
||||
@sort-change="onSortChange"
|
||||
>
|
||||
<ElTableColumn prop="name" :label="t('datasource.columns.name')" min-width="140" sortable="custom" />
|
||||
<ElTableColumn prop="engine" :label="t('datasource.columns.engine')" min-width="110" sortable="custom">
|
||||
<template #default="{ row }">{{ engineLabel(row.engine) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="host" :label="t('datasource.columns.host')" min-width="170" sortable="custom" />
|
||||
<ElTableColumn prop="port" :label="t('datasource.columns.port')" width="90" sortable="custom" />
|
||||
<ElTableColumn
|
||||
prop="database_name"
|
||||
:label="t('datasource.columns.database')"
|
||||
min-width="130"
|
||||
sortable="custom"
|
||||
/>
|
||||
<ElTableColumn
|
||||
prop="username"
|
||||
:label="t('datasource.columns.username')"
|
||||
min-width="130"
|
||||
sortable="custom"
|
||||
/>
|
||||
<ElTableColumn prop="status" :label="t('datasource.columns.status')" min-width="180" sortable="custom">
|
||||
<template #default="{ row }">
|
||||
<span class="inline-flex flex-wrap items-center gap-1.5">
|
||||
<ElTag :type="row.enabled ? 'success' : 'info'" effect="light">
|
||||
{{ row.enabled ? t("datasource.status.enabled") : t("datasource.status.disabled") }}
|
||||
</ElTag>
|
||||
<ElTag
|
||||
v-if="row.circuit_state === 'open'"
|
||||
type="danger"
|
||||
effect="light"
|
||||
data-testid="row-circuit-open"
|
||||
>
|
||||
{{ t("datasource.status.circuitOpen") }}
|
||||
</ElTag>
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="last_test_at"
|
||||
:label="t('datasource.columns.lastTest')"
|
||||
min-width="190"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<ElTag
|
||||
v-if="row.last_test_category"
|
||||
:type="row.last_test_category === 'success' ? 'success' : 'danger'"
|
||||
effect="light"
|
||||
>
|
||||
{{ lastTestText(row) }}
|
||||
</ElTag>
|
||||
<span v-else>{{ lastTestText(row) }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
:label="t('datasource.columns.actions')"
|
||||
:width="actionsWidth"
|
||||
align="right"
|
||||
fixed="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="whitespace-nowrap" :data-testid="`datasource-row-${row.id}`">
|
||||
<ElButton link type="primary" data-testid="row-edit" @click="openDetail(row)">
|
||||
{{ t("datasource.actions.edit") }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
data-testid="row-test"
|
||||
:disabled="testBlocked(row)"
|
||||
:title="testTitle(row)"
|
||||
@click="openTest(row)"
|
||||
>
|
||||
{{ t("datasource.actions.test") }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="row.enabled"
|
||||
link
|
||||
type="danger"
|
||||
data-testid="row-disable"
|
||||
@click="disable(row)"
|
||||
>
|
||||
{{ t("datasource.actions.disable") }}
|
||||
</ElButton>
|
||||
<ElButton v-else link type="success" data-testid="row-enable" @click="enable(row)">
|
||||
{{ t("datasource.actions.enable") }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
|
||||
<template v-if="!loadError && (loading || total > 0)" #pagination>
|
||||
<div data-testid="datasource-pagination">
|
||||
<ElPagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[...LIST_PAGE_SIZES]"
|
||||
:current-page="page"
|
||||
@current-change="onPageChange"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</ListPageShell>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { ElAlert, ElButton, ElCheckbox, ElDialog, ElInput, ElTable, ElTableColumn, ElTag } from "element-plus";
|
||||
import FormPageShell from "../shared/components/FormPageShell.vue";
|
||||
import { getQuery } from "../queries/client";
|
||||
import { buildPreviewParams, initialPreviewValues, specsFromSchema, type PreviewSpec } from "../queries/payload";
|
||||
import type { OutputType } from "../queries/types";
|
||||
@@ -218,12 +219,23 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="flex h-full min-h-0 flex-col">
|
||||
<main class="min-h-0 flex-1 overflow-auto p-8">
|
||||
<ElAlert :title="loadedVersion < 1 ? '还没有版本。字段来自查询输出,另存后成为 v1。' : `正在编辑 v${loadedVersion};当前生效 v${currentVersion}。保存会另存为新版本,历史版本不会修改。`" type="info" :closable="false" />
|
||||
<FormPageShell test-id="mapping-edit" footer-test-id="mapping-footer">
|
||||
<ElAlert
|
||||
class="mb-4"
|
||||
:title="
|
||||
loadedVersion < 1
|
||||
? '还没有版本。字段来自查询输出,另存后成为 v1。'
|
||||
: `正在编辑 v${loadedVersion};当前生效 v${currentVersion}。保存会另存为新版本,历史版本不会修改。`
|
||||
"
|
||||
type="info"
|
||||
:closable="false"
|
||||
/>
|
||||
|
||||
<h2 class="mb-2 mt-6 text-base font-semibold">字段映射</h2>
|
||||
<p class="mb-3 text-sm text-[var(--text-secondary)]">列来自当前查询输出。身份列和观测时间都可以不选;不选身份列时,多行结果只采用第一行。</p>
|
||||
<section class="wm-form-section">
|
||||
<h2 class="wm-form-section__title">字段映射</h2>
|
||||
<p class="wm-form-section__hint">
|
||||
列来自当前查询输出。身份列和观测时间都可以不选;不选身份列时,多行结果只采用第一行。
|
||||
</p>
|
||||
<ElTable :data="columns" row-key="source_column_name">
|
||||
<ElTableColumn prop="source_column_name" label="查询列" min-width="180" />
|
||||
<ElTableColumn label="类型" width="100">
|
||||
@@ -233,48 +245,82 @@ onMounted(async () => {
|
||||
<template #default="{ row }"><ElCheckbox v-model="row.is_identity" /></template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="观测时间" width="110" align="center">
|
||||
<template #default="{ row }"><ElCheckbox v-model="row.is_observation_time" :disabled="row.value_type !== 'datetime' && !row.is_observation_time" /></template>
|
||||
<template #default="{ row }">
|
||||
<ElCheckbox
|
||||
v-model="row.is_observation_time"
|
||||
:disabled="row.value_type !== 'datetime' && !row.is_observation_time"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="数值换算" min-width="240">
|
||||
<template #default="{ row }">
|
||||
<div v-if="row.value_type === 'number'" class="flex items-center gap-2">
|
||||
<span>×</span>
|
||||
<ElInput :model-value="row.numeric_multiply ?? ''" class="w-24" placeholder="乘数" @update:model-value="row.numeric_multiply = $event === '' ? null : String($event)" />
|
||||
<ElInput
|
||||
:model-value="row.numeric_multiply ?? ''"
|
||||
class="w-24"
|
||||
placeholder="乘数"
|
||||
@update:model-value="row.numeric_multiply = $event === '' ? null : String($event)"
|
||||
/>
|
||||
<span>+</span>
|
||||
<ElInput :model-value="row.numeric_offset ?? ''" class="w-24" placeholder="偏移" @update:model-value="row.numeric_offset = $event === '' ? null : String($event)" />
|
||||
<ElInput
|
||||
:model-value="row.numeric_offset ?? ''"
|
||||
class="w-24"
|
||||
placeholder="偏移"
|
||||
@update:model-value="row.numeric_offset = $event === '' ? null : String($event)"
|
||||
/>
|
||||
</div>
|
||||
<span v-else class="text-[var(--text-secondary)]">—</span>
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</section>
|
||||
|
||||
<h2 class="mb-2 mt-8 text-base font-semibold">判断规则</h2>
|
||||
<p class="mb-3 text-sm text-[var(--text-secondary)]">用条件描述什么情况算异常。并且:有一条正常则整体正常;或者:有一条异常则整体异常。缺值或无法比较时为未知。</p>
|
||||
<section class="wm-form-section">
|
||||
<h2 class="wm-form-section__title">判断规则</h2>
|
||||
<p class="wm-form-section__hint">
|
||||
用条件描述什么情况算异常。并且:有一条正常则整体正常;或者:有一条异常则整体异常。缺值或无法比较时为未知。
|
||||
</p>
|
||||
<RuleGroup :node="root" :columns="columns" :depth="1" root />
|
||||
<div class="mt-3 rounded-lg bg-[var(--fill-subtle,#f5f9fa)] px-4 py-3 text-sm">异常条件:{{ conditionSummary(root) }}</div>
|
||||
<div class="mt-3 rounded-lg bg-[var(--bg-surface-soft)] px-4 py-3">
|
||||
异常条件:{{ conditionSummary(root) }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<h2 class="mb-2 mt-8 text-base font-semibold">试算</h2>
|
||||
<section class="wm-form-section">
|
||||
<h2 class="wm-form-section__title">试算</h2>
|
||||
<div class="mb-3 flex gap-2">
|
||||
<ElButton :type="trialMode === 'query' ? 'primary' : 'default'" @click="trialMode = 'query'">用查询数据</ElButton>
|
||||
<ElButton :type="trialMode === 'manual' ? 'primary' : 'default'" @click="trialMode = 'manual'">手填数据</ElButton>
|
||||
<ElButton :type="trialMode === 'query' ? 'primary' : 'default'" @click="trialMode = 'query'">
|
||||
用查询数据
|
||||
</ElButton>
|
||||
<ElButton :type="trialMode === 'manual' ? 'primary' : 'default'" @click="trialMode = 'manual'">
|
||||
手填数据
|
||||
</ElButton>
|
||||
</div>
|
||||
<div v-if="trialMode === 'query'" class="mb-3">
|
||||
<p class="mb-3 text-sm text-[var(--text-secondary)]">使用查询「{{ queryName }}」在数据源里的结果。默认取前 10 条,可以改条数。留空的可选参数不会传给查询。</p>
|
||||
<p class="wm-form-section__hint">
|
||||
使用查询「{{ queryName }}」在数据源里的结果。默认取前 10 条,可以改条数。留空的可选参数不会传给查询。
|
||||
</p>
|
||||
<div class="mb-3 flex flex-wrap items-end gap-3">
|
||||
<div v-for="spec in paramSpecs" :key="spec.name" class="w-56">
|
||||
<div class="mb-1 text-sm">{{ spec.name }}<span v-if="spec.required" class="text-[var(--color-danger,#cf222e)]"> *</span></div>
|
||||
<div class="mb-1">
|
||||
{{ spec.name
|
||||
}}<span v-if="spec.required" class="text-[var(--el-color-danger)]"> *</span>
|
||||
</div>
|
||||
<ElInput v-model="paramValues[spec.name]" :placeholder="spec.required ? '必填' : '可留空'" />
|
||||
</div>
|
||||
<div class="w-28">
|
||||
<div class="mb-1 text-sm">条数</div>
|
||||
<div class="mb-1">条数</div>
|
||||
<ElInput v-model="rowLimit" type="number" data-testid="mapping-row-limit" />
|
||||
</div>
|
||||
<ElButton type="primary" data-testid="mapping-trial-query" @click="trialFromQuery">试算</ElButton>
|
||||
</div>
|
||||
<p v-if="paramError" class="text-sm text-[var(--color-danger,#cf222e)]">{{ paramError }}</p>
|
||||
<p v-if="paramError" class="text-[var(--el-color-danger)]">{{ paramError }}</p>
|
||||
</div>
|
||||
<div v-else class="mb-3">
|
||||
<p class="mb-3 text-sm text-[var(--text-secondary)]">手填查询输出行。样例里有能判异常、正常的行,也有缺值和没有时区的时间。空样例会得到空结果。</p>
|
||||
<p class="wm-form-section__hint">
|
||||
手填查询输出行。样例里有能判异常、正常的行,也有缺值和没有时区的时间。空样例会得到空结果。
|
||||
</p>
|
||||
<div class="mb-3 flex gap-2">
|
||||
<ElButton @click="fillRows">能判出结果的样例</ElButton>
|
||||
<ElButton @click="fillFailure">会失败的空样例</ElButton>
|
||||
@@ -282,13 +328,40 @@ onMounted(async () => {
|
||||
<ElInput v-model="rowsJson" type="textarea" :rows="8" data-testid="mapping-rows" />
|
||||
<ElButton class="mt-3" data-testid="mapping-trial" @click="trial">试算</ElButton>
|
||||
</div>
|
||||
<ElAlert v-if="saveError" class="mt-3" :title="saveError" type="error" data-testid="mapping-save-error" :closable="false" />
|
||||
<ElAlert v-if="skippedRows > 0" class="mt-3" :title="`未勾选身份列时采用第一行,其余 ${skippedRows} 行未采用。`" type="warning" data-testid="mapping-skip" :closable="false" />
|
||||
<ElAlert v-if="outcome" class="mt-3" data-testid="mapping-outcome" :title="conclusion(outcome)" :type="outcome === 'abnormal' || outcome === 'error' ? 'error' : outcome === 'normal' ? 'success' : 'warning'" :closable="false" />
|
||||
<ElAlert
|
||||
v-if="saveError"
|
||||
class="mt-3"
|
||||
:title="saveError"
|
||||
type="error"
|
||||
data-testid="mapping-save-error"
|
||||
:closable="false"
|
||||
/>
|
||||
<ElAlert
|
||||
v-if="skippedRows > 0"
|
||||
class="mt-3"
|
||||
:title="`未勾选身份列时采用第一行,其余 ${skippedRows} 行未采用。`"
|
||||
type="warning"
|
||||
data-testid="mapping-skip"
|
||||
:closable="false"
|
||||
/>
|
||||
<ElAlert
|
||||
v-if="outcome"
|
||||
class="mt-3"
|
||||
data-testid="mapping-outcome"
|
||||
:title="conclusion(outcome)"
|
||||
:type="
|
||||
outcome === 'abnormal' || outcome === 'error'
|
||||
? 'error'
|
||||
: outcome === 'normal'
|
||||
? 'success'
|
||||
: 'warning'
|
||||
"
|
||||
:closable="false"
|
||||
/>
|
||||
<ElTable v-if="trialTable.length" class="mt-3" :data="trialTable" data-testid="mapping-trial-table">
|
||||
<ElTableColumn type="index" label="#" width="58" />
|
||||
<ElTableColumn v-for="name in trialColumns" :key="name" :label="name" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ cellText(row[name]) }}</template>
|
||||
<ElTableColumn v-for="col in trialColumns" :key="col" :label="col" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ cellText(row[col]) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="结论" width="110" fixed="right">
|
||||
<template #default="{ row }">
|
||||
@@ -296,19 +369,38 @@ onMounted(async () => {
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</main>
|
||||
<footer class="flex shrink-0 justify-center gap-2 border-t p-3">
|
||||
</section>
|
||||
|
||||
<template #footer>
|
||||
<ElButton @click="router.push('/mappings')">返回列表</ElButton>
|
||||
<ElButton @click="switching = true">切换版本</ElButton>
|
||||
<ElButton type="primary" data-testid="mapping-save" @click="save">另存为新版本</ElButton>
|
||||
</footer>
|
||||
<ElDialog v-model="switching" title="切换版本" width="680px" align-center append-to-body :close-on-click-modal="false">
|
||||
<p class="mb-3 text-sm text-[var(--text-secondary)]">激活仅切换当前版本;以此编辑不会修改历史版本。</p>
|
||||
<div v-for="version in versions" :key="version" class="mb-2 flex items-center gap-3">
|
||||
<span class="w-16 font-mono">v{{ version }}</span>
|
||||
<ElButton link type="primary" @click="activateMappingVersion(id, version).then((data) => currentVersion = data.current_version_no)">激活</ElButton>
|
||||
<ElButton link type="primary" @click="load(version).then(() => switching = false)">以此编辑</ElButton>
|
||||
</div>
|
||||
</ElDialog>
|
||||
</section>
|
||||
</template>
|
||||
</FormPageShell>
|
||||
|
||||
<ElDialog
|
||||
v-model="switching"
|
||||
title="切换版本"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<p class="mb-3 text-[length:var(--el-font-size-small)] text-[var(--text-secondary)]">
|
||||
激活仅切换当前版本;以此编辑不会修改历史版本。
|
||||
</p>
|
||||
<div v-for="version in versions" :key="version" class="mb-2 flex items-center gap-3">
|
||||
<span class="w-16 font-mono">v{{ version }}</span>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
@click="
|
||||
activateMappingVersion(id, version).then((data) => (currentVersion = data.current_version_no))
|
||||
"
|
||||
>
|
||||
激活
|
||||
</ElButton>
|
||||
<ElButton link type="primary" @click="load(version).then(() => (switching = false))">以此编辑</ElButton>
|
||||
</div>
|
||||
</ElDialog>
|
||||
</template>
|
||||
@@ -1,14 +1,27 @@
|
||||
<script setup lang="ts">
|
||||
/** Mapping list and shared-version editor entrypoint; historical versions are opened read-only. */
|
||||
import { onMounted, ref } from "vue";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ElButton, ElDialog, ElInput, ElOption, ElSelect, ElTable, ElTableColumn } from "element-plus";
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElDialog,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
vLoading,
|
||||
} from "element-plus";
|
||||
import ListPageShell from "../shared/components/ListPageShell.vue";
|
||||
import { actionsColumnWidth } from "../tableLayout";
|
||||
import { versionLabel } from "../queries/format";
|
||||
import { createMapping, listMappings, type MappingSummary } from "./client";
|
||||
import { listQueries } from "../queries/client";
|
||||
|
||||
const name = ref("");
|
||||
const query = ref("");
|
||||
const applied = ref({ name: "", query: "" });
|
||||
const rows = ref<MappingSummary[]>([]);
|
||||
const router = useRouter();
|
||||
const createOpen = ref(false);
|
||||
@@ -16,27 +29,58 @@ const selectedQuery = ref("");
|
||||
const queries = ref<{ id: string; name: string }[]>([]);
|
||||
const createError = ref("");
|
||||
const loadError = ref("");
|
||||
const loading = ref(false);
|
||||
const actionsWidth = actionsColumnWidth(3);
|
||||
|
||||
const hasAppliedFilters = computed(
|
||||
() => applied.value.name.trim() !== "" || applied.value.query.trim() !== "",
|
||||
);
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
loadError.value = "";
|
||||
try {
|
||||
rows.value = (await listMappings({ name: name.value, query: query.value })).items;
|
||||
rows.value = (
|
||||
await listMappings({
|
||||
name: applied.value.name.trim() || undefined,
|
||||
query: applied.value.query.trim() || undefined,
|
||||
})
|
||||
).items;
|
||||
} catch {
|
||||
rows.value = [];
|
||||
loadError.value = "映射列表没有加载出来。";
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function applyFilters() {
|
||||
applied.value = { name: name.value, query: query.value };
|
||||
void load();
|
||||
}
|
||||
|
||||
function resetFilters() {
|
||||
name.value = "";
|
||||
query.value = "";
|
||||
applied.value = { name: "", query: "" };
|
||||
void load();
|
||||
}
|
||||
|
||||
async function openCreate() {
|
||||
createError.value = "";
|
||||
selectedQuery.value = "";
|
||||
createOpen.value = true;
|
||||
try {
|
||||
queries.value = (await listQueries({ page: 1, page_size: 100 })).items ?? [];
|
||||
if (queries.value.length === 0) createError.value = "还没有查询。请先到「查询」里新建一条,再回来建映射。";
|
||||
if (queries.value.length === 0) {
|
||||
createError.value = "还没有查询。请先到「查询」里新建一条,再回来建映射。";
|
||||
}
|
||||
} catch {
|
||||
queries.value = [];
|
||||
createError.value = "查询列表没有加载出来,请再点一次新建。";
|
||||
}
|
||||
}
|
||||
|
||||
async function create() {
|
||||
if (!selectedQuery.value) {
|
||||
createError.value = "请先选择一条查询。";
|
||||
@@ -51,44 +95,124 @@ async function create() {
|
||||
createError.value = "没有创建成功。请确认这条查询还能用,然后再试一次。";
|
||||
}
|
||||
}
|
||||
onMounted(load);
|
||||
|
||||
onMounted(() => {
|
||||
applyFilters();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="flex h-full flex-col p-8">
|
||||
<div class="mb-4 flex gap-2">
|
||||
<ElInput v-model="name" placeholder="名称" class="w-64" />
|
||||
<ElInput v-model="query" placeholder="查询" class="w-48" />
|
||||
<ElButton @click="load">查询</ElButton><ElButton @click="name = ''; query = ''; load()">重置</ElButton>
|
||||
<span class="flex-1" /><ElButton type="primary" @click="openCreate">新建</ElButton>
|
||||
<ListPageShell test-id="mapping-list">
|
||||
<template #filters>
|
||||
<div class="w-[16rem]">
|
||||
<ElInput v-model="name" clearable placeholder="名称" />
|
||||
</div>
|
||||
<div class="w-[12rem]">
|
||||
<ElInput v-model="query" clearable placeholder="查询" />
|
||||
</div>
|
||||
<ElButton type="primary" @click="applyFilters">查询</ElButton>
|
||||
<ElButton @click="resetFilters">重置</ElButton>
|
||||
<div class="ml-auto">
|
||||
<ElButton type="primary" @click="openCreate">新建</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<ElAlert
|
||||
v-if="loadError"
|
||||
class="m-4 mx-8"
|
||||
type="error"
|
||||
:title="loadError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div
|
||||
v-else-if="!loading && rows.length === 0 && !hasAppliedFilters"
|
||||
class="wm-list-empty"
|
||||
data-testid="mapping-empty"
|
||||
>
|
||||
<div>
|
||||
<h3 class="wm-list-empty__title">暂无映射</h3>
|
||||
<p class="wm-list-empty__hint">新建一条映射,关联已有查询后即可配置字段与规则。</p>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="loadError" class="mb-3 text-sm text-[var(--color-danger,#cf222e)]">{{ loadError }}</p>
|
||||
<ElTable :data="rows" row-key="id" class="min-h-0 flex-1" height="100%" empty-text="暂无映射" data-testid="mapping-table">
|
||||
<ElTableColumn prop="name" label="名称" min-width="220" show-overflow-tooltip />
|
||||
<ElTableColumn prop="query" label="查询" min-width="220" show-overflow-tooltip />
|
||||
<ElTableColumn label="当前版本" width="120">
|
||||
<template #default="{ row }">{{ versionLabel(row.current_version_no) ?? "—" }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="操作" width="248" align="right" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<div class="whitespace-nowrap">
|
||||
<ElButton link type="primary" data-testid="mapping-open" @click="router.push(`/mappings/${row.id}`)">打开</ElButton>
|
||||
<ElButton link type="primary" @click="router.push(`/mappings/${row.id}?switch=1`)">切换版本</ElButton>
|
||||
<ElButton link type="primary" @click="router.push(`/mappings/${row.id}?trial=1`)">试算</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
<ElDialog v-model="createOpen" title="新建映射" width="480px" align-center append-to-body :close-on-click-modal="false">
|
||||
<p class="mb-2 text-sm text-[var(--text-secondary)]">选择这条映射要使用的查询。字段会按该查询的输出列带出来。</p>
|
||||
<ElSelect v-model="selectedQuery" class="w-full" placeholder="选择查询" filterable :teleported="false">
|
||||
<ElOption v-for="item in queries" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</ElSelect>
|
||||
<p v-if="createError" class="mt-3 text-sm text-[var(--color-danger,#cf222e)]">{{ createError }}</p>
|
||||
<template #footer>
|
||||
<ElButton @click="createOpen = false">取消</ElButton>
|
||||
<ElButton type="primary" @click="create">新建</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</section>
|
||||
<div
|
||||
v-else-if="!loading && rows.length === 0 && hasAppliedFilters"
|
||||
class="wm-list-empty"
|
||||
data-testid="mapping-filter-empty"
|
||||
>
|
||||
<div>
|
||||
<h3 class="wm-list-empty__title">没有匹配的映射</h3>
|
||||
<p class="wm-list-empty__hint">试试清空条件后再查询。</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="min-h-0 flex-1">
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
class="wm-admin-table"
|
||||
:data="rows"
|
||||
row-key="id"
|
||||
height="100%"
|
||||
empty-text="暂无映射"
|
||||
data-testid="mapping-table"
|
||||
>
|
||||
<ElTableColumn prop="name" label="名称" min-width="220" show-overflow-tooltip />
|
||||
<ElTableColumn prop="query" label="查询" min-width="220" show-overflow-tooltip />
|
||||
<ElTableColumn label="当前版本" width="120">
|
||||
<template #default="{ row }">{{ versionLabel(row.current_version_no) ?? "—" }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="操作" :width="actionsWidth" align="right" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<div class="whitespace-nowrap">
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
data-testid="mapping-open"
|
||||
@click="router.push(`/mappings/${row.id}`)"
|
||||
>
|
||||
打开
|
||||
</ElButton>
|
||||
<ElButton link type="primary" @click="router.push(`/mappings/${row.id}?switch=1`)">
|
||||
切换版本
|
||||
</ElButton>
|
||||
<ElButton link type="primary" @click="router.push(`/mappings/${row.id}?trial=1`)">
|
||||
试算
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
</ListPageShell>
|
||||
|
||||
<ElDialog
|
||||
v-model="createOpen"
|
||||
title="新建映射"
|
||||
width="480px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<p class="mb-2 text-[length:var(--el-font-size-small)] text-[var(--text-secondary)]">
|
||||
选择这条映射要使用的查询。字段会按该查询的输出列带出来。
|
||||
</p>
|
||||
<ElSelect
|
||||
v-model="selectedQuery"
|
||||
class="w-full"
|
||||
placeholder="选择查询"
|
||||
filterable
|
||||
:teleported="false"
|
||||
>
|
||||
<ElOption v-for="item in queries" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</ElSelect>
|
||||
<p
|
||||
v-if="createError"
|
||||
class="mt-3 text-[length:var(--el-font-size-small)] text-[var(--el-color-danger)]"
|
||||
>
|
||||
{{ createError }}
|
||||
</p>
|
||||
<template #footer>
|
||||
<ElButton @click="createOpen = false">取消</ElButton>
|
||||
<ElButton type="primary" @click="create">新建</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
@@ -78,7 +78,7 @@ const maskedColumns = computed(() =>
|
||||
|
||||
<template>
|
||||
<section
|
||||
class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4"
|
||||
class="wm-form-section"
|
||||
data-testid="preview-card"
|
||||
>
|
||||
<h3 class="mb-1 text-[14.5px] font-semibold">{{ t("query.preview.title") }}</h3>
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
} from "element-plus";
|
||||
import { listDatasources } from "../datasources/client";
|
||||
import type { Datasource } from "../datasources/types";
|
||||
import FormPageShell from "../shared/components/FormPageShell.vue";
|
||||
import {
|
||||
createQuery,
|
||||
disableQuery,
|
||||
@@ -364,8 +365,7 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full min-h-0 flex-col">
|
||||
<div class="min-h-0 flex-1 overflow-y-auto p-5" data-testid="query-scroll">
|
||||
<FormPageShell test-id="query-edit" body-test-id="query-scroll" footer-test-id="query-footer">
|
||||
<ElAlert
|
||||
v-if="loadError"
|
||||
type="error"
|
||||
@@ -411,7 +411,7 @@ onMounted(async () => {
|
||||
data-testid="query-form"
|
||||
@submit.prevent
|
||||
>
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">
|
||||
{{ t("query.form.basic") }}
|
||||
<span class="ml-2 font-normal text-[var(--text-muted)]" data-testid="basic-sub">
|
||||
@@ -459,7 +459,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("query.form.sql") }}</h3>
|
||||
<ElFormItem prop="sql_template" label-width="0" data-testid="field-sql">
|
||||
<ElInput
|
||||
@@ -502,7 +502,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-1 text-[14.5px] font-semibold">{{ t("query.form.paramsTitle") }}</h3>
|
||||
<p class="mb-2.5 text-xs text-[var(--text-muted)]">{{ t("query.form.paramsHint") }}</p>
|
||||
<ElFormItem prop="params" label-width="0" data-testid="field-params">
|
||||
@@ -510,7 +510,7 @@ onMounted(async () => {
|
||||
</ElFormItem>
|
||||
</section>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-1 text-[14.5px] font-semibold">{{ t("query.form.outputsTitle") }}</h3>
|
||||
<p class="mb-2.5 text-xs text-[var(--text-muted)]">{{ t("query.form.outputsHint") }}</p>
|
||||
<ElFormItem prop="outputs" label-width="0" data-testid="field-outputs">
|
||||
@@ -518,7 +518,7 @@ onMounted(async () => {
|
||||
</ElFormItem>
|
||||
</section>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-1 text-[14.5px] font-semibold">{{ t("query.form.identifiersTitle") }}</h3>
|
||||
<p class="mb-2.5 text-xs text-[var(--text-muted)]">
|
||||
{{ t("query.form.identifiersHint", { example: IDENTIFIER_EXAMPLE }) }}
|
||||
@@ -526,7 +526,7 @@ onMounted(async () => {
|
||||
<IdentifierTags v-model="form.identifiers" />
|
||||
</section>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("query.form.limits") }}</h3>
|
||||
<div class="grid max-w-3xl grid-cols-1 gap-x-6 sm:grid-cols-2">
|
||||
<ElFormItem label="timeout_ms" prop="timeout_ms" data-testid="field-timeout">
|
||||
@@ -568,7 +568,7 @@ onMounted(async () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-1 text-[14.5px] font-semibold">{{ t("query.versions.title") }}</h3>
|
||||
<p class="mb-2.5 text-xs text-[var(--text-muted)]">{{ t("query.versions.hint") }}</p>
|
||||
<p
|
||||
@@ -596,7 +596,7 @@ onMounted(async () => {
|
||||
</section>
|
||||
|
||||
<section
|
||||
class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4"
|
||||
class="wm-form-section"
|
||||
data-testid="query-references"
|
||||
>
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("query.refs.title") }}</h3>
|
||||
@@ -619,12 +619,8 @@ onMounted(async () => {
|
||||
</p>
|
||||
</section>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<footer
|
||||
data-testid="query-footer"
|
||||
class="flex shrink-0 flex-wrap items-center justify-center gap-2 border-t border-[var(--border-subtle)] bg-white px-5 py-3"
|
||||
>
|
||||
<template #footer>
|
||||
<ElButton data-testid="footer-back" @click="backToList">{{ t("query.actions.backToList") }}</ElButton>
|
||||
<template v-if="loaded && !loadError">
|
||||
<ElButton
|
||||
@@ -660,8 +656,8 @@ onMounted(async () => {
|
||||
{{ t("query.actions.runPreview") }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</footer>
|
||||
</div>
|
||||
</template>
|
||||
</FormPageShell>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
} from "element-plus";
|
||||
import { listDatasources } from "../datasources/client";
|
||||
import type { Datasource } from "../datasources/types";
|
||||
import ListPageShell from "../shared/components/ListPageShell.vue";
|
||||
import { LIST_DEFAULT_PAGE_SIZE, LIST_PAGE_SIZES, actionsColumnWidth } from "../tableLayout";
|
||||
import { listQueries, listVersions } from "./client";
|
||||
import { describeError } from "./errors";
|
||||
@@ -202,91 +203,89 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- Page itself does not scroll: toolbar + table body + pagination footer. -->
|
||||
<div class="flex h-full min-h-0 flex-col overflow-hidden" data-testid="query-list">
|
||||
<div class="flex shrink-0 flex-wrap items-center gap-2 px-5 pb-3 pt-5" data-testid="query-list-toolbar">
|
||||
<div class="w-[200px]" data-testid="query-filter-name">
|
||||
<ElInput v-model="draft.name" clearable :placeholder="t('query.list.filterName')" />
|
||||
</div>
|
||||
<div class="w-[200px]" data-testid="query-filter-datasource">
|
||||
<ElSelect
|
||||
v-model="draft.datasourceId"
|
||||
clearable
|
||||
class="w-full"
|
||||
:placeholder="t('query.list.filterDatasource')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="source in datasources"
|
||||
:key="source.id"
|
||||
:label="source.name"
|
||||
:value="source.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</div>
|
||||
<div class="w-[140px]" data-testid="query-filter-status">
|
||||
<ElSelect
|
||||
v-model="draft.status"
|
||||
clearable
|
||||
class="w-full"
|
||||
:placeholder="t('query.list.filterStatus')"
|
||||
>
|
||||
<ElOption :label="t('query.status.enabled')" value="enabled" />
|
||||
<ElOption :label="t('query.status.disabled')" value="disabled" />
|
||||
</ElSelect>
|
||||
</div>
|
||||
<ElButton type="primary" data-testid="query-filter-search" @click="applyFilters">
|
||||
{{ t("query.list.filterSearch") }}
|
||||
</ElButton>
|
||||
<ElButton data-testid="query-filter-reset" @click="resetFilters">
|
||||
{{ t("query.list.filterReset") }}
|
||||
</ElButton>
|
||||
<div class="ml-auto">
|
||||
<ElButton type="primary" data-testid="query-create" @click="openCreate">
|
||||
{{ t("query.list.create") }}
|
||||
<ListPageShell test-id="query-list">
|
||||
<template #filters>
|
||||
<div data-testid="query-list-toolbar" class="contents">
|
||||
<div class="w-[16rem]" data-testid="query-filter-name">
|
||||
<ElInput v-model="draft.name" clearable :placeholder="t('query.list.filterName')" />
|
||||
</div>
|
||||
<div class="w-[16rem]" data-testid="query-filter-datasource">
|
||||
<ElSelect
|
||||
v-model="draft.datasourceId"
|
||||
clearable
|
||||
class="w-full"
|
||||
:placeholder="t('query.list.filterDatasource')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="source in datasources"
|
||||
:key="source.id"
|
||||
:label="source.name"
|
||||
:value="source.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</div>
|
||||
<div class="w-[9rem]" data-testid="query-filter-status">
|
||||
<ElSelect
|
||||
v-model="draft.status"
|
||||
clearable
|
||||
class="w-full"
|
||||
:placeholder="t('query.list.filterStatus')"
|
||||
>
|
||||
<ElOption :label="t('query.status.enabled')" value="enabled" />
|
||||
<ElOption :label="t('query.status.disabled')" value="disabled" />
|
||||
</ElSelect>
|
||||
</div>
|
||||
<ElButton type="primary" data-testid="query-filter-search" @click="applyFilters">
|
||||
{{ t("query.list.filterSearch") }}
|
||||
</ElButton>
|
||||
<ElButton data-testid="query-filter-reset" @click="resetFilters">
|
||||
{{ t("query.list.filterReset") }}
|
||||
</ElButton>
|
||||
<div class="ml-auto">
|
||||
<ElButton type="primary" data-testid="query-create" @click="openCreate">
|
||||
{{ t("query.list.create") }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<ElAlert
|
||||
v-if="loadError"
|
||||
class="m-4 mx-8"
|
||||
type="error"
|
||||
data-testid="query-load-error"
|
||||
:title="loadError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div v-else-if="!loading && total === 0 && !hasAppliedFilters" data-testid="query-empty" class="wm-list-empty">
|
||||
<div>
|
||||
<h3 class="wm-list-empty__title">{{ t("query.list.empty") }}</h3>
|
||||
<p class="wm-list-empty__hint">{{ t("query.list.emptyHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex min-h-0 flex-1 flex-col px-5">
|
||||
<ElAlert
|
||||
v-if="loadError"
|
||||
type="error"
|
||||
data-testid="query-load-error"
|
||||
:title="loadError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && !hasAppliedFilters"
|
||||
data-testid="query-empty"
|
||||
class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<div>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("query.list.empty") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("query.list.emptyHint") }}</p>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && hasAppliedFilters"
|
||||
data-testid="query-filter-empty"
|
||||
class="wm-list-empty"
|
||||
>
|
||||
<div>
|
||||
<h3 class="wm-list-empty__title">{{ t("query.list.filterEmpty") }}</h3>
|
||||
<p class="wm-list-empty__hint">{{ t("query.list.filterEmptyHint") }}</p>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && hasAppliedFilters"
|
||||
data-testid="query-filter-empty"
|
||||
class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
</div>
|
||||
<div v-else class="min-h-0 flex-1" data-testid="query-table-wrap">
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
class="wm-admin-table"
|
||||
height="100%"
|
||||
:data="items"
|
||||
row-key="id"
|
||||
data-testid="query-table"
|
||||
:default-sort="{ prop: 'updated_at', order: 'descending' }"
|
||||
:row-class-name="rowClass"
|
||||
@sort-change="onSortChange"
|
||||
>
|
||||
<div>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("query.list.filterEmpty") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("query.list.filterEmptyHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="min-h-0 flex-1" data-testid="query-table-wrap">
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
height="100%"
|
||||
:data="items"
|
||||
row-key="id"
|
||||
data-testid="query-table"
|
||||
:default-sort="{ prop: 'updated_at', order: 'descending' }"
|
||||
:row-class-name="rowClass"
|
||||
@sort-change="onSortChange"
|
||||
>
|
||||
<ElTableColumn
|
||||
prop="name"
|
||||
:label="t('query.columns.name')"
|
||||
@@ -356,54 +355,51 @@ onMounted(async () => {
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
</ElTable>
|
||||
</div>
|
||||
|
||||
<footer
|
||||
v-if="!loadError && (loading || total > 0)"
|
||||
data-testid="query-pagination"
|
||||
class="flex shrink-0 items-center justify-end border-t border-[var(--border-subtle)] bg-white px-5 py-3"
|
||||
>
|
||||
<ElPagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[...LIST_PAGE_SIZES]"
|
||||
:current-page="page"
|
||||
@current-change="onPageChange"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</footer>
|
||||
|
||||
<ElDialog
|
||||
v-model="switchOpen"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:title="t('query.versions.switchTitle', { name: switchRow?.name ?? '' })"
|
||||
width="680px"
|
||||
data-testid="query-switch-dialog"
|
||||
>
|
||||
<ElAlert
|
||||
v-if="switchError"
|
||||
type="error"
|
||||
:title="switchError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div v-else v-loading="switchLoading">
|
||||
<VersionsTable
|
||||
v-if="switchRow"
|
||||
:definition-id="switchRow.id"
|
||||
:versions="switchVersions"
|
||||
:active-no="switchRow.current_version_no ?? undefined"
|
||||
@activated="onSwitchActivated"
|
||||
<template v-if="!loadError && (loading || total > 0)" #pagination>
|
||||
<div data-testid="query-pagination">
|
||||
<ElPagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[...LIST_PAGE_SIZES]"
|
||||
:current-page="page"
|
||||
@current-change="onPageChange"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</ElDialog>
|
||||
</div>
|
||||
</template>
|
||||
</ListPageShell>
|
||||
|
||||
<ElDialog
|
||||
v-model="switchOpen"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:title="t('query.versions.switchTitle', { name: switchRow?.name ?? '' })"
|
||||
width="680px"
|
||||
data-testid="query-switch-dialog"
|
||||
>
|
||||
<ElAlert
|
||||
v-if="switchError"
|
||||
type="error"
|
||||
:title="switchError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div v-else v-loading="switchLoading">
|
||||
<VersionsTable
|
||||
v-if="switchRow"
|
||||
:definition-id="switchRow.id"
|
||||
:versions="switchVersions"
|
||||
:active-no="switchRow.current_version_no ?? undefined"
|
||||
@activated="onSwitchActivated"
|
||||
/>
|
||||
</div>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useRoute, useRouter } from "vue-router";
|
||||
import { ElAlert, ElButton, ElDescriptions, ElDescriptionsItem, ElMessage, ElTag } from "element-plus";
|
||||
import { listDatasources } from "../datasources/client";
|
||||
import type { Datasource } from "../datasources/types";
|
||||
import FormPageShell from "../shared/components/FormPageShell.vue";
|
||||
import { activateQueryVersion, getQuery, getVersion, listVersions, previewVersion } from "./client";
|
||||
import { describeError, isNotFound } from "./errors";
|
||||
import { formatDateTime } from "./format";
|
||||
@@ -141,8 +142,7 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full min-h-0 flex-col">
|
||||
<div class="min-h-0 flex-1 overflow-y-auto p-5" data-testid="query-scroll">
|
||||
<FormPageShell test-id="query-version" body-test-id="query-scroll" footer-test-id="query-footer">
|
||||
<ElAlert
|
||||
v-if="loadError"
|
||||
type="error"
|
||||
@@ -161,7 +161,7 @@ onMounted(async () => {
|
||||
:closable="false"
|
||||
/>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">
|
||||
{{ t("query.versions.info") }}
|
||||
<ElTag type="info" effect="plain" class="ml-2" data-testid="version-readonly-tag">
|
||||
@@ -186,7 +186,7 @@ onMounted(async () => {
|
||||
</ElDescriptions>
|
||||
</section>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("query.form.sql") }}</h3>
|
||||
<pre
|
||||
data-testid="version-sql"
|
||||
@@ -195,22 +195,22 @@ onMounted(async () => {
|
||||
>
|
||||
</section>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("query.form.paramsTitle") }}</h3>
|
||||
<ParamsTable :model-value="params" readonly />
|
||||
</section>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("query.form.outputsTitle") }}</h3>
|
||||
<OutputsTable :model-value="outputs" readonly />
|
||||
</section>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("query.form.identifiersTitle") }}</h3>
|
||||
<IdentifierTags :model-value="version.allowed_identifiers" readonly />
|
||||
</section>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("query.form.limits") }}</h3>
|
||||
<ElDescriptions :column="2" data-testid="version-limits">
|
||||
<ElDescriptionsItem label="timeout_ms">{{ version.timeout_ms }}</ElDescriptionsItem>
|
||||
@@ -231,7 +231,7 @@ onMounted(async () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<section class="mb-4 rounded-lg border border-[var(--border-subtle)] bg-white px-[18px] py-4">
|
||||
<section class="wm-form-section">
|
||||
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("query.versions.title") }}</h3>
|
||||
<VersionsTable
|
||||
:definition-id="queryId"
|
||||
@@ -242,12 +242,8 @@ onMounted(async () => {
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<footer
|
||||
data-testid="query-footer"
|
||||
class="flex shrink-0 flex-wrap items-center justify-center gap-2 border-t border-[var(--border-subtle)] bg-white px-5 py-3"
|
||||
>
|
||||
<template #footer>
|
||||
<ElButton data-testid="footer-back" @click="backToList">{{ t("query.actions.backToList") }}</ElButton>
|
||||
<template v-if="loaded && !loadError">
|
||||
<ElButton data-testid="footer-query" @click="backToQuery">{{ t("query.actions.backToQuery") }}</ElButton>
|
||||
@@ -265,8 +261,8 @@ onMounted(async () => {
|
||||
{{ t("query.actions.runPreview") }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</footer>
|
||||
</div>
|
||||
</template>
|
||||
</FormPageShell>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* shared/components/FormPageShell.vue
|
||||
* 用途:详情/编辑页唯一卡片骨架(可滚正文 + 固定居中页脚)。
|
||||
* 依赖:shared/styles/admin-page.css。
|
||||
* 逻辑:页脚在卡片内、不随正文滚动;业务按钮放进 footer 槽。
|
||||
*/
|
||||
defineProps<{
|
||||
testId?: string;
|
||||
bodyTestId?: string;
|
||||
footerTestId?: string;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="wm-form-page" :data-testid="testId">
|
||||
<div class="wm-form-page__body" :data-testid="bodyTestId">
|
||||
<slot />
|
||||
</div>
|
||||
<footer v-if="$slots.footer" class="wm-form-page__footer" :data-testid="footerTestId">
|
||||
<slot name="footer" />
|
||||
</footer>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* shared/components/ListPageShell.vue
|
||||
* 用途:业务列表页唯一卡片骨架(筛选 / 表体 / 分页槽位)。
|
||||
* 依赖:shared/styles/admin-page.css。
|
||||
* 逻辑:不请求数据;Watchman 面包屑已表达页面名,故不设标题槽位(与 HXOPS 标题行不同)。
|
||||
*/
|
||||
defineProps<{
|
||||
/** Root data-testid for the page. */
|
||||
testId?: string;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="wm-list-page" :data-testid="testId">
|
||||
<div v-if="$slots.filters" class="wm-list-page__filters">
|
||||
<slot name="filters" />
|
||||
</div>
|
||||
<div class="wm-list-page__body">
|
||||
<slot />
|
||||
</div>
|
||||
<div v-if="$slots.pagination" class="wm-list-page__pager">
|
||||
<slot name="pagination" />
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
* shared/styles/admin-page.css
|
||||
* 用途:控制台列表/表单页唯一卡片骨架(左右 32px 对齐)。
|
||||
* 依赖:web/design/tokens.css、element-theme.css。
|
||||
* 逻辑:对齐和信 Design System / HXOPS AdminListPage Pattern;Watchman 列表不加面包屑下重复标题。
|
||||
*/
|
||||
.wm-list-page,
|
||||
.wm-form-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
background-color: var(--bg-surface);
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: var(--radius-surface);
|
||||
box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
|
||||
}
|
||||
|
||||
.wm-list-page__filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 16px 32px;
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.wm-list-page__filters .el-input,
|
||||
.wm-list-page__filters .el-select {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.wm-list-page__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.wm-list-page__pager {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
padding: 12px 32px;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
flex-shrink: 0;
|
||||
background-color: var(--bg-surface);
|
||||
}
|
||||
|
||||
.wm-list-empty {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 16px 32px 24px;
|
||||
padding: 56px 20px;
|
||||
text-align: center;
|
||||
border: 1px dashed var(--border-default);
|
||||
border-radius: var(--radius-control);
|
||||
background-color: var(--bg-surface-soft);
|
||||
}
|
||||
|
||||
.wm-list-empty__title {
|
||||
margin: 0 0 6px;
|
||||
font-size: var(--el-font-size-medium);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.wm-list-empty__hint {
|
||||
margin: 0;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
/* 表头首末列与筛选/分页 32px 对齐 */
|
||||
.wm-admin-table .el-table__cell:first-child .cell {
|
||||
padding-left: 32px;
|
||||
}
|
||||
|
||||
.wm-admin-table .el-table__cell:last-child .cell {
|
||||
padding-right: 32px;
|
||||
}
|
||||
|
||||
.wm-form-page__body {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
padding: 24px 32px;
|
||||
}
|
||||
|
||||
.wm-form-page__footer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 12px 32px;
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
flex-shrink: 0;
|
||||
background-color: var(--bg-surface);
|
||||
}
|
||||
|
||||
/* 表单分区:一层卡片内用分隔,禁止再套白底卡片 */
|
||||
.wm-form-section {
|
||||
margin-bottom: 1.5rem;
|
||||
padding-bottom: 1.5rem;
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
}
|
||||
|
||||
.wm-form-section:last-child {
|
||||
margin-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.wm-form-section__title {
|
||||
margin: 0 0 0.75rem;
|
||||
font-size: var(--el-font-size-base);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.wm-form-section__hint {
|
||||
margin: -0.25rem 0 0.75rem;
|
||||
font-size: var(--el-font-size-small);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.wm-home-page {
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.wm-home-page .el-card {
|
||||
border-radius: var(--radius-surface);
|
||||
border-color: var(--border-default);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
@import "tailwindcss";
|
||||
@import "../../../design/tokens.css";
|
||||
@import "./shared/styles/element-theme.css";
|
||||
@import "./shared/styles/admin-page.css";
|
||||
Reference in new issue
Block a user