NIFI-2475: - Updating UI to better suggest that component specific administrators do not override higher level administrators.

This closes #813
This commit is contained in:
Matt Gilman 2016-08-08 16:52:53 -04:00 committed by Matt Burgess
parent 7575e87cb1
commit 7a1f749f69
3 changed files with 142 additions and 45 deletions

View File

@ -24,6 +24,7 @@
<div id="policy-message"></div> <div id="policy-message"></div>
<div id="new-policy-message" class="hidden"><span id="create-policy-link" class="link">Create</span> a new policy.</div> <div id="new-policy-message" class="hidden"><span id="create-policy-link" class="link">Create</span> a new policy.</div>
<div id="override-policy-message" class="hidden"><span id="override-policy-link" class="link">Override</span> this policy.</div> <div id="override-policy-message" class="hidden"><span id="override-policy-link" class="link">Override</span> this policy.</div>
<div id="add-local-admin-message" class="hidden"><span id="add-local-admin-link" class="link">Add</span> policy for additional administrators.</div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<div id="global-policy-controls" class="hidden policy-controls"> <div id="global-policy-controls" class="hidden policy-controls">
@ -88,5 +89,7 @@
Last updated:&nbsp;<span id="policy-last-refreshed" class="last-refreshed"></span> Last updated:&nbsp;<span id="policy-last-refreshed" class="last-refreshed"></span>
</div> </div>
<div id="policy-loading-container" class="loading-container"></div> <div id="policy-loading-container" class="loading-container"></div>
<div id="admin-policy-message" class="hidden">Only listing component specific administrators. Inherited administrators not shown.</div>
<div class="clear"></div>
</div> </div>
</div> </div>

View File

@ -210,3 +210,15 @@ div.policy-selected-component-type {
border: 1px solid #999999; border: 1px solid #999999;
border-radius: 0; border-radius: 0;
} }
/*
admin policy message
*/
#admin-policy-message {
float: right;
margin-top: 8px;
color: #775351;
font-family: Roboto;
font-size: 13px;
}

View File

