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

Modify send command to IC buttons (point 1 of #225)

This commit is contained in:
Sonja Happ 2020-06-23 09:34:33 +02:00
parent 766ccc23d3
commit eb1756852b
2 changed files with 18 additions and 6 deletions

View file

@ -55,11 +55,12 @@ class ICAction extends React.Component {
));
return <div>
Send command to infrastructure component
<ButtonToolbar>
<DropdownButton title={this.state.selectedAction != null ? this.state.selectedAction.title : ''} id="action-dropdown" onSelect={this.setAction}>
{actionList}
</DropdownButton>
<Button style={{ marginLeft: '5px' }} disabled={this.props.runDisabled} onClick={() => this.props.runAction(this.state.selectedAction)}>Run</Button>
<Button style={{ marginLeft: '5px' }} disabled={this.props.runDisabled} onClick={() => this.props.runAction(this.state.selectedAction)}>Send command</Button>
</ButtonToolbar>
</div>;

View file

@ -234,12 +234,18 @@ class Scenario extends React.Component {
this.setState({ selectedConfigs: selectedConfigs });
}
runAction = action => {
runAction(action) {
if(action.data.action === 'none'){
console.warn("No command selected. Nothing was sent.");
return;
}
for (let index of this.state.selectedConfigs) {
// get IC for component config
let ic = null;
for (let component of this.state.ics) {
if (component._id === this.state.configs[index].icID) {
if (component.id === this.state.configs[index].icID) {
ic = component;
}
}
@ -410,11 +416,15 @@ class Scenario extends React.Component {
marginLeft: '10px'
};
const tableHeadingStyle = {
paddingTop: '30px'
}
return <div className='section'>
<h1>{this.state.scenario.name}</h1>
{/*Component Configurations table*/}
<h2>Component Configurations</h2>
<h2 style={tableHeadingStyle}>Component Configurations</h2>
<Table data={this.state.configs}>
<TableColumn checkbox onChecked={(index, event) => this.onConfigChecked(index, event)} width='30' />
<TableColumn title='Name' dataKey='name' />
@ -447,8 +457,9 @@ class Scenario extends React.Component {
<div style={{ float: 'left' }}>
<ICAction
runDisabled={this.state.selectedConfigs.length === 0}
runAction={this.runAction}
runAction={(action) => this.runAction(action)}
actions={[
{ id: '-1', title: 'Select command', data: { action: 'none' } },
{ id: '0', title: 'Start', data: { action: 'start' } },
{ id: '1', title: 'Stop', data: { action: 'stop' } },
{ id: '2', title: 'Pause', data: { action: 'pause' } },
@ -493,7 +504,7 @@ class Scenario extends React.Component {
configID={this.state.modalConfigData.id}/>
{/*Dashboard table*/}
<h2>Dashboards</h2>
<h2 style={tableHeadingStyle}>Dashboards</h2>
<Table data={this.state.dashboards}>
<TableColumn title='Name' dataKey='name' link='/dashboards/' linkKey='id' />
<TableColumn title='Grid' dataKey='grid' />