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

IC page customization for VILLASnode and VILLASrelay #303 #304 #305

This commit is contained in:
Laura Fuentes Grau 2021-05-06 01:01:15 +02:00
parent 92a4f5ec4d
commit dd453f668e
2 changed files with 72 additions and 50 deletions

View file

@ -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 {
</Table>
</Col>
<Col>
{this.state.ic.type === "villas-node" ?
{this.state.ic.type === "villas-node" ?
<>
<b>Raw Status</b>
{this.state.ic.statusupdateraw !== null && this.isJSON(this.state.ic.statusupdateraw) ?
<ReactJson
src={this.state.ic.statusupdateraw}
name={false}
displayDataTypes={false}
displayObjectSize={false}
enableClipboard={false}
collapsed={0}
/> : <div>No valid JSON raw data available.</div>}
<b>Raw Config</b>
{this.state.ic.statusupdateraw && this.isJSON(this.state.ic.statusupdateraw["config"]) ?
<ReactJson
src={this.state.ic.statusupdateraw["config"]}
name={false}
displayDataTypes={false}
displayObjectSize={false}
enableClipboard={false}
collapsed={0}
/> : <div>No valid config JSON raw data available.</div>}
<b>Raw Statistics</b>
{this.state.ic.statusupdateraw && this.isJSON(this.state.ic.statusupdateraw["statistics"]) ?
<ReactJson
src={this.state.ic.statusupdateraw["statistics"]}
name={false}
displayDataTypes={false}
displayObjectSize={false}
enableClipboard={false}
collapsed={0}
/> : <div>No valid statistics JSON raw data available.</div>}
<div className='section-buttons-group-right'>
<Button style={{ margin: '5px' }} size='sm' onClick={() => this.downloadGraph(graphURL)}><Icon
icon="download" /></Button>
@ -278,6 +264,10 @@ class InfrastructureComponent extends React.Component {
{this.state.ic.type === "villas-relay" ?
<>
<div className='section-buttons-group-right'>
<Button style={{ margin: '5px' }} size='sm' onClick={() => this.refresh()}><Icon
icon="sync-alt" /></Button>
</div>
<b>Raw Status</b>
{this.state.ic.statusupdateraw !== null && this.isJSON(this.state.ic.statusupdateraw) ?
<ReactJson
@ -286,14 +276,59 @@ class InfrastructureComponent extends React.Component {
displayDataTypes={false}
displayObjectSize={false}
enableClipboard={false}
collapsed={0}
collapsed={1}
/> : <div>No valid JSON raw data available.</div>}
</>
:
<div />}
</Col>
</Row>
<Row>
{this.state.ic.type === "villas-node" ?
<>
<Col>
<b>Raw Status</b>
{this.state.ic.statusupdateraw !== null && this.isJSON(this.state.ic.statusupdateraw) ?
<ReactJson
src={this.state.ic.statusupdateraw}
name={false}
displayDataTypes={false}
displayObjectSize={false}
enableClipboard={false}
collapsed={1}
/> : <div>No valid JSON raw data available.</div>}
</Col>
<Col>
<b>Raw Config</b>
{this.state.ic.statusupdateraw && this.isJSON(this.state.ic.statusupdateraw["config"]) ?
<ReactJson
src={this.state.ic.statusupdateraw["config"]}
name={false}
displayDataTypes={false}
displayObjectSize={false}
enableClipboard={false}
collapsed={1}
/> : <div>No valid config JSON raw data available.</div>}
</Col>
<Col>
<div className='section-buttons-group-right'>
<Button style={{ margin: '5px' }} onClick={() => this.refresh()}><Icon
icon="sync-alt" /></Button>
</div>
<b>Raw Statistics</b>
{this.state.ic.statusupdateraw && this.isJSON(this.state.ic.statusupdateraw["statistics"]) ?
<ReactJson
src={this.state.ic.statusupdateraw["statistics"]}
name={false}
displayDataTypes={false}
displayObjectSize={false}
enableClipboard={false}
collapsed={1}
/> : <div>No valid statistics JSON raw data available.</div>}
</Col>
</>
: <div />}
</Row>
</Container>
</div>;
}

View file

@ -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
});
}
})
}
}