Repository: nifi
Updated Branches:
  refs/heads/master fa639e259 -> e5e86cf07


NIFI-2548:
- Allowing selection of User/Cluster node when searching and encountering an 
exact match.

This closes #839

Signed-off-by: Koji Kawamura <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/e5e86cf0
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/e5e86cf0
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/e5e86cf0

Branch: refs/heads/master
Commit: e5e86cf07caedede4add1935bc0f893168b78115
Parents: fa639e2
Author: Matt Gilman <[email protected]>
Authored: Thu Aug 11 14:50:57 2016 -0400
Committer: Koji Kawamura <[email protected]>
Committed: Fri Aug 12 20:41:49 2016 +0900

----------------------------------------------------------------------
 .../webapp/js/nf/canvas/nf-policy-management.js | 48 ++++++++++++++------
 .../webapp/js/nf/summary/nf-cluster-search.js   | 46 +++++++++++++------
 2 files changed, 67 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/e5e86cf0/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-policy-management.js
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-policy-management.js
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-policy-management.js
index bcd40d8..a0d5fb1 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-policy-management.js
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-policy-management.js
@@ -75,20 +75,8 @@ nf.PolicyManagement = (function () {
                             var selectedUser = [];
                             selectedUser = selectedUser.concat(selectedUsers, 
selectedGroups);
 
-                            // ensure the search found some results
-                            if (!$.isArray(selectedUser) || 
selectedUser.length === 0) {
-                                nf.Dialog.showOkDialog({
-                                    headerText: 'User Search',
-                                    dialogContent: 'No users match \'' + 
nf.Common.escapeHtml(tenantSearchTerm) + '\'.'
-                                });
-                            } else if (selectedUser.length > 1) {
-                                nf.Dialog.showOkDialog({
-                                    headerText: 'User Search',
-                                    dialogContent: 'More than one user matches 
\'' + nf.Common.escapeHtml(tenantSearchTerm) + '\'.'
-                                });
-                            } else if (selectedUser.length === 1) {
-                                var user = selectedUser[0];
-
+                            // add the user to the policy table
+                            var addUser = function (user) {
                                 // add to table and update policy
                                 var policyGrid = 
$('#policy-table').data('gridInstance');
                                 var policyData = policyGrid.getData();
@@ -104,6 +92,38 @@ nf.PolicyManagement = (function () {
 
                                 // update the policy
                                 updatePolicy();
+                            };
+
+                            // ensure the search found some results
+                            if (!$.isArray(selectedUser) || 
selectedUser.length === 0) {
+                                nf.Dialog.showOkDialog({
+                                    headerText: 'User Search',
+                                    dialogContent: 'No users match \'' + 
nf.Common.escapeHtml(tenantSearchTerm) + '\'.'
+                                });
+                            } else if (selectedUser.length > 1) {
+                                var exactMatch = false;
+
+                                // look for an exact match
+                                $.each(selectedUser, function (_, userEntity) {
+                                    if (userEntity.component.identity === 
tenantSearchTerm) {
+                                        addUser(userEntity);
+                                        exactMatch = true;
+                                        return false;
+                                    }
+                                });
+
+                                // if there is an exact match, use it
+                                if (exactMatch) {
+                                    // close the dialog
+                                    $('#search-users-dialog').modal('hide');
+                                } else {
+                                    nf.Dialog.showOkDialog({
+                                        headerText: 'User Search',
+                                        dialogContent: 'More than one user 
matches \'' + nf.Common.escapeHtml(tenantSearchTerm) + '\'.'
+                                    });
+                                }
+                            } else if (selectedUser.length === 1) {
+                                addUser(selectedUser[0]);
 
                                 // close the dialog
                                 $('#search-users-dialog').modal('hide');

http://git-wip-us.apache.org/repos/asf/nifi/blob/e5e86cf0/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/summary/nf-cluster-search.js
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/summary/nf-cluster-search.js
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/summary/nf-cluster-search.js
index b5c9e68..b0d55ef 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/summary/nf-cluster-search.js
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/summary/nf-cluster-search.js
@@ -56,6 +56,18 @@ nf.ClusterSearch = (function () {
                             }).done(function (response) {
                                 var searchResults = response.nodeResults;
 
+                                // selects the specified node
+                                var selectNode = function (node) {
+                                    // update the urls to point to this 
specific node of the cluster
+                                    nf.SummaryTable.setClusterNodeId(node.id);
+
+                                    // load the summary for the selected node
+                                    nf.SummaryTable.loadSummaryTable();
+
+                                    // update the header
+                                    
$('#summary-header-text').text(node.address + ' Summary');
+                                };
+
                                 // ensure the search found some results
                                 if (!$.isArray(searchResults) || 
searchResults.length === 0) {
                                     nf.Dialog.showOkDialog({
@@ -63,21 +75,29 @@ nf.ClusterSearch = (function () {
                                         dialogContent: 'No nodes match \'' + 
nf.Common.escapeHtml(clusterSearchTerm) + '\'.'
                                     });
                                 } else if (searchResults.length > 1) {
-                                    nf.Dialog.showOkDialog({
-                                        headerText: 'Cluster Search',
-                                        dialogContent: 'More than one node 
matches \'' + nf.Common.escapeHtml(clusterSearchTerm) + '\'.'
-                                    });
-                                } else if (searchResults.length === 1) {
-                                    var node = searchResults[0];
-
-                                    // update the urls to point to this 
specific node of the cluster
-                                    nf.SummaryTable.setClusterNodeId(node.id);
+                                    var exactMatch = false;
 
-                                    // load the summary for the selected node
-                                    nf.SummaryTable.loadSummaryTable();
+                                    // look for an exact match
+                                    $.each(searchResults, function (_, result) 
{
+                                        if (result.address === 
clusterSearchTerm) {
+                                            selectNode(result);
+                                            exactMatch = true;
+                                            return false;
+                                        }
+                                    });
 
-                                    // update the header
-                                    
$('#summary-header-text').text(node.address + ' Summary');
+                                    // if there is an exact match, use it
+                                    if (exactMatch) {
+                                        // close the dialog
+                                        
$('#view-single-node-dialog').modal('hide');
+                                    } else {
+                                        nf.Dialog.showOkDialog({
+                                            headerText: 'Cluster Search',
+                                            dialogContent: 'More than one node 
matches \'' + nf.Common.escapeHtml(clusterSearchTerm) + '\'.'
+                                        });
+                                    }
+                                } else if (searchResults.length === 1) {
+                                    selectNode(searchResults[0]);
 
                                     // close the dialog
                                     
$('#view-single-node-dialog').modal('hide');

Reply via email to