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

improve styling over labels in simulator view

This commit is contained in:
Steffen Vogel 2018-11-27 19:21:48 +01:00
parent 29ffefaea1
commit 9efdd2f111
2 changed files with 33 additions and 24 deletions

View file

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

View file

@ -91,6 +91,7 @@ class Simulators extends Component {
});
}
closeNewModal(data) {
this.setState({ newModal : false });
@ -200,32 +201,39 @@ class Simulators extends Component {
return Date.now() - new Date(simulator.stateUpdatedAt) > fiveMinutes;
}
isSimulatorOnline(state) {
return state !== '' && state !== 'shutdown' && state !== 'unknown';
}
stateLabelStyle = (state, simulator) => {
if (this.isSimulatorOutdated(simulator)) {
return 'default';
var style = [ 'label' ];
if (this.isSimulatorOutdated(simulator) && state !== 'shutdown') {
style.push('label-outdated');
}
if (this.isSimulatorOnline(state)) {
return 'success';
switch (state) {
case 'running':
style.push('label-success');
break;
case 'paused':
style.push('label-info');
break;
case 'idle':
style.push('label-primary');
break;
case 'error':
style.push('label-danger');
break;
case 'shutdown':
style.push('label-warning');
break;
default:
style.push('label-default');
}
return 'danger';
}
stateLabelModifier = (state, simulator) => {
if (this.isSimulatorOutdated(simulator)) {
return 'unknown';
}
if (this.isSimulatorOnline(state)) {
return 'online';
}
return 'offline';
return style.join(' ');
}
stateUpdateModifier = updatedAt => {
@ -246,10 +254,11 @@ class Simulators extends Component {
<Table data={this.state.simulators}>
<TableColumn checkbox onChecked={(index, event) => this.onSimulatorChecked(index, event)} width='30' />
<TableColumn title='Name' dataKeys={['properties.name', 'rawProperties.name']} />
<TableColumn title='State' dataKey='state' labelKey='state' labelModifier={this.stateLabelModifier} labelStyle={this.stateLabelStyle} />
<TableColumn title='State' labelKey='state' tooltipKey='error' labelModifier={this.stateLabelModifier} labelStyle={this.stateLabelStyle} />
<TableColumn title='Category' dataKeys={['properties.category', 'rawProperties.category']} />
<TableColumn title='Type' dataKeys={['properties.type', 'rawProperties.type']} />
<TableColumn title='Location' dataKeys={['properties.location', 'rawProperties.location']} />
<TableColumn title='Realm' dataKeys={['properties.realm', 'rawProperties.realm']} />
{/* <TableColumn title='Realm' dataKeys={['properties.realm', 'rawProperties.realm']} /> */}
<TableColumn title='Host' dataKey='host' />
<TableColumn title='Last Update' dataKey='stateUpdatedAt' modifier={this.stateUpdateModifier} />
<TableColumn