NIFI-2548:

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

This closes #839

Signed-off-by: Koji Kawamura <ijokarumawak@apache.org>
This commit is contained in:
Matt Gilman 2016-08-11 14:50:57 -04:00 committed by Koji Kawamura
parent fa639e2596
commit e5e86cf07c
2 changed files with 68 additions and 28 deletions

View File

@ -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');

View File

@ -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');