NIFI-2232:

- Dynamically updating the global menu according to the current users permissions.

This closes #635.
This commit is contained in:
Matt Gilman 2016-07-12 20:26:27 -04:00 committed by Mark Payne
parent 9e2f52c8b5
commit 8ab9fca7f8
1 changed files with 25 additions and 14 deletions

View File

@ -147,7 +147,7 @@ nf.Canvas = (function () {
}; };
/** /**
* Register the pooler. * Register the poller.
* *
* @argument {int} autoRefreshInterval The auto refresh interval * @argument {int} autoRefreshInterval The auto refresh interval
*/ */
@ -665,12 +665,26 @@ nf.Canvas = (function () {
// update the birdseye // update the birdseye
nf.Birdseye.refresh(); nf.Birdseye.refresh();
// inform Angular app values have changed
nf.ng.Bridge.digest();
}).fail(nf.Common.handleAjaxError); }).fail(nf.Common.handleAjaxError);
}; };
/**
* Loads the current user and updates the current user locally.
*
* @returns xhr
*/
var loadCurrentUser = function () {
// get the current user
return $.ajax({
type: 'GET',
url: config.urls.currentUser,
dataType: 'json'
}).done(function (currentUser) {
// set the current user
nf.Common.setCurrentUser(currentUser);
});
};
return { return {
CANVAS_OFFSET: 0, CANVAS_OFFSET: 0,
@ -706,7 +720,12 @@ nf.Canvas = (function () {
// get the process group to refresh everything // get the process group to refresh everything
var processGroupXhr = reloadProcessGroup(nf.Canvas.getGroupId(), options); var processGroupXhr = reloadProcessGroup(nf.Canvas.getGroupId(), options);
var statusXhr = nf.ng.Bridge.injector.get('flowStatusCtrl').reloadFlowStatus(); var statusXhr = nf.ng.Bridge.injector.get('flowStatusCtrl').reloadFlowStatus();
$.when(processGroupXhr, statusXhr).done(function (processGroupResult) { var currentUserXhr = loadCurrentUser();
$.when(processGroupXhr, statusXhr, currentUserXhr).done(function (processGroupResult) {
// inform Angular app values have changed
nf.ng.Bridge.digest();
// resolve the deferred
deferred.resolve(processGroupResult); deferred.resolve(processGroupResult);
}).fail(function () { }).fail(function () {
deferred.reject(); deferred.reject();
@ -742,15 +761,7 @@ nf.Canvas = (function () {
// load the current user // load the current user
var userXhr = $.Deferred(function (deferred) { var userXhr = $.Deferred(function (deferred) {
ticketExchange.always(function () { ticketExchange.always(function () {
// get the current user loadCurrentUser().done(function (currentUser) {
$.ajax({
type: 'GET',
url: config.urls.currentUser,
dataType: 'json'
}).done(function (currentUser) {
// at this point the user may be themselves or anonymous
nf.Common.setCurrentUser(currentUser)
// if the user is logged, we want to determine if they were logged in using a certificate // if the user is logged, we want to determine if they were logged in using a certificate
if (currentUser.anonymous === false) { if (currentUser.anonymous === false) {
// render the users name // render the users name