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 LoopCache from '../../../api/LoopCache';
26 import styled from 'styled-components';
28 const LoopLogsHeaderDivStyled = styled.div`
29 background-color: ${props => props.theme.loopViewerHeaderBackgroundColor};
31 color: ${props => props.theme.loopViewerHeaderFontColor};
33 const TableStyled = styled(Table)`
37 const TableRow = ({ logRow }) => (
39 <td>{logRow.logInstant}</td>
40 <td>{logRow.logType}</td>
41 <td>{logRow.logComponent}</td>
42 <td>{logRow.message}</td>
47 export default class LoopLogs extends React.Component {
50 loopCache: new LoopCache({}),
54 this.renderLogs = this.renderLogs.bind(this);
55 this.state.loopCache = props.loopCache;
58 shouldComponentUpdate(nextProps, nextState) {
59 return this.state.loopCache !== nextState.loopCache;
62 componentWillReceiveProps(newProps) {
64 loopCache: newProps.loopCache,
69 if (this.state.loopCache.getLoopLogsArray() != null) {
71 this.state.loopCache.getLoopLogsArray().map(row => <TableRow logRow={row} />)
78 <LoopLogsHeaderDivStyled>
79 <label>Loop Logs</label>
80 <TableStyled striped hover variant responsive>
83 <th><span align="left">Date</span></th>
84 <th><span align="left">Type</span></th>
85 <th><span align="left">Component</span></th>
86 <th><span align="right">Log</span></th>
93 </LoopLogsHeaderDivStyled>