From 34e26c293c423cad30ec588638b9471a32f687f5 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 8 Mar 2021 13:39:02 +0100 Subject: [PATCH] several whitespace code cleanups --- src/ic/edit-ic.js | 6 ----- src/ic/ic-action.js | 1 - src/ic/ic-dialog.js | 38 ++++++++++++++----------------- src/ic/ics.js | 48 +++++++++++++++++----------------------- src/ic/new-ic.js | 4 +--- src/scenario/scenario.js | 3 +-- 6 files changed, 39 insertions(+), 61 deletions(-) diff --git a/src/ic/edit-ic.js b/src/ic/edit-ic.js index 69ba89b..74fea1e 100644 --- a/src/ic/edit-ic.js +++ b/src/ic/edit-ic.js @@ -50,14 +50,9 @@ class EditICDialog extends React.Component { data.name = this.state.name; } - data.websocketurl = this.state.websocketurl; - - - data.apiurl = this.state.apiurl; - if (this.state.location != null && this.state.location !== this.props.ic.location) { data.location = this.state.location; } @@ -79,7 +74,6 @@ class EditICDialog extends React.Component { data.managedexternally = this.state.managedexternally; - this.props.onClose(data); this.setState({managedexternally: false}); } diff --git a/src/ic/ic-action.js b/src/ic/ic-action.js index 0565be7..584f1f5 100644 --- a/src/ic/ic-action.js +++ b/src/ic/ic-action.js @@ -55,7 +55,6 @@ class ICAction extends React.Component { } runAction(action, when) { - if (action.data.action === 'none') { console.warn("No command selected. Nothing was sent."); return; diff --git a/src/ic/ic-dialog.js b/src/ic/ic-dialog.js index cba6291..435bb92 100644 --- a/src/ic/ic-dialog.js +++ b/src/ic/ic-dialog.js @@ -6,7 +6,6 @@ import ConfirmCommand from './confirm-command'; import ReactJson from 'react-json-view'; import FileSaver from 'file-saver'; - class ICDialog extends React.Component { valid = true; @@ -46,7 +45,6 @@ class ICDialog extends React.Component { FileSaver.saveAs(blob, this.props.ic.name + ".svg"); } - render() { let graphURL = "" @@ -54,7 +52,6 @@ class ICDialog extends React.Component { graphURL = this.props.ic.apiurl + "/graph.svg" } - return ( -
Raw Status:
- {this.props.userRole === "Admin" ? ( -
-
Controls:
-
- - -
-
) - : (
)} - + {this.props.userRole === "Admin" ? +
+
Controls:
+
+ + +
+
+ :
+ } this.closeConfirmModal(c)}/> - - ) : (
)} + + :
+ }
- ); } } diff --git a/src/ic/ics.js b/src/ic/ics.js index 6152c17..c630cb0 100644 --- a/src/ic/ics.js +++ b/src/ic/ics.js @@ -88,7 +88,6 @@ class InfrastructureComponents extends Component { let services = ics.filter(ic => ic.category === "service") let equipment = ics.filter(ic => ic.category === "equipment") - return { sessionToken: localStorage.getItem("token"), ics: ics, @@ -112,7 +111,7 @@ class InfrastructureComponents extends Component { token: this.state.sessionToken, }); - // Start timer for periodic refresh + // Start timer for periodic refresh this.timer = window.setInterval(() => this.refresh(), 10000); } @@ -121,7 +120,6 @@ class InfrastructureComponents extends Component { } refresh() { - if (this.state.editModal || this.state.deleteModal || this.state.icModal){ // do nothing since a dialog is open at the moment } @@ -160,6 +158,7 @@ class InfrastructureComponents extends Component { } else { // externally managed IC: dispatch create action to selected manager let newAction = {}; + newAction["action"] = "create"; newAction["parameters"] = data; newAction["when"] = new Date() @@ -178,7 +177,6 @@ class InfrastructureComponents extends Component { result: null, token: this.state.sessionToken }); - } } } @@ -266,8 +264,6 @@ class InfrastructureComponents extends Component { this.setState({ selectedICs: selectedICs }); } - - static isICOutdated(component) { if (!component.stateUpdateAt) return true; @@ -323,18 +319,18 @@ class InfrastructureComponents extends Component { style.push('badge-default'); /* Possible states of ICs - * 'error': ['resetting', 'error'], - 'idle': ['resetting', 'error', 'idle', 'starting', 'shuttingdown'], - 'starting': ['resetting', 'error', 'running'], - 'running': ['resetting', 'error', 'pausing', 'stopping'], - 'pausing': ['resetting', 'error', 'paused'], - 'paused': ['resetting', 'error', 'resuming', 'stopping'], - 'resuming': ['resetting', 'error', 'running'], - 'stopping': ['resetting', 'error', 'idle'], - 'resetting': ['resetting', 'error', 'idle'], - 'shuttingdown': ['shutdown', 'error'], - 'shutdown': ['starting', 'error'] - * */ + * 'error': ['resetting', 'error'], + * 'idle': ['resetting', 'error', 'idle', 'starting', 'shuttingdown'], + * 'starting': ['resetting', 'error', 'running'], + * 'running': ['resetting', 'error', 'pausing', 'stopping'], + * 'pausing': ['resetting', 'error', 'paused'], + * 'paused': ['resetting', 'error', 'resuming', 'stopping'], + * 'resuming': ['resetting', 'error', 'running'], + * 'stopping': ['resetting', 'error', 'idle'], + * 'resetting': ['resetting', 'error', 'idle'], + * 'shuttingdown': ['shutdown', 'error'], + * 'shutdown': ['starting', 'error'] + */ } return style.join(' ') @@ -483,24 +479,21 @@ class InfrastructureComponents extends Component {

Infrastructure Components {this.state.currentUser.role === "Admin" ? - ( + Add Infrastructure Component } > - + Import Infrastructure Component } > - + - ) - : - ( ) + + : }

@@ -525,8 +518,7 @@ class InfrastructureComponents extends Component { ]} />
- : -
+ :
}
diff --git a/src/ic/new-ic.js b/src/ic/new-ic.js index 39aeebd..1fbef20 100644 --- a/src/ic/new-ic.js +++ b/src/ic/new-ic.js @@ -75,7 +75,7 @@ class NewICDialog extends React.Component { this.setState({ managedexternally : !this.state.managedexternally}); } else{ - this.setState({ [e.target.id]: e.target.value }); + this.setState({ [e.target.id]: e.target.value }); } } @@ -163,7 +163,6 @@ class NewICDialog extends React.Component { ); } - return ( this.onClose(c)} onReset={() => this.resetState()} valid={this.validateForm()}>
@@ -185,7 +184,6 @@ class NewICDialog extends React.Component { :
- } :
diff --git a/src/scenario/scenario.js b/src/scenario/scenario.js index 1f8dee2..9432b71 100644 --- a/src/scenario/scenario.js +++ b/src/scenario/scenario.js @@ -376,7 +376,7 @@ class Scenario extends React.Component { let ic = null; for (let component of this.state.ics) { - if (component.id === this.state.configs[index].icID) { + if (component.id === icID) { ic = component; } } @@ -391,7 +391,6 @@ class Scenario extends React.Component { } return false - } getICName(icID) {