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

Add import notification with info on what has been imported

Closes #1862
This commit is contained in:
Nick O'Leary 2018-10-24 11:07:48 +01:00
parent 4a027b8a79
commit 7dcca2c907
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
4 changed files with 132 additions and 86 deletions

View File

@ -150,6 +150,15 @@
}, },
"clipboard": { "clipboard": {
"nodes": "Nodes", "nodes": "Nodes",
"node": "__count__ node",
"node_plural": "__count__ nodes",
"configNode": "__count__ configuration node",
"configNode_plural": "__count__ configuration nodes",
"node_plural": "__count__ nodes",
"flow": "__count__ flow",
"flow_plural": "__count__ flows",
"subflow": "__count__ subflow",
"subflow_plural": "__count__ subflows",
"selectNodes": "Select the text above and copy to the clipboard.", "selectNodes": "Select the text above and copy to the clipboard.",
"pasteNodes": "Paste nodes here", "pasteNodes": "Paste nodes here",
"importNodes": "Import nodes", "importNodes": "Import nodes",
@ -157,6 +166,7 @@
"importUnrecognised": "Imported unrecognised type:", "importUnrecognised": "Imported unrecognised type:",
"importUnrecognised_plural": "Imported unrecognised types:", "importUnrecognised_plural": "Imported unrecognised types:",
"nodesExported": "Nodes exported to clipboard", "nodesExported": "Nodes exported to clipboard",
"nodesImported": "Imported:",
"nodeCopied": "__count__ node copied", "nodeCopied": "__count__ node copied",
"nodeCopied_plural": "__count__ nodes copied", "nodeCopied_plural": "__count__ nodes copied",
"invalidFlow": "Invalid flow: __message__", "invalidFlow": "Invalid flow: __message__",

View File

@ -764,7 +764,6 @@ RED.nodes = (function() {
} }
if (!isInitialLoad && unknownTypes.length > 0) { if (!isInitialLoad && unknownTypes.length > 0) {
var typeList = "<ul><li>"+unknownTypes.join("</li><li>")+"</li></ul>"; var typeList = "<ul><li>"+unknownTypes.join("</li><li>")+"</li></ul>";
var type = "type"+(unknownTypes.length > 1?"s":"");
RED.notify("<p>"+RED._("clipboard.importUnrecognised",{count:unknownTypes.length})+"</p>"+typeList,"error",false,10000); RED.notify("<p>"+RED._("clipboard.importUnrecognised",{count:unknownTypes.length})+"</p>"+typeList,"error",false,10000);
} }

View File

@ -75,9 +75,11 @@ RED.clipboard = (function() {
$(this).parent().find(".ui-dialog-titlebar-close").hide(); $(this).parent().find(".ui-dialog-titlebar-close").hide();
}, },
close: function(e) { close: function(e) {
if (popover) {
popover.close(true); popover.close(true);
currentPopoverError = null; currentPopoverError = null;
} }
}
}); });
dialogContainer = dialog.children(".dialog-form"); dialogContainer = dialog.children(".dialog-form");
@ -115,7 +117,13 @@ RED.clipboard = (function() {
'</div>'; '</div>';
} }
var validateImportTimeout;
function validateImport() { function validateImport() {
if (validateImportTimeout) {
clearTimeout(validateImportTimeout);
}
validateImportTimeout = setTimeout(function() {
var importInput = $("#clipboard-import"); var importInput = $("#clipboard-import");
var v = importInput.val().trim(); var v = importInput.val().trim();
if (v === "") { if (v === "") {
@ -200,6 +208,7 @@ RED.clipboard = (function() {
} }
$("#clipboard-dialog-ok").button("disable"); $("#clipboard-dialog-ok").button("disable");
} }
},100);
} }
function importNodes() { function importNodes() {

View File

@ -2853,6 +2853,34 @@ RED.view = (function() {
updateActiveNodes(); updateActiveNodes();
redraw(); redraw();
var counts = [];
var newNodeCount = 0;
var newConfigNodeCount = 0;
new_nodes.forEach(function(n) {
if (n.hasOwnProperty("x") && n.hasOwnProperty("y")) {
newNodeCount++;
} else {
newConfigNodeCount++;
}
})
if (new_workspaces.length > 0) {
counts.push(RED._("clipboard.flow",{count:new_workspaces.length}));
}
if (newNodeCount > 0) {
counts.push(RED._("clipboard.node",{count:newNodeCount}));
}
if (newConfigNodeCount > 0) {
counts.push(RED._("clipboard.configNode",{count:newNodeCount}));
}
if (new_subflows.length > 0) {
counts.push(RED._("clipboard.subflow",{count:new_subflows.length}));
}
if (counts.length > 0) {
var countList = "<ul><li>"+counts.join("</li><li>")+"</li></ul>";
RED.notify("<p>"+RED._("clipboard.nodesImported")+"</p>"+countList);
}
} }
} catch(error) { } catch(error) {
if (error.code != "NODE_RED") { if (error.code != "NODE_RED") {