You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2023/01/11 19:30:03 UTC

[nifi] branch main updated: NIFI-10241 Add comments tooltip for controller services, reporting tasks

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 692e74e90d NIFI-10241 Add comments tooltip for controller services, reporting tasks
692e74e90d is described below

commit 692e74e90dd9dd258fdd8d5ace2933e5dab7e1cb
Author: Nissim Shiman <ns...@yahoo.com>
AuthorDate: Fri Jul 29 18:28:54 2022 +0000

    NIFI-10241 Add comments tooltip for controller services, reporting tasks
    
    Signed-off-by: Matthew Burgess <ma...@apache.org>
    
    This closes #6768
---
 .../images/controller-services-info-buttons.png    | Bin 10024 -> 9594 bytes
 .../images/reporting-tasks-info-buttons.png        | Bin 13352 -> 13815 bytes
 nifi-docs/src/main/asciidoc/user-guide.adoc        |   4 +-
 .../webapp/js/nf/canvas/nf-controller-services.js  |  38 ++++++++++++++++++-
 .../src/main/webapp/js/nf/canvas/nf-settings.js    |  42 +++++++++++++++++++--
 .../nifi-web-ui/src/main/webapp/js/nf/nf-common.js |  15 ++++++++
 6 files changed, 93 insertions(+), 6 deletions(-)

diff --git a/nifi-docs/src/main/asciidoc/images/controller-services-info-buttons.png b/nifi-docs/src/main/asciidoc/images/controller-services-info-buttons.png
index ea58df688d..1aee4b820b 100644
Binary files a/nifi-docs/src/main/asciidoc/images/controller-services-info-buttons.png and b/nifi-docs/src/main/asciidoc/images/controller-services-info-buttons.png differ
diff --git a/nifi-docs/src/main/asciidoc/images/reporting-tasks-info-buttons.png b/nifi-docs/src/main/asciidoc/images/reporting-tasks-info-buttons.png
index 93f561cfba..339c4cacda 100644
Binary files a/nifi-docs/src/main/asciidoc/images/reporting-tasks-info-buttons.png and b/nifi-docs/src/main/asciidoc/images/reporting-tasks-info-buttons.png differ
diff --git a/nifi-docs/src/main/asciidoc/user-guide.adoc b/nifi-docs/src/main/asciidoc/user-guide.adoc
index e94d9cbb38..8a76fdead4 100644
--- a/nifi-docs/src/main/asciidoc/user-guide.adoc
+++ b/nifi-docs/src/main/asciidoc/user-guide.adoc
@@ -1303,7 +1303,7 @@ far-right column. Other buttons in this column include "Enable", "Remove" and "A
 
 image:controller-services-configure-buttons.png["Controller Services Buttons"]
 
-You can obtain information about Controller Services by clicking the "Usage" and "Alerts" buttons in the left-hand column.
+You can obtain information about Controller Services by clicking the "Usage", "Comments" and "Alerts" buttons in the left-hand column.
 
 image:controller-services-info-buttons.png["Controller Services Information Buttons"]
 
@@ -1370,7 +1370,7 @@ Once a Reporting Task has been added, the DFM may configure it by clicking the "
 
 image:reporting-tasks-edit-buttons.png["Reporting Tasks Edit Buttons"]
 
-You can obtain information about Reporting Tasks by clicking the "View Details", "Usage", and "Alerts" buttons in the left-hand column.
+You can obtain information about Reporting Tasks by clicking the "View Details", "Usage", "Comments" and "Alerts" buttons in the left-hand column.
 
 image:reporting-tasks-info-buttons.png["Reporting Tasks Information Buttons"]
 
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-services.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-services.js
index 8e241a96f3..7dff947913 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-services.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-services.js
@@ -868,9 +868,14 @@
             // always include a button to view the usage
             var markup = '<div title="Usage" class="pointer controller-service-usage fa fa-book"></div>';
 
+            var hasComments = !nfCommon.isBlank(dataContext.component.comments);
             var hasErrors = !nfCommon.isEmpty(dataContext.component.validationErrors);
             var hasBulletins = !nfCommon.isEmpty(dataContext.bulletins);
 
+            if (hasComments) {
+            	markup += '<div class="pointer has-comments fa fa-comment"></div>';
+            }
+
             if (hasErrors) {
                 markup += '<div class="pointer has-errors fa fa-warning"></div>';
             }
@@ -879,7 +884,7 @@
                 markup += '<div class="has-bulletins fa fa-sticky-note-o"></div>';
             }
 
