From 7678c12e17dc72495bf80cb0423b23ee47b777e0 Mon Sep 17 00:00:00 2001 From: nayeongkim Date: Thu, 3 Apr 2025 12:05:54 +0900 Subject: [PATCH] feat: add service_name, description fields at alert excel Signed-off-by: NaYeong,Kim --- .../v2/components/AlertsManagementTable.vue | 34 ++++++++++++++++--- .../v2/constants/alert-table-constant.ts | 3 +- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/apps/web/src/services/alert-manager/v2/components/AlertsManagementTable.vue b/apps/web/src/services/alert-manager/v2/components/AlertsManagementTable.vue index 05c5876853..8898864585 100644 --- a/apps/web/src/services/alert-manager/v2/components/AlertsManagementTable.vue +++ b/apps/web/src/services/alert-manager/v2/components/AlertsManagementTable.vue @@ -21,6 +21,7 @@ import type { AlertModel } from '@/schema/alert-manager/alert/model'; import { i18n } from '@/translations'; import { useAllReferenceStore } from '@/store/reference/all-reference-store'; +import type { ServiceReferenceMap } from '@/store/reference/service-reference-store'; import type { WebhookReferenceMap } from '@/store/reference/webhook-reference-store'; import { useUserStore } from '@/store/user/user-store'; @@ -64,6 +65,7 @@ const route = useRoute(); const storeState = reactive({ webhook: computed(() => allReferenceGetters.webhook), + serviceList: computed(() => allReferenceGetters.service), serviceId: computed(() => serviceDetailPageState.serviceInfo?.service_id), totalCount: computed(() => alertPageState.totalAlertCount), alertList: computed(() => alertPageState.alertList), @@ -193,14 +195,36 @@ const handleCustomFieldUpdate = (fields: DataTableFieldType[]) => { state.fields = fields; }; const handleExportToExcel = async () => { + // TODO: File manager changes need to be applied. + // const alertsExcelExportParams: ExportParameter = { + // file_name: FILE_NAME_PREFIX.alert, + // options: [ + // { + // name: 'Alert List', + // query_type: QueryType.SEARCH, + // search_query: { + // ...alertListApiQueryHelper.data, + // fields: ALERT_EXCEL_FIELDS, + // }, + // }, + // ], + // timezone: storeState.timezone, + // }; + // return SpaceConnector.clientV2.alertManager.alert.export(alertsExcelExportParams); + const data = state.refinedAlertList.map((i) => ({ + service_name: storeState.serviceList[i.service_id].data.name, + title: i.title, + description: i.description, + status: i.status, + urgency: i.urgency, + labels: i.labels, + triggered_by: i.triggered_by, + created_at: i.created_at, + })); await downloadExcel({ - url: '/alert-manager/alert/list', - param: { - query: { ...alertListApiQueryHelper.data, only: ALERT_EXCEL_FIELDS.map((d) => d.key) }, - }, + data, fields: ALERT_EXCEL_FIELDS, file_name_prefix: FILE_NAME_PREFIX.alert, - timezone: storeState.timezone, }); }; diff --git a/apps/web/src/services/alert-manager/v2/constants/alert-table-constant.ts b/apps/web/src/services/alert-manager/v2/constants/alert-table-constant.ts index 4ee63a51af..adb365f863 100644 --- a/apps/web/src/services/alert-manager/v2/constants/alert-table-constant.ts +++ b/apps/web/src/services/alert-manager/v2/constants/alert-table-constant.ts @@ -37,8 +37,9 @@ export const ALERT_MANAGEMENT_TABLE_HANDLER: AlertManagementTableHandlerType = { }, }; export const ALERT_EXCEL_FIELDS: ExcelDataField[] = [ - { key: 'service_id', name: 'Service' }, + { key: 'service_name', name: 'Service' }, { key: 'title', name: 'Title' }, + { key: 'description', name: 'Description' }, { key: 'status', name: 'Status' }, { key: 'urgency', name: 'Urgency' }, { key: 'labels', name: 'Labels' },