X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ui-react%2Fsrc%2FLoopUI.js;h=ff3c4445aa136b85bf02d1d91a5bbfc5793eb0b7;hb=ac42c4b3e7161a76bfa67cae9636ea63d7bd81f8;hp=b64cfbaa384713269e7362ade7985db98d4fffe2;hpb=b54c22cf12ebf4fda895e2b21d00cfac294447d7;p=clamp.git diff --git a/ui-react/src/LoopUI.js b/ui-react/src/LoopUI.js index b64cfbaa..ff3c4445 100644 --- a/ui-react/src/LoopUI.js +++ b/ui-react/src/LoopUI.js @@ -33,6 +33,7 @@ import LoopLogs from './components/loop_viewer/logs/LoopLogs'; import LoopStatus from './components/loop_viewer/status/LoopStatus'; import UserService from './api/UserService'; import LoopCache from './api/LoopCache'; +import LoopActionService from './api/LoopActionService'; import { Route } from 'react-router-dom' import OpenLoopModal from './components/dialogs/OpenLoop/OpenLoopModal'; @@ -44,13 +45,31 @@ import LoopService from './api/LoopService'; import PerformAction from './components/dialogs/PerformActions'; import RefreshStatus from './components/dialogs/RefreshStatus'; import DeployLoop from './components/dialogs/DeployLoop'; +import Alert from 'react-bootstrap/Alert'; + +import { Link } from 'react-router-dom'; + +const StyledMainDiv = styled.div` + background-color: ${props => props.theme.backgroundColor}; +` const ProjectNameStyled = styled.a` vertical-align: middle; padding-left: 30px; - font-size: 30px; + font-size: 36px; + font-weight: bold; +` + +const StyledRouterLink = styled(Link)` + color: ${props => props.theme.menuFontColor}; + background-color: ${props => props.theme.backgroundColor}; +` +const StyledLoginInfo = styled.a` + color: ${props => props.theme.menuFontColor}; + background-color: ${props => props.theme.backgroundColor}; ` + const LoopViewDivStyled = styled.div` height: 100%; overflow: hidden; @@ -83,15 +102,19 @@ export default class LoopUI extends React.Component { state = { userName: null, loopName: LoopUI.defaultLoopName, - loopCache: new LoopCache({}) + loopCache: new LoopCache({}), + showAlert: false }; constructor() { super(); this.getUser = this.getUser.bind(this); + this.logout = this.logout.bind(this); this.updateLoopCache = this.updateLoopCache.bind(this); this.loadLoop = this.loadLoop.bind(this); this.closeLoop = this.closeLoop.bind(this); + this.showAlert = this.showAlert.bind(this); + this.disableAlert = this.disableAlert.bind(this); } componentWillMount() { @@ -103,6 +126,14 @@ export default class LoopUI extends React.Component { this.setState({ userName: user }) }); } + + logout() { + UserService.logout().then(user => { + this.setState({ userName: user }); + window.location.reload(); + }); + + } renderMenuNavBar() { return ( @@ -113,7 +144,9 @@ export default class LoopUI extends React.Component { renderUserLoggedNavBar() { return ( - Signed in as: {this.state.userName} + Signed in as: + {this.state.userName} + (logout) ); } @@ -127,10 +160,19 @@ export default class LoopUI extends React.Component { ); } + renderAlertBar() { + return ( + + {this.state.showMessage} + + ); + } + renderNavBar() { return ( - + {this.renderLogoNavBar()} + {this.renderMenuNavBar()} {this.renderUserLoggedNavBar()} @@ -170,14 +212,30 @@ export default class LoopUI extends React.Component { } updateLoopCache(loopJson) { - this.setState({ loopCache: new LoopCache(loopJson), loopName: this.state.loopCache.getLoopName() }); + this.setState({ loopCache: new LoopCache(loopJson) }); + this.setState({ loopName: this.state.loopCache.getLoopName() }); console.info(this.state.loopName+" loop loaded successfully"); } + showAlert(message) { + this.setState ({ showAlert: true, showMessage:message }); + } + + disableAlert() { + this.setState ({ showAlert: false }); + } + loadLoop(loopName) { LoopService.getLoop(loopName).then(loop => { console.debug("Updating loopCache"); - this.updateLoopCache(loop); + LoopActionService.refreshStatus(loopName).then(data => { + this.updateLoopCache(data); + this.props.history.push('/'); + }) + .catch(error => { + this.updateLoopCache(loop); + this.props.history.push('/'); + }); }); } @@ -185,28 +243,30 @@ export default class LoopUI extends React.Component { this.setState({ loopCache: new LoopCache({}), loopName: LoopUI.defaultLoopName }); this.props.history.push('/'); } - - render() { + + render() { return ( -
+ ()} /> + render={(routeProps) => ()} /> ()} /> ()} /> ()} /> ()} /> - ()} /> - ()} /> - ()} /> - ()} /> - ()} /> - ()} /> - ()} /> - + ()} /> + ()} /> + ()} /> + ()} /> + ()} /> + ()} /> + ()} /> + + + {this.renderAlertBar()} {this.renderNavBar()} {this.renderLoopViewer()} -
+ ); } }