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

WIP: make TimeOffset Widget editable #208

This commit is contained in:
Laura Fuentes Grau 2020-11-30 19:25:50 +01:00
parent 62840e939d
commit cf402c7ca7
4 changed files with 39 additions and 7 deletions

View file

@ -394,4 +394,20 @@ div[class*="-widget"] label {
height: 100%;
border: 2px solid lightgray;
}
/* End box widget */
/* End box widget */
/* Begin time offset widget */
.time-offset {
display: flex;
align-items: center;
justify-content: space-around;
flex-direction: column;
}
.time-offset span {
text-align: center;
font-size: 1.5em;
font-weight: 600;
padding-top: 10px;
}
/* End time offset widget */

View file

@ -158,6 +158,15 @@ export default function CreateControls(widgetType = null, widget = null, session
);
break;
case 'TimeOffset':
DialogControls.push(
<EditWidgetNumberControl key={1} widget={widget} controlId={'customProperties.threshold_yellow'} label={'Threshold yellow'} defaultValue={0} handleChange={(e) => handleChange(e)} />,
<EditWidgetNumberControl key={2} widget={widget} controlId={'customProperties.threshold_red'} label={'Threshold red'} defaultValue={0} handleChange={(e) => handleChange(e)} />,
<EditWidgetCheckboxControl key={3} widget={widget} controlId={'customProperties.horizontal'} input text="Horizontal" handleChange={e => handleChange(e)} />,
<EditWidgetCheckboxControl key={4} widget={widget} controlId={'customProperties.showOffset'} input text="showOffset" handleChange={e => handleChange(e)} />,
);
break;
default:
console.log('Non-valid widget type: ' + widgetType);
}

View file

@ -198,11 +198,14 @@ class WidgetFactory {
case 'TimeOffset':
widget.minWidth = 20;
widget.minHeight = 20;
widget.width = 100;
widget.height = 100;
widget.width = 60;
widget.height = 60;
widget.customProperties.threshold_yellow = 1;
widget.customProperties.threshold_red = 2;
widget.customProperties.icID = 1;
widget.customProperties.horizontal = false;
widget.customProperties.showOffset = true;
break;
default:
widget.width = 100;

View file

@ -51,14 +51,18 @@ class WidgetTimeOffset extends Component {
render() {
return (
<div>
<TrafficLight
<div className="time-offset">
<TrafficLight Horizontal={this.props.widget.customProperties.horizontal}
RedOn={this.props.widget.customProperties.threshold_red <= this.state.timeOffset}
YellowOn={(this.props.widget.customProperties.threshold_yellow <= this.state.timeOffset) && (this.state.timeOffset < this.props.widget.customProperties.threshold_red)}
GreenOn={this.state.timeOffset < this.props.widget.customProperties.threshold_yellow}
/>
<div>Time offset:</div>
<strong>{this.state.timeOffset}s</strong>
{this.props.widget.customProperties.showOffset ?
(
<span>{this.state.timeOffset}s</span>)
:
(<div></div>)
}
</div>
);
}