implement flows runtime stop/start API and UI

This commit is contained in:
Steve-Mcl
2022-06-08 21:56:17 +01:00
parent 62cd3b2061
commit 68331fc40c
18 changed files with 657 additions and 63 deletions

View File

@@ -68,5 +68,28 @@ module.exports = {
}).catch(function(err) {
apiUtils.rejectHandler(req,res,err);
})
},
getState: function(req,res) {
const opts = {
user: req.user,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.flows.getState(opts).then(function(result) {
res.json(result);
}).catch(function(err) {
apiUtils.rejectHandler(req,res,err);
})
},
postState: function(req,res) {
const opts = {
user: req.user,
requestedState: req.get("Node-RED-Flow-Run-State-Change")||"",
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.flows.setState(opts).then(function(result) {
res.json(result);
}).catch(function(err) {
apiUtils.rejectHandler(req,res,err);
})
}
}

View File

@@ -54,6 +54,12 @@ module.exports = {
adminApp.get("/flows",needsPermission("flows.read"),flows.get,apiUtil.errorHandler);
adminApp.post("/flows",needsPermission("flows.write"),flows.post,apiUtil.errorHandler);
// Flows/state
adminApp.get("/flows/state", needsPermission("flows.read"), flows.getState, apiUtil.errorHandler);
if (!settings.runtimeState || settings.runtimeState.enabled !== false) {
adminApp.post("/flows/state", needsPermission("flows.write"), flows.postState, apiUtil.errorHandler);
}
// Flow
adminApp.get("/flow/:id",needsPermission("flows.read"),flow.get,apiUtil.errorHandler);
adminApp.post("/flow",needsPermission("flows.write"),flow.post,apiUtil.errorHandler);