diff options
author | 2021-08-09 14:19:33 +0100 | |
---|---|---|
committer | 2021-08-11 14:18:58 +0100 | |
commit | 706b284cb8091ef00bc352bc5ee32f4fdca1162a (patch) | |
tree | b7eb30cc36c9f0dc75c24784d71faeb992ace429 /gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.js | |
parent | bdc4cc9d4a75bfdd2f5656f102d2f6ac7817e4ef (diff) |
Add error handling and refactoring
Added error for when common or instance props can't be retrieved
Added error for monitoring when control loops can't be retrieved
Made node templates collapsed by default when editing properties
Added single service function to get common or instance properties
Issue-ID: POLICY-3439
Change-Id: I74560a06aae1a820862f977d5e7ac86597a093c0
Signed-off-by: saul.gill <saul.gill@est.tech>
Diffstat (limited to 'gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.js')
-rw-r--r-- | gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.js | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.js index 47de20c..6c589b8 100644 --- a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.js +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.js @@ -24,22 +24,36 @@ import Button from "react-bootstrap/Button"; import InstantiationItem from "./InstantiationItem"; import ControlLoopService from "../../../api/ControlLoopService"; import InstantiationElements from "./InstantiationElements"; +import { Alert } from "react-bootstrap"; const ModalStyled = styled(Modal)` background-color: transparent; ` +const AlertStyled = styled(Alert)` + margin-top: 10px; +` const MonitorInstantiation = (props) => { const [show, setShow] = useState(true); const [controlLoopList, setControlLoopList] = useState([]); const [windowLocationPathname, setWindowLocationPathname] = useState(''); + const [controlLoopInstantiationOk, setControlLoopInstantiationOk] = useState(true); + const [controlLoopInstantiationError, setControlLoopInstantiationError] = useState({}); - useEffect(() => { + useEffect(async () => { setWindowLocationPathname(window.location.pathname); - ControlLoopService.getControlLoopInstantiation(windowLocationPathname).then(controlLoopList => { - setControlLoopList(controlLoopList['controlLoopList']); - }); + const controlLoopInstantiation = await ControlLoopService.getControlLoopInstantiation(windowLocationPathname) + .catch(error => error.message); + + const controlLoopInstantiationJson = await controlLoopInstantiation.json() + console.log(controlLoopInstantiationJson) + if (!controlLoopInstantiation.ok || controlLoopInstantiationJson['controlLoopList'].length === 0) { + setControlLoopInstantiationOk(false) + setControlLoopInstantiationError(controlLoopInstantiationJson) + } else { + setControlLoopList(controlLoopInstantiationJson[['controlLoopList']]) + } }, []) const handleClose = () => { @@ -61,6 +75,8 @@ const MonitorInstantiation = (props) => { </InstantiationItem> )) } + <AlertStyled show={ !controlLoopInstantiationOk } + variant="danger">Can't get control loop instantiation info:<br/>{ JSON.stringify(controlLoopInstantiationError, null, 2) }</AlertStyled> </Modal.Body> <Modal.Footer> <Button variant="secondary" type="null" onClick={ handleClose }>Close</Button> |