1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

improve UI, i18n and layout of stop/start feature

This commit is contained in:
Steve-Mcl 2022-06-27 18:07:22 +01:00
parent 51baed4932
commit 1b8a4577d5
5 changed files with 6328 additions and 20 deletions

View File

@ -288,6 +288,17 @@
"copyMessageValue": "Value copied",
"copyMessageValue_truncated": "Truncated value copied"
},
"stopstart":{
"status": {
"state_changed": "Flows runtime has been changed to '__state__' state"
},
"errors": {
"notAllowed": "Method not allowed",
"notAuthorized": "Not authorized",
"notFound": "Not found",
"noResponse": "No response from server"
}
},
"deploy": {
"deploy": "Deploy",
"full": "Full",

View File

@ -297,41 +297,51 @@ RED.deploy = (function() {
$(".red-ui-deploy-button-spinner").hide();
}
function stopStartFlows(state) {
const startTime = Date.now();
const deployWasEnabled = !$("#red-ui-header-button-deploy").hasClass("disabled");
deployInflight = true;
deployButtonSetBusy();
shadeShow();
RED.runtime.updateState(state);
const startTime = Date.now()
const deployWasEnabled = !$("#red-ui-header-button-deploy").hasClass("disabled")
deployInflight = true
deployButtonSetBusy()
shadeShow()
RED.runtime.updateState(state)
$.ajax({
url:"flows/state",
type: "POST",
data: {state: state}
}).done(function(data,textStatus,xhr) {
if (deployWasEnabled) {
$("#red-ui-header-button-deploy").removeClass("disabled");
$("#red-ui-header-button-deploy").removeClass("disabled")
}
RED.runtime.updateState((data && data.state) || "unknown" )
RED.notify('<p>Done</p>',"success");
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");
$("#red-ui-header-button-deploy").removeClass("disabled")
}
if (xhr.status === 401) {
RED.notify("Not authorized" ,"error");
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")
} else if (xhr.responseText) {
RED.notify("Operation failed: " + xhr.responseText,"error");
const errorDetail = { message: err ? (err + "") : "" }
try {
errorDetail.message = JSON.parse(xhr.responseText).message
} finally {
errorDetail.message = errorDetail.message || xhr.responseText
}
RED.notify(RED._("notification.error", errorDetail), "error")
} else {
RED.notify("Operation failed: no response","error");
RED.notify(RED._("notification.error", { message: RED._("stopstart.errors.noResponse") }), "error")
}
RED.runtime.requestState()
}).always(function() {
const delta = Math.max(0,300-(Date.now()-startTime));
setTimeout(function() {
deployButtonClearBusy();
const delta = Math.max(0, 300 - (Date.now() - startTime))
setTimeout(function () {
deployButtonClearBusy()
shadeHide()
deployInflight = false;
},delta);
deployInflight = false
}, delta);
});
}
function restart() {

File diff suppressed because it is too large Load Diff

View File

@ -219,7 +219,7 @@
span.red-ui-menu-sublabel {
color: $header-menu-sublabel-color;
font-size: 13px;
display: inline-block;
display: block;
text-indent: 0px;
}
}

View File

@ -335,7 +335,7 @@ var api = module.exports = {
throw (makeError(err, err.code, 500))
}
default:
throw (makeError("Cannot set runtime state. Invalid state", "invalid_run_state", 400))
throw (makeError(`Cannot change flows runtime state to '${opts.requestedState}'}`, "invalid_run_state", 400))
}
},
}