Add status node

This commit is contained in:
Nick O'Leary
2015-08-19 21:14:45 +01:00
parent 658746d2a3
commit a6644ad5ff
6 changed files with 395 additions and 36 deletions

View File

@@ -46,7 +46,7 @@ var flowNodes = module.exports = {
settings = _settings;
storage = _storage;
},
/**
* Load the current activeConfig from storage and start it running
* @return a promise for the loading of the config
@@ -62,7 +62,7 @@ var flowNodes = module.exports = {
console.log(err.stack);
});
},
/**
* Get a node
* @param i the node id
@@ -71,18 +71,18 @@ var flowNodes = module.exports = {
get: function(i) {
return activeFlow.getNode(i);
},
eachNode: function(cb) {
activeFlow.eachNode(cb);
},
/**
* @return the active configuration
*/
getFlows: function() {
return activeFlow.getFlow();
},
/**
* Sets the current active config.
* @param config the configuration to enable
@@ -90,14 +90,14 @@ var flowNodes = module.exports = {
* @return a promise for the starting of the new flow
*/
setFlows: function (config,type) {
type = type||"full";
var credentialsChanged = false;
var credentialSavePromise = null;
// Clone config and extract credentials prior to saving
// Original config needs to retain credentials so that flow.applyConfig
// knows which nodes have had changes.
@@ -108,7 +108,7 @@ var flowNodes = module.exports = {
credentialsChanged = true;
}
});
if (credentialsChanged) {
credentialSavePromise = credentials.save();
} else {
@@ -122,7 +122,7 @@ var flowNodes = module.exports = {
} else {
return credentialSavePromise
.then(function() { return storage.saveFlows(cleanConfig);})
.then(function() {
.then(function() {
var configDiff = activeFlow.diffConfig(config,type);
return flowNodes.stopFlows(configDiff).then(function() {
activeFlow.parseConfig(config);
@@ -190,6 +190,9 @@ var flowNodes = module.exports = {
},
handleError: function(node,logMessage,msg) {
activeFlow.handleError(node,logMessage,msg);
},
handleStatus: function(node,statusMessage) {
activeFlow.handleStatus(node,statusMessage);
}
};