Просмотр исходного кода

convert event timestamp to milliseconds

jnfrati 4 лет назад
Родитель
Сommit
83b5288827

+ 20 - 2
dashboard/src/main/home/cluster-dashboard/dashboard/incidents/IncidentPage.tsx

@@ -42,9 +42,17 @@ const IncidentPage = () => {
         }
       )
       .then((res) => {
-        if (isSubscribed) {
-          setIncident(res.data);
+        if (!isSubscribed) {
+          return;
         }
+
+        let incident = res.data;
+
+        incident.events = convertEventsTimestampsToMilliseconds(
+          incident.events
+        );
+
+        setIncident(incident);
       });
 
     return () => {
@@ -140,6 +148,16 @@ const IncidentPage = () => {
 
 export default IncidentPage;
 
+const convertEventsTimestampsToMilliseconds = (events: IncidentEvent[]) => {
+  return events.map((e) => {
+    let newEvent = e;
+
+    newEvent.timestamp = newEvent.timestamp * 1000;
+
+    return newEvent;
+  });
+};
+
 const groupEventsByDate = (
   events: IncidentEvent[]
 ): { [key: string]: IncidentEvent[] } => {