From dcd03d8a3f94505c53e667a4b967a29b698c5728 Mon Sep 17 00:00:00 2001 From: Ernst Widerberg Date: Wed, 30 Mar 2022 12:53:34 +0200 Subject: Merge redesign (refs/archive/redesign-2022-03-30) --- src/components/ScanView.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/components/ScanView.js (limited to 'src/components/ScanView.js') diff --git a/src/components/ScanView.js b/src/components/ScanView.js new file mode 100644 index 0000000..aefd287 --- /dev/null +++ b/src/components/ScanView.js @@ -0,0 +1,55 @@ +import React from "react"; + +import ScanDetail from "./ScanDetail"; + +class ScanView extends React.Component { + constructor(props) { + super(props); + this.state = { + object: null + }; + + this.getData = this.getData.bind(this); + } + + componentDidMount() { + this.getData(); + } + + getData() { + fetch( + `${window.injectedEnv.COLLECTOR_URL}/sc/v0/get/${this.props.id}`, + { + headers: { + Authorization: "Bearer " + this.props.token + } + } + ) + // TODO: Look at `status` or return code or both? + .then(resp => { + if (resp.status !== 200) + throw new Error( + `Unexpected HTTP response code from soc_collector: ${resp.status} ${resp.statusText}` + ); + return resp.json(); + }) + .then(json => { + if (json.status != "success") + throw new Error( + `Unexpected status from soc_collector: ${json.status}` + ); + this.setState({ + object: json.docs + }); + }) + .catch(e => this.props.setError(e)); + } + + render() { + return this.state.object === null ? null : ( + + ); + } +} + +export default ScanView; -- cgit v1.1