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

send multiple actions in a single request

This commit is contained in:
Steffen Vogel 2018-11-23 22:05:53 +02:00
parent eb2cc000c0
commit c40998cc61
5 changed files with 20 additions and 12 deletions

View file

@ -48,7 +48,7 @@ export default function createControls(widgetType = null, widget = null, session
<EditWidgetTextControl key={0} widget={widget} controlId={'name'} label={'Text'} placeholder={'Enter text'} validate={id => validateForm(id)} handleChange={e => handleChange(e)} />,
<EditWidgetTextControl key={1} widget={widget} controlId={'icon'} label={'Icon'} placeholder={'Enter an awesome font icon name'} validate={id => validateForm(id)} handleChange={e => handleChange(e)} />,
<EditWidgetSimulationControl key={2} widget={widget} validate={(id) => validateForm(id)} simulationModels={simulationModels} handleChange={(e) => handleChange(e)} />,
<EditWidgetParametersControl key={3} widget={widget} controlId={'action'} label={'Action'} handleChange={(e) => handleChange(e)} />
<EditWidgetParametersControl key={3} widget={widget} controlId={'actions'} label={'Actions'} handleChange={(e) => handleChange(e)} />
)
break;
case 'Action':

View file

@ -41,15 +41,20 @@ class WidgetFactory {
// set type specific properties
switch(type) {
case 'CustomAction':
widget.action = {
action: 'start',
model: {
url: 'ftp://user:pass@example.com/projectA/model.zip'
widget.actions = [
{
action: 'stop'
},
parameters: {
timestep: 50e-6
{
action: 'pause',
model: {
url: 'ftp://user:pass@example.com/projectA/model.zip'
},
parameters: {
timestep: 50e-6
}
}
};
];
widget.name = 'Action';
widget.icon = 'star';
widget.width = 100;

View file

@ -54,7 +54,7 @@ class WidgetCustomAction extends Component {
AppDispatcher.dispatch({
type: 'simulators/start-action',
simulator: this.state.simulator,
data: this.props.widget.action,
data: this.props.widget.actions,
token: this.state.sessionToken
});
}

View file

@ -28,7 +28,7 @@ class SimulatorsDataManager extends RestDataManager {
super('simulator', '/simulators');
}
doAction(simulator, action, token = null) {
doActions(simulator, action, token = null) {
// TODO: Make only simulator id dependent
RestAPI.post(this.makeURL(this.url + '/' + simulator._id), action, token).then(response => {
AppDispatcher.dispatch({
@ -39,7 +39,7 @@ class SimulatorsDataManager extends RestDataManager {
AppDispatcher.dispatch({
type: 'simulators/action-error',
error
});
});
});
}
}

View file

@ -65,7 +65,10 @@ class SimulatorStore extends ArrayStore {
return state;
case 'simulators/start-action':
SimulatorsDataManager.doAction(action.simulator, action.data, action.token);
if (!Array.isArray(action.data))
action.data = [ action.data ]
SimulatorsDataManager.doActions(action.simulator, action.data, action.token);
return state;
case 'simulators/action-error':