From a628c050adf15ac6d4f0c1939856913e9ad3ba58 Mon Sep 17 00:00:00 2001 From: Ernst Widerberg Date: Mon, 25 Apr 2022 15:15:31 +0200 Subject: ScanView: Move object.* to state root --- src/components/ScanView.js | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/components/ScanView.js b/src/components/ScanView.js index d12874b..ce4901b 100644 --- a/src/components/ScanView.js +++ b/src/components/ScanView.js @@ -16,7 +16,7 @@ class ScanView extends React.Component { constructor(props) { super(props); this.state = { - object: null, + loaded: false, rescanInProgress: false }; @@ -46,12 +46,11 @@ class ScanView extends React.Component { }) .then(json => { this.setState({ - object: { - ...json.docs, - timestamp_in_utc: new Date( - json.docs.timestamp_in_utc.replace(/ UTC$/, "Z") - ) - } + loaded: true, + ...json.docs, + timestamp_in_utc: new Date( + json.docs.timestamp_in_utc.replace(/ UTC$/, "Z") + ) }); }) .catch(e => this.props.setError(e)); @@ -64,19 +63,17 @@ class ScanView extends React.Component { () => this.setState(prevState => ({ rescanInProgress: false, - object: { ...prevState.object, timestamp_in_utc: Date.now() } + timestamp_in_utc: Date.now() })), 2000 ); } render() { - return this.state.object === null ? null : ( + return this.state.loaded && (
- - #{this.state.object._id} - + #{this.state._id}

General info

@@ -84,42 +81,40 @@ class ScanView extends React.Component { Domain - {this.state.object.domain} + {this.state.domain} Endpoint - {`${this.state.object.ip}:${this.props.port}`} + {`${this.state.ip}:${this.props.port}`} Hostname - {this.state.object.ptr} + {this.state.ptr} Owner - {this.state.object.whois_description} + {this.state.whois_description} ASN - {`${this.state.object.asn} (${this.props.asn_country_code})`} + {`${this.state.asn} (${this.props.asn_country_code})`} Abuse mail - {this.state.object.abuse_mail} + {this.state.abuse_mail} - {this.state.object.description && ( + {this.state.description && ( <>
- - {this.state.object.description} - + {this.state.description} )}

Custom info

- +

Latest scan:     {dateFormat( - this.state.object.timestamp_in_utc, + this.state.timestamp_in_utc, "isoUtcDateTime" )} @@ -155,7 +150,7 @@ class ScanView extends React.Component {

- {Object.entries(this.state.object.result) + {Object.entries(this.state.result) // Sort by vulnerable, investigation_needed, reliability, name .sort((a, b) => a[1].display_name > b[1].display_name ? -1 : 1 -- cgit v1.1