mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Add new options to export-nodes dialog
This commit is contained in:
		| @@ -537,7 +537,10 @@ RED.nodes = (function() { | ||||
|     } | ||||
|  | ||||
|     //TODO: rename this (createCompleteNodeSet) | ||||
|     function createCompleteNodeSet() { | ||||
|     function createCompleteNodeSet(exportCredentials) { | ||||
|         if (exportCredentials === undefined) { | ||||
|             exportCredentials = true; | ||||
|         } | ||||
|         var nns = []; | ||||
|         var i; | ||||
|         for (i=0;i<workspacesOrder.length;i++) { | ||||
| @@ -552,12 +555,12 @@ RED.nodes = (function() { | ||||
|         } | ||||
|         for (i in configNodes) { | ||||
|             if (configNodes.hasOwnProperty(i)) { | ||||
|                 nns.push(convertNode(configNodes[i], true)); | ||||
|                 nns.push(convertNode(configNodes[i], exportCredentials)); | ||||
|             } | ||||
|         } | ||||
|         for (i=0;i<nodes.length;i++) { | ||||
|             var node = nodes[i]; | ||||
|             nns.push(convertNode(node, true)); | ||||
|             nns.push(convertNode(node, exportCredentials)); | ||||
|         } | ||||
|         return nns; | ||||
|     } | ||||
|   | ||||
| @@ -46,6 +46,18 @@ RED.clipboard = (function() { | ||||
|                             $( 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", | ||||
|                         class: "primary", | ||||
| @@ -65,12 +77,23 @@ RED.clipboard = (function() { | ||||
|  | ||||
|         dialogContainer = dialog.children(".dialog-form"); | ||||
|  | ||||
|         exportNodesDialog = '<div class="form-row">'+ | ||||
|             '<label for="node-input-export" style="display: block; width:100%;"><i class="fa fa-clipboard"></i> '+RED._("clipboard.nodes")+'</label>'+ | ||||
|             '<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>'+ | ||||
|         exportNodesDialog = | ||||
|             '<div class="form-row">'+ | ||||
|                 '<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 class="form-tips">'+ | ||||
|             RED._("clipboard.selectNodes")+ | ||||
|             '<div class="form-row" style="text-align: right;">'+ | ||||
|                 '<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>'; | ||||
|  | ||||
|         importNodesDialog = '<div class="form-row">'+ | ||||
| @@ -103,6 +126,7 @@ RED.clipboard = (function() { | ||||
|         $("#clipboard-dialog-ok").show(); | ||||
|         $("#clipboard-dialog-cancel").show(); | ||||
|         $("#clipboard-dialog-close").hide(); | ||||
|         $("#clipboard-dialog-copy").hide(); | ||||
|         $("#clipboard-dialog-ok").button("disable"); | ||||
|         $("#clipboard-import").keyup(validateImport); | ||||
|         $("#clipboard-import").on('paste',function() { setTimeout(validateImport,10)}); | ||||
| @@ -113,29 +137,104 @@ RED.clipboard = (function() { | ||||
|     function exportNodes() { | ||||
|         dialogContainer.empty(); | ||||
|         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-cancel").hide(); | ||||
|         $("#clipboard-dialog-close").show(); | ||||
|         $("#clipboard-dialog-copy").hide(); | ||||
|         $("#clipboard-dialog-close").hide(); | ||||
|         var selection = RED.view.selection(); | ||||
|         if (selection.nodes) { | ||||
|             var nns = RED.nodes.createExportableNodeSet(selection.nodes); | ||||
|             if (RED.settings.flowFilePretty) { | ||||
|                 nns = JSON.stringify(nns,null,4); | ||||
|             } else { | ||||
|                 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" ); | ||||
|             $("#export-range-selected").click(); | ||||
|         } else { | ||||
|             $("#export-range-selected").addClass('disabled').removeClass('selected'); | ||||
|             $("#export-range-flow").click(); | ||||
|         } | ||||
|         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() { | ||||
|   | ||||
| @@ -43,13 +43,17 @@ $palette-header-background: #f3f3f3; | ||||
| $workspace-button-background: #fff; | ||||
| $workspace-button-background-hover: #ddd; | ||||
| $workspace-button-background-active: #efefef; | ||||
| $workspace-button-color: #999; | ||||
| $workspace-button-color: #888; | ||||
| $workspace-button-color-disabled: #ccc; | ||||
| $workspace-button-color-focus: #999; | ||||
| $workspace-button-color-hover: #666; | ||||
| $workspace-button-color-active: #666; | ||||
| $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); | ||||
|  | ||||
| $typedInput-button-background: #efefef; | ||||
|   | ||||
| @@ -76,16 +76,16 @@ | ||||
|         font-size: 14px; | ||||
|         padding: 6px 14px; | ||||
|         margin-right: 8px; | ||||
|         color: $editor-button-color; | ||||
|         color: $editor-button-color !important; | ||||
|         background: $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; | ||||
|             &.disabled, &.ui-state-disabled { | ||||
|                 background: none; | ||||
|                 color: $editor-button-color; | ||||
|                 color: $editor-button-color !important; | ||||
|                 border-color: $form-input-border-color; | ||||
|             } | ||||
|             &:not(.disabled):not(.ui-button-disabled):hover { | ||||
| @@ -230,7 +230,12 @@ | ||||
|     font-size: 13px; | ||||
|     border-radius: 4px; | ||||
|     padding: 0 10px; | ||||
|     &.toggle { | ||||
|         @include workspace-button-toggle; | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| .editor-button-small { | ||||
|     height: 20px; | ||||
|     line-height: 18px; | ||||
| @@ -239,6 +244,17 @@ | ||||
|     padding: 0 5px; | ||||
| } | ||||
|  | ||||
| .dialog-form { | ||||
|     .button-group { | ||||
|         .editor-button { | ||||
|             &:first-child { | ||||
|  | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
| #node-config-dialog-scope-container { | ||||
|     cursor: auto; | ||||
|     float: right; | ||||
|   | ||||
| @@ -92,7 +92,7 @@ | ||||
|  | ||||
|     &.primary { | ||||
|         border-color: $editor-button-background-primary; | ||||
|         color: $editor-button-color-primary; | ||||
|         color: $editor-button-color-primary !important; | ||||
|         background: $editor-button-background-primary; | ||||
|         &:not(.disabled):hover { | ||||
|             border-color: $editor-button-background-primary-hover; | ||||
|   | ||||
| @@ -40,39 +40,46 @@ | ||||
|     @include disable-selection; | ||||
|     box-sizing: border-box; | ||||
|     display: inline-block; | ||||
|     color: $workspace-button-color; | ||||
|     color: $workspace-button-color !important; | ||||
|     background: $workspace-button-background; | ||||
|     border: 1px solid $form-input-border-color; | ||||
|     text-align: center; | ||||
|     margin:0; | ||||
|     text-decoration: none; | ||||
|     cursor:pointer; | ||||
|  | ||||
|     &.disabled { | ||||
|         cursor: default; | ||||
|         color: $workspace-button-color-disabled; | ||||
|         color: $workspace-button-color-disabled !important; | ||||
|     } | ||||
|     &:hover, &:focus { | ||||
|         text-decoration: none; | ||||
|     } | ||||
|     &:not(.disabled):hover { | ||||
|         color: $workspace-button-color-hover; | ||||
|         color: $workspace-button-color-hover !important; | ||||
|         background: $workspace-button-background-hover; | ||||
|     } | ||||
|     &:not(.disabled):focus { | ||||
|         color: $workspace-button-color-focus; | ||||
|         color: $workspace-button-color-focus !important; | ||||
|     } | ||||
|     &:not(.disabled):active { | ||||
|         color: $workspace-button-color-active; | ||||
|         color: $workspace-button-color-active !important; | ||||
|         background: $workspace-button-background-active; | ||||
|         text-decoration: none; | ||||
|     } | ||||
|     &.selected:not(.disabled) { | ||||
|         color: $workspace-button-color-selected; | ||||
|         color: $workspace-button-color-selected !important; | ||||
|         background: $workspace-button-background-active; | ||||
|         cursor: default; | ||||
|     } | ||||
|     .button-group &:not(:first-child) { | ||||
|         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 { | ||||
| @@ -81,17 +88,20 @@ | ||||
| } | ||||
| @mixin workspace-button-toggle { | ||||
|     @include workspace-button; | ||||
|     color: $workspace-button-color-selected; | ||||
|     color: $workspace-button-toggle-color !important; | ||||
|     background:$workspace-button-background-active; | ||||
|     transition: all 0.1s ease-in-out; | ||||
|     margin-bottom: 1px; | ||||
|     &.selected:not(.disabled) { | ||||
|         color: $workspace-button-color; | ||||
|         color: $workspace-button-toggle-color-selected !important; | ||||
|         background: $workspace-button-background; | ||||
|         border-bottom-width: 2px; | ||||
|         border-bottom-color: $form-input-border-selected-color; | ||||
|         margin-bottom: 0; | ||||
|     } | ||||
|     &.disabled { | ||||
|         color: $workspace-button-toggle-color-disabled !important; | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -77,16 +77,25 @@ | ||||
|         } | ||||
|     }, | ||||
|     "clipboard": { | ||||
|         "nodes": "Nodes:", | ||||
|         "nodes": "Nodes", | ||||
|         "selectNodes": "Select the text above and copy to the clipboard.", | ||||
|         "pasteNodes": "Paste nodes here", | ||||
|         "importNodes": "Import nodes", | ||||
|         "exportNodes": "Export nodes to clipboard", | ||||
|         "importUnrecognised": "Imported unrecognised type:", | ||||
|         "importUnrecognised_plural": "Imported unrecognised types:", | ||||
|         "nodesExported": "Nodes exported to clipboard", | ||||
|         "nodeCopied": "__count__ node 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", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user