mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Provide notification when new flows deployed in the background
This commit is contained in:
parent
fb24dca019
commit
b9379f2ddf
@ -83,6 +83,10 @@
|
|||||||
RED.comms.subscribe("notification/#",function(topic,msg) {
|
RED.comms.subscribe("notification/#",function(topic,msg) {
|
||||||
var parts = topic.split("/");
|
var parts = topic.split("/");
|
||||||
var notificationId = parts[1];
|
var notificationId = parts[1];
|
||||||
|
if (notificationId === "runtime-deploy") {
|
||||||
|
// handled in ui/deploy.js
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (msg.text) {
|
if (msg.text) {
|
||||||
var text = RED._(msg.text,{default:msg.text});
|
var text = RED._(msg.text,{default:msg.text});
|
||||||
if (!persistentNotifications.hasOwnProperty(notificationId)) {
|
if (!persistentNotifications.hasOwnProperty(notificationId)) {
|
||||||
|
@ -30,6 +30,8 @@ RED.deploy = (function() {
|
|||||||
|
|
||||||
var deploymentType = "full";
|
var deploymentType = "full";
|
||||||
|
|
||||||
|
var deployInflight = false;
|
||||||
|
|
||||||
var currentDiff = null;
|
var currentDiff = null;
|
||||||
|
|
||||||
function changeDeploymentType(type) {
|
function changeDeploymentType(type) {
|
||||||
@ -153,6 +155,7 @@ RED.deploy = (function() {
|
|||||||
},
|
},
|
||||||
open: function() {
|
open: function() {
|
||||||
if ($( "#node-dialog-confirm-deploy-type" ).val() === "conflict") {
|
if ($( "#node-dialog-confirm-deploy-type" ).val() === "conflict") {
|
||||||
|
$( "#node-dialog-confirm-deploy" ).dialog('option','title', RED._('deploy.confirm.button.review'));
|
||||||
$("#node-dialog-confirm-deploy-deploy").hide();
|
$("#node-dialog-confirm-deploy-deploy").hide();
|
||||||
$("#node-dialog-confirm-deploy-review").addClass('disabled').show();
|
$("#node-dialog-confirm-deploy-review").addClass('disabled').show();
|
||||||
$("#node-dialog-confirm-deploy-merge").addClass('disabled').show();
|
$("#node-dialog-confirm-deploy-merge").addClass('disabled').show();
|
||||||
@ -181,6 +184,7 @@ RED.deploy = (function() {
|
|||||||
|
|
||||||
$("#node-dialog-confirm-deploy-hide").parent().hide();
|
$("#node-dialog-confirm-deploy-hide").parent().hide();
|
||||||
} else {
|
} else {
|
||||||
|
$( "#node-dialog-confirm-deploy" ).dialog('option','title', RED._('deploy.confirm.button.confirm'));
|
||||||
$("#node-dialog-confirm-deploy-deploy").show();
|
$("#node-dialog-confirm-deploy-deploy").show();
|
||||||
$("#node-dialog-confirm-deploy-review").hide();
|
$("#node-dialog-confirm-deploy-review").hide();
|
||||||
$("#node-dialog-confirm-deploy-merge").hide();
|
$("#node-dialog-confirm-deploy-merge").hide();
|
||||||
@ -201,7 +205,33 @@ RED.deploy = (function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var activeNotifyMessage;
|
||||||
|
RED.comms.subscribe("notification/runtime-deploy",function(topic,msg) {
|
||||||
|
if (!activeNotifyMessage) {
|
||||||
|
var currentRev = RED.nodes.version();
|
||||||
|
if (currentRev === null || deployInflight || currentRev === msg.revision) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var message = $('<div>'+RED._('deploy.confirm.backgroundUpdate')+
|
||||||
|
'<br><br><div class="ui-dialog-buttonset">'+
|
||||||
|
'<button>'+RED._('deploy.confirm.button.ignore')+'</button>'+
|
||||||
|
'<button class="primary">'+RED._('deploy.confirm.button.review')+'</button>'+
|
||||||
|
'</div></div>');
|
||||||
|
$(message.find('button')[0]).click(function(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
activeNotifyMessage.close();
|
||||||
|
activeNotifyMessage = null;
|
||||||
|
})
|
||||||
|
$(message.find('button')[1]).click(function(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
activeNotifyMessage.close();
|
||||||
|
var nns = RED.nodes.createCompleteNodeSet();
|
||||||
|
resolveConflict(nns);
|
||||||
|
activeNotifyMessage = null;
|
||||||
|
})
|
||||||
|
activeNotifyMessage = RED.notify(message,null,true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNodeInfo(node) {
|
function getNodeInfo(node) {
|
||||||
@ -318,6 +348,7 @@ RED.deploy = (function() {
|
|||||||
data.rev = RED.nodes.version();
|
data.rev = RED.nodes.version();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deployInflight = true;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"flows",
|
url:"flows",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@ -372,6 +403,7 @@ RED.deploy = (function() {
|
|||||||
RED.notify(RED._("deploy.deployFailed",{message:RED._("deploy.errors.noResponse")}),"error");
|
RED.notify(RED._("deploy.deployFailed",{message:RED._("deploy.errors.noResponse")}),"error");
|
||||||
}
|
}
|
||||||
}).always(function() {
|
}).always(function() {
|
||||||
|
deployInflight = false;
|
||||||
var delta = Math.max(0,300-(Date.now()-startTime));
|
var delta = Math.max(0,300-(Date.now()-startTime));
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$(".deploy-button-content").css('opacity',1);
|
$(".deploy-button-content").css('opacity',1);
|
||||||
|
@ -36,7 +36,11 @@ RED.notify = (function() {
|
|||||||
n.className = "notification notification-"+type;
|
n.className = "notification notification-"+type;
|
||||||
}
|
}
|
||||||
n.style.display = "none";
|
n.style.display = "none";
|
||||||
|
if (typeof msg === "string") {
|
||||||
n.innerHTML = msg;
|
n.innerHTML = msg;
|
||||||
|
} else {
|
||||||
|
$(n).append(msg);
|
||||||
|
}
|
||||||
$("#notifications").append(n);
|
$("#notifications").append(n);
|
||||||
$(n).slideDown(300);
|
$(n).slideDown(300);
|
||||||
n.close = (function() {
|
n.close = (function() {
|
||||||
@ -52,7 +56,11 @@ RED.notify = (function() {
|
|||||||
n.update = (function() {
|
n.update = (function() {
|
||||||
var nn = n;
|
var nn = n;
|
||||||
return function(msg,timeout) {
|
return function(msg,timeout) {
|
||||||
|
if (typeof msg === "string") {
|
||||||
nn.innerHTML = msg;
|
nn.innerHTML = msg;
|
||||||
|
} else {
|
||||||
|
$(nn).empty().append(msg);
|
||||||
|
}
|
||||||
if (timeout !== undefined && timeout > 0) {
|
if (timeout !== undefined && timeout > 0) {
|
||||||
window.clearTimeout(nn.timeoutid);
|
window.clearTimeout(nn.timeoutid);
|
||||||
nn.timeoutid = window.setTimeout(nn.close,timeout);
|
nn.timeoutid = window.setTimeout(nn.close,timeout);
|
||||||
|
@ -127,6 +127,7 @@
|
|||||||
},
|
},
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"button": {
|
"button": {
|
||||||
|
"ignore": "Ignore",
|
||||||
"confirm": "Confirm deploy",
|
"confirm": "Confirm deploy",
|
||||||
"review": "Review differences",
|
"review": "Review differences",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
@ -137,6 +138,7 @@
|
|||||||
"unknown": "The workspace contains some unknown node types:",
|
"unknown": "The workspace contains some unknown node types:",
|
||||||
"confirm": "Are you sure you want to deploy?",
|
"confirm": "Are you sure you want to deploy?",
|
||||||
"conflict": "The server is running a more recent set of flows.",
|
"conflict": "The server is running a more recent set of flows.",
|
||||||
|
"backgroundUpdate": "The flows on the server have been updated.",
|
||||||
"conflictChecking": "Checking to see if the changes can be merged automatically",
|
"conflictChecking": "Checking to see if the changes can be merged automatically",
|
||||||
"conflictAutoMerge": "The changes include no conflicts and can be merged automatically.",
|
"conflictAutoMerge": "The changes include no conflicts and can be merged automatically.",
|
||||||
"conflictManualMerge": "The changes include conflicts that must be resolved before they can be deployed."
|
"conflictManualMerge": "The changes include conflicts that must be resolved before they can be deployed."
|
||||||
|
@ -135,10 +135,14 @@ function setFlows(_config,type,muteLog) {
|
|||||||
if (started) {
|
if (started) {
|
||||||
return stop(type,diff,muteLog).then(function() {
|
return stop(type,diff,muteLog).then(function() {
|
||||||
context.clean(activeFlowConfig);
|
context.clean(activeFlowConfig);
|
||||||
start(type,diff,muteLog);
|
start(type,diff,muteLog).then(function() {
|
||||||
|
events.emit("runtime-event",{id:"runtime-deploy",revision:flowRevision});
|
||||||
|
});
|
||||||
return flowRevision;
|
return flowRevision;
|
||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
events.emit("runtime-event",{id:"runtime-deploy",revision:flowRevision});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user