mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Rework start/stop api to use runtime-event notification message
This commit is contained in:
@@ -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 === true) {
|
||||
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})
|
||||
}
|
||||
@@ -302,7 +302,6 @@ RED.deploy = (function() {
|
||||
deployInflight = true
|
||||
deployButtonSetBusy()
|
||||
shadeShow()
|
||||
RED.runtime.updateState(state)
|
||||
$.ajax({
|
||||
url:"flows/state",
|
||||
type: "POST",
|
||||
@@ -311,30 +310,23 @@ RED.deploy = (function() {
|
||||
if (deployWasEnabled) {
|
||||
$("#red-ui-header-button-deploy").removeClass("disabled")
|
||||
}
|
||||
RED.runtime.updateState((data && data.state) || "unknown")
|
||||
RED.notify(RED._("stopstart.status.state_changed", data), "success")
|
||||
}).fail(function(xhr,textStatus,err) {
|
||||
if (deployWasEnabled) {
|
||||
$("#red-ui-header-button-deploy").removeClass("disabled")
|
||||
}
|
||||
if (xhr.status === 401) {
|
||||
RED.notify(RED._("notification.error", { message: RED._("stopstart.errors.notAuthorized") }), "error")
|
||||
} else if (xhr.status === 404) {
|
||||
RED.notify(RED._("notification.error", { message: RED._("stopstart.errors.notFound") }), "error")
|
||||
} else if (xhr.status === 405) {
|
||||
RED.notify(RED._("notification.error", { message: RED._("stopstart.errors.notAllowed") }), "error")
|
||||
RED.notify(RED._("notification.error", { message: RED._("user.notAuthorized") }), "error")
|
||||
} else if (xhr.responseText) {
|
||||
const errorDetail = { message: err ? (err + "") : "" }
|
||||
try {
|
||||
errorDetail.message = JSON.parse(xhr.responseText).message
|
||||
} finally {
|
||||
} finally {
|
||||
errorDetail.message = errorDetail.message || xhr.responseText
|
||||
}
|
||||
RED.notify(RED._("notification.error", errorDetail), "error")
|
||||
} else {
|
||||
RED.notify(RED._("notification.error", { message: RED._("stopstart.errors.noResponse") }), "error")
|
||||
RED.notify(RED._("notification.error", { message: RED._("deploy.errors.noResponse") }), "error")
|
||||
}
|
||||
RED.runtime.requestState()
|
||||
}).always(function() {
|
||||
const delta = Math.max(0, 300 - (Date.now() - startTime))
|
||||
setTimeout(function () {
|
||||
@@ -514,13 +506,10 @@ RED.deploy = (function() {
|
||||
|
||||
deployButtonSetBusy();
|
||||
const data = { flows: nns };
|
||||
data.runtimeState = RED.runtime.state;
|
||||
if (data.runtimeState === RED.runtime.states.STOPPED || force) {
|
||||
data._rev = RED.nodes.version();
|
||||
} else {
|
||||
if (!force) {
|
||||
data.rev = RED.nodes.version();
|
||||
}
|
||||
|
||||
|
||||
deployInflight = true;
|
||||
shadeShow();
|
||||
$.ajax({
|
||||
|
@@ -4877,7 +4877,7 @@ RED.view = (function() {
|
||||
if (d._def.button) {
|
||||
var buttonEnabled = isButtonEnabled(d);
|
||||
this.__buttonGroup__.classList.toggle("red-ui-flow-node-button-disabled", !buttonEnabled);
|
||||
if(RED.runtime && Object.hasOwn(RED.runtime,'started')) {
|
||||
if (RED.runtime && Object.hasOwn(RED.runtime,'started')) {
|
||||
this.__buttonGroup__.classList.toggle("red-ui-flow-node-button-stopped", !RED.runtime.started);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user