diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/ListItem.js | 6 | ||||
-rw-r--r-- | src/components/ListView.js | 19 | ||||
-rw-r--r-- | src/components/ScanDetail.js | 7 | ||||
-rw-r--r-- | src/components/ScanView.js | 7 |
4 files changed, 24 insertions, 15 deletions
diff --git a/src/components/ListItem.js b/src/components/ListItem.js index dcafe24..43a5513 100644 --- a/src/components/ListItem.js +++ b/src/components/ListItem.js @@ -3,6 +3,8 @@ import React from "react"; import Button from "@mui/material/Button"; import Card from "@mui/material/Card"; +import dateFormat from "dateformat"; + import { resultClassName } from "../util"; class ListItem extends React.Component { @@ -20,7 +22,9 @@ class ListItem extends React.Component { }} onClick={() => (window.location = `/${this.props._id}`)} > - <td>{this.props.timestamp_in_utc}</td> + <td> + {dateFormat(this.props.timestamp_in_utc, "isoUtcDateTime")} + </td> <td> {this.props.ip}:{this.props.port} </td> diff --git a/src/components/ListView.js b/src/components/ListView.js index 811f075..409c802 100644 --- a/src/components/ListView.js +++ b/src/components/ListView.js @@ -79,7 +79,12 @@ class ListView extends React.Component { `Unexpected status from soc_collector: ${json.status}` ); this.setState({ - scans: json.docs + scans: json.docs.map(d => ({ + ...d, + timestamp_in_utc: new Date( + d.timestamp_in_utc.replace(/ UTC$/, "Z") + ) + })) }); }) .catch(e => this.props.setError(e)); @@ -122,17 +127,7 @@ class ListView extends React.Component { <tbody> {this.state.scans .sort((a, b) => - Date.parse( - a.timestamp_in_utc.replace(" UTC", "") > - Date.parse( - b.timestamp_in_utc.replace( - " UTC", - "" - ) - ) - ) - ? 1 - : -1 + a.timestamp_in_utc > b.timestamp_in_utc ? 1 : -1 ) .map(scan => Object.entries(scan.result) diff --git a/src/components/ScanDetail.js b/src/components/ScanDetail.js index 9cf4740..c489397 100644 --- a/src/components/ScanDetail.js +++ b/src/components/ScanDetail.js @@ -7,6 +7,8 @@ import Tooltip from "@mui/material/Tooltip"; import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined"; +import dateFormat from "dateformat"; + import { resultClassName } from "../util"; class ScanDetail extends React.Component { @@ -65,7 +67,10 @@ class ScanDetail extends React.Component { > <div> Latest scan: - {this.props.timestamp_in_utc} + {dateFormat( + this.props.timestamp_in_utc, + "isoUtcDateTime" + )} </div> <div> <Button variant="contained">Re-scan</Button> diff --git a/src/components/ScanView.js b/src/components/ScanView.js index aefd287..9fe57d7 100644 --- a/src/components/ScanView.js +++ b/src/components/ScanView.js @@ -39,7 +39,12 @@ class ScanView extends React.Component { `Unexpected status from soc_collector: ${json.status}` ); this.setState({ - object: json.docs + object: { + ...json.docs, + timestamp_in_utc: new Date( + json.docs.timestamp_in_utc.replace(/ UTC$/, "Z") + ) + } }); }) .catch(e => this.props.setError(e)); |