diff --git a/LCU/Maintenance/MDB_WebView/maintenancedb_view/src/components/StationTestView.js b/LCU/Maintenance/MDB_WebView/maintenancedb_view/src/components/StationTestView.js index 5d11f32de742c49355f3fb4d86da2f8ec07f23a9..6a351c92dfffb0031a283f5f75adab0a05631c7a 100644 --- a/LCU/Maintenance/MDB_WebView/maintenancedb_view/src/components/StationTestView.js +++ b/LCU/Maintenance/MDB_WebView/maintenancedb_view/src/components/StationTestView.js @@ -45,7 +45,7 @@ class GenericStatusTdC extends Component { onMouseOver = (e) => { e.stopPropagation(); if (this.props.n_errors > 0) { - this.props.onSelect(this.props.errors); + this.props.onSelect(this.props.data); } }; @@ -66,7 +66,7 @@ class GenericStatusTdC extends Component { onContextMenu = (e) => { e.preventDefault(); if (this.props.n_errors > 0) { - this.props.onSelect(this.props.errors, true); + this.props.onSelect(this.props.data, true); } }; @@ -100,12 +100,12 @@ class TestLineC extends Component { shouldHighlight() { const props = this.props, - data = props.highlightData; + errorData = props.highlightData; - return data !== null && - data.component_type === props.component_type && - data.test_type === props.test_type && - data.datetime === TestLineC.formatDate(props.data.start_date); + return errorData !== null && + errorData.component_type === props.component_type && + errorData.test_type === props.test_type && + errorData.datetime === TestLineC.formatDate(props.data.start_date); } shouldComponentUpdate(nextProps, nextState, nextContext) { @@ -125,31 +125,35 @@ class TestLineC extends Component { renderComponentErrors() { const componentErrors = this.props.data.component_errors; + const renderedComponentErrors = this.props.ordered_component_ids.map((component_id, key) => { - let nErrors = 0; - let errors = []; - let errorDetails = {}; + let nErrors = 0, + errors = [], + errorData = {}; + if (componentErrors.hasOwnProperty(component_id)) { - nErrors = Object.keys(componentErrors[component_id]).length; errors = componentErrors[component_id]; - errorDetails.errors = errors; - errorDetails.datetime= TestLineC.formatDate(this.props.data.start_date); - errorDetails.test_type = this.props.test_type; - errorDetails.component_id = component_id; - errorDetails.component_type = this.props.component_type; + nErrors = Object.keys(errors).length; + + // Data for child panel and checking if an antenna item must be highlighted permanently (see shouldHighlight) + errorData.errors = errors; + errorData.datetime= TestLineC.formatDate(this.props.data.start_date); + errorData.test_type = this.props.test_type; + errorData.component_id = component_id; + errorData.component_type = this.props.component_type; } return <GenericStatusTd doHighlight={this.doHighlight && component_id === this.props.highlightData.component_id} key={key} - errors={errorDetails} + data={errorData} antenna_id={component_id} antenna_type={this.props.component_type} station_name={this.props.station_name} n_errors={nErrors} - onSelect={this.onSelect} - /> + onSelect={this.onSelect} /> }); + return renderedComponentErrors; } @@ -182,19 +186,8 @@ const TestLine = connect(state => { class RTSMSummaryLine extends Component { - constructor(props) { - super(props); - this.state = {displaySingleTests: false} - } - - renderTestLine(key, data, component_id_list) { - return (<TestLine className="collapse open" - key={key} - ordered_component_ids={component_id_list} - test_type="RT" - station_name={this.props.station_name} - component_type={this.props.component_type} - station_type={this.props.station_type} data={data}/>) + state = { + displaySingleTests: false } renderTestSummaryLine(data, component_id_list) { @@ -235,17 +228,13 @@ class RTSMSummaryLine extends Component { let summary = this.computeSummary(); const component_id_list = this.props.ordered_component_ids; const summaryLine = this.renderTestSummaryLine(summary, component_id_list); - let jsx; - let all_rtsm; - if (this.state.displaySingleTests) { - all_rtsm = this.props.data.map((item, key) => this.renderTestLine(key, item, component_id_list)) - } + let all_rtsm = this.state.displaySingleTests ? this.props.data : []; let dropdownAdditionStyles = classNames( 'dropdownbutton', {'dropdownbutton-up': this.state.displaySingleTests}); - jsx = ( + return ( <React.Fragment> <tr className='stv-rtsm-summary-row'> <td className="row-header" onClick={this.toggleDisplaySingleTests}> @@ -254,12 +243,19 @@ class RTSMSummaryLine extends Component { </td> {summaryLine} </tr> - {all_rtsm} + { // All RTSM lines in this block (expanded or folded) + all_rtsm.map((item, key) => + <TestLine className="collapse open" + key={key} + ordered_component_ids={component_id_list} + test_type="RT" + station_name={this.props.station_name} + component_type={this.props.component_type} + station_type={this.props.station_type} data={item}/> + ) + } </React.Fragment> ); - - - return jsx; } }