- {"Select delay for command execution (Format hh:mm, max 1h):"}
-
-
-
- {actionList}
-
-
-
-
-
-
;
+ setAction = id => {
+ // search action
+ for (let action of this.props.actions) {
+ if (action.id === id) {
+ this.setState({ selectedAction: action });
+ }
}
+ };
+
+ setTimeForAction = (time) => {
+ this.setState({ time: new Date(time) })
+ }
+
+ render() {
+
+ let sendCommandDisabled = this.props.runDisabled || this.state.selectedAction == null || this.state.selectedAction.id === "-1"
+
+ let time = this.state.time.getFullYear().pad(4) + '-' +
+ this.state.time.getMonth().pad(2) + '-' +
+ this.state.time.getDay().pad(2) + 'T' +
+ this.state.time.getHours().pad(2) + ':' +
+ this.state.time.getMinutes().pad(2);
+
+ const actionList = this.props.actions.map(action => (
+
Infrastructure Components
@@ -407,69 +481,20 @@ class InfrastructureComponents extends Component {
( )
}
-
- this.isExternalIC(index)}
- onChecked={(index, event) => this.onICChecked(index, event)}
- width='30'
- />
- this.modifyNameColumn(name, component)}
- />
- this.stateLabelStyle(state, component)}
- />
-
-
- this.modifyUptimeColumn(uptime, component)}
- />
- this.stateUpdateModifier(stateUpdateAt, component)}
- />
- {this.state.currentUser.role === "Admin" ?
- this.setState({editModal: true, modalIC: this.state.ics[index], modalIndex: index})}
- onExport={index => this.exportIC(index)}
- onDelete={index => this.setState({deleteModal: true, modalIC: this.state.ics[index], modalIndex: index})}
- />
- :
- this.exportIC(index)}
- />
- }
-
+ {managerTable}
+ {simulatorTable}
+ {gatewayTable}
+ {serviceTable}
+ {equipmentTable}
{this.state.currentUser.role === "Admin" && this.state.numberOfExternalICs > 0 ?
this.runAction(action)}
+ runAction={(action, when) => this.runAction(action, when)}
actions={[
- {id: '-1', title: 'Select command', data: {action: 'none'}},
+ {id: '-1', title: 'Action', data: {action: 'none'}},
{id: '0', title: 'Reset', data: {action: 'reset'}},
{id: '1', title: 'Shutdown', data: {action: 'shutdown'}},
]}
@@ -481,9 +506,10 @@ class InfrastructureComponents extends Component {
- this.closeNewModal(data)} />
+ this.closeNewModal(data)} managers={this.state.managers} />
this.closeEditModal(data)} ic={this.state.modalIC} />
this.closeImportModal(data)} />
+ this.closeDeleteModal(e)} />
this.closeICModal(data)}
@@ -492,7 +518,6 @@ class InfrastructureComponents extends Component {
userRole={this.state.currentUser.role}
sendControlCommand={(command, ic) => this.sendControlCommand(command, ic)}/>
- this.closeDeleteModal(e)} />
);
}
diff --git a/src/ic/new-ic.js b/src/ic/new-ic.js
index 4f52667..2e81887 100644
--- a/src/ic/new-ic.js
+++ b/src/ic/new-ic.js
@@ -34,7 +34,8 @@ class NewICDialog extends React.Component {
category: '',
managedexternally: false,
description: '',
- location: ''
+ location: '',
+ manager: ''
};
}
@@ -48,7 +49,8 @@ class NewICDialog extends React.Component {
uuid: this.state.uuid,
managedexternally: this.state.managedexternally,
location: this.state.location,
- description: this.state.description
+ description: this.state.description,
+ manager: this.state.manager
};
if (this.state.websocketurl != null && this.state.websocketurl !== "" && this.state.websocketurl !== 'http://') {
@@ -88,6 +90,7 @@ class NewICDialog extends React.Component {
let websocketurl = true;
let type = true;
let category = true;
+ let manager = true;
if (this.state.name === '') {
name = false;
@@ -97,6 +100,10 @@ class NewICDialog extends React.Component {
uuid = false;
}
+ if(this.state.managedexternally && manager === ''){
+ manager = false;
+ }
+
if (this.state.type === '') {
type = false;
}
@@ -105,7 +112,7 @@ class NewICDialog extends React.Component {
category = false;
}
- this.valid = name && uuid && websocketurl && type && category;
+ this.valid = name && uuid && websocketurl && type && category && manager;
// return state to control
if (target === 'name') return name ? "success" : "error";
@@ -113,6 +120,7 @@ class NewICDialog extends React.Component {
if (target === 'websocketurl') return websocketurl ? "success" : "error";
if (target === 'type') return type ? "success" : "error";
if (target === 'category') return category ? "success" : "error";
+ if (target === 'manager') return manager ? "success" : "error";
return this.valid;
}
@@ -131,8 +139,8 @@ class NewICDialog extends React.Component {
case "simulator":
typeOptions = ["dummy","generic","dpsim","rtlab","rscad","opalrt"];
break;
- case "controller":
- typeOptions = ["kubernetes","villas-controller"];
+ case "manager":
+ typeOptions = ["villas-node","villas-relay","generic"];
break;
case "gateway":
typeOptions = ["villas-node","villas-relay"];
@@ -146,33 +154,60 @@ class NewICDialog extends React.Component {
default:
typeOptions =[];
}
+
+ let managerOptions = [];
+ managerOptions.push(
);
+ for (let m of this.props.managers) {
+ managerOptions.push (
+
+ );
+ }
+
+
return (
);
diff --git a/src/scenario/scenario.js b/src/scenario/scenario.js
index 5397bb5..7bf2de9 100644
--- a/src/scenario/scenario.js
+++ b/src/scenario/scenario.js
@@ -390,9 +390,7 @@ class Scenario extends React.Component {
}
- runAction(action, delay) {
- // delay in seconds
-
+ runAction(action, when) {
if (action.data.action === 'none') {
console.warn("No command selected. Nothing was sent.");
return;
@@ -415,8 +413,7 @@ class Scenario extends React.Component {
action.data.parameters = this.state.configs[index].startParameters;
}
- // Unix time stamp + delay
- action.data.when = Math.round(Date.now() / 1000.0 + delay)
+ action.data.when = when;
console.log("Sending action: ", action.data)
@@ -798,8 +795,6 @@ class Scenario extends React.Component {
scenarioID={this.state.scenario.id}
/>
-
-
{/*Component Configurations table*/}
Component Configurations
this.runAction(action, delay)}
+ runAction={(action, when) => this.runAction(action, when)}
actions={[
- {id: '-1', title: 'Select command', data: {action: 'none'}},
+ {id: '-1', title: 'Action', data: {action: 'none'}},
{id: '0', title: 'Start', data: {action: 'start'}},
{id: '1', title: 'Stop', data: {action: 'stop'}},
{id: '2', title: 'Pause', data: {action: 'pause'}},