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": "Value copied",
"copyMessageValue_truncated": "Truncated 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": "Deploy", "deploy": "Deploy",
"full": "Full", "full": "Full",

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -335,7 +335,7 @@ var api = module.exports = {
throw (makeError(err, err.code, 500)) throw (makeError(err, err.code, 500))
} }
default: 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))
} }
}, },
} }