1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

add refresh of IC and status query to IC page; improve error handling for start parameter schema JSON view

This commit is contained in:
Sonja Happ 2021-04-28 11:58:51 +02:00
parent acde44528f
commit 7935e8ff6a

View file

@ -61,6 +61,31 @@ class InfrastructureComponent extends React.Component {
data: icID,
token: this.state.sessionToken,
});
// Start timer for periodic refresh
this.timer = window.setInterval(() => this.refresh(), 10000);
}
refresh() {
let icID = parseInt(this.props.match.params.ic, 10);
AppDispatcher.dispatch({
type: 'ics/start-load',
token: this.state.sessionToken,
data: icID
});
// get status of VILLASnode and VILLASrelay ICs
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
});
}
}
isJSON(data) {
@ -102,12 +127,12 @@ class InfrastructureComponent extends React.Component {
if(!canceled){
this.sendControlCommand();
}
this.setState({confirmCommand: false, command: ''});
}
async downloadGraph(url) {
let blob = await fetch(url).then(r => r.blob())
FileSaver.saveAs(blob, this.props.ic.name + ".svg");
}
@ -172,14 +197,15 @@ class InfrastructureComponent extends React.Component {
<tr>
<td>Start parameter schema</td>
<td>
<ReactJson
{this.isJSON(this.state.ic.startparameterschema) ?
<ReactJson
src={this.state.ic.startparameterschema}
name={false}
displayDataTypes={false}
displayObjectSize={false}
enableClipboard={false}
collapsed={0}
/>
/> : <div>No Start parameter schema JSON available.</div>}
</td>
</tr>
</tbody>
@ -237,4 +263,4 @@ class InfrastructureComponent extends React.Component {
}
let fluxContainerConverter = require('../common/FluxContainerConverter');
export default FluxContainer.create(fluxContainerConverter.convert(InfrastructureComponent), { withProps: true });
export default FluxContainer.create(fluxContainerConverter.convert(InfrastructureComponent), { withProps: true });