@Select(MSUCBMAlertState.gettablealert) alerts$!: Observable; @Select(MSUCBMAlertState.getChartData) alertCharts$!: Observable; isClickableAlert(parameterName: string): boolean { const clickableAlertTypes = [ 'periodic', 'cyclic maintenance', 'Abnormal Fuel Consumption - Main', 'Abnormal Fuel Consumption - Boiler', 'high discharge pressure', 'low discharge pressure', ]; return clickableAlertTypes.some((type) => parameterName.toLowerCase().includes(type.toLowerCase()) ); } acknowledgeAlert(alert: MSUCBMAlertTable, event: Event): void { event.stopPropagation(); // Prevent event bubbling if (this.isClickableAlert(alert.parameter_name) && !alert.is_clear) { this.store.dispatch( new MSUCBMAlertActions.MSUUpdateAlertClearTime(alert.id) ); } } @Action(MSUCBMAlertActions.MSUUpdateAlertClearTime) updateAlertClearTime( ctx: StateContext, action: MSUCBMAlertActions.MSUUpdateAlertClearTime ) { ctx.patchState({ loading: true }); this.spinner.show(); return this.cbmAlertService.updateAlertClearTime(action.alertId).pipe( tap((response) => { // Instead of trying to access non-existent properties, we'll update the alert in the current state const state = ctx.getState(); // Update the specific alert that was acknowledged const updatedAlerts = state.alerts.map((alert) => alert.id === action.alertId ? { ...alert, is_clear: 1, clearedAt: new Date().toISOString() } : alert ); ctx.patchState({ alerts: updatedAlerts, loading: false, }); }), finalize(() => { this.spinner.hide(); }) ); } export namespace MSUCBMAlertActions { export class MSUUpdateAlertClearTime { static readonly type = '[MSU CBM Alert] Update Alert Clear Time'; constructor(public alertId: number) {} } } updateAlertClearTime(alertId: number): Observable { const url = ${this.API_URL}${CBM_API_ROUTES.ALERT_NOTIFICATION}/${alertId}; return this.httpService.putReqWithToken(url, {}); // Provide an empty object if no data is required } Acknowledge Acknowledged export interface MsuAlertData { tableData: MSUCBMAlertTable[]; // ✅ Now it's an array of objects cardData: MSUCBMAlertCard[]; } export interface MSUCBMAlertTable { id: number; Alert_Id: number; vehicle_id: number[]; is_clear: number; alert_value: number; clearedAt: string | null; createdAt: string; updatedAt: string; deletedAt: string | null; isActive: number; vehicle_name: string; parameter_name: string; alert_condition: string; alert_level: string; location: string; } export interface MSUCBMAlertCard { id: number; vehicle_id: number[]; vehicle_name: string; alertLevel: string; parameter_name: string; alertCount: number; alert_type: string; count: number; vehicle_names: string | null; } export interface MSUAlertChartData { id: number; name: string; timestamp: string; cal_running_meter_reading: number | string; diff_fuel_reading_boiler: number | string; diff_fuel_reading_main: number | string; discharge_pressure: number; } {{ alert.createdAt | date : "dd-MM-yyyy HH:mm:ss" }} {{ alert.clearedAt ? (alert.clearedAt | date : "dd-MM-yyyy HH:mm:ss") : "------------------" }} {{ alert.vehicle_name }} {{ alert.parameter_name }} {{ alert.alert_level }} {{ alert.location }} {{ alert.is_clear ? "Cleared" : "Uncleared" }} Acknowledge Acknowledged issue: The alert cannot be checked or acknowledged without refreshing the page. After clicking on the dark acknowledge icon, the page must be refreshed for the alert to display as acknowledged along with the acknowledgment time.

视频信息