From 82ccc187cde44dccb33db45cf404c27ddb99a8d9 Mon Sep 17 00:00:00 2001 From: wucm667 Date: Thu, 6 Aug 2026 02:26:42 +0800 Subject: [PATCH] fix(ops): preserve custom range in error lists --- frontend/src/views/admin/ops/OpsDashboard.vue | 2 ++ .../ops/components/OpsErrorDetailsModal.vue | 7 +++++-- .../ops/utils/__tests__/opsErrorParams.spec.ts | 16 ++++++++++++++++ .../src/views/admin/ops/utils/opsErrorParams.ts | 11 +++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 frontend/src/views/admin/ops/utils/__tests__/opsErrorParams.spec.ts create mode 100644 frontend/src/views/admin/ops/utils/opsErrorParams.ts diff --git a/frontend/src/views/admin/ops/OpsDashboard.vue b/frontend/src/views/admin/ops/OpsDashboard.vue index 8bb42f3b6..cd5c67296 100644 --- a/frontend/src/views/admin/ops/OpsDashboard.vue +++ b/frontend/src/views/admin/ops/OpsDashboard.vue @@ -114,6 +114,8 @@ = { page: page.value, page_size: pageSize.value, - time_range: props.timeRange, view: viewMode.value, sort_by: sortBy.value, sort_order: sortOrder.value } + Object.assign(params, buildOpsErrorTimeParams(props.timeRange, props.customStartTime, props.customEndTime)) const platform = String(props.platform || '').trim() if (platform) params.platform = platform @@ -160,7 +163,7 @@ watch( ) watch( - () => [props.timeRange, props.platform, props.groupId] as const, + () => [props.timeRange, props.customStartTime, props.customEndTime, props.platform, props.groupId] as const, () => { if (!props.show) return page.value = 1 diff --git a/frontend/src/views/admin/ops/utils/__tests__/opsErrorParams.spec.ts b/frontend/src/views/admin/ops/utils/__tests__/opsErrorParams.spec.ts new file mode 100644 index 000000000..d4b8c296c --- /dev/null +++ b/frontend/src/views/admin/ops/utils/__tests__/opsErrorParams.spec.ts @@ -0,0 +1,16 @@ +import { describe, expect, it } from 'vitest' +import { buildOpsErrorTimeParams } from '../opsErrorParams' + +describe('buildOpsErrorTimeParams', () => { + it('uses explicit timestamps for a complete custom range', () => { + expect(buildOpsErrorTimeParams('custom', '2026-08-01T00:00:00Z', '2026-08-02T00:00:00Z')).toEqual({ + start_time: '2026-08-01T00:00:00Z', + end_time: '2026-08-02T00:00:00Z' + }) + }) + + it('preserves predefined ranges and falls back for incomplete custom ranges', () => { + expect(buildOpsErrorTimeParams('24h')).toEqual({ time_range: '24h' }) + expect(buildOpsErrorTimeParams('custom', null, null)).toEqual({ time_range: '1h' }) + }) +}) diff --git a/frontend/src/views/admin/ops/utils/opsErrorParams.ts b/frontend/src/views/admin/ops/utils/opsErrorParams.ts new file mode 100644 index 000000000..d994b229f --- /dev/null +++ b/frontend/src/views/admin/ops/utils/opsErrorParams.ts @@ -0,0 +1,11 @@ +export function buildOpsErrorTimeParams( + timeRange: string, + customStartTime?: string | null, + customEndTime?: string | null +): Record { + if (timeRange === 'custom' && customStartTime && customEndTime) { + return { start_time: customStartTime, end_time: customEndTime } + } + + return { time_range: timeRange === 'custom' ? '1h' : timeRange } +}