diff --git a/src/ic/ic-action.js b/src/ic/ic-action.js index b187c5e..33fe9a8 100644 --- a/src/ic/ic-action.js +++ b/src/ic/ic-action.js @@ -54,13 +54,6 @@ class ICAction extends React.Component { runAction(action, when) { - console.log("configs", this.props.configs) - console.log("selectedConfigs", this.props.selectedConfigs) - console.log("ics", this.props.ics) - console.log("selectedICs", this.props.selectedICs) - console.log("action", action) - console.log("when", when) - if (action.data.action === 'none') { console.warn("No command selected. Nothing was sent."); return; @@ -169,9 +162,10 @@ class ICAction extends React.Component { if (newAction.action === 'start') { newAction["parameters"] = config.startParameters; - newAction["model"] = {} + if (config.fileIDs.length > 0){ + newAction["model"] = {} newAction.model["type"] = "url" newAction.model["token"] = this.props.token // TODO do not default to the first file of the config @@ -187,7 +181,6 @@ class ICAction extends React.Component { // add the new action newActions.push(newAction); - console.log("New actions in loop", newAction, newActions) } // end for loop over selected configs @@ -204,7 +197,7 @@ class ICAction extends React.Component { } // create new result for new run - newResult.result["description"] = "Placeholder for description" + newResult.result["description"] = "Start at " + when; newResult.result["scenarioID"] = this.props.selectedConfigs[0].scenarioID newResult.result["configSnapshots"] = configSnapshots } diff --git a/src/ic/ic-store.js b/src/ic/ic-store.js index c6d0810..d2e00de 100644 --- a/src/ic/ic-store.js +++ b/src/ic/ic-store.js @@ -79,7 +79,6 @@ class InfrastructureComponentStore extends ArrayStore { case 'ics/action-result-added': for (let a of action.actions){ - let icid = Object.assign({}, a.icid) if (a.results !== undefined && a.results != null){ // adapt URL for newly created result ID @@ -87,13 +86,12 @@ class InfrastructureComponentStore extends ArrayStore { a.results.url = ICsDataManager.makeURL(a.results.url); a.results.url = window.location.host + a.results.url; } - if (a.model !== undefined && a.model != null) { + if (a.model !== undefined && a.model != null && JSON.stringify(a.model) !== JSON.stringify({})) { // adapt URL for model file a.model.url = ICsDataManager.makeURL(a.model.url); a.model.url = window.location.host + a.model.url; } - delete a.icid - ICsDataManager.doActions(icid, [a], action.token) + ICsDataManager.doActions(a.icid, [a], action.token) } return state; diff --git a/src/ic/ics-data-manager.js b/src/ic/ics-data-manager.js index a6a625d..a2382fc 100644 --- a/src/ic/ics-data-manager.js +++ b/src/ic/ics-data-manager.js @@ -25,15 +25,16 @@ class IcsDataManager extends RestDataManager { } doActions(icid, actions, token = null, result=null) { - for (let action of actions) { - if (action.when) - // Send timestamp as Unix Timestamp - action.when = Math.round(action.when.getTime() / 1000); - } - if (icid !== undefined && icid != null) { - console.log("doActions, icid:", icid) + if (icid !== undefined && icid != null && JSON.stringify(icid) !== JSON.stringify({})) { + + for (let action of actions) { + if (action.when) { + // Send timestamp as Unix Timestamp + action.when = Math.round(action.when.getTime() / 1000); + } + } // sending action to a specific IC via IC list RestAPI.post(this.makeURL(this.url + '/' + icid + '/action'), actions, token).then(response => { @@ -54,13 +55,14 @@ class IcsDataManager extends RestDataManager { if (actions[0].action !== "start"){ for (let a of actions){ - console.log("doActions, a.icid:", a.icid) - icid = JSON.parse(JSON.stringify(a.icid)) - delete a.icid - console.log("doActions, icid:", icid) - // sending action to a specific IC via IC list - RestAPI.post(this.makeURL(this.url + '/' + icid + '/action'), [a], token).then(response => { + // sending action to a specific IC via IC list + if (a.when) { + // Send timestamp as Unix Timestamp + a.when = Math.round(a.when.getTime() / 1000); + } + + RestAPI.post(this.makeURL(this.url + '/' + a.icid + '/action'), [a], token).then(response => { AppDispatcher.dispatch({ type: 'ics/action-started', data: response @@ -84,6 +86,11 @@ class IcsDataManager extends RestDataManager { actions: actions, token: token, }); + + AppDispatcher.dispatch({ + type: "results/added", + data: response.result, + }); }).catch(error => { AppDispatcher.dispatch({ type: 'ics/action-result-add-error', diff --git a/src/scenario/scenario.js b/src/scenario/scenario.js index cacb2db..ab65b82 100644 --- a/src/scenario/scenario.js +++ b/src/scenario/scenario.js @@ -302,7 +302,6 @@ class Scenario extends React.Component { } copyConfig(index) { - console.log("index", index, "copyConfig: ", this.state.configs[index]) let config = JSON.parse(JSON.stringify(this.state.configs[index])); let signals = JSON.parse(JSON.stringify(SignalStore.getState().filter(s => s.configID === parseInt(config.id, 10)))); @@ -665,7 +664,7 @@ class Scenario extends React.Component { }); } else { this.setState({ - modalResultConfigs: JSON.parse(result.configSnapshots), + modalResultConfigs: result.configSnapshots, modalResultConfigsIndex: result.id, resultConfigsModal: true }); @@ -873,7 +872,7 @@ class Scenario extends React.Component { /> - {/*{this.state.ExternalICInUse ? (*/} + {this.state.ExternalICInUse ? (