mirror of https://github.com/apache/nifi.git
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:
parent
7575e87cb1
commit
7a1f749f69
|
@ -24,6 +24,7 @@
|
|||
<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="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>
|
||||
<div id="global-policy-controls" class="hidden policy-controls">
|
||||
|
@ -88,5 +89,7 @@
|
|||
Last updated: <span id="policy-last-refreshed" class="last-refreshed"></span>
|
||||
</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>
|
|
@ -210,3 +210,15 @@ div.policy-selected-component-type {
|
|||
border: 1px solid #999999;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
admin policy message
|
||||
*/
|
||||
|
||||
#admin-policy-message {
|
||||
float: right;
|
||||
margin-top: 8px;
|
||||
color: #775351;
|
||||
font-family: Roboto;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ nf.PolicyManagement = (function () {
|
|||
|
||||
var initPolicyTable = function () {
|
||||
// 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();
|
||||
});
|
||||
|
||||
|
@ -692,7 +692,85 @@ nf.PolicyManagement = (function () {
|
|||
*/
|
||||
var loadPolicy = function () {
|
||||
var resourceAndAction = getSelectedResourceAndAction();
|
||||
return $.Deferred(function (deferred) {
|
||||
|
||||
var policyDeferred;
|
||||
if (resourceAndAction.resource.startsWith('/policies')) {
|
||||
$('#admin-policy-message').show();
|
||||
|
||||
policyDeferred = $.Deferred(function (deferred) {
|
||||
$.ajax({
|
||||
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);
|
||||
|
||||
// ensure appropriate actions for the loaded policy
|
||||
if (policyEntity.permissions.canRead === true) {
|
||||
var policy = policyEntity.component;
|
||||
|
||||
// if the return policy is for the desired policy (not inherited, show it)
|
||||
if (resourceAndAction.resource === policy.resource) {
|
||||
$('#policy-message').text(policy.resource);
|
||||
|
||||
// populate the policy details
|
||||
populatePolicy(policyEntity);
|
||||
} else {
|
||||
// reset the policy
|
||||
resetPolicy();
|
||||
|
||||
// show an appropriate message
|
||||
$('#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();
|
||||
}
|
||||
} else {
|
||||
// reset the policy
|
||||
resetPolicy();
|
||||
|
||||
// show an appropriate message
|
||||
$('#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();
|
||||
}).fail(function (xhr, status, error) {
|
||||
if (xhr.status === 404) {
|
||||
// reset the policy
|
||||
resetPolicy();
|
||||
|
||||
// show an appropriate message
|
||||
$('#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,
|
||||
|
@ -751,6 +829,9 @@ nf.PolicyManagement = (function () {
|
|||
}
|
||||
});
|
||||
}).promise();
|
||||
}
|
||||
|
||||
return policyDeferred;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -880,6 +961,7 @@ nf.PolicyManagement = (function () {
|
|||
$('#policy-message').text('');
|
||||
$('#new-policy-message').hide();
|
||||
$('#override-policy-message').hide();
|
||||
$('#add-local-admin-message').hide();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue