Add notification when runtime stopped due to missing types

Part of #832
This commit is contained in:
Nick O'Leary
2016-12-05 13:24:24 +00:00
parent 16ecb1a9cb
commit 8d21e441a0
5 changed files with 35 additions and 4 deletions

View File

@@ -79,6 +79,23 @@
if (/^#flow\/.+$/.test(currentHash)) {
RED.workspaces.show(currentHash.substring(6));
}
var persistentNotifications = {};
RED.comms.subscribe("notification/#",function(topic,msg) {
var parts = topic.split("/");
var notificationId = parts[1];
if (msg.text) {
var text = RED._(msg.text,{default:msg.text});
if (!persistentNotifications.hasOwnProperty(notificationId)) {
persistentNotifications[notificationId] = RED.notify(text,msg.type,msg.timeout === undefined,msg.timeout);
} else {
persistentNotifications[notificationId].update(text,msg.timeout);
}
} else if (persistentNotifications.hasOwnProperty(notificationId)) {
persistentNotifications[notificationId].close();
delete persistentNotifications[notificationId];
}
});
RED.comms.subscribe("status/#",function(topic,msg) {
var parts = topic.split("/");
var node = RED.nodes.node(parts[1]);

View File

@@ -51,11 +51,17 @@ RED.notify = (function() {
n.update = (function() {
var nn = n;
return function(msg) {
return function(msg,timeout) {
nn.innerHTML = msg;
if (timeout !== undefined && timeout > 0) {
window.clearTimeout(nn.timeoutid);
nn.timeoutid = window.setTimeout(nn.close,timeout);
} else {
window.clearTimeout(nn.timeoutid);
}
}
})();
if (!fixed) {
$(n).click((function() {
var nn = n;