Repository: nifi Updated Branches: refs/heads/master 7575e87cb -> 7a1f749f6
NIFI-2475: - Updating UI to better suggest that component specific administrators do not override higher level administrators. This closes #813 Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/7a1f749f Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/7a1f749f Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/7a1f749f Branch: refs/heads/master Commit: 7a1f749f6900399685f5d5e5a4c737e66c569c6b Parents: 7575e87 Author: Matt Gilman <matt.c.gil...@gmail.com> Authored: Mon Aug 8 16:52:53 2016 -0400 Committer: Matt Burgess <mattyb...@apache.org> Committed: Tue Aug 9 15:40:28 2016 -0400 ---------------------------------------------------------------------- .../partials/canvas/policy-management.jsp | 3 + .../src/main/webapp/css/policy-management.css | 12 ++ .../webapp/js/nf/canvas/nf-policy-management.js | 174 ++++++++++++++----- 3 files changed, 143 insertions(+), 46 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/7a1f749f/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/policy-management.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/policy-management.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/policy-management.jsp index b0e10e9..b833c7c 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/policy-management.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/policy-management.jsp @@ -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> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi/blob/7a1f749f/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/policy-management.css ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/policy-management.css b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/policy-management.css index 0124106..2fa956b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/policy-management.css +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/policy-management.css @@ -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; +} http://git-wip-us.apache.org/repos/asf/nifi/blob/7a1f749f/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 adbc42d..bcd40d8 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 @@ -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,65 +692,146 @@ nf.PolicyManagement = (function () { */ var loadPolicy = function () { 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 - $('#policy-last-refreshed').text(policyEntity.generated); + var policyDeferred; + if (resourceAndAction.resource.startsWith('/policies')) { + $('#admin-policy-message').show(); - // ensure appropriate actions for the loaded policy - if (policyEntity.permissions.canRead === true) { - var policy = policyEntity.component; + 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(); - $('#policy-message').text(policy.resource); + // show an appropriate message + $('#policy-message').text('No component specific administrators.'); - // populate the policy details - populatePolicy(policyEntity); - } else { - // reset the policy - resetPolicy(); + // 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(); - // since we cannot read, the policy may be inherited or not... we cannot tell - $('#policy-message').text('Not authorized to view the policy.'); + // show an appropriate message + $('#policy-message').text('No component specific administrators.'); - // allow option to override because we don't know if it's supported or not - $('#override-policy-message').show(); - } + // 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(); + deferred.resolve(); + }).fail(function (xhr, status, error) { + if (xhr.status === 404) { + // reset the policy + resetPolicy(); - // show an appropriate message - $('#policy-message').text('No policy for the specified resource.'); + // 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 - $('#new-policy-message').show(); + // 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(); + 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); - // show an appropriate message - $('#policy-message').text('Not authorized to access the policy for the specified resource.'); + // 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(); - } else { - resetPolicy(); + }).fail(function (xhr, status, error) { + if (xhr.status === 404) { + // reset the policy + resetPolicy(); - deferred.reject(); - nf.Common.handleAjaxError(xhr, status, error); - } - }); - }).promise(); + // show an appropriate message + $('#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 + $('#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(''); $('#new-policy-message').hide(); $('#override-policy-message').hide(); + $('#add-local-admin-message').hide(); }; /**