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 labels to simulator state

This commit is contained in:
Markus Grigull 2018-06-07 21:10:30 +02:00
parent 609fd6249e
commit d3364ed010
2 changed files with 15 additions and 17 deletions

View file

@ -85,10 +85,10 @@ class CustomTable extends Component {
var labelContent = data[labelKey];
if (child.props.labelModifier) {
labelContent = child.props.labelModifier(labelContent);
labelContent = child.props.labelModifier(labelContent, data);
}
cell.push(<span>&nbsp;<Label bsStyle={child.props.labelStyle(data[labelKey])}>{labelContent.toString()}</Label></span>);
cell.push(<span>&nbsp;<Label bsStyle={child.props.labelStyle(data[labelKey], data)}>{labelContent.toString()}</Label></span>);
}
if (child.props.dataIndex) {

View file

@ -165,27 +165,21 @@ class Simulators extends Component {
}
}
labelSimulatorState = state => {
if (state === 'unknown' || state === 'shutdown') {
return <span>
<Label>offline</Label>
isSimulatorOutdated(simulator) {
const fiveMinutes = 5 * 60 * 1000;
{state}
</span>;
}
return <span>
<Label>online</Label>
{state}
</span>;
return Date.now() - new Date(simulator.stateUpdatedAt) > fiveMinutes;
}
isSimulatorOnline(state) {
return state !== 'shutdown' && state !== 'unknown';
}
stateLabelStyle = state => {
stateLabelStyle = (state, simulator) => {
if (this.isSimulatorOutdated(simulator)) {
return 'default';
}
if (this.isSimulatorOnline(state)) {
return 'success';
}
@ -193,7 +187,11 @@ class Simulators extends Component {
return 'danger';
}
stateLabelModifier = state => {
stateLabelModifier = (state, simulator) => {
if (this.isSimulatorOutdated(simulator)) {
return 'unknown';
}
if (this.isSimulatorOnline(state)) {
return 'online';
}