diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 0473e0c..27d637d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,12 +2,10 @@ + + - - - - @@ -69,7 +68,8 @@ - + + diff --git a/src/App.tsx b/src/App.tsx index 679d8e3..d56d704 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,16 +5,13 @@ import 'bootstrap/dist/css/bootstrap.min.css'; import {Incident, UptimeResponse} from "./nws-api/types"; import {getIncidents, getUptime} from "./nws-api/calls"; import ReactTooltip from 'react-tooltip'; +import UptimeCard from "./components/UptimeCard"; +import IncidentCard from "./components/IncidentCard"; function App() { const [uptime, setUptime] = useState({datacenters: [], services:[], lastUpdated: ""}); const [incidents, setIncidents] = useState([]); - const severityText: string[] = [ - "Low Severity means that this issue does not affect any services running on NWS.", - "Medium Severity means that this issue may cause some slowdowns or outages on some services.", - "High Severity means that this issue causes an outage on the entire NWS network or most of the services running on it." - ]; const fetchUptime = async () => { let resp: UptimeResponse = await getUptime(); @@ -55,32 +52,13 @@ function App() {
-

NWS System Status

Last updated at {new Date(uptime.lastUpdated).toLocaleString()}

Service Status

{uptime.services.map((e) => { return ( -
-

{e.name}

-
-

- {e.isUp ? 'Up' : (e.undergoingMaintenance ? 'Maintenance' : 'Down')} -

-
-
-

- {e.isUp ? 'Up' : (e.undergoingMaintenance ? 'Maintenance' : 'Down')} -

-
-

Last Month Uptime: {e.uptimeMonth}%

-

All Time Uptime: {e.uptimeAllTime}%

-
+ ); })}
@@ -88,29 +66,10 @@ function App() {

Datacenter Status

{uptime.datacenters.map((e) => { return ( -
-

{e.name}

-
-

- {e.isUp ? 'Up' : (e.undergoingMaintenance ? 'Maintenance' : 'Down')} -

-
-
-

- {e.isUp ? 'Up' : (e.undergoingMaintenance ? 'Maintenance' : 'Down')} -

-
-

Last Month Uptime: {e.uptimeMonth}%

-

All Time Uptime: {e.uptimeAllTime}%

-
+ ); })}
-
@@ -119,20 +78,8 @@ function App() {

Service Alerts

{incidents.map((e) => { - let severityClass: string = e.severity == 0 ? 'low' : (e.severity == 1 ? 'med' : 'high'); - let severityString: string = e.severity == 0 ? 'Low' : (e.severity == 1 ? 'Medium' : 'High'); return ( -
-

{e.title}

-
- - {severityString} Severity ⓘ - - -
-

{e.description}

-
+ ); })} {incidents.length == 0 &&
diff --git a/src/components/IncidentCard.tsx b/src/components/IncidentCard.tsx new file mode 100644 index 0000000..e33f8ae --- /dev/null +++ b/src/components/IncidentCard.tsx @@ -0,0 +1,30 @@ +import {Incident} from "../nws-api/types"; +import ReactTooltip from "react-tooltip"; +import React from "react"; + +export default function IncidentCard(props: {incident: Incident}) { + + const severityText: string[] = [ + "Low Severity means that this issue does not affect any services running on NWS.", + "Medium Severity means that this issue may cause some slowdowns or outages on some services.", + "High Severity means that this issue causes an outage on the entire NWS network or most of the services running on it." + ]; + let severityClass: string = props.incident.severity == 0 ? 'low' : (props.incident.severity == 1 ? 'med' : 'high'); + let severityString: string = props.incident.severity == 0 ? 'Low' : (props.incident.severity == 1 ? 'Medium' : 'High'); + + return ( +
+

{props.incident.title}

+
+
+ + {severityString} Severity ⓘ + + +
+
+

{props.incident.description}

+
+ ); +} diff --git a/src/components/UptimeCard.tsx b/src/components/UptimeCard.tsx new file mode 100644 index 0000000..e3a7062 --- /dev/null +++ b/src/components/UptimeCard.tsx @@ -0,0 +1,29 @@ +import {UptimeRecord} from "../nws-api/types"; +import React from "react"; +import '../App.css'; + +export default function UptimeCard(props: {uptime: UptimeRecord}) { + return( +
+ {props.uptime.url != null &&

{props.uptime.name}

} + {props.uptime.url == null &&

{props.uptime.name}

} + +
+

+ {props.uptime.isUp ? 'Up' : (props.uptime.undergoingMaintenance ? 'Maintenance' : 'Down')} +

+
+
+

+ {props.uptime.isUp ? 'Up' : (props.uptime.undergoingMaintenance ? 'Maintenance' : 'Down')} +

+
+

Last Month Uptime: {props.uptime.uptimeMonth}%

+

All Time Uptime: {props.uptime.uptimeAllTime}%

+
+ ); +}