From 312f4bbe849c3c4f41b300f9b0b5ae343bbbef44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=8A=B9=EC=97=B0?= <165753731+seungyeoneeee@users.noreply.github.com> Date: Thu, 8 May 2025 20:02:39 +0900 Subject: [PATCH] feat: update service landing page - pagination as service_healthy (#5836) * feat: update service schema model Signed-off-by: seungyeoneeee * feat: update service landing page - pagination as service_healthy Signed-off-by: seungyeoneeee --------- Signed-off-by: seungyeoneeee --- .../schema/alert-manager/service/constants.ts | 5 + .../src/schema/alert-manager/service/model.ts | 3 +- .../src/schema/alert-manager/service/type.ts | 2 + .../v2/components/ServiceDetailHeader.vue | 17 +- .../v2/components/ServiceList.vue | 249 +++++++++++++----- .../v2/stores/service-list-page-store.ts | 18 ++ 6 files changed, 224 insertions(+), 70 deletions(-) create mode 100644 apps/web/src/services/alert-manager/v2/stores/service-list-page-store.ts diff --git a/apps/web/src/schema/alert-manager/service/constants.ts b/apps/web/src/schema/alert-manager/service/constants.ts index 646b22b57c..a0afd1eb66 100644 --- a/apps/web/src/schema/alert-manager/service/constants.ts +++ b/apps/web/src/schema/alert-manager/service/constants.ts @@ -19,3 +19,8 @@ export const SERVICE_ALERTS_TYPE = { ACKNOWLEDGED: 'ACKNOWLEDGED', RESOLVED: 'RESOLVED', } as const; + +export const SERVICE_HEALTHY_TYPE = { + HEALTHY: 'HEALTHY', + UNHEALTHY: 'UNHEALTHY', +}; diff --git a/apps/web/src/schema/alert-manager/service/model.ts b/apps/web/src/schema/alert-manager/service/model.ts index 9abedbd232..bad20bc731 100644 --- a/apps/web/src/schema/alert-manager/service/model.ts +++ b/apps/web/src/schema/alert-manager/service/model.ts @@ -1,6 +1,6 @@ import type { Tags } from '@/api-clients/_common/schema/model'; import type { - AlertsInfoType, AlertsType, MembersType, ServiceOptionsType, + AlertsInfoType, AlertsType, HealthyType, MembersType, ServiceOptionsType, } from '@/schema/alert-manager/service/type'; export interface ServiceModel { @@ -9,6 +9,7 @@ export interface ServiceModel { service_key: string; description: string; members: Record; + service_healthy: HealthyType; options: ServiceOptionsType; channels?: string[]; webhooks?: string[]; diff --git a/apps/web/src/schema/alert-manager/service/type.ts b/apps/web/src/schema/alert-manager/service/type.ts index e1e93dd0c5..67cc5867ec 100644 --- a/apps/web/src/schema/alert-manager/service/type.ts +++ b/apps/web/src/schema/alert-manager/service/type.ts @@ -1,11 +1,13 @@ import type { NOTIFICATION_URGENCY, RECOVERY_MODE, MEMBERS_TYPE, SERVICE_ALERTS_TYPE, + SERVICE_HEALTHY_TYPE, } from '@/schema/alert-manager/service/constants'; export type NotificationUrgencyType = typeof NOTIFICATION_URGENCY[keyof typeof NOTIFICATION_URGENCY]; export type RecoveryModeType = typeof RECOVERY_MODE[keyof typeof RECOVERY_MODE]; export type MembersType = typeof MEMBERS_TYPE[keyof typeof MEMBERS_TYPE]; export type AlertsType = typeof SERVICE_ALERTS_TYPE[keyof typeof SERVICE_ALERTS_TYPE]; +export type HealthyType = typeof SERVICE_HEALTHY_TYPE[keyof typeof SERVICE_HEALTHY_TYPE]; export type ServiceOptionsType = { notification_urgency: NotificationUrgencyType; diff --git a/apps/web/src/services/alert-manager/v2/components/ServiceDetailHeader.vue b/apps/web/src/services/alert-manager/v2/components/ServiceDetailHeader.vue index b377f02207..245f93d81e 100644 --- a/apps/web/src/services/alert-manager/v2/components/ServiceDetailHeader.vue +++ b/apps/web/src/services/alert-manager/v2/components/ServiceDetailHeader.vue @@ -22,6 +22,7 @@ import ServiceDetailEditModal from '@/services/alert-manager/v2/components/Servi import ServiceDetailMemberModal from '@/services/alert-manager/v2/components/ServiceDetailMemberModal.vue'; import { ALERT_MANAGER_ROUTE } from '@/services/alert-manager/v2/routes/route-constant'; import { useServiceDetailPageStore } from '@/services/alert-manager/v2/stores/service-detail-page-store'; +import { useServiceListPageStore } from '@/services/alert-manager/v2/stores/service-list-page-store'; import type { Service } from '@/services/alert-manager/v2/types/alert-manager-type'; type ModalType = 'edit' | 'delete' | 'member' | 'alert'; @@ -30,6 +31,8 @@ const serviceDetailPageStore = useServiceDetailPageStore(); const serviceDetailPageState = serviceDetailPageStore.state; const serviceDetailPageGetters = serviceDetailPageStore.getters; +const serviceListPageStore = useServiceListPageStore(); + const router = useRouter(); const route = useRoute(); @@ -75,7 +78,19 @@ const handleActionModal = (type: ModalType) => { }; const handleGoBackButton = () => { if (state.isSettingMode) { - router.push({ name: ALERT_MANAGER_ROUTE.SERVICE._NAME }).catch(() => {}); + const validUnhealthyPage = (!Number.isNaN(serviceListPageStore.unhealthyThisPage) && serviceListPageStore.unhealthyThisPage > 0) + ? serviceListPageStore.unhealthyThisPage + : 1; + const validHealthyPage = (!Number.isNaN(serviceListPageStore.healthyThisPage) && serviceListPageStore.healthyThisPage > 0) + ? serviceListPageStore.healthyThisPage + : 1; + router.push({ + name: ALERT_MANAGER_ROUTE.SERVICE._NAME, + query: { + unhealthyPage: validUnhealthyPage.toString(), + healthyPage: validHealthyPage.toString(), + }, + }).catch(() => {}); return; } replaceUrlQuery({ diff --git a/apps/web/src/services/alert-manager/v2/components/ServiceList.vue b/apps/web/src/services/alert-manager/v2/components/ServiceList.vue index ff2982e235..c837126e70 100644 --- a/apps/web/src/services/alert-manager/v2/components/ServiceList.vue +++ b/apps/web/src/services/alert-manager/v2/components/ServiceList.vue @@ -1,36 +1,36 @@ + + diff --git a/apps/web/src/services/alert-manager/v2/stores/service-list-page-store.ts b/apps/web/src/services/alert-manager/v2/stores/service-list-page-store.ts new file mode 100644 index 0000000000..b63fda6296 --- /dev/null +++ b/apps/web/src/services/alert-manager/v2/stores/service-list-page-store.ts @@ -0,0 +1,18 @@ +import { defineStore } from 'pinia'; + +export const useServiceListPageStore = defineStore('serviceListPage', { + state: () => ({ + unhealthyThisPage: 1, + unhealthyPageSize: 10, + healthyThisPage: 1, + healthyPageSize: 6, + }), + actions: { + setUnhealthyPage(page: number) { + this.unhealthyThisPage = page; + }, + setHealthyPage(page: number) { + this.healthyThisPage = page; + }, + }, +});