You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by pw...@apache.org on 2019/04/19 22:25:21 UTC

[nifi] branch master updated: NIFI-6221 Adding 'Download' and 'View' content buttons to List Queue (#3440)

This is an automated email from the ASF dual-hosted git repository.

pwicks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new 512555d  NIFI-6221 Adding 'Download' and 'View' content buttons to List Queue (#3440)
512555d is described below

commit 512555dbb0808d1b4c5b60a6478af0578a6c9abc
Author: aeaversa <36...@users.noreply.github.com>
AuthorDate: Fri Apr 19 18:25:15 2019 -0400

    NIFI-6221 Adding 'Download' and 'View' content buttons to List Queue (#3440)
    
    NIFI-6221 Adding 'Download' and 'View' content icon buttons to slick grid actions column to improve end user navigation.
---
 .../main/webapp/js/nf/canvas/nf-queue-listing.js   | 67 +++++++++++++++-------
 1 file changed, 45 insertions(+), 22 deletions(-)

diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-queue-listing.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-queue-listing.js
index 79fef78..89131bd 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-queue-listing.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-queue-listing.js
@@ -204,32 +204,48 @@
             });
         }
 
-        // add an actions column when the user can access provenance
-        if (nfCommon.canAccessProvenance()) {
-            // function for formatting actions
-            var actionsFormatter = function () {
-                return '<div title="Provenance" class="pointer icon icon-provenance view-provenance"></div>';
-            };
+        // function for formatting actions column
+        var actionsFormatter = function (row,cell,value,columnDef,dataContext) {
+            var formatted = '';
+
+            var disabled = (dataContext.size > 0)?false:true;
+            formatted += '<div class="icon download-flowfile-content fa fa-download '+((disabled)?'disabled':'pointer')+'"'+
+                ' title="'+((disabled)?'No content available to download':'Download content')+'" aria-hidden="true"></div>';
+
+            if(nfCommon.isContentViewConfigured()){
+                formatted += '<div class="icon view-flowfile-content fa fa-eye '+((disabled)?'disabled':'pointer')+'"'+
+                    ' title="'+((disabled)?'No content available to view':'View content')+'" aria-hidden="true"></div>';
+            }
+
+            if(nfCommon.canAccessProvenance()){
+                formatted += '<div title="Provenance" class="pointer icon icon-provenance view-provenance" aria-hidden="true"></div>';
+            }
+
+            return formatted;
+        };
+
+        // add an actions column to the column model
+        queueListingColumns.push({
+            id: 'actions',
+            name: '&nbsp;',
+            resizable: false,
+            formatter: actionsFormatter,
+            sortable: false,
+            width: 75,
+            maxWidth: 75
+        });
 
-            queueListingColumns.push({
-                id: 'actions',
-                name: '&nbsp;',
-                resizable: false,
-                formatter: actionsFormatter,
-                sortable: false,
-                width: 50,
-                maxWidth: 50
-            });
-        }
 
         return queueListingColumns;
     };
 
     /**
      * Downloads the content for the flowfile currently being viewed.
+     *
+     * @param flowFileSummary|{flowfile} (optional) -  the flowfile summary
      */
-    var downloadContent = function () {
-        var dataUri = $('#flowfile-uri').text() + '/content';
+    var downloadContent = function (flowFileSummary) {
+        var dataUri = ((nfCommon.isDefinedAndNotNull(flowFileSummary.uri))?flowFileSummary.uri:$('#flowfile-uri').text())+ '/content';
 
         // perform the request once we've received a token
         nfCommon.getAccessToken(config.urls.downloadToken).done(function (downloadToken) {
@@ -241,7 +257,7 @@
             }
 
             // conditionally include the cluster node id
-            var clusterNodeId = $('#flowfile-cluster-node-id').text();
+            var clusterNodeId = (nfCommon.isDefinedAndNotNull(flowFileSummary.clusterNodeId))?flowFileSummary.clusterNodeId:$('#flowfile-cluster-node-id').text();
             if (!nfCommon.isBlank(clusterNodeId)) {
                 parameters['clusterNodeId'] = clusterNodeId;
             }
@@ -262,9 +278,12 @@
 
     /**
      * Views the content for the flowfile currently being viewed.
+     *
+     * @param flowFileSummary|{flowfile} (optional) -  the flowfile summary
      */
-    var viewContent = function () {
-        var dataUri = $('#flowfile-uri').text() + '/content';
+    var viewContent = function (flowFileSummary) {
+
+        var dataUri = ((nfCommon.isDefinedAndNotNull(flowFileSummary.uri))?flowFileSummary.uri:$('#flowfile-uri').text())+ '/content';
 
         // generate tokens as necessary
         var getAccessTokens = $.Deferred(function (deferred) {
@@ -301,7 +320,7 @@
             var dataUriParameters = {};
 
             // conditionally include the cluster node id
-            var clusterNodeId = $('#flowfile-cluster-node-id').text();
+            var clusterNodeId = (nfCommon.isDefinedAndNotNull(flowFileSummary.clusterNodeId))?flowFileSummary.clusterNodeId:$('#flowfile-cluster-node-id').text();
             if (!nfCommon.isBlank(clusterNodeId)) {
                 dataUriParameters['clusterNodeId'] = clusterNodeId;
             }
@@ -675,6 +694,10 @@
                         nfShell.showPage('provenance?' + $.param({
                                 flowFileUuid: item.uuid
                             }));
+                    } else if (target.hasClass('download-flowfile-content') && !target.hasClass('disabled')) {
+                        downloadContent(item);
+                    } else if (target.hasClass('view-flowfile-content') && !target.hasClass('disabled')) {
+                        viewContent(item);
                     }
                 }
             });