nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pvill...@apache.org
Subject [nifi] branch main updated: NIFI-8471 Parameter Contexts - show referencing process groups
Date Wed, 02 Jun 2021 16:22:48 GMT
This is an automated email from the ASF dual-hosted git repository.

pvillard 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 66f0f90  NIFI-8471 Parameter Contexts - show referencing process groups
66f0f90 is described below

commit 66f0f902525fe8303389c316f3b63029e96a565f
Author: s9514171 <s9514171@gmail.com>
AuthorDate: Mon May 3 08:39:07 2021 +0000

    NIFI-8471 Parameter Contexts - show referencing process groups
    
    Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>
    
    This closes #5048.
---
 .../canvas/new-parameter-context-dialog.jsp        |  9 ++
 .../webapp/js/nf/canvas/nf-parameter-contexts.js   | 96 ++++++++++++++++++++++
 2 files changed, 105 insertions(+)

diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/new-parameter-context-dialog.jsp
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/new-parameter-context-dialog.jsp
index e308faa..d1e10a5 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/new-parameter-context-dialog.jsp
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/new-parameter-context-dialog.jsp
@@ -46,6 +46,15 @@
                 </div>
                 <div class="spacer">&nbsp;</div>
                 <div class="settings-right">
+                    <div class="setting">
+                        <div class="setting-name">
+                            Referencing Components
+                            <div class="fa fa-question-circle" alt="Info" title="Other
components referencing this parameter context."></div>
+                        </div>
+                        <div class="setting-field">
+                            <div id="parameter-context-referencing-components"></div>
+                        </div>
+                    </div>
                 </div>
             </div>
             <div id="parameter-context-parameters-tab-content" class="configuration-tab">
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-parameter-contexts.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-parameter-contexts.js
index 2f9ffc6..d7e9c64 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-parameter-contexts.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-parameter-contexts.js
@@ -195,6 +195,8 @@
         $('#parameter-context-description-field').val('');
         $('#parameter-context-description-read-only').text('');
 
+        $('#parameter-context-referencing-components').empty();
+
         $('#parameter-table, #add-parameter').show();
         $('#parameter-context-tabs').show();
         $('#parameter-context-tabs').find('.tab')[0].click();
@@ -1345,6 +1347,90 @@
     var parameterIndex = 0;
 
     /**
+     * Loads the reference for this parameter context.
+     *
+     * @param {jQuery} referencingProcessGroupsContainer
+     * @param {object} parameterContext
+     */
+    var loadReferencingProcessGroups = function (referencingProcessGroupsContainer, parameterContext)
{
+        if (parameterContext.permissions.canRead === false) {
+            referencingProcessGroupsContainer.append('<div class="unset">Unauthorized</div>');
+            return;
+        }
+        var referencingProcessGroups = parameterContext.component.boundProcessGroups;
+        if (nfCommon.isEmpty(referencingProcessGroups)) {
+            referencingProcessGroupsContainer.append('<div class="unset">No referencing
components.</div>');
+            return;
+        }
+
+        // toggles the visibility of a container
+        var toggle = function (twist, container) {
+            if (twist.hasClass('expanded')) {
+                twist.removeClass('expanded').addClass('collapsed');
+                container.hide();
+            } else {
+                twist.removeClass('collapsed').addClass('expanded');
+                container.show();
+            }
+        };
+
+        var processGroups = $('<ul class="referencing-component-listing clear"></ul>');
+        var unauthorized = $('<ul class="referencing-component-listing clear"></ul>');
+        $.each(referencingProcessGroups, function (_, referencingProcessGroupsEntity) {
+            // check the access policy for this referencing component
+            if (referencingProcessGroupsEntity.permissions.canRead === false) {
+                var unauthorizedReferencingComponent = $('<div class="unset"></div>').text(referencingProcessGroupsEntity.id);
+                unauthorized.append(unauthorizedReferencingComponent);
+            } else {
+                var referencingComponent = referencingProcessGroupsEntity.component;
+
+                var processGroupLink = $('<span class="referencing-component-name link"></span>').text(referencingComponent.name).on('click',
function () {
+                    // show the component
+                    if (nfCommon.isDefinedAndNotNull(referencingComponent.parentGroupId))
{
+                        nfCanvasUtils.showComponent(referencingComponent.parentGroupId, referencingComponent.id);
+                    } else {
+                        nfProcessGroup.enterGroup(referencingComponent.id);
+                    }
+
+                    // close the dialog and shell
+                    referencingProcessGroupsContainer.closest('.dialog').modal('hide');
+                    $('#shell-close-button').click();
+                });
+                var processGroupItem = $('<li></li>').append(processGroupLink);
+                processGroups.append(processGroupItem);
+            }
+        });
+
+        // create the collapsable listing for each type
+        var createReferenceBlock = function (titleText, list) {
+            if (list.is(':empty')) {
+                list.remove();
+                return;
+            }
+
+            var twist = $('<div class="expansion-button expanded"></div>');
+            var title = $('<span class="referencing-component-title"></span>').text(titleText);
+            var count = $('<span class="referencing-component-count"></span>').text('('
+ list.children().length + ')');
+
+            // create the reference block
+            $('<div class="referencing-component-block pointer unselectable"></div>').on('click',
function () {
+                // toggle this block
+                toggle(twist, list);
+
+                // update the border if necessary
+                updateReferencingComponentsBorder(referencingProcessGroupsContainer);
+            }).append(twist).append(title).append(count).appendTo(referencingProcessGroupsContainer);
+
+            // add the listing
+            list.appendTo(referencingProcessGroupsContainer);
+        };
+
+        // create blocks for each type of component
+        createReferenceBlock('Process Groups', processGroups);
+        createReferenceBlock('Unauthorized', unauthorized);
+    };
+
+    /**
      * Loads the specified parameter registry.
      *
      * @param {object} parameterContext
@@ -2439,6 +2525,12 @@
                     .prop('title', parameterContextEntity.id)
                     .text(parameterContextEntity.id);
 
+                // get the reference container
+                var referencingComponentsContainer = $('#parameter-context-referencing-components');
+
+                // load the controller referencing components list
+                loadReferencingProcessGroups(referencingComponentsContainer, parameterContextEntity);
+
                 loadParameters(parameterContextEntity, parameterToSelect, readOnly || !canWrite);
 
                 var editModeButtonModel = [{
@@ -2501,6 +2593,10 @@
 
                 // check if border is necessary
                 updateReferencingComponentsBorder($('#parameter-referencing-components-container'));
+
+                // show the border if necessary
+                updateReferencingComponentsBorder(referencingComponentsContainer);
+
             }).fail(nfErrorHandler.handleAjaxError);
         },
 

Mime
View raw message