diff --git a/src/dashboard/dashboard.js b/src/dashboard/dashboard.js
index 2fbc259..f3354cc 100644
--- a/src/dashboard/dashboard.js
+++ b/src/dashboard/dashboard.js
@@ -15,7 +15,7 @@
* along with VILLASweb. If not, see
, prevState: Readonly, snapshot: SS) {
- // open web sockets if ICs are already known and sockets are not opened yet
- if(this.state.ics !== undefined && !Dashboard.webSocketsOpened){
- if(this.state.ics.length > 0){
+ // open web sockets if ICs are already known and sockets are not opened yet
+ if (this.state.ics !== undefined && !Dashboard.webSocketsOpened) {
+ if (this.state.ics.length > 0) {
console.log("Starting to open IC websockets:", this.state.ics);
AppDispatcher.dispatch({
type: 'ics/open-sockets',
@@ -186,7 +187,7 @@ class Dashboard extends Component {
}
- if(prevState.dashboard === undefined && this.state.dashboard !== undefined){
+ if (prevState.dashboard === undefined && this.state.dashboard !== undefined) {
// the dashboard was loaded, so that the scenarioID is available
// load configs of scenario
@@ -231,7 +232,7 @@ class Dashboard extends Component {
transformToWidgetsList(widgets) {
- return Object.keys(widgets).map( (key) => widgets[key]);
+ return Object.keys(widgets).map((key) => widgets[key]);
}
handleDrop(widget) {
@@ -252,35 +253,35 @@ class Dashboard extends Component {
this.widgetChange(updated_widget, key, this.saveChanges);
}
- widgetChange(widget, index, callback = null){
+ widgetChange(widget, index, callback = null) {
let temp = this.state.widgetChangeData;
temp.push(widget);
- this.setState({widgetChangeData: temp});
+ this.setState({ widgetChangeData: temp });
}
- editWidget(widget, index){
+ editWidget(widget, index) {
this.setState({ editModal: true, modalData: widget, modalIndex: index });
};
- startEditFiles(){
+ startEditFiles() {
let tempFiles = [];
- this.state.files.forEach( file => {
+ this.state.files.forEach(file => {
tempFiles.push({
id: file.id,
name: file.name
});
})
- this.setState({filesEditModal: true, filesEditSaveState: tempFiles});
+ this.setState({ filesEditModal: true, filesEditSaveState: tempFiles });
}
- closeEditFiles(){
+ closeEditFiles() {
this.setState({ filesEditModal: false });
}
- closeEdit(data){
+ closeEdit(data) {
if (data == null) {
@@ -315,11 +316,11 @@ class Dashboard extends Component {
};
- startEditing(){
+ startEditing() {
let originalIDs = [];
- this.state.widgets.forEach( widget => {
+ this.state.widgets.forEach(widget => {
originalIDs.push(widget.id);
- if(widget.type === 'Slider' || widget.type === 'NumberInput' || widget.type === 'Button'){
+ if (widget.type === 'Slider' || widget.type === 'NumberInput' || widget.type === 'Button') {
AppDispatcher.dispatch({
type: 'widgets/start-edit',
token: this.state.sessionToken,
@@ -339,21 +340,21 @@ class Dashboard extends Component {
token: this.state.sessionToken
});
- this.state.widgetChangeData.forEach( widget => {
+ this.state.widgetChangeData.forEach(widget => {
AppDispatcher.dispatch({
type: 'widgets/start-edit',
token: this.state.sessionToken,
data: widget
});
});
- this.setState({ editing: false, widgetChangeData: []});
+ this.setState({ editing: false, widgetChangeData: [] });
};
saveChanges() {
// Transform to a list
const dashboard = Object.assign({}, this.state.dashboard.toJS(), {
- widgets: this.transformToWidgetsList(this.state.widgets)
- });
+ widgets: this.transformToWidgetsList(this.state.widgets)
+ });
AppDispatcher.dispatch({
type: 'dashboards/start-edit',
@@ -364,16 +365,16 @@ class Dashboard extends Component {
cancelEditing() {
//raw widget has no id -> cannot be deleted in its original form
- this.state.widgets.forEach(widget => {
- let tempID = this.state.widgetOrigIDs.find(element => element === widget.id);
- if(typeof tempID === 'undefined'){
- AppDispatcher.dispatch({
- type: 'widgets/start-remove',
- data: widget,
- token: this.state.sessionToken
- });
- }
- })
+ this.state.widgets.forEach(widget => {
+ let tempID = this.state.widgetOrigIDs.find(element => element === widget.id);
+ if (typeof tempID === 'undefined') {
+ AppDispatcher.dispatch({
+ type: 'widgets/start-remove',
+ data: widget,
+ token: this.state.sessionToken
+ });
+ }
+ })
AppDispatcher.dispatch({
type: 'widgets/start-load',
@@ -386,7 +387,7 @@ class Dashboard extends Component {
data: this.props.match.params.dashboard,
token: this.state.sessionToken
});
- this.setState({ editing: false, widgetChangeData: []});
+ this.setState({ editing: false, widgetChangeData: [] });
};
@@ -400,30 +401,30 @@ class Dashboard extends Component {
setDashboardSize(value) {
const maxHeight = Object.values(this.state.widgets).reduce((currentHeight, widget) => {
- const absolutHeight = widget.y + widget.height;
+ const absolutHeight = widget.y + widget.height;
- return absolutHeight > currentHeight ? absolutHeight : currentHeight;
+ return absolutHeight > currentHeight ? absolutHeight : currentHeight;
}, 0);
let dashboard = this.state.dashboard;
- if(value === -1){
+ if (value === -1) {
let tempHeight = this.state.dashboard.height - 50;
- if(tempHeight >= 400 && tempHeight >= (maxHeight + 80)){
+ if (tempHeight >= 400 && tempHeight >= (maxHeight + 80)) {
dashboard.height = tempHeight;
- this.setState({dashboard});
+ this.setState({ dashboard });
}
}
- else{
- dashboard.height = this.state.dashboard.height +50;
- this.setState( {dashboard});
+ else {
+ dashboard.height = this.state.dashboard.height + 50;
+ this.setState({ dashboard });
}
this.forceUpdate();
}
- pauseData(){
+ pauseData() {
this.setState({ paused: true });
};
@@ -431,25 +432,25 @@ class Dashboard extends Component {
this.setState({ paused: false });
};
- editInputSignals(){
- this.setState({editInputSignalsModal: true});
+ editInputSignals() {
+ this.setState({ editInputSignalsModal: true });
};
- editOutputSignals(){
- this.setState({editOutputSignalsModal: true});
+ editOutputSignals() {
+ this.setState({ editOutputSignalsModal: true });
};
- closeEditSignalsModal(direction){
- if( direction === "in") {
- this.setState({editInputSignalsModal: false});
- } else if( direction === "out"){
- this.setState({editOutputSignalsModal: false});
+ closeEditSignalsModal(direction) {
+ if (direction === "in") {
+ this.setState({ editInputSignalsModal: false });
+ } else if (direction === "out") {
+ this.setState({ editOutputSignalsModal: false });
}
}
render() {
- if (this.state.dashboard === undefined){
+ if (this.state.dashboard === undefined) {
return