Skip to content

Commit

Permalink
add history days in status page
Browse files Browse the repository at this point in the history
  • Loading branch information
simlarsen committed May 19, 2023
1 parent f67e3a5 commit 7ec5e50
Show file tree
Hide file tree
Showing 9 changed files with 319 additions and 47 deletions.
21 changes: 15 additions & 6 deletions CommonServer/API/StatusPageAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,7 @@ export default class StatusPageAPI extends BaseAPI<
select: {
_id: true,
projectId: true,
showScheduledEventHistoryInDays: true,
},
props: {
isRoot: true,
Expand Down Expand Up @@ -1236,10 +1237,12 @@ export default class StatusPageAPI extends BaseAPI<

// check if status page has active scheduled events.
const today: Date = OneUptimeDate.getCurrentDate();
const last14Days: Date = OneUptimeDate.getSomeDaysAgo(14);
const historyDays: Date = OneUptimeDate.getSomeDaysAgo(
statusPage.showScheduledEventHistoryInDays || 14
);

let query: Query<ScheduledMaintenance> = {
startsAt: QueryHelper.inBetween(last14Days, today),
startsAt: QueryHelper.inBetween(historyDays, today),
statusPages: [statusPageId] as any,
projectId: statusPage.projectId!,
};
Expand Down Expand Up @@ -1441,6 +1444,7 @@ export default class StatusPageAPI extends BaseAPI<
select: {
_id: true,
projectId: true,
showAnnouncementHistoryInDays: true,
},
props: {
isRoot: true,
Expand All @@ -1455,11 +1459,13 @@ export default class StatusPageAPI extends BaseAPI<
// check if status page has actuve announcement.

const today: Date = OneUptimeDate.getCurrentDate();
const last14Days: Date = OneUptimeDate.getSomeDaysAgo(14);
const historyDays: Date = OneUptimeDate.getSomeDaysAgo(
statusPage.showAnnouncementHistoryInDays || 14
);

let query: Query<StatusPageAnnouncement> = {
statusPages: [statusPageId] as any,
showAnnouncementAt: QueryHelper.inBetween(last14Days, today),
showAnnouncementAt: QueryHelper.inBetween(historyDays, today),
projectId: statusPage.projectId!,
};

Expand Down Expand Up @@ -1549,6 +1555,7 @@ export default class StatusPageAPI extends BaseAPI<
select: {
_id: true,
projectId: true,
showIncidentHistoryInDays: true,
},
props: {
isRoot: true,
Expand Down Expand Up @@ -1594,12 +1601,14 @@ export default class StatusPageAPI extends BaseAPI<
);

const today: Date = OneUptimeDate.getCurrentDate();
const last14Days: Date = OneUptimeDate.getSomeDaysAgo(14);
const historyDays: Date = OneUptimeDate.getSomeDaysAgo(
statusPage.showIncidentHistoryInDays || 14
);

let incidentQuery: Query<Incident> = {
monitors: monitorsOnStatusPage as any,
projectId: statusPage.projectId!,
createdAt: QueryHelper.inBetween(last14Days, today),
createdAt: QueryHelper.inBetween(historyDays, today),
};

if (incidentId) {
Expand Down
19 changes: 19 additions & 0 deletions Dashboard/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import StatusPageViewPrivateUser from './Pages/StatusPages/View/PrivateUser';
import StatusPageViewOwners from './Pages/StatusPages/View/Owners';
import StatusPageViewAuthenticationSettings from './Pages/StatusPages/View/AuthenticationSettings';
import StatusPageViewCustomSMTP from './Pages/StatusPages/View/CustomSMTP';
import StatusPageViewSettings from './Pages/StatusPages/View/StatusPageSettings';

import Incidents from './Pages/Incidents/Incidents';
import IncidentView from './Pages/Incidents/View/Index';
Expand Down Expand Up @@ -847,6 +848,24 @@ const App: FunctionComponent = () => {
}
/>

<PageRoute
path={
RouteMap[
PageMap.STATUS_PAGE_VIEW_SETTINGS
]?.toString() || ''
}
element={
<StatusPageViewSettings
{...commonPageProps}
pageRoute={
RouteMap[
PageMap.STATUS_PAGE_VIEW_SETTINGS
] as Route
}
/>
}
/>

<PageRoute
path={
RouteMap[
Expand Down
13 changes: 13 additions & 0 deletions Dashboard/src/Pages/StatusPages/View/SideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,19 @@ const DashboardSideMenu: FunctionComponent<ComponentProps> = (
icon={IconProp.TableCells}
/>

<SideMenuItem
link={{
title: 'Advanced Settings',
to: RouteUtil.populateRouteParams(
RouteMap[
PageMap.STATUS_PAGE_VIEW_SETTINGS
] as Route,
props.modelId
),
}}
icon={IconProp.Settings}
/>

<SideMenuItem
link={{
title: 'Delete Status Page',
Expand Down
133 changes: 133 additions & 0 deletions Dashboard/src/Pages/StatusPages/View/StatusPageSettings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import Route from 'Common/Types/API/Route';
import ModelPage from 'CommonUI/src/Components/Page/ModelPage';
import React, { FunctionComponent, ReactElement } from 'react';
import PageMap from '../../../Utils/PageMap';
import RouteMap, { RouteUtil } from '../../../Utils/RouteMap';
import PageComponentProps from '../../PageComponentProps';
import SideMenu from './SideMenu';
import ObjectID from 'Common/Types/ObjectID';
import StatusPage from 'Model/Models/StatusPage';
import CardModelDetail from 'CommonUI/src/Components/ModelDetail/CardModelDetail';
import IconProp from 'Common/Types/Icon/IconProp';
import FormFieldSchemaType from 'CommonUI/src/Components/Forms/Types/FormFieldSchemaType';
import FieldType from 'CommonUI/src/Components/Types/FieldType';
import Navigation from 'CommonUI/src/Utils/Navigation';

const StatusPageDelete: FunctionComponent<PageComponentProps> = (
_props: PageComponentProps
): ReactElement => {
const modelId: ObjectID = Navigation.getLastParamAsObjectID(1);

return (
<ModelPage
title="Status Page"
modelType={StatusPage}
modelId={modelId}
modelNameField="name"
breadcrumbLinks={[
{
title: 'Project',
to: RouteUtil.populateRouteParams(
RouteMap[PageMap.HOME] as Route,
modelId
),
},
{
title: 'Status Pages',
to: RouteUtil.populateRouteParams(
RouteMap[PageMap.STATUS_PAGES] as Route,
modelId
),
},
{
title: 'View Status Page',
to: RouteUtil.populateRouteParams(
RouteMap[PageMap.STATUS_PAGE_VIEW] as Route,
modelId
),
},
{
title: 'Settings',
to: RouteUtil.populateRouteParams(
RouteMap[
PageMap.STATUS_PAGE_VIEW_AUTHENTICATION_SETTINGS
] as Route,
modelId
),
},
]}
sideMenu={<SideMenu modelId={modelId} />}
>
<CardModelDetail<StatusPage>
name="Status Page > Settings"
cardProps={{
title: 'Status Page Settings',
description: 'Settings for this status page.',
icon: IconProp.Settings,
}}
editButtonText="Edit Settings"
isEditable={true}
formFields={[
{
field: {
showIncidentHistoryInDays: true,
},
title: 'Show Incident History (in days)',
fieldType: FormFieldSchemaType.Number,
required: true,
placeholder: '14',
},
{
field: {
showAnnouncementHistoryInDays: true,
},
title: 'Show Announcement History (in days)',
fieldType: FormFieldSchemaType.Number,
required: true,
placeholder: '14',
},
{
field: {
showScheduledEventHistoryInDays: true,
},
title: 'Show Scheduled Event History (in days)',
fieldType: FormFieldSchemaType.Number,
required: true,
placeholder: '14',
},
]}
modelDetailProps={{
showDetailsInNumberOfColumns: 1,
modelType: StatusPage,
id: 'model-detail-status-page',
fields: [
{
field: {
showIncidentHistoryInDays: true,
},
fieldType: FieldType.Number,
title: 'Show Incident History (in days)',
},
{
field: {
showAnnouncementHistoryInDays: true,
},
fieldType: FieldType.Number,
title: 'Show Announcement History (in days)',
},
{
field: {
showScheduledEventHistoryInDays: true,
},
fieldType: FieldType.Number,
title: 'Show Scheduled Event History (in days)',
},
],
modelId: modelId,
}}
/>
</ModelPage>
);
};

export default StatusPageDelete;
1 change: 1 addition & 0 deletions Dashboard/src/Utils/PageMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ enum PageMap {
STATUS_PAGE_VIEW_SSO = 'STATUS_PAGE_VIEW_SSO',
STATUS_PAGE_VIEW_CUSTOM_SMTP = 'STATUS_PAGE_VIEW_CUSTOM_SMTP',
STATUS_PAGE_VIEW_OWNERS = 'STATUS_PAGE_VIEW_OWNERS',
STATUS_PAGE_VIEW_SETTINGS = 'STATUS_PAGE_VIEW_SETTINGS',

LOGS = 'LOGS',
ON_CALL_DUTY = 'ON_CALL_DUTY',
Expand Down
4 changes: 4 additions & 0 deletions Dashboard/src/Utils/RouteMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ const RouteMap: Dictionary<Route> = {
`/dashboard/${RouteParams.ProjectID}/status-pages/${RouteParams.ModelID}/authentication-settings`
),

[PageMap.STATUS_PAGE_VIEW_SETTINGS]: new Route(
`/dashboard/${RouteParams.ProjectID}/status-pages/${RouteParams.ModelID}/settings`
),

[PageMap.LOGS]: new Route(`/dashboard/${RouteParams.ProjectID}/logs/`),

[PageMap.MONITORS]: new Route(
Expand Down
Loading

0 comments on commit 7ec5e50

Please sign in to comment.