From 691e2b7a8bb16d224a0fbe30390152ea309e88e2 Mon Sep 17 00:00:00 2001 From: xuegao Date: Fri, 16 Aug 2019 11:07:24 +0200 Subject: [PATCH] Rework deploy action and close model Rework the deploy action and the close model feature. Issue-ID: CLAMP-445, CLAMP-451 Change-Id: Ic122a584b676d50b9bddcac6e5553266b2281a01 Signed-off-by: xuegao --- ui-react/src/LoopUI.js | 18 ++- ui-react/src/React-Spinner.jpg | Bin 5140 -> 0 bytes ui-react/src/components/dialogs/DeployLoop.js | 128 +++++++++++++++++++++ ui-react/src/components/dialogs/LoopProperties.js | 7 +- .../components/{menu => dialogs}/PerformActions.js | 0 .../components/{menu => dialogs}/RefreshStatus.js | 0 ui-react/src/components/loop_viewer/svg/LoopSvg.js | 17 +-- ui-react/src/components/menu/MenuBar.js | 31 +++-- 8 files changed, 175 insertions(+), 26 deletions(-) delete mode 100644 ui-react/src/React-Spinner.jpg create mode 100644 ui-react/src/components/dialogs/DeployLoop.js rename ui-react/src/components/{menu => dialogs}/PerformActions.js (100%) rename ui-react/src/components/{menu => dialogs}/RefreshStatus.js (100%) diff --git a/ui-react/src/LoopUI.js b/ui-react/src/LoopUI.js index c7080a2b..5b8283f8 100644 --- a/ui-react/src/LoopUI.js +++ b/ui-react/src/LoopUI.js @@ -34,7 +34,7 @@ import LoopStatus from './components/loop_viewer/status/LoopStatus'; import UserService from './api/UserService'; import LoopCache from './api/LoopCache'; -import { Route, Redirect } from 'react-router-dom' +import { Route } from 'react-router-dom' import OpenLoopModal from './components/dialogs/OpenLoop/OpenLoopModal'; import OperationalPolicyModal from './components/dialogs/OperationalPolicy/OperationalPolicyModal'; import ConfigurationPolicyModal from './components/dialogs/ConfigurationPolicy/ConfigurationPolicyModal'; @@ -43,6 +43,7 @@ import UserInfo from './components/dialogs/UserInfo'; import LoopService from './api/LoopService'; import PerformAction from './components/menu/PerformActions'; import RefreshStatus from './components/menu/RefreshStatus'; +import DeployLoop from './components/menu/DeployLoop'; const ProjectNameStyled = styled.a` vertical-align: middle; @@ -90,6 +91,7 @@ export default class LoopUI extends React.Component { this.getUser = this.getUser.bind(this); this.updateLoopCache = this.updateLoopCache.bind(this); this.loadLoop = this.loadLoop.bind(this); + this.closeLoop = this.closeLoop.bind(this); } componentWillMount() { @@ -104,7 +106,7 @@ export default class LoopUI extends React.Component { renderMenuNavBar() { return ( - + ); } @@ -168,8 +170,7 @@ export default class LoopUI extends React.Component { } updateLoopCache(loopJson) { - this.setState({ loopCache: new LoopCache(loopJson) }); - this.setState({ loopName: this.state.loopCache.getLoopName() }); + this.setState({ loopCache: new LoopCache(loopJson), loopName: this.state.loopCache.getLoopName() }); console.info(this.state.loopName+" loop loaded successfully"); } @@ -180,7 +181,11 @@ export default class LoopUI extends React.Component { }); } - render() { + closeLoop() { + this.setState({ loopCache: new LoopCache({}), loopName: LoopUI.defaultLoopName }); + this.props.history.push('/'); + } + render() { return (
()} /> ()} /> ()} /> - ()} /> + ()} /> ()} /> ()} /> ()} /> ()} /> + ()} /> ()} /> {this.renderNavBar()} diff --git a/ui-react/src/React-Spinner.jpg b/ui-react/src/React-Spinner.jpg deleted file mode 100644 index 22768976403cc5d9a5841d45ece9522dbfcf2391..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5140 zcmcgv2Ut_fw%$odNFYKIieRA$#DG8of`IfYAXShe3ZbK*M5U;dP(`YALJ?7VZxT2t zU7Da2kANbAD2PTn2uOKBJ@?%2obSH(z3<(3SN3GqteM$sWzWjL|Ft`^I{~0{wRE%q z5C{a=(m%lN8$cZZgFt)NFM&WIdjex%fIt~xjEs8?j$lT>;Y@HwMy7pCOw35SFd|r3 z_aRyK^u3$xZQt8PzmRZ7_}+^Do$R&(XgIJA%7%ah05BQ^L4$VNfy4Ar0Wf4Q-aiBi zV}vlk!HB(SF8ahj&(YUFKn&pB*8mbi--m*r008t&ts=feuoxlIs{4mxAX;(Usam`& z{%c42gR+PbMQiGJi_0ak+7J9|GTW*vR)zNURrdGaFpO}f>`%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Q4A!ZRmU?yOgt(U#m)ivW8>oi1t%uN39QN^R@VO>mEQ-}K^pnjik zk2LL=kA8`)oWQ6WF(aFI0oF9lgV!bfw)N2?$stNz`XnKkLfLTL&{V8#pKpxs2c8q0 z!M1Ga44wABr!0B0(#VUq);5FdvjZX5$F>%F2axezpJx{rpH0>tL<)1E<|}6c>-V)g z#&+w(I0pM#@^IpyFksw(Pc$pC0aA3Cse1NkzDBTQP?Y-I!{h&ud`8ktX9 zvJJkps3j$_AVRif%y@-RQHwSm<-=oeukU-2f_9{_#FjG>Z&yADv&@w5Z+pAF7_$pJ zxxn%Gd_{K5aW}3bS{+_~N98c0#R|-H#<}5%NvfXcd>8+|In@x6Ff_+sEwI|Jbl9IC zs^aK*E~?axM*`z~`GBh`^@hT-%MB<$WrCl{dPQ?_Si7>#QD&XJx0{yHfw58>OM3C$ zPlY=)`C+Hh9;1>)zIqY+{+JVL*%0cz(_*veEw? K?>KgM^uGYVEBY(| diff --git a/ui-react/src/components/dialogs/DeployLoop.js b/ui-react/src/components/dialogs/DeployLoop.js new file mode 100644 index 00000000..2ec395d2 --- /dev/null +++ b/ui-react/src/components/dialogs/DeployLoop.js @@ -0,0 +1,128 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ +import React from 'react'; +import LoopActionService from '../../api/LoopActionService'; +import LoopService from '../../api/LoopService'; +import Button from 'react-bootstrap/Button'; +import Modal from 'react-bootstrap/Modal'; +import Form from 'react-bootstrap/Form'; +import styled from 'styled-components'; + +const ModalStyled = styled(Modal)` + background-color: transparent; +` +const FormStyled = styled(Form.Group)` + padding: .25rem 1.5rem; +` +export default class DeployLoop extends React.Component { + state = { + loopCache: this.props.loopCache, + temporaryPropertiesJson: JSON.parse(JSON.stringify(this.props.loopCache.getGlobalProperties())), + show: true + }; + constructor(props, context) { + super(props, context); + + this.handleSave = this.handleSave.bind(this); + this.handleClose = this.handleClose.bind(this); + this.handleChange = this.handleChange.bind(this); + this.refreshStatus = this.refreshStatus.bind(this); + this.renderDeployParam = this.renderDeployParam.bind(this); + } + componentWillReceiveProps(newProps) { + this.setState({ + loopName: newProps.loopCache.getLoopName(), + show: true + }); + } + handleClose(){ + this.props.history.push('/'); + } + handleSave(e) { + const loopName = this.props.loopCache.getLoopName(); + // save the global propserties + LoopService.updateGlobalProperties(loopName, this.state.temporaryPropertiesJson).then(resp => { + this.setState({ show: false }); + + console.log("Perform action: deploy"); + LoopActionService.performAction(loopName, "deploy").then(pars => { + alert("Action deploy successfully performed"); + // refresh status and update loop logs + this.refreshStatus(loopName); + }) + .catch(error => { + alert("Action deploy failed"); + // refresh status and update loop logs + this.refreshStatus(loopName); + }); + }); + } + + refreshStatus(loopName) { + LoopActionService.refreshStatus(loopName).then(data => { + this.props.updateLoopFunction(data); + this.props.history.push('/'); + }) + .catch(error => { + alert("Refresh status failed"); + this.props.history.push('/'); + }); + } + handleChange(event) { + let deploymentParam = this.state.temporaryPropertiesJson["dcaeDeployParameters"]; + deploymentParam[event.target.name] = event.target.value; + + this.setState({temporaryPropertiesJson:{dcaeDeployParameters: deploymentParam}}); + } + renderDeployParam() { + if (typeof (this.state.temporaryPropertiesJson) === "undefined") { + return ""; + } + + const deployJson = this.state.temporaryPropertiesJson["dcaeDeployParameters"]; + var indents = []; + Object.keys(deployJson).map((item,key) => + indents.push( + {item} + + )); + + return indents; + } + + + render() { + return ( + + + Deployment parameters + + {this.renderDeployParam()} + + + + + + ); + } +} diff --git a/ui-react/src/components/dialogs/LoopProperties.js b/ui-react/src/components/dialogs/LoopProperties.js index dac77655..fa82a7e4 100644 --- a/ui-react/src/components/dialogs/LoopProperties.js +++ b/ui-react/src/components/dialogs/LoopProperties.js @@ -30,7 +30,6 @@ import LoopService from '../../api/LoopService'; const ModalStyled = styled(Modal)` background-color: transparent; ` - export default class LoopProperties extends React.Component { state = { @@ -45,7 +44,7 @@ export default class LoopProperties extends React.Component { this.handleClose = this.handleClose.bind(this); this.handleSave = this.handleSave.bind(this); this.handleChange = this.handleChange.bind(this); - + this.renderDcaeParameters = this.renderDcaeParameters.bind(this); this.renderAllParameters = this.renderAllParameters.bind(this); this.getDcaeParameters = this.getDcaeParameters.bind(this); @@ -55,7 +54,7 @@ export default class LoopProperties extends React.Component { this.setState({ loopCache: newProps.loopCache, temporaryPropertiesJson: JSON.parse(JSON.stringify(newProps.loopCache.getGlobalProperties())), - + }); } @@ -90,7 +89,7 @@ export default class LoopProperties extends React.Component { } else { return ""; } - + } renderDcaeParameters() { diff --git a/ui-react/src/components/menu/PerformActions.js b/ui-react/src/components/dialogs/PerformActions.js similarity index 100% rename from ui-react/src/components/menu/PerformActions.js rename to ui-react/src/components/dialogs/PerformActions.js diff --git a/ui-react/src/components/menu/RefreshStatus.js b/ui-react/src/components/dialogs/RefreshStatus.js similarity index 100% rename from ui-react/src/components/menu/RefreshStatus.js rename to ui-react/src/components/dialogs/RefreshStatus.js diff --git a/ui-react/src/components/loop_viewer/svg/LoopSvg.js b/ui-react/src/components/loop_viewer/svg/LoopSvg.js index 3ac2f31f..1b1e2428 100644 --- a/ui-react/src/components/loop_viewer/svg/LoopSvg.js +++ b/ui-react/src/components/loop_viewer/svg/LoopSvg.js @@ -61,13 +61,14 @@ class LoopViewSvg extends React.Component { return this.state.svgContent !== nextState.svgContent; } - componentWillReceiveProps(newProps) { - this.setState({ - loopCache: newProps.loopCache, - componentModalMapping: LoopComponentConverter.buildMapOfComponents(newProps.loopCache), - - }); - this.getSvg(newProps.loopCache.getLoopName()); + componentWillReceiveProps(newProps) { + if (this.state.loopCache !== newProps.loopCache) { + this.setState({ + loopCache: newProps.loopCache, + componentModalMapping: LoopComponentConverter.buildMapOfComponents(newProps.loopCache), + }); + this.getSvg(newProps.loopCache.getLoopName()); + } } getSvg(loopName) { @@ -79,6 +80,8 @@ class LoopViewSvg extends React.Component { this.setState({ svgContent: LoopViewSvg.emptySvg }) } }); + } else { + this.setState({ svgContent: LoopViewSvg.emptySvg }) } } diff --git a/ui-react/src/components/menu/MenuBar.js b/ui-react/src/components/menu/MenuBar.js index 5022152e..121787ff 100644 --- a/ui-react/src/components/menu/MenuBar.js +++ b/ui-react/src/components/menu/MenuBar.js @@ -24,6 +24,7 @@ import React from 'react'; import Nav from 'react-bootstrap/Nav'; import Navbar from 'react-bootstrap/Navbar'; import NavDropdown from 'react-bootstrap/NavDropdown'; +import LoopUI from '../../LoopUI'; import 'bootstrap-css-only/css/bootstrap.min.css'; import styled from 'styled-components'; import { Link } from 'react-router-dom' @@ -56,25 +57,37 @@ const StyledNavLink = styled(Nav.Link)` } `; export default class MenuBar extends React.Component { + state = { + loopName: this.props.loopName, + disabled: true + }; + + componentWillReceiveProps(newProps) { + if (newProps.loopName !== LoopUI.defaultLoopName) { + this.setState({ disabled: false }); + } else { + this.setState({ disabled: true }); + } + } render () { return ( Open CL - Properties CL - Close Model + Properties CL + Close Model - Submit - Stop - Restart - Delete - Deploy - UnDeploy + Submit + Stop + Restart + Delete + Deploy + UnDeploy - Refresh Status + Refresh Status Wiki -- 2.16.6