sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 1 | /*- |
| 2 | * ============LICENSE_START======================================================= |
| 3 | * ONAP CLAMP |
| 4 | * ================================================================================ |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 5 | * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 6 | * reserved. |
| 7 | * ================================================================================ |
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | * you may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | * |
| 14 | * Unless required by applicable law or agreed to in writing, software |
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | * See the License for the specific language governing permissions and |
| 18 | * limitations under the License. |
| 19 | * ============LICENSE_END============================================ |
| 20 | * =================================================================== |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | import React from 'react'; |
| 25 | import styled from 'styled-components'; |
sebdet | e44fdb1 | 2019-07-12 12:25:56 +0200 | [diff] [blame] | 26 | import MenuBar from './components/menu/MenuBar'; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 27 | import Navbar from 'react-bootstrap/Navbar'; |
| 28 | import logo from './logo.png'; |
sebdet | e44fdb1 | 2019-07-12 12:25:56 +0200 | [diff] [blame] | 29 | import { GlobalClampStyle } from './theme/globalStyle.js'; |
Ted Humphrey | 01e5fde | 2020-01-27 18:57:39 -0500 | [diff] [blame] | 30 | import OnapConstants from './utils/OnapConstants'; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 31 | |
sebdet | c0ec0fc | 2020-05-18 12:31:11 +0200 | [diff] [blame] | 32 | import SvgGenerator from './components/loop_viewer/svg/SvgGenerator'; |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame] | 33 | import LoopLogs from './components/loop_viewer/logs/LoopLogs'; |
| 34 | import LoopStatus from './components/loop_viewer/status/LoopStatus'; |
sebdet | e44fdb1 | 2019-07-12 12:25:56 +0200 | [diff] [blame] | 35 | import UserService from './api/UserService'; |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame] | 36 | import LoopCache from './api/LoopCache'; |
xuegao | ac42c4b | 2019-10-09 16:12:37 +0200 | [diff] [blame] | 37 | import LoopActionService from './api/LoopActionService'; |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame] | 38 | |
xuegao | 691e2b7 | 2019-08-16 11:07:24 +0200 | [diff] [blame] | 39 | import { Route } from 'react-router-dom' |
sebdet | d2a4df0 | 2020-02-26 15:47:30 -0800 | [diff] [blame] | 40 | import CreateLoopModal from './components/dialogs/Loop/CreateLoopModal'; |
sebdet | 67c76a4 | 2019-11-15 17:33:44 +0100 | [diff] [blame] | 41 | import OpenLoopModal from './components/dialogs/Loop/OpenLoopModal'; |
sebdet | aa486be | 2020-02-18 02:00:11 -0800 | [diff] [blame] | 42 | import ModifyLoopModal from './components/dialogs/Loop/ModifyLoopModal'; |
sebdet | d2a4df0 | 2020-02-26 15:47:30 -0800 | [diff] [blame] | 43 | import PolicyModal from './components/dialogs/Policy/PolicyModal'; |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 44 | import ViewAllPolicies from './components/dialogs/Policy/ViewAllPolicies'; |
sebdet | b13a790 | 2019-11-15 17:26:45 +0100 | [diff] [blame] | 45 | import LoopPropertiesModal from './components/dialogs/Loop/LoopPropertiesModal'; |
sebdet | 4dc849f | 2019-11-15 17:49:42 +0100 | [diff] [blame] | 46 | import UserInfoModal from './components/dialogs/UserInfoModal'; |
sebdet | 83ce076 | 2019-08-02 14:53:59 +0200 | [diff] [blame] | 47 | import LoopService from './api/LoopService'; |
sebdet | 3b7f669 | 2020-02-17 06:03:31 -0800 | [diff] [blame] | 48 | import ViewLoopTemplatesModal from './components/dialogs/Tosca/ViewLoopTemplatesModal'; |
drveerendra | 5032095 | 2020-03-04 20:30:44 -0500 | [diff] [blame] | 49 | import ManageDictionaries from './components/dialogs/ManageDictionaries/ManageDictionaries'; |
sebdet | f9e2cee | 2019-08-09 18:36:09 +0200 | [diff] [blame] | 50 | import PerformAction from './components/dialogs/PerformActions'; |
| 51 | import RefreshStatus from './components/dialogs/RefreshStatus'; |
sebdet | 2e9ae12 | 2019-11-15 16:28:55 +0100 | [diff] [blame] | 52 | import DeployLoopModal from './components/dialogs/Loop/DeployLoopModal'; |
xuegao | 0efeb6b | 2019-10-07 14:36:34 +0200 | [diff] [blame] | 53 | import Alert from 'react-bootstrap/Alert'; |
Ted Humphrey | 4fb3239 | 2020-07-06 16:59:47 -0400 | [diff] [blame] | 54 | import Spinner from 'react-bootstrap/Spinner'; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 55 | |
sebdet | d0d6563 | 2019-08-26 05:47:01 -0700 | [diff] [blame] | 56 | import { Link } from 'react-router-dom'; |
| 57 | |
| 58 | const StyledMainDiv = styled.div` |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 59 | background-color: ${props => props.theme.backgroundColor}; |
sebdet | d0d6563 | 2019-08-26 05:47:01 -0700 | [diff] [blame] | 60 | ` |
| 61 | |
Ted Humphrey | 4fb3239 | 2020-07-06 16:59:47 -0400 | [diff] [blame] | 62 | const StyledSpinnerDiv = styled.div` |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 63 | justify-content: center !important; |
| 64 | display: flex !important; |
Ted Humphrey | 4fb3239 | 2020-07-06 16:59:47 -0400 | [diff] [blame] | 65 | `; |
| 66 | |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 67 | const ProjectNameStyled = styled.a` |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 68 | vertical-align: middle; |
| 69 | padding-left: 30px; |
| 70 | font-size: 36px; |
| 71 | font-weight: bold; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 72 | ` |
sebdet | d0d6563 | 2019-08-26 05:47:01 -0700 | [diff] [blame] | 73 | |
| 74 | const StyledRouterLink = styled(Link)` |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 75 | color: ${props => props.theme.menuFontColor}; |
| 76 | background-color: ${props => props.theme.backgroundColor}; |
sebdet | d0d6563 | 2019-08-26 05:47:01 -0700 | [diff] [blame] | 77 | ` |
| 78 | |
| 79 | const StyledLoginInfo = styled.a` |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 80 | color: ${props => props.theme.menuFontColor}; |
| 81 | background-color: ${props => props.theme.backgroundColor}; |
sebdet | d0d6563 | 2019-08-26 05:47:01 -0700 | [diff] [blame] | 82 | ` |
| 83 | |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 84 | const LoopViewDivStyled = styled.div` |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 85 | height: 100%; |
| 86 | overflow: hidden; |
| 87 | margin-left: 10px; |
| 88 | margin-right: 10px; |
| 89 | margin-bottom: 10px; |
| 90 | color: ${props => props.theme.loopViewerFontColor}; |
| 91 | background-color: ${props => props.theme.loopViewerBackgroundColor}; |
| 92 | border: 1px solid transparent; |
| 93 | border-color: ${props => props.theme.loopViewerHeaderBackgroundColor}; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 94 | ` |
| 95 | |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 96 | const LoopViewHeaderDivStyled = styled.div` |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 97 | background-color: ${props => props.theme.loopViewerHeaderBackgroundColor}; |
| 98 | padding: 10px 10px; |
| 99 | color: ${props => props.theme.loopViewerHeaderFontColor}; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 100 | ` |
| 101 | |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 102 | const LoopViewBodyDivStyled = styled.div` |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 103 | background-color: ${props => (props.theme.loopViewerBackgroundColor)}; |
| 104 | padding: 10px 10px; |
| 105 | color: ${props => (props.theme.loopViewerHeaderFontColor)}; |
| 106 | height: 95%; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 107 | ` |
| 108 | |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 109 | export default class LoopUI extends React.Component { |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame] | 110 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 111 | state = { |
| 112 | userName: null, |
| 113 | loopName: OnapConstants.defaultLoopName, |
| 114 | loopCache: new LoopCache({}), |
| 115 | showSucAlert: false, |
| 116 | showFailAlert: false, |
| 117 | busyLoadingCount: 0 |
| 118 | }; |
xuegao | 7c7323d | 2019-07-09 11:52:20 +0200 | [diff] [blame] | 119 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 120 | constructor() { |
| 121 | super(); |
| 122 | this.getUser = this.getUser.bind(this); |
| 123 | this.updateLoopCache = this.updateLoopCache.bind(this); |
| 124 | this.loadLoop = this.loadLoop.bind(this); |
| 125 | this.closeLoop = this.closeLoop.bind(this); |
| 126 | this.showSucAlert = this.showSucAlert.bind(this); |
| 127 | this.showFailAlert = this.showFailAlert.bind(this); |
| 128 | this.disableAlert = this.disableAlert.bind(this); |
| 129 | this.setBusyLoading = this.setBusyLoading.bind(this); |
| 130 | this.clearBusyLoading = this.clearBusyLoading.bind(this); |
| 131 | this.isBusyLoading = this.isBusyLoading.bind(this); |
| 132 | this.renderGlobalStyle = this.renderGlobalStyle.bind(this); |
| 133 | this.renderSvg = this.renderSvg.bind(this); |
| 134 | } |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame] | 135 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 136 | componentWillMount() { |
| 137 | this.getUser(); |
| 138 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 139 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 140 | getUser() { |
| 141 | UserService.login().then(user => { |
| 142 | this.setState({ userName: user }) |
| 143 | }); |
| 144 | } |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame] | 145 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 146 | renderMenuNavBar() { |
| 147 | return ( |
| 148 | <MenuBar loopName={this.state.loopName}/> |
| 149 | ); |
| 150 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 151 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 152 | renderUserLoggedNavBar() { |
| 153 | return ( |
| 154 | <Navbar.Text> |
| 155 | <StyledLoginInfo>Signed in as: </StyledLoginInfo> |
| 156 | <StyledRouterLink to="/userInfo">{this.state.userName}</StyledRouterLink> |
| 157 | </Navbar.Text> |
| 158 | ); |
| 159 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 160 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 161 | renderLogoNavBar() { |
| 162 | return ( |
| 163 | <Navbar.Brand> |
| 164 | <img height="50px" width="234px" src={logo} alt="" /> |
| 165 | <ProjectNameStyled>CLAMP</ProjectNameStyled> |
| 166 | </Navbar.Brand> |
| 167 | ); |
| 168 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 169 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 170 | renderAlertBar() { |
| 171 | return ( |
| 172 | <div> |
| 173 | <Alert variant="success" show={this.state.showSucAlert} onClose={this.disableAlert} dismissible> |
| 174 | {this.state.showMessage} |
| 175 | </Alert> |
| 176 | <Alert variant="danger" show={this.state.showFailAlert} onClose={this.disableAlert} dismissible> |
| 177 | {this.state.showMessage} |
| 178 | </Alert> |
| 179 | </div> |
| 180 | ); |
| 181 | } |
xuegao | 0efeb6b | 2019-10-07 14:36:34 +0200 | [diff] [blame] | 182 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 183 | renderNavBar() { |
| 184 | return ( |
| 185 | <Navbar > |
| 186 | {this.renderLogoNavBar()} |
| 187 | <Navbar.Toggle aria-controls="responsive-navbar-nav" /> |
| 188 | {this.renderMenuNavBar()} |
| 189 | {this.renderUserLoggedNavBar()} |
| 190 | </Navbar> |
| 191 | ); |
| 192 | } |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame] | 193 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 194 | renderLoopViewHeader() { |
| 195 | return ( |
| 196 | <LoopViewHeaderDivStyled> |
| 197 | Loop Viewer - {this.state.loopName} - ({this.state.loopCache.getTemplateName()}) |
| 198 | </LoopViewHeaderDivStyled> |
| 199 | ); |
| 200 | } |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame] | 201 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 202 | renderSvg() { |
| 203 | return ( |
| 204 | <SvgGenerator loopCache={this.state.loopCache} clickable={true} generatedFrom={SvgGenerator.GENERATED_FROM_INSTANCE} isBusyLoading={this.isBusyLoading}/> |
| 205 | ) |
| 206 | } |
| 207 | renderLoopViewBody() { |
| 208 | return ( |
| 209 | <LoopViewBodyDivStyled> |
| 210 | {this.renderSvg()} |
| 211 | <LoopStatus loopCache={this.state.loopCache}/> |
| 212 | <LoopLogs loopCache={this.state.loopCache} /> |
| 213 | </LoopViewBodyDivStyled> |
| 214 | ); |
| 215 | } |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame] | 216 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 217 | getLoopCache() { |
| 218 | return this.state.loopCache; |
xuegao | e52d572 | 2019-07-25 15:43:06 +0200 | [diff] [blame] | 219 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 220 | } |
xuegao | 5fe750c | 2019-08-06 13:03:53 +0200 | [diff] [blame] | 221 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 222 | renderLoopViewer() { |
| 223 | return ( |
| 224 | <LoopViewDivStyled> |
| 225 | {this.renderLoopViewHeader()} |
| 226 | {this.renderLoopViewBody()} |
| 227 | </LoopViewDivStyled> |
| 228 | ); |
| 229 | } |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame] | 230 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 231 | updateLoopCache(loopJson) { |
Ted Humphrey | 083e5a2 | 2020-07-08 16:48:40 -0400 | [diff] [blame] | 232 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 233 | // If call with an empty object for loopJson, this is a reset to empty |
| 234 | // from someplace like PerformActions for the case where we are "deleting" |
| 235 | // a Control Loop model. Set the loopName to the default. |
Ted Humphrey | 083e5a2 | 2020-07-08 16:48:40 -0400 | [diff] [blame] | 236 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 237 | if (loopJson === null) { |
| 238 | this.setState({ loopName: OnapConstants.defaultLoopName }); |
| 239 | this.setState({ loopCache: new LoopCache({}) }); |
| 240 | } else { |
| 241 | this.setState({ loopCache: new LoopCache(loopJson) }); |
| 242 | this.setState({ loopName: this.state.loopCache.getLoopName() }); |
| 243 | } |
| 244 | console.info(this.state.loopName+" loop loaded successfully"); |
Ted Humphrey | 083e5a2 | 2020-07-08 16:48:40 -0400 | [diff] [blame] | 245 | } |
xuegao | 5fe750c | 2019-08-06 13:03:53 +0200 | [diff] [blame] | 246 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 247 | showSucAlert(message) { |
| 248 | this.setState ({ showSucAlert: true, showMessage:message }); |
| 249 | } |
xuegao | 0efeb6b | 2019-10-07 14:36:34 +0200 | [diff] [blame] | 250 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 251 | showFailAlert(message) { |
| 252 | this.setState ({ showFailAlert: true, showMessage:message }); |
| 253 | } |
Ted Humphrey | 4fb3239 | 2020-07-06 16:59:47 -0400 | [diff] [blame] | 254 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 255 | disableAlert() { |
| 256 | this.setState ({ showSucAlert: false, showFailAlert: false }); |
| 257 | } |
xuegao | 0efeb6b | 2019-10-07 14:36:34 +0200 | [diff] [blame] | 258 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 259 | loadLoop(loopName) { |
| 260 | this.setBusyLoading(); |
| 261 | LoopService.getLoop(loopName).then(loop => { |
| 262 | console.debug("Updating loopCache"); |
| 263 | LoopActionService.refreshStatus(loopName).then(data => { |
| 264 | this.updateLoopCache(data); |
| 265 | this.clearBusyLoading(); |
| 266 | this.props.history.push('/'); |
| 267 | }) |
| 268 | .catch(error => { |
| 269 | this.updateLoopCache(loop); |
| 270 | this.clearBusyLoading(); |
| 271 | this.props.history.push('/'); |
| 272 | }); |
| 273 | }); |
| 274 | } |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame] | 275 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 276 | setBusyLoading() { |
| 277 | this.setState((state,props) => ({ busyLoadingCount: ++state.busyLoadingCount })); |
| 278 | } |
Ted Humphrey | 4fb3239 | 2020-07-06 16:59:47 -0400 | [diff] [blame] | 279 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 280 | clearBusyLoading() { |
| 281 | this.setState((state,props) => ({ busyLoadingCount: --state.busyLoadingCount })); |
| 282 | } |
Ted Humphrey | 4fb3239 | 2020-07-06 16:59:47 -0400 | [diff] [blame] | 283 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 284 | isBusyLoading() { |
| 285 | if (this.state.busyLoadingCount === 0) { |
| 286 | return false; |
| 287 | } else { |
| 288 | return true; |
| 289 | } |
| 290 | } |
Ted Humphrey | 4fb3239 | 2020-07-06 16:59:47 -0400 | [diff] [blame] | 291 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 292 | closeLoop() { |
| 293 | this.setState({ loopCache: new LoopCache({}), loopName: OnapConstants.defaultLoopName }); |
| 294 | this.props.history.push('/'); |
| 295 | } |
sebdet | 687b8de | 2019-08-26 14:29:11 -0700 | [diff] [blame] | 296 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 297 | renderRoutes() { |
| 298 | return( |
| 299 | <React.Fragment> |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 300 | <Route path="/viewLoopTemplatesModal" render={(routeProps) => (<ViewLoopTemplatesModal {...routeProps} />)} /> |
| 301 | <Route path="/manageDictionaries" render={(routeProps) => (<ManageDictionaries {...routeProps} />)} /> |
| 302 | <Route path="/viewAllPolicies" render={(routeProps) => (<ViewAllPolicies {...routeProps} />)} /> |
| 303 | <Route path="/policyModal/:policyInstanceType/:policyName" render={(routeProps) => (<PolicyModal {...routeProps} |
| 304 | loopCache={this.getLoopCache()} |
| 305 | loadLoopFunction={this.loadLoop}/>)} |
| 306 | /> |
| 307 | <Route path="/createLoop" render={(routeProps) => (<CreateLoopModal {...routeProps} |
| 308 | loadLoopFunction={this.loadLoop} />)} |
| 309 | /> |
| 310 | <Route path="/openLoop" render={(routeProps) => (<OpenLoopModal {...routeProps} |
| 311 | loadLoopFunction={this.loadLoop} />)} |
| 312 | /> |
| 313 | <Route path="/loopProperties" render={(routeProps) => (<LoopPropertiesModal {...routeProps} |
| 314 | loopCache={this.getLoopCache()} |
| 315 | loadLoopFunction={this.loadLoop}/>)} |
| 316 | /> |
| 317 | <Route path="/modifyLoop" render={(routeProps) => (<ModifyLoopModal {...routeProps} |
| 318 | loopCache={this.getLoopCache()} |
| 319 | loadLoopFunction={this.loadLoop}/>)} |
| 320 | /> |
Ted Humphrey | 4fb3239 | 2020-07-06 16:59:47 -0400 | [diff] [blame] | 321 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 322 | <Route path="/userInfo" render={(routeProps) => (<UserInfoModal {...routeProps} />)} /> |
| 323 | <Route path="/closeLoop" render={this.closeLoop} /> |
sebdet | aa486be | 2020-02-18 02:00:11 -0800 | [diff] [blame] | 324 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 325 | <Route path="/submit" render={(routeProps) => (<PerformAction {...routeProps} |
| 326 | loopAction="submit" |
| 327 | loopCache={this.getLoopCache()} |
| 328 | updateLoopFunction={this.updateLoopCache} |
| 329 | showSucAlert={this.showSucAlert} |
| 330 | showFailAlert={this.showFailAlert} |
| 331 | setBusyLoading={this.setBusyLoading} |
| 332 | clearBusyLoading={this.clearBusyLoading}/>)} |
| 333 | /> |
| 334 | <Route path="/stop" render={(routeProps) => (<PerformAction {...routeProps} |
| 335 | loopAction="stop" |
| 336 | loopCache={this.getLoopCache()} |
| 337 | updateLoopFunction={this.updateLoopCache} |
| 338 | showSucAlert={this.showSucAlert} |
| 339 | showFailAlert={this.showFailAlert} |
| 340 | setBusyLoading={this.setBusyLoading} |
| 341 | clearBusyLoading={this.clearBusyLoading}/>)} |
| 342 | /> |
| 343 | <Route path="/restart" render={(routeProps) => (<PerformAction {...routeProps} |
| 344 | loopAction="restart" |
| 345 | loopCache={this.getLoopCache()} |
| 346 | updateLoopFunction={this.updateLoopCache} |
| 347 | showSucAlert={this.showSucAlert} |
| 348 | showFailAlert={this.showFailAlert} |
| 349 | setBusyLoading={this.setBusyLoading} |
| 350 | clearBusyLoading={this.clearBusyLoading}/>)} |
| 351 | /> |
| 352 | <Route path="/delete" render={(routeProps) => (<PerformAction {...routeProps} |
| 353 | loopAction="delete" |
| 354 | loopCache={this.getLoopCache()} |
| 355 | updateLoopFunction={this.updateLoopCache} |
| 356 | showSucAlert={this.showSucAlert} |
| 357 | showFailAlert={this.showFailAlert} |
| 358 | setBusyLoading={this.setBusyLoading} |
| 359 | clearBusyLoading={this.clearBusyLoading}/>)} |
| 360 | /> |
| 361 | <Route path="/undeploy" render={(routeProps) => (<PerformAction {...routeProps} |
| 362 | loopAction="undeploy" |
| 363 | loopCache={this.getLoopCache()} |
| 364 | updateLoopFunction={this.updateLoopCache} |
| 365 | showSucAlert={this.showSucAlert} |
| 366 | showFailAlert={this.showFailAlert} |
| 367 | setBusyLoading={this.setBusyLoading} |
| 368 | clearBusyLoading={this.clearBusyLoading}/>)} |
| 369 | /> |
| 370 | <Route path="/deploy" render={(routeProps) => (<DeployLoopModal {...routeProps} |
| 371 | loopCache={this.getLoopCache()} |
| 372 | updateLoopFunction={this.updateLoopCache} |
| 373 | showSucAlert={this.showSucAlert} |
| 374 | showFailAlert={this.showFailAlert}/>)} |
| 375 | /> |
| 376 | <Route path="/refreshStatus" render={(routeProps) => (<RefreshStatus {...routeProps} |
| 377 | loopCache={this.getLoopCache()} |
| 378 | updateLoopFunction={this.updateLoopCache} |
| 379 | showSucAlert={this.showSucAlert} |
| 380 | showFailAlert={this.showFailAlert}/>)} |
| 381 | /> |
| 382 | </React.Fragment> |
| 383 | ); |
| 384 | } |
Ted Humphrey | 4fb3239 | 2020-07-06 16:59:47 -0400 | [diff] [blame] | 385 | |
Ted Humphrey | 083e5a2 | 2020-07-08 16:48:40 -0400 | [diff] [blame] | 386 | renderGlobalStyle() { |
| 387 | return ( |
| 388 | <GlobalClampStyle /> |
| 389 | ); |
| 390 | }; |
| 391 | |
| 392 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 393 | renderSpinner() { |
| 394 | if (this.isBusyLoading()) { |
| 395 | return ( |
| 396 | <StyledSpinnerDiv> |
| 397 | <Spinner animation="border" role="status"> |
| 398 | <span className="sr-only">Loading...</span> |
| 399 | </Spinner> |
| 400 | </StyledSpinnerDiv> |
| 401 | ); |
| 402 | } else { |
| 403 | return (<div></div>); |
| 404 | } |
| 405 | } |
Ted Humphrey | 4fb3239 | 2020-07-06 16:59:47 -0400 | [diff] [blame] | 406 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 407 | render() { |
| 408 | return ( |
| 409 | <StyledMainDiv id="main_div"> |
| 410 | {this.renderGlobalStyle()} |
| 411 | {this.renderRoutes()} |
| 412 | {this.renderSpinner()} |
| 413 | {this.renderAlertBar()} |
| 414 | {this.renderNavBar()} |
| 415 | {this.renderLoopViewer()} |
| 416 | </StyledMainDiv> |
| 417 | ); |
| 418 | } |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 419 | } |