@ -210,7 +210,7 @@ nf.PolicyManagement = (function () {
var initPolicyTable = function () { var initPolicyTable = function () {
// create/override a policy // create/override a policy
$('#create-policy-link, #override-policy-link').on('click', function () { $('#create-policy-link, #override-policy-link, #add-local-admin-link').on('click', function () {
createPolicy(); createPolicy();
}); });
@ -692,65 +692,146 @@ nf.PolicyManagement = (function () {
*/ */
var loadPolicy = function () { var loadPolicy = function () {
var resourceAndAction = getSelectedResourceAndAction(); var resourceAndAction = getSelectedResourceAndAction();
return $.Deferred(function (deferred) {
$.ajax({
type: 'GET',
url: '../nifi-api/policies/' + resourceAndAction.action + resourceAndAction.resource,
dataType: 'json'
}).done(function (policyEntity) {
// return OK so we either have access to the policy or we don't have access to an inherited policy
// update the refresh timestamp var policyDeferred;
$('#policy-last-refreshed').text(policyEntity.generated); if (resourceAndAction.resource.startsWith('/policies')) {
$('#admin-policy-message').show();
// ensure appropriate actions for the loaded policy policyDeferred = $.Deferred(function (deferred) {
if (policyEntity.permissions.canRead === true) { $.ajax({
var policy = policyEntity.component; type: 'GET',
url: '../nifi-api/policies/' + resourceAndAction.action + resourceAndAction.resource,
dataType: 'json'
}).done(function (policyEntity) {
// update the refresh timestamp
$('#policy-last-refreshed').text(policyEntity.generated);
$('#policy-message').text(policy.resource); // ensure appropriate actions for the loaded policy
if (policyEntity.permissions.canRead === true) {
var policy = policyEntity.component;
// populate the policy details // if the return policy is for the desired policy (not inherited, show it)
populatePolicy(policyEntity); if (resourceAndAction.resource === policy.resource) {
} else { $('#policy-message').text(policy.resource);
// reset the policy
resetPolicy();
// since we cannot read, the policy may be inherited or not... we cannot tell // populate the policy details
$('#policy-message').text('Not authorized to view the policy.'); populatePolicy(policyEntity);
} else {
// reset the policy
resetPolicy();
// allow option to override because we don't know if it's supported or not // show an appropriate message
$('#override-policy-message').show(); $('#policy-message').text('No component specific administrators.');
}
deferred.resolve(); // we don't know if the user has permissions to the desired policy... show create button and allow the server to decide
}).fail(function (xhr, status, error) { $('#add-local-admin-message').show();
if (xhr.status === 404) { }
// reset the policy } else {
resetPolicy(); // reset the policy
resetPolicy();
// show an appropriate message // show an appropriate message
$('#policy-message').text('No policy for the specified resource.'); $('#policy-message').text('No component specific administrators.');
// we don't know if the user has permissions to the desired policy... show create button and allow the server to decide // we don't know if the user has permissions to the desired policy... show create button and allow the server to decide
$('#new-policy-message').show(); $('#add-local-admin-message').show();
}
deferred.resolve(); deferred.resolve();
} else if (xhr.status === 403) { }).fail(function (xhr, status, error) {
// reset the policy if (xhr.status === 404) {
resetPolicy(); // reset the policy
resetPolicy();
// show an appropriate message // show an appropriate message
$('#policy-message').text('Not authorized to access the policy for the specified resource.'); $('#policy-message').text('No component specific administrators.');
// we don't know if the user has permissions to the desired policy... show create button and allow the server to decide
$('#add-local-admin-message').show();
deferred.resolve();
} else if (xhr.status === 403) {
// reset the policy
resetPolicy();
// show an appropriate message
$('#policy-message').text('Not authorized to access the policy for the specified resource.');
deferred.resolve();
} else {
// reset the policy
resetPolicy();
deferred.reject();
nf.Common.handleAjaxError(xhr, status, error);
}
});
}).promise();
} else {
$('#admin-policy-message').hide();
policyDeferred = $.Deferred(function (deferred) {
$.ajax({
type: 'GET',
url: '../nifi-api/policies/' + resourceAndAction.action + resourceAndAction.resource,
dataType: 'json'
}).done(function (policyEntity) {
// return OK so we either have access to the policy or we don't have access to an inherited policy
// update the refresh timestamp
$('#policy-last-refreshed').text(policyEntity.generated);
// ensure appropriate actions for the loaded policy
if (policyEntity.permissions.canRead === true) {
var policy = policyEntity.component;
$('#policy-message').text(policy.resource);
// populate the policy details
populatePolicy(policyEntity);
} else {
// reset the policy
resetPolicy();
// since we cannot read, the policy may be inherited or not... we cannot tell
$('#policy-message').text('Not authorized to view the policy.');
// allow option to override because we don't know if it's supported or not
$('#override-policy-message').show();
}
deferred.resolve(); deferred.resolve();
} else { }).fail(function (xhr, status, error) {
resetPolicy(); if (xhr.status === 404) {
// reset the policy
resetPolicy();
deferred.reject(); // show an appropriate message
nf.Common.handleAjaxError(xhr, status, error); $('#policy-message').text('No policy for the specified resource.');
}
}); // we don't know if the user has permissions to the desired policy... show create button and allow the server to decide
}).promise(); $('#new-policy-message').show();
deferred.resolve();
} else if (xhr.status === 403) {
// reset the policy
resetPolicy();
// show an appropriate message
$('#policy-message').text('Not authorized to access the policy for the specified resource.');
deferred.resolve();
} else {
resetPolicy();
deferred.reject();
nf.Common.handleAjaxError(xhr, status, error);
}
});
}).promise();
}
return policyDeferred;
}; };
/** /**
@ -880,6 +961,7 @@ nf.PolicyManagement = (function () {
$('#policy-message').text(''); $('#policy-message').text('');
$('#new-policy-message').hide(); $('#new-policy-message').hide();
$('#override-policy-message').hide(); $('#override-policy-message').hide();
$('#add-local-admin-message').hide();
}; };
/** /**