From 5ebcba9f4652f988aa0fd483ed727f7862d1d965 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Fri, 10 Jan 2025 14:44:31 +0000 Subject: [PATCH] refactor: improve code readability in StatusPageAPI and Overview components --- Common/Server/API/StatusPageAPI.ts | 17 ++++++++++------- StatusPage/src/Pages/Overview/Overview.tsx | 15 +++++++-------- Worker/Routes.ts | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Common/Server/API/StatusPageAPI.ts b/Common/Server/API/StatusPageAPI.ts index 59458471a23..f1b4590de95 100644 --- a/Common/Server/API/StatusPageAPI.ts +++ b/Common/Server/API/StatusPageAPI.ts @@ -725,7 +725,7 @@ export default class StatusPageAPI extends BaseAPI< statusPageResources.find((resource: StatusPageResource) => { return ( resource.monitorGroupId?.toString() === - monitorGroupId.toString() && + monitorGroupId.toString() && (resource.showStatusHistoryChart || resource.showUptimePercent) ); @@ -1093,12 +1093,17 @@ export default class StatusPageAPI extends BaseAPI< }, }); - - const overallStatus: MonitorStatus | null = this.getOverallMonitorStatus(statusPageResources, monitorStatuses, monitorGroupCurrentStatuses); + const overallStatus: MonitorStatus | null = + this.getOverallMonitorStatus( + statusPageResources, + monitorStatuses, + monitorGroupCurrentStatuses, + ); const response: JSONObject = { - - overallStatus: overallStatus ? BaseModel.toJSON(overallStatus, MonitorStatus) : null, + overallStatus: overallStatus + ? BaseModel.toJSON(overallStatus, MonitorStatus) + : null, scheduledMaintenanceEventsPublicNotes: BaseModel.toJSONArray( scheduledMaintenanceEventsPublicNotes, @@ -2291,7 +2296,6 @@ export default class StatusPageAPI extends BaseAPI< return response; } - public getOverallMonitorStatus( statusPageResources: Array, monitorStatuses: Array, @@ -2341,5 +2345,4 @@ export default class StatusPageAPI extends BaseAPI< return currentStatus; } - } diff --git a/StatusPage/src/Pages/Overview/Overview.tsx b/StatusPage/src/Pages/Overview/Overview.tsx index 83fdd84967c..b8bf68ddec5 100644 --- a/StatusPage/src/Pages/Overview/Overview.tsx +++ b/StatusPage/src/Pages/Overview/Overview.tsx @@ -256,15 +256,15 @@ const Overview: FunctionComponent = ( setIncidentStateTimelines(incidentStateTimelines); setScheduledMaintenanceStateTimelines(scheduledMaintenanceStateTimelines); - const overallStatus: MonitorStatus | null = data["overallStatus"] ? BaseModel.fromJSONObject( - (data["overallStatus"] as JSONObject) || {}, - MonitorStatus, - ) : null; + const overallStatus: MonitorStatus | null = data["overallStatus"] + ? BaseModel.fromJSONObject( + (data["overallStatus"] as JSONObject) || {}, + MonitorStatus, + ) + : null; // Parse Data. - setCurrentStatus( - overallStatus - ); + setCurrentStatus(overallStatus); setIsLoading(false); props.onLoadComplete(); @@ -366,7 +366,6 @@ const Overview: FunctionComponent = ( return <>; }; - if (isLoading) { return ; } diff --git a/Worker/Routes.ts b/Worker/Routes.ts index a3418beb7e0..9b9d81e287c 100644 --- a/Worker/Routes.ts +++ b/Worker/Routes.ts @@ -64,7 +64,7 @@ import "./Jobs/StatusPageOwners/SendCreatedResourceNotification"; import "./Jobs/StatusPageOwners/SendOwnerAddedNotification"; // Status Page Reports -// import "./Jobs/StatusPage/SendReportsToSubscribers"; +import "./Jobs/StatusPage/SendReportsToSubscribers"; // Telemetry Service import "./Jobs/TelemetryService/DeleteOldData";