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 bcd40d85dd..a0d5fb15bc 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'); 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 b5c9e681ac..b0d55ef51a 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,20 +56,8 @@ nf.ClusterSearch = (function () { }).done(function (response) { var searchResults = response.nodeResults; - // ensure the search found some results - if (!$.isArray(searchResults) || searchResults.length === 0) { - nf.Dialog.showOkDialog({ - headerText: 'Cluster Search', - 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]; - + // 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); @@ -78,6 +66,38 @@ nf.ClusterSearch = (function () { // 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({ + headerText: 'Cluster Search', + dialogContent: 'No nodes match \'' + nf.Common.escapeHtml(clusterSearchTerm) + '\'.' + }); + } else if (searchResults.length > 1) { + var exactMatch = false; + + // look for an exact match + $.each(searchResults, function (_, result) { + if (result.address === clusterSearchTerm) { + selectNode(result); + exactMatch = true; + return false; + } + }); + + // 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');