diff --git a/api/core/scenario/scenario.export.js b/api/core/scenario/scenario.export.js index 61494c9c73..407c2984fb 100644 --- a/api/core/scenario/scenario.export.js +++ b/api/core/scenario/scenario.export.js @@ -20,20 +20,20 @@ module.exports = function exportScenario(id){ }); }; -function normalize(data){ +function normalize(data) { var newArray = []; var dictionnary = {}; data.forEach(function(elem){ - if(dictionnary[elem.code]){ - dictionnary[elem.code].params[elem.variablename] = elem.value; + if(dictionnary[elem.id]){ + dictionnary[elem.id].params[elem.variablename] = elem.value; } else { - dictionnary[elem.code] = { + dictionnary[elem.id] = { code: elem.code, params: { [elem.variablename]: elem.value } }; - newArray.push(dictionnary[elem.code]); + newArray.push(dictionnary[elem.id]); } }); return newArray; diff --git a/api/core/scenario/scenario.queries.js b/api/core/scenario/scenario.queries.js index f0d2e62d46..eb795da7e0 100644 --- a/api/core/scenario/scenario.queries.js +++ b/api/core/scenario/scenario.queries.js @@ -27,7 +27,7 @@ module.exports = { WHERE launcher.id = ?; `, getStates: ` - SELECT CONCAT(statetype.service, '.', statetype.function) as code, state.condition_template, state.active, + SELECT state.id, CONCAT(statetype.service, '.', statetype.function) as code, state.condition_template, state.active, stateparam.value, statetypeparam.variablename FROM state JOIN statetype ON state.state = statetype.id @@ -37,7 +37,7 @@ module.exports = { `, getActions: ` - SELECT CONCAT(actiontype.service, '.', actiontype.function) as code, actionparam.value, actiontypeparam.variablename + SELECT action.id, CONCAT(actiontype.service, '.', actiontype.function) as code, actionparam.value, actiontypeparam.variablename FROM action JOIN actiontype ON action.action = actiontype.id JOIN actionparam ON actionparam.action = action.id