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 * ===================================================================
23 import React from 'react';
24 import Table from 'react-bootstrap/Table';
25 import styled from 'styled-components';
26 import LoopCache from '../../../api/LoopCache';
28 const LoopStatusViewDivStyled = styled.div`
29 background-color: ${props => props.theme.loopViewerHeaderBackgroundColor};
31 color: ${props => props.theme.loopViewerHeaderFontColor};
34 const TableStyled = styled(Table)`
38 const TableRow = ({ statusRow }) => (
40 <td>{statusRow.componentName}</td>
41 <td>{statusRow.stateName}</td>
42 <td>{statusRow.description}</td>
47 export default class LoopStatus extends React.Component {
49 loopCache: new LoopCache({}),
54 this.renderStatus = this.renderStatus.bind(this);
55 this.state.loopCache = props.loopCache;
60 if (this.state.loopCache.getComponentStates() != null) {
61 return Object.keys(this.state.loopCache.getComponentStates()).map((key) => {
62 console.debug("Adding status for: ",key);
64 res[key]=this.state.loopCache.getComponentStates()[key];
65 return (<TableRow statusRow={{'componentName':key,'stateName':this.state.loopCache.getComponentStates()[key].componentState.stateName,'description':this.state.loopCache.getComponentStates()[key].componentState.description}} />)
71 shouldComponentUpdate(nextProps, nextState) {
72 return this.state.loopCache !== nextState.loopCache;
75 componentWillReceiveProps(newProps) {
77 loopCache: newProps.loopCache,
83 <LoopStatusViewDivStyled>
84 <label>Loop Status: {this.state.loopCache.getComputedState()}
88 <TableStyled striped hover variant responsive>
91 <th><span align="left">Component Name</span></th>
92 <th><span align="left">Component State</span></th>
93 <th><span align="right">Description</span></th>
101 </LoopStatusViewDivStyled>