Skip to content
Snippets Groups Projects
Commit 3ece963f authored by Reinoud Bokhorst's avatar Reinoud Bokhorst
Browse files

OSB-35: refactoring

parent cea7b8e7
No related branches found
No related tags found
2 merge requests!89Monitoring maintenance Epic branch merge,!1Resolve OSB-13 "Monitoringmaintenance "
...@@ -45,7 +45,7 @@ class GenericStatusTdC extends Component { ...@@ -45,7 +45,7 @@ class GenericStatusTdC extends Component {
onMouseOver = (e) => { onMouseOver = (e) => {
e.stopPropagation(); e.stopPropagation();
if (this.props.n_errors > 0) { 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 { ...@@ -66,7 +66,7 @@ class GenericStatusTdC extends Component {
onContextMenu = (e) => { onContextMenu = (e) => {
e.preventDefault(); e.preventDefault();
if (this.props.n_errors > 0) { 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 { ...@@ -100,12 +100,12 @@ class TestLineC extends Component {
shouldHighlight() { shouldHighlight() {
const props = this.props, const props = this.props,
data = props.highlightData; errorData = props.highlightData;
return data !== null && return errorData !== null &&
data.component_type === props.component_type && errorData.component_type === props.component_type &&
data.test_type === props.test_type && errorData.test_type === props.test_type &&
data.datetime === TestLineC.formatDate(props.data.start_date); errorData.datetime === TestLineC.formatDate(props.data.start_date);
} }
shouldComponentUpdate(nextProps, nextState, nextContext) { shouldComponentUpdate(nextProps, nextState, nextContext) {
...@@ -125,31 +125,35 @@ class TestLineC extends Component { ...@@ -125,31 +125,35 @@ class TestLineC extends Component {
renderComponentErrors() { renderComponentErrors() {
const componentErrors = this.props.data.component_errors; const componentErrors = this.props.data.component_errors;
const renderedComponentErrors = this.props.ordered_component_ids.map((component_id, key) => { const renderedComponentErrors = this.props.ordered_component_ids.map((component_id, key) => {
let nErrors = 0; let nErrors = 0,
let errors = []; errors = [],
let errorDetails = {}; errorData = {};
if (componentErrors.hasOwnProperty(component_id)) { if (componentErrors.hasOwnProperty(component_id)) {
nErrors = Object.keys(componentErrors[component_id]).length;
errors = componentErrors[component_id]; errors = componentErrors[component_id];
errorDetails.errors = errors; nErrors = Object.keys(errors).length;
errorDetails.datetime= TestLineC.formatDate(this.props.data.start_date);
errorDetails.test_type = this.props.test_type; // Data for child panel and checking if an antenna item must be highlighted permanently (see shouldHighlight)
errorDetails.component_id = component_id; errorData.errors = errors;
errorDetails.component_type = this.props.component_type; 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 return <GenericStatusTd
doHighlight={this.doHighlight && component_id === this.props.highlightData.component_id} doHighlight={this.doHighlight && component_id === this.props.highlightData.component_id}
key={key} key={key}
errors={errorDetails} data={errorData}
antenna_id={component_id} antenna_id={component_id}
antenna_type={this.props.component_type} antenna_type={this.props.component_type}
station_name={this.props.station_name} station_name={this.props.station_name}
n_errors={nErrors} n_errors={nErrors}
onSelect={this.onSelect} onSelect={this.onSelect} />
/>
}); });
return renderedComponentErrors; return renderedComponentErrors;
} }
...@@ -182,19 +186,8 @@ const TestLine = connect(state => { ...@@ -182,19 +186,8 @@ const TestLine = connect(state => {
class RTSMSummaryLine extends Component { class RTSMSummaryLine extends Component {
constructor(props) { state = {
super(props); displaySingleTests: false
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}/>)
} }
renderTestSummaryLine(data, component_id_list) { renderTestSummaryLine(data, component_id_list) {
...@@ -235,17 +228,13 @@ class RTSMSummaryLine extends Component { ...@@ -235,17 +228,13 @@ class RTSMSummaryLine extends Component {
let summary = this.computeSummary(); let summary = this.computeSummary();
const component_id_list = this.props.ordered_component_ids; const component_id_list = this.props.ordered_component_ids;
const summaryLine = this.renderTestSummaryLine(summary, component_id_list); const summaryLine = this.renderTestSummaryLine(summary, component_id_list);
let jsx;
let all_rtsm;
if (this.state.displaySingleTests) { let all_rtsm = this.state.displaySingleTests ? this.props.data : [];
all_rtsm = this.props.data.map((item, key) => this.renderTestLine(key, item, component_id_list))
}
let dropdownAdditionStyles = classNames( let dropdownAdditionStyles = classNames(
'dropdownbutton', {'dropdownbutton-up': this.state.displaySingleTests}); 'dropdownbutton', {'dropdownbutton-up': this.state.displaySingleTests});
jsx = ( return (
<React.Fragment> <React.Fragment>
<tr className='stv-rtsm-summary-row'> <tr className='stv-rtsm-summary-row'>
<td className="row-header" onClick={this.toggleDisplaySingleTests}> <td className="row-header" onClick={this.toggleDisplaySingleTests}>
...@@ -254,12 +243,19 @@ class RTSMSummaryLine extends Component { ...@@ -254,12 +243,19 @@ class RTSMSummaryLine extends Component {
</td> </td>
{summaryLine} {summaryLine}
</tr> </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> </React.Fragment>
); );
return jsx;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment