mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add new options to export-nodes dialog
This commit is contained in:
parent
39d90fe881
commit
d915b280d4
@ -537,7 +537,10 @@ RED.nodes = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO: rename this (createCompleteNodeSet)
|
//TODO: rename this (createCompleteNodeSet)
|
||||||
function createCompleteNodeSet() {
|
function createCompleteNodeSet(exportCredentials) {
|
||||||
|
if (exportCredentials === undefined) {
|
||||||
|
exportCredentials = true;
|
||||||
|
}
|
||||||
var nns = [];
|
var nns = [];
|
||||||
var i;
|
var i;
|
||||||
for (i=0;i<workspacesOrder.length;i++) {
|
for (i=0;i<workspacesOrder.length;i++) {
|
||||||
@ -552,12 +555,12 @@ RED.nodes = (function() {
|
|||||||
}
|
}
|
||||||
for (i in configNodes) {
|
for (i in configNodes) {
|
||||||
if (configNodes.hasOwnProperty(i)) {
|
if (configNodes.hasOwnProperty(i)) {
|
||||||
nns.push(convertNode(configNodes[i], true));
|
nns.push(convertNode(configNodes[i], exportCredentials));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=0;i<nodes.length;i++) {
|
for (i=0;i<nodes.length;i++) {
|
||||||
var node = nodes[i];
|
var node = nodes[i];
|
||||||
nns.push(convertNode(node, true));
|
nns.push(convertNode(node, exportCredentials));
|
||||||
}
|
}
|
||||||
return nns;
|
return nns;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,18 @@ RED.clipboard = (function() {
|
|||||||
$( this ).dialog( "close" );
|
$( this ).dialog( "close" );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "clipboard-dialog-copy",
|
||||||
|
class: "primary",
|
||||||
|
text: RED._("clipboard.export.copy"),
|
||||||
|
click: function() {
|
||||||
|
$("#clipboard-export").select();
|
||||||
|
document.execCommand("copy");
|
||||||
|
document.getSelection().removeAllRanges();
|
||||||
|
RED.notify(RED._("clipboard.nodesExported"));
|
||||||
|
$( this ).dialog( "close" );
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "clipboard-dialog-ok",
|
id: "clipboard-dialog-ok",
|
||||||
class: "primary",
|
class: "primary",
|
||||||
@ -65,12 +77,23 @@ RED.clipboard = (function() {
|
|||||||
|
|
||||||
dialogContainer = dialog.children(".dialog-form");
|
dialogContainer = dialog.children(".dialog-form");
|
||||||
|
|
||||||
exportNodesDialog = '<div class="form-row">'+
|
exportNodesDialog =
|
||||||
'<label for="node-input-export" style="display: block; width:100%;"><i class="fa fa-clipboard"></i> '+RED._("clipboard.nodes")+'</label>'+
|
'<div class="form-row">'+
|
||||||
'<textarea readonly style="resize: none; width: 100%; border-radius: 0px;font-family: monospace; font-size: 12px; background:#eee; padding-left: 0.5em; box-sizing:border-box;" id="clipboard-export" rows="5"></textarea>'+
|
'<label style="width:auto;margin-right: 10px;">Export to clipboard</label>'+
|
||||||
|
'<span id="export-range-group" class="button-group">'+
|
||||||
|
'<a id="export-range-selected" class="editor-button toggle" href="#" data-i18n="clipboard.export.selected"></a>'+
|
||||||
|
'<a id="export-range-flow" class="editor-button toggle" href="#" data-i18n="clipboard.export.current"></a>'+
|
||||||
|
'<a id="export-range-full" class="editor-button toggle" href="#" data-i18n="clipboard.export.all"></a>'+
|
||||||
|
'</span>'+
|
||||||
|
'</div>'+
|
||||||
|
'<div class="form-row">'+
|
||||||
|
'<textarea readonly style="resize: none; width: 100%; border-radius: 4px;font-family: monospace; font-size: 12px; background:#f3f3f3; padding-left: 0.5em; box-sizing:border-box;" id="clipboard-export" rows="5"></textarea>'+
|
||||||
'</div>'+
|
'</div>'+
|
||||||
'<div class="form-tips">'+
|
'<div class="form-row" style="text-align: right;">'+
|
||||||
RED._("clipboard.selectNodes")+
|
'<span id="export-format-group" class="button-group">'+
|
||||||
|
'<a id="export-format-mini" class="editor-button editor-button-small toggle" href="#" data-i18n="clipboard.export.compact"></a>'+
|
||||||
|
'<a id="export-format-full" class="editor-button editor-button-small toggle" href="#" data-i18n="clipboard.export.formatted"></a>'+
|
||||||
|
'</span>'+
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
importNodesDialog = '<div class="form-row">'+
|
importNodesDialog = '<div class="form-row">'+
|
||||||
@ -103,6 +126,7 @@ RED.clipboard = (function() {
|
|||||||
$("#clipboard-dialog-ok").show();
|
$("#clipboard-dialog-ok").show();
|
||||||
$("#clipboard-dialog-cancel").show();
|
$("#clipboard-dialog-cancel").show();
|
||||||
$("#clipboard-dialog-close").hide();
|
$("#clipboard-dialog-close").hide();
|
||||||
|
$("#clipboard-dialog-copy").hide();
|
||||||
$("#clipboard-dialog-ok").button("disable");
|
$("#clipboard-dialog-ok").button("disable");
|
||||||
$("#clipboard-import").keyup(validateImport);
|
$("#clipboard-import").keyup(validateImport);
|
||||||
$("#clipboard-import").on('paste',function() { setTimeout(validateImport,10)});
|
$("#clipboard-import").on('paste',function() { setTimeout(validateImport,10)});
|
||||||
@ -113,29 +137,104 @@ RED.clipboard = (function() {
|
|||||||
function exportNodes() {
|
function exportNodes() {
|
||||||
dialogContainer.empty();
|
dialogContainer.empty();
|
||||||
dialogContainer.append($(exportNodesDialog));
|
dialogContainer.append($(exportNodesDialog));
|
||||||
|
dialogContainer.i18n();
|
||||||
|
|
||||||
|
$("#export-format-group > a").click(function(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
if ($(this).hasClass('disabled') || $(this).hasClass('selected')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$(this).parent().children().removeClass('selected');
|
||||||
|
$(this).addClass('selected');
|
||||||
|
|
||||||
|
var flow = $("#clipboard-export").val();
|
||||||
|
if (flow.length > 0) {
|
||||||
|
var nodes = JSON.parse(flow);
|
||||||
|
|
||||||
|
var format = $(this).attr('id');
|
||||||
|
if (format === 'export-format-full') {
|
||||||
|
flow = JSON.stringify(nodes,null,4);
|
||||||
|
} else {
|
||||||
|
flow = JSON.stringify(nodes);
|
||||||
|
}
|
||||||
|
$("#clipboard-export").val(flow);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#export-range-group > a").click(function(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
if ($(this).hasClass('disabled') || $(this).hasClass('selected')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$(this).parent().children().removeClass('selected');
|
||||||
|
$(this).addClass('selected');
|
||||||
|
var type = $(this).attr('id');
|
||||||
|
var flow = "";
|
||||||
|
var nodes = null;
|
||||||
|
if (type === 'export-range-selected') {
|
||||||
|
var selection = RED.view.selection();
|
||||||
|
nodes = RED.nodes.createExportableNodeSet(selection.nodes);
|
||||||
|
} else if (type === 'export-range-flow') {
|
||||||
|
var activeWorkspace = RED.workspaces.active();
|
||||||
|
nodes = RED.nodes.filterNodes({z:activeWorkspace});
|
||||||
|
var parentNode = RED.nodes.workspace(activeWorkspace)||RED.nodes.subflow(activeWorkspace);
|
||||||
|
nodes.unshift(parentNode);
|
||||||
|
nodes = RED.nodes.createExportableNodeSet(nodes);
|
||||||
|
} else if (type === 'export-range-full') {
|
||||||
|
nodes = RED.nodes.createCompleteNodeSet(false);
|
||||||
|
}
|
||||||
|
if (nodes !== null) {
|
||||||
|
if (RED.settings.flowFilePretty) {
|
||||||
|
flow = JSON.stringify(nodes,null,4);
|
||||||
|
} else {
|
||||||
|
flow = JSON.stringify(nodes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flow.length > 0) {
|
||||||
|
$("#export-copy").removeClass('disabled');
|
||||||
|
} else {
|
||||||
|
$("#export-copy").addClass('disabled');
|
||||||
|
}
|
||||||
|
$("#clipboard-export").val(flow);
|
||||||
|
})
|
||||||
|
|
||||||
$("#clipboard-dialog-ok").hide();
|
$("#clipboard-dialog-ok").hide();
|
||||||
$("#clipboard-dialog-cancel").hide();
|
$("#clipboard-dialog-cancel").hide();
|
||||||
$("#clipboard-dialog-close").show();
|
$("#clipboard-dialog-copy").hide();
|
||||||
|
$("#clipboard-dialog-close").hide();
|
||||||
var selection = RED.view.selection();
|
var selection = RED.view.selection();
|
||||||
if (selection.nodes) {
|
if (selection.nodes) {
|
||||||
var nns = RED.nodes.createExportableNodeSet(selection.nodes);
|
$("#export-range-selected").click();
|
||||||
if (RED.settings.flowFilePretty) {
|
} else {
|
||||||
nns = JSON.stringify(nns,null,4);
|
$("#export-range-selected").addClass('disabled').removeClass('selected');
|
||||||
} else {
|
$("#export-range-flow").click();
|
||||||
nns = JSON.stringify(nns);
|
|
||||||
}
|
|
||||||
$("#clipboard-export")
|
|
||||||
.val(nns)
|
|
||||||
.focus(function() {
|
|
||||||
var textarea = $(this);
|
|
||||||
textarea.select();
|
|
||||||
textarea.mouseup(function() {
|
|
||||||
textarea.unbind("mouseup");
|
|
||||||
return false;
|
|
||||||
})
|
|
||||||
});
|
|
||||||
dialog.dialog("option","title",RED._("clipboard.exportNodes")).dialog( "open" );
|
|
||||||
}
|
}
|
||||||
|
if (RED.settings.flowFilePretty) {
|
||||||
|
$("#export-format-full").click();
|
||||||
|
} else {
|
||||||
|
$("#export-format-mini").click();
|
||||||
|
}
|
||||||
|
$("#clipboard-export")
|
||||||
|
.focus(function() {
|
||||||
|
var textarea = $(this);
|
||||||
|
textarea.select();
|
||||||
|
textarea.mouseup(function() {
|
||||||
|
textarea.unbind("mouseup");
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
dialog.dialog("option","title",RED._("clipboard.exportNodes")).dialog( "open" );
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
$("#clipboard-export").focus();
|
||||||
|
if (!document.queryCommandEnabled("copy")) {
|
||||||
|
$("#clipboard-dialog-cancel").hide();
|
||||||
|
$("#clipboard-dialog-close").show();
|
||||||
|
} else {
|
||||||
|
$("#clipboard-dialog-cancel").show();
|
||||||
|
$("#clipboard-dialog-copy").show();
|
||||||
|
}
|
||||||
|
|
||||||
|
},0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideDropTarget() {
|
function hideDropTarget() {
|
||||||
|
@ -43,13 +43,17 @@ $palette-header-background: #f3f3f3;
|
|||||||
$workspace-button-background: #fff;
|
$workspace-button-background: #fff;
|
||||||
$workspace-button-background-hover: #ddd;
|
$workspace-button-background-hover: #ddd;
|
||||||
$workspace-button-background-active: #efefef;
|
$workspace-button-background-active: #efefef;
|
||||||
$workspace-button-color: #999;
|
$workspace-button-color: #888;
|
||||||
$workspace-button-color-disabled: #ccc;
|
$workspace-button-color-disabled: #ccc;
|
||||||
$workspace-button-color-focus: #999;
|
$workspace-button-color-focus: #999;
|
||||||
$workspace-button-color-hover: #666;
|
$workspace-button-color-hover: #666;
|
||||||
$workspace-button-color-active: #666;
|
$workspace-button-color-active: #666;
|
||||||
$workspace-button-color-selected: #AAA;
|
$workspace-button-color-selected: #AAA;
|
||||||
|
|
||||||
|
$workspace-button-toggle-color: #999;
|
||||||
|
$workspace-button-toggle-color-selected: #888;
|
||||||
|
$workspace-button-toggle-color-disabled: #ddd;
|
||||||
|
|
||||||
$workspace-button-color-focus-outline: rgba(85,150,230,0.2);
|
$workspace-button-color-focus-outline: rgba(85,150,230,0.2);
|
||||||
|
|
||||||
$typedInput-button-background: #efefef;
|
$typedInput-button-background: #efefef;
|
||||||
|
@ -76,16 +76,16 @@
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
padding: 6px 14px;
|
padding: 6px 14px;
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
color: $editor-button-color;
|
color: $editor-button-color !important;
|
||||||
background: $editor-button-background;
|
background: $editor-button-background;
|
||||||
|
|
||||||
&.primary {
|
&.primary {
|
||||||
border-color: $editor-button-background-primary;
|
border-color: $editor-button-background-primary;
|
||||||
color: $editor-button-color-primary;
|
color: $editor-button-color-primary !important;
|
||||||
background: $editor-button-background-primary;
|
background: $editor-button-background-primary;
|
||||||
&.disabled, &.ui-state-disabled {
|
&.disabled, &.ui-state-disabled {
|
||||||
background: none;
|
background: none;
|
||||||
color: $editor-button-color;
|
color: $editor-button-color !important;
|
||||||
border-color: $form-input-border-color;
|
border-color: $form-input-border-color;
|
||||||
}
|
}
|
||||||
&:not(.disabled):not(.ui-button-disabled):hover {
|
&:not(.disabled):not(.ui-button-disabled):hover {
|
||||||
@ -230,7 +230,12 @@
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
|
&.toggle {
|
||||||
|
@include workspace-button-toggle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.editor-button-small {
|
.editor-button-small {
|
||||||
height: 20px;
|
height: 20px;
|
||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
@ -239,6 +244,17 @@
|
|||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dialog-form {
|
||||||
|
.button-group {
|
||||||
|
.editor-button {
|
||||||
|
&:first-child {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#node-config-dialog-scope-container {
|
#node-config-dialog-scope-container {
|
||||||
cursor: auto;
|
cursor: auto;
|
||||||
float: right;
|
float: right;
|
||||||
|
@ -92,7 +92,7 @@
|
|||||||
|
|
||||||
&.primary {
|
&.primary {
|
||||||
border-color: $editor-button-background-primary;
|
border-color: $editor-button-background-primary;
|
||||||
color: $editor-button-color-primary;
|
color: $editor-button-color-primary !important;
|
||||||
background: $editor-button-background-primary;
|
background: $editor-button-background-primary;
|
||||||
&:not(.disabled):hover {
|
&:not(.disabled):hover {
|
||||||
border-color: $editor-button-background-primary-hover;
|
border-color: $editor-button-background-primary-hover;
|
||||||
|
@ -40,39 +40,46 @@
|
|||||||
@include disable-selection;
|
@include disable-selection;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
color: $workspace-button-color;
|
color: $workspace-button-color !important;
|
||||||
background: $workspace-button-background;
|
background: $workspace-button-background;
|
||||||
border: 1px solid $form-input-border-color;
|
border: 1px solid $form-input-border-color;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin:0;
|
margin:0;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
|
|
||||||
&.disabled {
|
&.disabled {
|
||||||
cursor: default;
|
cursor: default;
|
||||||
color: $workspace-button-color-disabled;
|
color: $workspace-button-color-disabled !important;
|
||||||
}
|
}
|
||||||
&:hover, &:focus {
|
&:hover, &:focus {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
&:not(.disabled):hover {
|
&:not(.disabled):hover {
|
||||||
color: $workspace-button-color-hover;
|
color: $workspace-button-color-hover !important;
|
||||||
background: $workspace-button-background-hover;
|
background: $workspace-button-background-hover;
|
||||||
}
|
}
|
||||||
&:not(.disabled):focus {
|
&:not(.disabled):focus {
|
||||||
color: $workspace-button-color-focus;
|
color: $workspace-button-color-focus !important;
|
||||||
}
|
}
|
||||||
&:not(.disabled):active {
|
&:not(.disabled):active {
|
||||||
color: $workspace-button-color-active;
|
color: $workspace-button-color-active !important;
|
||||||
background: $workspace-button-background-active;
|
background: $workspace-button-background-active;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
&.selected:not(.disabled) {
|
&.selected:not(.disabled) {
|
||||||
color: $workspace-button-color-selected;
|
color: $workspace-button-color-selected !important;
|
||||||
background: $workspace-button-background-active;
|
background: $workspace-button-background-active;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
.button-group &:not(:first-child) {
|
.button-group &:not(:first-child) {
|
||||||
border-left: none;
|
border-left: none;
|
||||||
|
border-top-left-radius: 0;
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
}
|
||||||
|
.button-group &:not(:last-child) {
|
||||||
|
border-top-right-radius: 0;
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
@ -81,17 +88,20 @@
|
|||||||
}
|
}
|
||||||
@mixin workspace-button-toggle {
|
@mixin workspace-button-toggle {
|
||||||
@include workspace-button;
|
@include workspace-button;
|
||||||
color: $workspace-button-color-selected;
|
color: $workspace-button-toggle-color !important;
|
||||||
background:$workspace-button-background-active;
|
background:$workspace-button-background-active;
|
||||||
transition: all 0.1s ease-in-out;
|
transition: all 0.1s ease-in-out;
|
||||||
margin-bottom: 1px;
|
margin-bottom: 1px;
|
||||||
&.selected:not(.disabled) {
|
&.selected:not(.disabled) {
|
||||||
color: $workspace-button-color;
|
color: $workspace-button-toggle-color-selected !important;
|
||||||
background: $workspace-button-background;
|
background: $workspace-button-background;
|
||||||
border-bottom-width: 2px;
|
border-bottom-width: 2px;
|
||||||
border-bottom-color: $form-input-border-selected-color;
|
border-bottom-color: $form-input-border-selected-color;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
&.disabled {
|
||||||
|
color: $workspace-button-toggle-color-disabled !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,16 +77,25 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"clipboard": {
|
"clipboard": {
|
||||||
"nodes": "Nodes:",
|
"nodes": "Nodes",
|
||||||
"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",
|
||||||
"exportNodes": "Export nodes to clipboard",
|
"exportNodes": "Export nodes to clipboard",
|
||||||
"importUnrecognised": "Imported unrecognised type:",
|
"importUnrecognised": "Imported unrecognised type:",
|
||||||
"importUnrecognised_plural": "Imported unrecognised types:",
|
"importUnrecognised_plural": "Imported unrecognised types:",
|
||||||
|
"nodesExported": "Nodes exported to clipboard",
|
||||||
"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__",
|
||||||
|
"export": {
|
||||||
|
"selected":"selected nodes",
|
||||||
|
"current":"current flow",
|
||||||
|
"all":"all flows",
|
||||||
|
"compact":"compact",
|
||||||
|
"formatted":"formatted",
|
||||||
|
"copy": "Export to clipboard"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"deploy": {
|
"deploy": {
|
||||||
"deploy": "Deploy",
|
"deploy": "Deploy",
|
||||||
|
Loading…
Reference in New Issue
Block a user