2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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 * ===================================================================
24 import React from 'react';
25 import styled from 'styled-components';
26 import MenuBar from './components/menu/MenuBar';
27 import Navbar from 'react-bootstrap/Navbar';
28 import logo from './logo.png';
29 import { GlobalClampStyle } from './theme/globalStyle.js';
31 import LoopSvg from './components/loop_viewer/svg/LoopSvg';
32 import LoopLogs from './components/loop_viewer/logs/LoopLogs';
33 import LoopStatus from './components/loop_viewer/status/LoopStatus';
34 import UserService from './api/UserService';
35 import LoopCache from './api/LoopCache';
37 import { Route, Redirect } from 'react-router-dom'
38 import OpenLoopModal from './components/dialogs/OpenLoop/OpenLoopModal';
39 import OperationalPolicyModal from './components/dialogs/OperationalPolicy/OperationalPolicyModal';
40 import ConfigurationPolicyModal from './components/dialogs/ConfigurationPolicy/ConfigurationPolicyModal';
42 const ProjectNameStyled = styled.a`
43 vertical-align: middle;
48 const LoopViewDivStyled = styled.div`
54 color: ${props => props.theme.loopViewerFontColor};
55 background-color: ${props => props.theme.loopViewerBackgroundColor};
56 border: 1px solid transparent;
57 border-color: ${props => props.theme.loopViewerHeaderBackgroundColor};
60 const LoopViewHeaderDivStyled = styled.div`
61 background-color: ${props => props.theme.loopViewerHeaderBackgroundColor};
63 color: ${props => props.theme.loopViewerHeaderFontColor};
66 const LoopViewBodyDivStyled = styled.div`
67 background-color: ${props => (props.theme.loopViewerBackgroundColor)};
69 color: ${props => (props.theme.loopViewerHeaderFontColor)};
73 const LoopViewLoopNameSpanStyled = styled.span`
75 color: ${props => (props.theme.loopViewerHeaderFontColor)};
76 background-color: ${props => (props.theme.loopViewerHeaderBackgroundColor)};
79 export default class LoopUI extends React.Component {
81 static defaultLoopName="Empty (NO loop loaded yet)";
85 loopName: LoopUI.defaultLoopName,
86 loopCache: new LoopCache({}),
91 this.getUser = this.getUser.bind(this);
92 this.updateLoopCache = this.updateLoopCache.bind(this);
95 componentWillMount() {
100 UserService.login().then(user => {
101 this.setState({ userName: user })
111 renderUserLoggedNavBar() {
114 Signed in as: <a href="/login">{this.state.userName}</a>
122 <img height="50px" width="234px" src={logo} alt="" />
123 <ProjectNameStyled>CLAMP</ProjectNameStyled>
131 {this.renderLogoNavBar()}
132 {this.renderMenuNavBar()}
133 {this.renderUserLoggedNavBar()}
138 renderLoopViewHeader() {
140 <LoopViewHeaderDivStyled>
141 Loop Viewer - {this.state.loopName}
142 </LoopViewHeaderDivStyled>
146 renderLoopViewBody() {
148 <LoopViewBodyDivStyled>
149 <LoopSvg loopCache={this.state.loopCache} />
150 <LoopStatus loopCache={this.state.loopCache}/>
151 <LoopLogs loopCache={this.state.loopCache} />
152 </LoopViewBodyDivStyled>
159 {this.renderLoopViewHeader()}
160 {this.renderLoopViewBody()}
165 updateLoopCache(loopJson) {
166 this.setState({ loopCache: new LoopCache(loopJson) });
167 this.setState({ loopName: this.state.loopCache.getLoopName() });
174 {this.renderNavBar()}
175 {this.renderLoopViewer()}
176 <Route path="/operationalPolicyModal"
177 render={(routeProps) => (<OperationalPolicyModal {...routeProps} loopCache={this.state.loopCache} />)} />
178 <Route path="/configurationPolicyModal/:componentName" render={(routeProps) => (<ConfigurationPolicyModal {...routeProps} loopCache={this.state.loopCache} />)} />
179 <Route path="/openLoop" render={(routeProps) => (<OpenLoopModal {...routeProps} updateLoopCacheFunction={this.updateLoopCache} />)} />
180 <Route path="/closeLoop" render={(routeProps) => (<Redirect to='/'/>)} />