diff --git a/src/ic/ic.js b/src/ic/ic.js index a62eaa2..1d9a38c 100644 --- a/src/ic/ic.js +++ b/src/ic/ic.js @@ -62,9 +62,23 @@ class InfrastructureComponent extends React.Component { token: this.state.sessionToken, }); - // Start timer for periodic refresh - this.timer = window.setInterval(() => this.refresh(), 10000); + // get status of VILLASnode and VILLASrelay ICs + if(this.state.ic != undefined){ + if ((this.state.ic.type === "villas-node" || this.state.ic.type === "villas-relay") + && this.state.ic.apiurl !== '' && this.state.ic.apiurl !== undefined && this.state.ic.apiurl !== null && !this.state.ic.managedexternally) { + AppDispatcher.dispatch({ + type: 'ics/get-status', + url: this.state.ic.apiurl, + token: this.state.sessionToken, + ic: this.state.ic + }); + } } + else{ + this.timer = window.setInterval(() => this.refresh(), 10000); + } + } + refresh() { @@ -86,6 +100,10 @@ class InfrastructureComponent extends React.Component { }); } + if(this.timer){ + window.clearInterval(this.timer); + } + } isJSON(data) { @@ -212,40 +230,8 @@ class InfrastructureComponent extends React.Component { - {this.state.ic.type === "villas-node" ? + {this.state.ic.type === "villas-node" ? <> - Raw Status - {this.state.ic.statusupdateraw !== null && this.isJSON(this.state.ic.statusupdateraw) ? - :
No valid JSON raw data available.
} - - Raw Config - {this.state.ic.statusupdateraw && this.isJSON(this.state.ic.statusupdateraw["config"]) ? - :
No valid config JSON raw data available.
} - Raw Statistics - {this.state.ic.statusupdateraw && this.isJSON(this.state.ic.statusupdateraw["statistics"]) ? - :
No valid statistics JSON raw data available.
} -
@@ -278,6 +264,10 @@ class InfrastructureComponent extends React.Component { {this.state.ic.type === "villas-relay" ? <> +
+ +
Raw Status {this.state.ic.statusupdateraw !== null && this.isJSON(this.state.ic.statusupdateraw) ? :
No valid JSON raw data available.
} :
} - + + {this.state.ic.type === "villas-node" ? + <> + + Raw Status + {this.state.ic.statusupdateraw !== null && this.isJSON(this.state.ic.statusupdateraw) ? + :
No valid JSON raw data available.
} + + + Raw Config + {this.state.ic.statusupdateraw && this.isJSON(this.state.ic.statusupdateraw["config"]) ? + :
No valid config JSON raw data available.
} + + +
+ +
+ Raw Statistics + {this.state.ic.statusupdateraw && this.isJSON(this.state.ic.statusupdateraw["statistics"]) ? + :
No valid statistics JSON raw data available.
} + + + :
} +
; } diff --git a/src/ic/ics.js b/src/ic/ics.js index 01e9c0b..f64c47e 100644 --- a/src/ic/ics.js +++ b/src/ic/ics.js @@ -133,19 +133,6 @@ class InfrastructureComponents extends Component { token: this.state.sessionToken, }); - // get status of VILLASnode and VILLASrelay ICs - this.state.ics.forEach(ic => { - if ((ic.type === "villas-node" || ic.type === "villas-relay") - && ic.apiurl !== '' && ic.apiurl !== undefined && ic.apiurl !== null && !ic.managedexternally) { - AppDispatcher.dispatch({ - type: 'ics/get-status', - url: ic.apiurl, - token: this.state.sessionToken, - ic: ic - }); - } - }) - } }