default stop/start feature to `enabled:false`

This commit is contained in:
Steve-Mcl 2022-06-27 18:06:53 +01:00
parent 2f1f587c50
commit 51baed4932
6 changed files with 16 additions and 16 deletions

View File

@ -56,7 +56,7 @@ module.exports = {
// Flows/state
adminApp.get("/flows/state", needsPermission("flows.read"), flows.getState, apiUtil.errorHandler);
if (!settings.runtimeState || settings.runtimeState.enabled !== false) {
if (settings.runtimeState && settings.runtimeState.enabled === true) {
adminApp.post("/flows/state", needsPermission("flows.write"), flows.postState, apiUtil.errorHandler);
}

View File

@ -1,12 +1,12 @@
RED.runtime = (function() {
let state = ""
let settings = {ui: true, enabled: true};
let settings = {ui: false, enabled: false};
const STOPPED = "stopped"
const STARTED = "started"
return {
init: function() {
// refresh the current runtime status from server
settings = RED.settings.runtimeState;
settings = Object.assign({}, settings, RED.settings.runtimeState);
RED.runtime.requestState()
// {id:"flows-run-state", started: false, state: "stopped", retain:true}
@ -29,7 +29,7 @@ RED.runtime = (function() {
// disable pointer events on node buttons (e.g. inject/debug nodes)
$(".red-ui-flow-node-button").toggleClass("red-ui-flow-node-button-stopped", state === STOPPED)
// show/hide Start/Stop based on current state
if(!RED.settings.runtimeState || RED.settings.runtimeState.ui !== false) {
if(settings.enabled === true && settings.ui === true) {
RED.menu.setVisible("deploymenu-item-runtime-stop", state === STARTED)
RED.menu.setVisible("deploymenu-item-runtime-start", state === STOPPED)
}

View File

@ -69,7 +69,7 @@ RED.deploy = (function() {
{id:"deploymenu-item-node",toggle:"deploy-type",icon:"red/images/deploy-nodes.svg",label:RED._("deploy.modifiedNodes"),sublabel:RED._("deploy.modifiedNodesDesc"),onselect:function(s) { if(s){changeDeploymentType("nodes")}}},
null
]
if(!RED.settings.runtimeState || RED.settings.runtimeState.ui !== false) {
if(RED.settings.runtimeState && RED.settings.runtimeState.ui === true) {
mainMenuItems.push({id:"deploymenu-item-runtime-start", icon:"red/images/start.svg",label:"Start"/*RED._("deploy.startFlows")*/,sublabel:"Start Flows" /*RED._("deploy.startFlowsDesc")*/,onselect:"core:start-flows", visible:false})
mainMenuItems.push({id:"deploymenu-item-runtime-stop", icon:"red/images/stop.svg",label:"Stop"/*RED._("deploy.startFlows")*/,sublabel:"Stop Flows" /*RED._("deploy.startFlowsDesc")*/,onselect:"core:stop-flows", visible:false})
}

View File

@ -310,7 +310,7 @@ var api = module.exports = {
}
}
if(runtime.settings.runtimeState ? runtime.settings.runtimeState.enabled === false : false) {
if(!runtime.settings.runtimeState || runtime.settings.runtimeState.enabled !== true) {
throw (makeError("Method Not Allowed", "not_allowed", 405))
}
switch (opts.requestedState) {

View File

@ -153,11 +153,11 @@ var api = module.exports = {
}
safeSettings.runtimeState = {
//unless runtimeState.ui and runtimeState.enabled are explicitly false, they will default to true.
enabled: (runtime.settings.runtimeState && runtime.settings.runtimeState.enabled === false) ? false : true,
ui: (runtime.settings.runtimeState && runtime.settings.runtimeState.ui === false) ? false : true
//unless runtimeState.ui and runtimeState.enabled are explicitly true, they will default to false.
enabled: !!runtime.settings.runtimeState && runtime.settings.runtimeState.enabled === true,
ui: !!runtime.settings.runtimeState && runtime.settings.runtimeState.ui === true
}
if(safeSettings.runtimeState.enabled === false) {
if(safeSettings.runtimeState.enabled !== true) {
safeSettings.runtimeState.ui = false; // cannot have UI without endpoint
}

View File

@ -269,17 +269,17 @@ module.exports = {
ui: true,
},
/** Configure runtimeState options
* - enabled: When `enabled` is `true` (or unset), runtime Start/Stop will
* be available at http://localhost:1880/flows/state
* - ui: When `ui` is `true` (or unset), the action `core:start-flows` and
* `core:stop-flows` be available to logged in users of node-red editor
* - enabled: When `enabled` is `true` flows runtime can be Started/Stoped
* by POSTing to available at http://localhost:1880/flows/state
* - ui: When `ui` is `true`, the action `core:start-flows` and
* `core:stop-flows` will be available to logged in users of node-red editor
* Also, the deploy menu (when set to default) will show a stop or start button
*/
runtimeState: {
/** enable or disable flows/state endpoint. Must be set to `false` to disable */
enabled: true,
enabled: false,
/** show or hide runtime stop/start options in the node-red editor. Must be set to `false` to hide */
ui: true,
ui: false,
},
/** Configure the logging output */
logging: {