mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add 'restart flows' option to deploy menu
This commit is contained in:
parent
195342f7db
commit
8c169dc82b
3
packages/node_modules/@node-red/editor-api/lib/editor/locales/en-US/editor.json
generated
vendored
3
packages/node_modules/@node-red/editor-api/lib/editor/locales/en-US/editor.json
generated
vendored
@ -172,7 +172,10 @@
|
|||||||
"modifiedFlowsDesc": "Only deploys flows that contain changed nodes",
|
"modifiedFlowsDesc": "Only deploys flows that contain changed nodes",
|
||||||
"modifiedNodes": "Modified Nodes",
|
"modifiedNodes": "Modified Nodes",
|
||||||
"modifiedNodesDesc": "Only deploys nodes that have changed",
|
"modifiedNodesDesc": "Only deploys nodes that have changed",
|
||||||
|
"restartFlows": "Restart Flows",
|
||||||
|
"restartFlowsDesc": "Restarts the current deployed flows",
|
||||||
"successfulDeploy": "Successfully deployed",
|
"successfulDeploy": "Successfully deployed",
|
||||||
|
"successfulRestart": "Successfully restarted flows",
|
||||||
"deployFailed": "Deploy failed: __message__",
|
"deployFailed": "Deploy failed: __message__",
|
||||||
"unusedConfigNodes":"You have some unused configuration nodes.",
|
"unusedConfigNodes":"You have some unused configuration nodes.",
|
||||||
"unusedConfigNodesLink":"Click here to see them",
|
"unusedConfigNodesLink":"Click here to see them",
|
||||||
|
BIN
packages/node_modules/@node-red/editor-client/src/images/deploy-reload.png
generated
vendored
Normal file
BIN
packages/node_modules/@node-red/editor-client/src/images/deploy-reload.png
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1015 B |
56
packages/node_modules/@node-red/editor-client/src/js/ui/deploy.js
generated
vendored
56
packages/node_modules/@node-red/editor-client/src/js/ui/deploy.js
generated
vendored
@ -67,7 +67,10 @@ RED.deploy = (function() {
|
|||||||
options: [
|
options: [
|
||||||
{id:"deploymenu-item-full",toggle:"deploy-type",icon:"red/images/deploy-full.png",label:RED._("deploy.full"),sublabel:RED._("deploy.fullDesc"),selected: true, onselect:function(s) { if(s){changeDeploymentType("full")}}},
|
{id:"deploymenu-item-full",toggle:"deploy-type",icon:"red/images/deploy-full.png",label:RED._("deploy.full"),sublabel:RED._("deploy.fullDesc"),selected: true, onselect:function(s) { if(s){changeDeploymentType("full")}}},
|
||||||
{id:"deploymenu-item-flow",toggle:"deploy-type",icon:"red/images/deploy-flows.png",label:RED._("deploy.modifiedFlows"),sublabel:RED._("deploy.modifiedFlowsDesc"), onselect:function(s) {if(s){changeDeploymentType("flows")}}},
|
{id:"deploymenu-item-flow",toggle:"deploy-type",icon:"red/images/deploy-flows.png",label:RED._("deploy.modifiedFlows"),sublabel:RED._("deploy.modifiedFlowsDesc"), onselect:function(s) {if(s){changeDeploymentType("flows")}}},
|
||||||
{id:"deploymenu-item-node",toggle:"deploy-type",icon:"red/images/deploy-nodes.png",label:RED._("deploy.modifiedNodes"),sublabel:RED._("deploy.modifiedNodesDesc"),onselect:function(s) { if(s){changeDeploymentType("nodes")}}}
|
{id:"deploymenu-item-node",toggle:"deploy-type",icon:"red/images/deploy-nodes.png",label:RED._("deploy.modifiedNodes"),sublabel:RED._("deploy.modifiedNodesDesc"),onselect:function(s) { if(s){changeDeploymentType("nodes")}}},
|
||||||
|
null,
|
||||||
|
{id:"deploymenu-item-reload", icon:"red/images/deploy-reload.png",label:RED._("deploy.restartFlows"),sublabel:RED._("deploy.restartFlowsDesc"),onselect:"core:restart-flows"},
|
||||||
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
} else if (type == "simple") {
|
} else if (type == "simple") {
|
||||||
@ -96,6 +99,7 @@ RED.deploy = (function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
RED.actions.add("core:deploy-flows",save);
|
RED.actions.add("core:deploy-flows",save);
|
||||||
|
RED.actions.add("core:restart-flows",restart);
|
||||||
|
|
||||||
|
|
||||||
RED.events.on('nodes:change',function(state) {
|
RED.events.on('nodes:change',function(state) {
|
||||||
@ -257,6 +261,56 @@ RED.deploy = (function() {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function restart() {
|
||||||
|
var startTime = Date.now();
|
||||||
|
$(".deploy-button-content").css('opacity',0);
|
||||||
|
$(".deploy-button-spinner").show();
|
||||||
|
var deployWasEnabled = !$("#btn-deploy").hasClass("disabled");
|
||||||
|
$("#btn-deploy").addClass("disabled");
|
||||||
|
deployInflight = true;
|
||||||
|
$("#header-shade").show();
|
||||||
|
$("#editor-shade").show();
|
||||||
|
$("#palette-shade").show();
|
||||||
|
$("#sidebar-shade").show();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url:"flows",
|
||||||
|
type: "POST",
|
||||||
|
headers: {
|
||||||
|
"Node-RED-Deployment-Type":"reload"
|
||||||
|
}
|
||||||
|
}).done(function(data,textStatus,xhr) {
|
||||||
|
if (deployWasEnabled) {
|
||||||
|
$("#btn-deploy").removeClass("disabled");
|
||||||
|
}
|
||||||
|
RED.notify('<p>'+RED._("deploy.successfulRestart")+'</p>',"success");
|
||||||
|
}).fail(function(xhr,textStatus,err) {
|
||||||
|
if (deployWasEnabled) {
|
||||||
|
$("#btn-deploy").removeClass("disabled");
|
||||||
|
}
|
||||||
|
if (xhr.status === 401) {
|
||||||
|
RED.notify(RED._("deploy.deployFailed",{message:RED._("user.notAuthorized")}),"error");
|
||||||
|
} else if (xhr.status === 409) {
|
||||||
|
resolveConflict(nns, true);
|
||||||
|
} else if (xhr.responseText) {
|
||||||
|
RED.notify(RED._("deploy.deployFailed",{message:xhr.responseText}),"error");
|
||||||
|
} else {
|
||||||
|
RED.notify(RED._("deploy.deployFailed",{message:RED._("deploy.errors.noResponse")}),"error");
|
||||||
|
}
|
||||||
|
}).always(function() {
|
||||||
|
deployInflight = false;
|
||||||
|
var delta = Math.max(0,300-(Date.now()-startTime));
|
||||||
|
setTimeout(function() {
|
||||||
|
$(".deploy-button-content").css('opacity',1);
|
||||||
|
$(".deploy-button-spinner").hide();
|
||||||
|
$("#header-shade").hide();
|
||||||
|
$("#editor-shade").hide();
|
||||||
|
$("#palette-shade").hide();
|
||||||
|
$("#sidebar-shade").hide();
|
||||||
|
},delta);
|
||||||
|
});
|
||||||
|
}
|
||||||
function save(skipValidation,force) {
|
function save(skipValidation,force) {
|
||||||
if (!$("#btn-deploy").hasClass("disabled")) {
|
if (!$("#btn-deploy").hasClass("disabled")) {
|
||||||
if (!RED.user.hasPermission("flows.write")) {
|
if (!RED.user.hasPermission("flows.write")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user