Commit c40998cc authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

send multiple actions in a single request

parent eb2cc000
......@@ -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':
......
......@@ -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;
......
......@@ -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
});
}
......
......@@ -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
});
});
});
}
}
......
......@@ -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':
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment