add resources affected.

This commit is contained in:
Simon Larsen
2022-12-15 16:38:42 +05:30
parent 903a206ed0
commit 5871154d6c
9 changed files with 52 additions and 14 deletions

View File

@@ -316,10 +316,10 @@ export default class OneUptimeDate {
date: string | Date,
onlyShowDate?: boolean
): string {
let formatstring: string = 'MMMM Do YYYY, HH:mm';
let formatstring: string = 'MMM DD YYYY, HH:mm';
if (onlyShowDate) {
formatstring = 'MMMM Do YYYY';
formatstring = 'MMM DD, YYYY';
}
return moment(date).format(formatstring);
@@ -329,10 +329,10 @@ export default class OneUptimeDate {
date: string | Date,
onlyShowDate?: boolean
): string {
let formatstring: string = 'MMMM Do YYYY, HH:mm';
let formatstring: string = 'MMM DD YYYY, HH:mm';
if (onlyShowDate) {
formatstring = 'MMMM Do YYYY';
formatstring = 'MMM DD, YYYY';
}
const momentDate: moment.Moment = moment(date).local();

View File

@@ -8,6 +8,7 @@ export interface ComponentProps {
cardTitleRight?: string | undefined;
cardColor: Color;
eventTitle: string;
eventResourcesAffected?: Array<string> | undefined,
eventDescription?: string | undefined;
eventMiniDescription?: string | undefined;
eventTimeline: Array<TimelineItem>;

View File

@@ -23,10 +23,10 @@ const EventHistoryDayList: FunctionComponent<ComponentProps> = (
borderBottomWidth: props.isLastItem ? '0px' : '1px',
}}
>
<div style={{ padding: '20px', paddingRight: '0px' }}>
<div style={{ padding: '20px', paddingRight: '0px', width: "15%" }}>
{OneUptimeDate.getDateAsLocalFormattedString(props.date, true)}
</div>
<div style={{ padding: '10px', paddingTop: '0px' }}>
<div style={{ padding: '10px', paddingTop: '0px', width: "85%" }}>
{props.items.map((item: ItemComponentProps, i: number) => {
return <EventHistoryItem key={i} {...item} />;
})}

View File

@@ -4,13 +4,15 @@ import OneUptimeDate from 'Common/Types/Date';
import React, { FunctionComponent, ReactElement } from 'react';
import Link from '../Link/Link';
import URL from 'Common/Types/API/URL';
export interface TimelineItem {
date: Date;
text: string;
text: string | ReactElement;
isBold?: boolean | undefined;
}
export interface ComponentProps {
eventTitle: string;
eventResourcesAffected?: Array<string> | undefined,
eventDescription?: string | undefined;
eventTimeline: Array<TimelineItem>;
eventMiniDescription?: string | undefined;
@@ -47,11 +49,27 @@ const EventItem: FunctionComponent<ComponentProps> = (
className="active-event-box-body"
style={{ marginTop: '0px', paddingTop: '0px' }}
>
{props.eventResourcesAffected && props.eventResourcesAffected?.length > 0 ? <div
key={0}
className="active-event-box-body-description"
>
{' '}
<span
style={{
fontWeight: 400,
}}
>
<b>Resources Affected</b> - {props.eventResourcesAffected?.join(",")}
</span>{' '}
</div> : <></>}
{props.eventTimeline &&
props.eventTimeline.map((item: TimelineItem, i: number) => {
return (
<div
key={i}
key={i+1}
className="active-event-box-body-description"
>
{' '}
@@ -60,7 +78,7 @@ const EventItem: FunctionComponent<ComponentProps> = (
fontWeight: item.isBold ? 500 : 400,
}}
>
{item.text || ''}
{item.text}
</span>{' '}
<span className="color-grey">
{' '}

View File

@@ -112,11 +112,10 @@ export default class Incident extends BaseModel {
read: [Permission.ProjectOwner, Permission.CanReadProjectIncident],
update: [Permission.ProjectOwner, Permission.CanEditProjectIncident],
})
@TableColumn({ required: false, type: TableColumnType.LongText })
@TableColumn({ required: false, type: TableColumnType.Description })
@Column({
nullable: true,
type: ColumnType.LongText,
length: ColumnLength.LongText,
type: ColumnType.VeryLongText,
})
public description?: string = undefined;

View File

@@ -209,7 +209,10 @@ const Overview: FunctionComponent<PageComponentProps> = (
return (
<Page>
{incidents && incidents.length > 0 ? <h3>Incidents</h3> : <></>}
{incidents && incidents.length > 0 ? <div>
<h4>Incidents</h4>
<p>Here is the incident history for all the resources on this status page.</p>
</div> : <></>}
{incidents && incidents.length > 0 ? <EventHistoryList {...parsedData} /> : <></>}
{incidents.length === 0 ? (
<ErrorMessage

View File

@@ -337,9 +337,14 @@ const Overview: FunctionComponent<PageComponentProps> = (
throw new BadDataException('Incident Timeline not found.');
}
const monitorIds = activeIncident.monitors?.map((monitor) => monitor._id) || [];
const namesOfResources = statusPageResources.filter((resource) => monitorIds.includes(resource.monitorId?.toString()));
const group: IncidentGroup = {
incident: activeIncident,
incidentState: activeIncident.currentIncidentState,
incidentResources: namesOfResources,
publicNote: incidentPublicNotes.find(
(publicNote: IncidentPublicNote) => {
return (
@@ -383,10 +388,15 @@ const Overview: FunctionComponent<PageComponentProps> = (
throw new BadDataException('Incident Timeline not found.');
}
const monitorIds = activeEvent.monitors?.map((monitor) => monitor._id) || [];
const namesOfResources = statusPageResources.filter((resource) => monitorIds.includes(resource.monitorId?.toString()));
const group: ScheduledMaintenanceGroup = {
scheduledMaintenance: activeEvent,
scheduledMaintenanceState:
activeEvent.currentScheduledMaintenanceState,
scheduledEventResources: namesOfResources,
publicNote: scheduledMaintenanceEventsPublicNotes.find(
(publicNote: ScheduledMaintenancePublicNote) => {
return (
@@ -499,7 +509,7 @@ const Overview: FunctionComponent<PageComponentProps> = (
if (incidentGroup.publicNote) {
timeline.push({
text: incidentGroup.publicNote?.note || '',
text: (<span><b>Update</b> - {incidentGroup.publicNote?.note}</span>),
date: incidentGroup.publicNote?.createdAt!,
isBold: false,
});
@@ -562,6 +572,7 @@ const Overview: FunctionComponent<PageComponentProps> = (
incidentGroup.incidentSeverity.color ||
Red
}
eventResourcesAffected={incidentGroup.incidentResources.map((i)=> i.displayName?.toString() || '') || []}
eventTitle={
incidentGroup.incident.title || ''
}
@@ -613,6 +624,8 @@ const Overview: FunctionComponent<PageComponentProps> = (
eventTimeline={getScheduledEventGroupEventTimeline(
scheduledEventGroup
)}
eventResourcesAffected={scheduledEventGroup.scheduledEventResources.map((i)=> i.displayName?.toString() || '') || []}
footerDateTime={
scheduledEventGroup.scheduledMaintenance
.endsAt!

View File

@@ -3,6 +3,7 @@ import IncidentPublicNote from 'Model/Models/IncidentPublicNote';
import IncidentSeverity from 'Model/Models/IncidentSeverity';
import IncidentState from 'Model/Models/IncidentState';
import IncidentStateTimeline from 'Model/Models/IncidentStateTimeline';
import StatusPageResource from 'Model/Models/StatusPageResource';
export default interface IncidentGroup {
incident: Incident;
@@ -10,4 +11,5 @@ export default interface IncidentGroup {
publicNote?: IncidentPublicNote | undefined | null;
incidentState: IncidentState;
incidentStateTimeline: IncidentStateTimeline;
incidentResources: Array<StatusPageResource>
}

View File

@@ -2,10 +2,12 @@ import ScheduledMaintenance from 'Model/Models/ScheduledMaintenance';
import ScheduledMaintenancePublicNote from 'Model/Models/ScheduledMaintenancePublicNote';
import ScheduledMaintenanceState from 'Model/Models/ScheduledMaintenanceState';
import ScheduledMaintenanceStateTimeline from 'Model/Models/ScheduledMaintenanceStateTimeline';
import StatusPageResource from 'Model/Models/StatusPageResource';
export default interface ScheduledMaintenanceGroup {
scheduledMaintenance: ScheduledMaintenance;
publicNote?: ScheduledMaintenancePublicNote | undefined | null;
scheduledMaintenanceState: ScheduledMaintenanceState;
scheduledMaintenanceStateTimeline: ScheduledMaintenanceStateTimeline;
scheduledEventResources: Array<StatusPageResource>
}