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

removed unused js module

This commit is contained in:
Ricardo Hernandez-Montoya 2017-05-23 10:57:28 +02:00
parent 72ffd6cd96
commit 0e7ce1aff0

View file

@ -1,64 +0,0 @@
/**
* File: edit-widget-signal-type-control.js
* Author: Ricardo Hernandez-Montoya <rhernandez@gridhound.de>
* Date: 03.04.2017
* Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
* This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
* Unauthorized copying of this file, via any medium is strictly prohibited.
**********************************************************************************/
import React, { Component } from 'react';
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
class EditWidgetSignalTypeControl extends Component {
constructor(props) {
super(props);
this.state = {
widget: {}
};
}
componentWillReceiveProps(nextProps) {
// Update state's widget with props
this.setState({ widget: nextProps.widget });
}
render() {
// get selected simulation model
var simulationModel = {};
if (this.props.simulation) {
this.props.simulation.models.forEach((model) => {
if (model.simulation === this.state.widget.simulation) {
simulationModel = model;
}
});
}
// Obtain unique signal types with the help of dictionary keys
var signalTypes = Object.keys(simulationModel.mapping.reduce( (collection, signal) => {
var lower = signal.type.toLowerCase();
collection[lower] = '';
return collection;
}, {}));
var capitalize = (str) => { return str.charAt(0).toUpperCase() + str.slice(1); }
var selectedValue = signalTypes.includes(this.state.widget.signalType) ? this.state.widget.signalType : '';
return (
<FormGroup controlId="signalType">
<ControlLabel>Signal type</ControlLabel>
<FormControl componentClass="select" placeholder="Select signal type" value={ selectedValue } onChange={(e) => this.props.handleChange(e)}>
<option disabled value style={{ display: 'none' }}> Select signal type </option>
{signalTypes.map((type, index) => (
<option key={type} value={type}>{ capitalize(type) }</option>
))}
</FormControl>
</FormGroup>
);
}
}
export default EditWidgetSignalTypeControl;