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

several whitespace code cleanups

This commit is contained in:
Steffen Vogel 2021-03-08 13:39:02 +01:00
parent 83712a7693
commit 34e26c293c
6 changed files with 39 additions and 61 deletions

View file

@ -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});
}

View file

@ -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;

View file

@ -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 (
<Dialog
show={this.props.show}
@ -88,7 +85,6 @@ class ICDialog extends React.Component {
</Col>
<Col>
<h5>Raw Status:</h5>
<ReactJson
src={this.props.ic.statusupdateraw}
@ -110,29 +106,29 @@ class ICDialog extends React.Component {
<img alt={"Graph image download failed and/or incorrect image API URL"} src={graphURL}/>
</div>
{this.props.userRole === "Admin" ? (
<div>
<h5>Controls:</h5>
<div className='solid-button'>
<Button variant='secondary' style={{margin: '5px'}} size='lg'
onClick={() => this.setState({confirmCommand: true, command: 'restart'})}>Restart</Button>
<Button variant='secondary' style={{margin: '5px'}} size='lg' onClick={() => this.setState({
confirmCommand: true,
command: 'shutdown'
})}>Shutdown</Button>
</div>
</div>)
: (<div/>)}
{this.props.userRole === "Admin" ?
<div>
<h5>Controls:</h5>
<div className='solid-button'>
<Button variant='secondary' style={{margin: '5px'}} size='lg'
onClick={() => this.setState({confirmCommand: true, command: 'restart'})}>Restart</Button>
<Button variant='secondary' style={{margin: '5px'}} size='lg' onClick={() => this.setState({
confirmCommand: true,
command: 'shutdown'
})}>Shutdown</Button>
</div>
</div>
: <div/>
}
<ConfirmCommand show={this.state.confirmCommand} command={this.state.command} name={this.props.ic.name}
onClose={c => this.closeConfirmModal(c)}/>
</>) : (<div/>)}
</>
: <div/>
}
</Col>
</Row>
</form>
</Dialog>
);
}
}

View file

@ -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 {
<div className='section'>
<h1>Infrastructure Components
{this.state.currentUser.role === "Admin" ?
(<span className='icon-button'>
<span className='icon-button'>
<OverlayTrigger
key={1}
placement={'top'}
overlay={<Tooltip id={`tooltip-${"add"}`}> Add Infrastructure Component </Tooltip>} >
<Button variant='light' onClick={() => this.setState({newModal: true})} style={buttonStyle}><Icon icon="plus" classname='icon-color' style={iconStyle}
/></Button>
<Button variant='light' onClick={() => this.setState({newModal: true})} style={buttonStyle}><Icon icon="plus" classname='icon-color' style={iconStyle}/></Button>
</OverlayTrigger>
<OverlayTrigger
key={2}
placement={'top'}
overlay={<Tooltip id={`tooltip-${"import"}`}> Import Infrastructure Component </Tooltip>} >
<Button variant='light' onClick={() => this.setState({importModal: true})} style={buttonStyle}><Icon icon="upload" classname='icon-color' style={iconStyle}
/></Button>
<Button variant='light' onClick={() => this.setState({importModal: true})} style={buttonStyle}><Icon icon="upload" classname='icon-color' style={iconStyle}/></Button>
</OverlayTrigger>
</span>)
:
(<span> </span>)
</span>
: <span/>
}
</h1>
@ -525,8 +518,7 @@ class InfrastructureComponents extends Component {
]}
/>
</div>
:
<div/>
: <div/>
}
<div style={{ clear: 'both' }} />

View file

@ -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 (
<Dialog show={this.props.show} title="New Infrastructure Component" buttonTitle="Add" onClose={(c) => this.onClose(c)} onReset={() => this.resetState()} valid={this.validateForm()}>
<form>
@ -185,7 +184,6 @@ class NewICDialog extends React.Component {
</FormControl>
</FormGroup>
: <div/>
}
</>
: <div/>

View file

@ -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) {