You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by sc...@apache.org on 2019/09/03 16:08:59 UTC

[nifi] branch master updated: NIFI-6608: - Conditionally support parameters in controller service configuration.

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

scottyaslan 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 07e1c11  NIFI-6608: - Conditionally support parameters in controller service configuration.
07e1c11 is described below

commit 07e1c11520aa5490c6d10afae17ab74b2fab0d1c
Author: Matt Gilman <ma...@gmail.com>
AuthorDate: Tue Sep 3 11:52:45 2019 -0400

    NIFI-6608:
    - Conditionally support parameters in controller service configuration.
    
    This closes #3688
    
    Signed-off-by: Scott Aslan <sc...@gmail.com>
---
 .../webapp/js/nf/canvas/nf-controller-service.js   | 91 +++++++++++++---------
 1 file changed, 53 insertions(+), 38 deletions(-)

diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
index 9017ce4..6814edc 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
@@ -1510,6 +1510,52 @@
     };
 
     /**
+     * Gets the parameters for the specified property descriptor and group.
+     *
+     * @param propertyDescriptor    The property descriptor in question
+     * @param groupId               The group in question
+     * @returns {deferred}
+     */
+    var getParameters = function (propertyDescriptor, groupId) {
+        return $.Deferred(function (deferred) {
+            if (nfCommon.isDefinedAndNotNull(groupId)) {
+                var parameterContextId;
+
+                // attempt to identify the parameter context id, conditional based on whether
+                // the user is configuring the current process group
+                if (groupId === nfCanvasUtils.getGroupId()) {
+                    parameterContextId = nfCanvasUtils.getParameterContextId();
+                } else {
+                    var parentProcessGroup = nfCanvasUtils.getComponentByType('ProcessGroup').get(groupId);
+                    parameterContextId = parentProcessGroup.parameterContextId;
+                }
+
+                if (nfCommon.isDefinedAndNotNull(parameterContextId)) {
+                    $.ajax({
+                        type: 'GET',
+                        url: '../nifi-api/parameter-contexts/' + parameterContextId,
+                        dataType: 'json'
+                    }).done(function (response) {
+                        var sensitive = nfCommon.isSensitiveProperty(propertyDescriptor);
+
+                        deferred.resolve(response.component.parameters.map(function (parameterEntity) {
+                            return parameterEntity.parameter;
+                        }).filter(function (parameter) {
+                            return parameter.sensitive === sensitive;
+                        }));
+                    }).fail(function () {
+                        deferred.resolve([]);
+                    });
+                } else {
+                    deferred.resolve([]);
+                }
+            } else {
+                deferred.resolve([]);
+            }
+        }).promise();
+    };
+
+    /**
      * Goes to a service configuration from the property table.
      *
      * @param {jQuery} serviceTable
@@ -1800,50 +1846,19 @@
                 $('#controller-service-configuration .controller-service-read-only').hide();
                 $('#controller-service-configuration .controller-service-editable').show();
 
+                // conditionally get the parameter deferred function
+                var getParameterDeferred = null;
+                if (nfCommon.isDefinedAndNotNull(controllerServiceEntity.parentGroupId)) {
+                    getParameterDeferred = getParameters;
+                }
+
                 // initialize the property table
                 $('#controller-service-properties').propertytable('destroy').propertytable({
                     readOnly: false,
                     supportsGoTo: true,
                     dialogContainer: '#new-controller-service-property-container',
                     descriptorDeferred: getControllerServicePropertyDescriptor,
-                    parameterDeferred: function (propertyDescriptor, groupId) {
-                        return $.Deferred(function (deferred) {
-                            if (nfCommon.isDefinedAndNotNull(groupId)) {
-                                var parameterContextId;
-
-                                // attempt to identify the parameter context id, conditional based on whether
-                                // the user is configuring the current process group
-                                if (groupId === nfCanvasUtils.getGroupId()) {
-                                    parameterContextId = nfCanvasUtils.getParameterContextId();
-                                } else {
-                                    var parentProcessGroup = nfCanvasUtils.getComponentByType('ProcessGroup').get(groupId);
-                                    parameterContextId = parentProcessGroup.parameterContextId;
-                                }
-
-                                if (nfCommon.isDefinedAndNotNull(parameterContextId)) {
-                                    $.ajax({
-                                        type: 'GET',
-                                        url: '../nifi-api/parameter-contexts/' + parameterContextId,
-                                        dataType: 'json'
-                                    }).done(function (response) {
-                                        var sensitive = nfCommon.isSensitiveProperty(propertyDescriptor);
-
-                                        deferred.resolve(response.component.parameters.map(function (parameterEntity) {
-                                            return parameterEntity.parameter;
-                                        }).filter(function (parameter) {
-                                            return parameter.sensitive === sensitive;
-                                        }));
-                                    }).fail(function () {
-                                        deferred.resolve([]);
-                                    });
-                                } else {
-                                    deferred.resolve([]);
-                                }
-                            } else {
-                                deferred.resolve([]);
-                            }
-                        }).promise();
-                    },
+                    parameterDeferred: getParameterDeferred,
                     controllerServiceCreatedDeferred: function (response) {
                         var controllerServicesUri;