-            if (hasErrors || hasBulletins) {
+            if (hasComments || hasErrors || hasBulletins) {
                 markup += '<span class="hidden row-id">' + nfCommon.escapeHtml(dataContext.id) + '</span>';
             }
 
@@ -1157,6 +1162,36 @@
 
         // hold onto an instance of the grid
         serviceTable.data('gridInstance', controllerServicesGrid).on('mouseenter', 'div.slick-cell', function (e) {
+            var commentsIcon = $(this).find('div.has-comments');
+            if (commentsIcon.length && !commentsIcon.data('qtip')) {
+                var serviceId = $(this).find('span.row-id').text();
+
+                // get the service item
+                var controllerServiceEntity = controllerServicesData.getItemById(serviceId);
+
+                // format the tooltip
+                var comments = nfCommon.escapeHtml(controllerServiceEntity.component.comments);
+                var tooltip = nfCommon.formatNewLines(comments);
+
+                // show the tooltip
+                if (nfCommon.isDefinedAndNotNull(tooltip)) {
+                    commentsIcon.qtip($.extend({},
+                        nfCommon.config.tooltipConfig,
+                        {
+                            content: tooltip,
+                            position: {
+                                target: 'mouse',
+                                viewport: $('#shell-container'),
+                                adjust: {
+                                    x: 8,
+                                    y: 8,
+                                    method: 'flipinvert flipinvert'
+                                }
+                            }
+                        }));
+                }
+            }
+
             var errorIcon = $(this).find('div.has-errors');
             if (errorIcon.length && !errorIcon.data('qtip')) {
                 var serviceId = $(this).find('span.row-id').text();
@@ -1241,6 +1276,7 @@
                 }, service));
             });
 
+            nfCommon.cleanUpTooltips(serviceTable, 'div.has-comments');
             nfCommon.cleanUpTooltips(serviceTable, 'div.has-errors');
             nfCommon.cleanUpTooltips(serviceTable, 'div.has-bulletins');
 
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
index 73bc81a1ae..290ce4dce6 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
@@ -1594,9 +1594,14 @@
             // always include a button to view the usage
             markup += '<div title="Usage" class="pointer reporting-task-usage fa fa-book"></div>';
 
+            var hasComments = !nfCommon.isBlank(dataContext.component.comments);
             var hasErrors = !nfCommon.isEmpty(dataContext.component.validationErrors);
             var hasBulletins = !nfCommon.isEmpty(dataContext.bulletins);
 
+            if (hasComments) {
+            	markup += '<div class="pointer has-comments fa fa-comment"></div>';
+            }
+
             if (hasErrors) {
                 markup += '<div class="pointer has-errors fa fa-warning" ></div>';
             }
@@ -1605,7 +1610,7 @@
                 markup += '<div class="has-bulletins fa fa-sticky-note-o"></div>';
             }
 
-            if (hasErrors || hasBulletins) {
+            if (hasComments || hasErrors || hasBulletins) {
                 markup += '<span class="hidden row-id">' + nfCommon.escapeHtml(dataContext.component.id) + '</span>';
             }
 
@@ -1698,8 +1703,8 @@
                 resizable: false,
                 formatter: moreReportingTaskDetails,
                 sortable: true,
-                width: 90,
-                maxWidth: 90,
+                width: 100,
+                maxWidth: 100,
                 toolTip: 'Sorts based on presence of bulletins'
             },
             {
@@ -1829,6 +1834,36 @@
 
         // hold onto an instance of the grid
         $('#reporting-tasks-table').data('gridInstance', reportingTasksGrid).on('mouseenter', 'div.slick-cell', function (e) {
+            var commentsIcon = $(this).find('div.has-comments');
+            if (commentsIcon.length && !commentsIcon.data('qtip')) {
+                 var taskId = $(this).find('span.row-id').text();
+
+                // get the task item
+                var reportingTaskEntity = reportingTasksData.getItemById(taskId);
+
+                // format the tooltip
+                var comments = nfCommon.escapeHtml(reportingTaskEntity.component.comments);
+                var tooltip = nfCommon.formatNewLines(comments);
+
+                // show the tooltip
+                if (nfCommon.isDefinedAndNotNull(tooltip)) {
+                    commentsIcon.qtip($.extend({},
+                        nfCommon.config.tooltipConfig,
+                        {
+                            content: tooltip,
+                            position: {
+                                target: 'mouse',
+                                viewport: $('#shell-container'),
+                                adjust: {
+                                    x: 8,
+                                    y: 8,
+                                    method: 'flipinvert flipinvert'
+                                }
+                            }
+                        }));
+                }
+            }
+
             var errorIcon = $(this).find('div.has-errors');
             if (errorIcon.length && !errorIcon.data('qtip')) {
                 var taskId = $(this).find('span.row-id').text();
@@ -2543,6 +2578,7 @@
             });
 
             var reportingTasksElement = $('#reporting-tasks-table');
+            nfCommon.cleanUpTooltips(reportingTasksElement, 'div.has-comments');
             nfCommon.cleanUpTooltips(reportingTasksElement, 'div.has-errors');
             nfCommon.cleanUpTooltips(reportingTasksElement, 'div.has-bulletins');
 
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js
index 477c16656e..758a19f8e7 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js
@@ -1083,6 +1083,21 @@
             };
         }()),
 
+        /**
+         * Formats the specified value, so new lines are represented as \<br\>
+         * If value is null or not defined an empty string is returned
+         *
+         * @argument {string} value     string value
+         * @returns {string}
+         */
+        formatNewLines: function (value) {
+            if (nfCommon.isDefinedAndNotNull(value)) {
+            	return value.replaceAll(/[\n]/g, "<br>");
+            } else {
+                return '';
+            }
+        },
+
         /**
          * Determines if the specified property is sensitive.
          *