Repository: nifi
Updated Branches:
  refs/heads/master 516075de0 -> dc934cbb8


http://git-wip-us.apache.org/repos/asf/nifi/blob/dc934cbb/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/templates/nf-templates.js
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/templates/nf-templates.js
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/templates/nf-templates.js
index da5785b..15af39c 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/templates/nf-templates.js
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/templates/nf-templates.js
@@ -15,14 +15,39 @@
  * limitations under the License.
  */
 
-/* global nf, top */
-
-$(document).ready(function () {
-    // initialize the templates page
-    nf.Templates.init();
-});
-
-nf.Templates = (function () {
+/* global nf, top, define, module, require, exports */
+
+(function (root, factory) {
+    if (typeof define === 'function' && define.amd) {
+        define(['jquery',
+                'nf.Common',
+                'nf.TemplatesTable',
+                'nf.ErrorHandler',
+                'nf.Storage'],
+            function ($, common, templatesTable, errorHandler, storage) {
+                return (nf.Templates = factory($, common, templatesTable, 
errorHandler, storage));
+            });
+    } else if (typeof exports === 'object' && typeof module === 'object') {
+        module.exports = (nf.Templates =
+            factory(require('jquery'),
+                require('nf.Common'),
+                require('nf.TemplatesTable'),
+                require('nf.ErrorHandler'),
+                require('nf.Storage')));
+    } else {
+        nf.Templates = factory(root.$,
+            root.nf.Common,
+            root.nf.TemplatesTable,
+            root.nf.ErrorHandler,
+            root.nf.Storage);
+    }
+}(this, function ($, common, templatesTable, errorHandler, storage) {
+    'use strict';
+
+    $(document).ready(function () {
+        // initialize the templates page
+        nfTemplates.init();
+    });
 
     /**
      * Configuration object used to hold a number of configuration items.
@@ -44,8 +69,8 @@ nf.Templates = (function () {
             url: config.urls.currentUser,
             dataType: 'json'
         }).done(function (currentUser) {
-            nf.Common.setCurrentUser(currentUser);
-        }).fail(nf.Common.handleAjaxError);
+            common.setCurrentUser(currentUser);
+        }).fail(errorHandler.handleAjaxError);
     };
 
     /**
@@ -54,7 +79,7 @@ nf.Templates = (function () {
     var initializeTemplatesPage = function () {
         // define mouse over event for the refresh button
         $('#refresh-button').click(function () {
-            nf.TemplatesTable.loadTemplatesTable();
+            templatesTable.loadTemplatesTable();
         });
 
         // get the banners if we're not in the shell
@@ -66,8 +91,8 @@ nf.Templates = (function () {
                     dataType: 'json'
                 }).done(function (response) {
                     // ensure the banners response is specified
-                    if (nf.Common.isDefinedAndNotNull(response.banners)) {
-                        if 
(nf.Common.isDefinedAndNotNull(response.banners.headerText) && 
response.banners.headerText !== '') {
+                    if (common.isDefinedAndNotNull(response.banners)) {
+                        if 
(common.isDefinedAndNotNull(response.banners.headerText) && 
response.banners.headerText !== '') {
                             // update the header text
                             var bannerHeader = 
$('#banner-header').text(response.banners.headerText).show();
 
@@ -81,7 +106,7 @@ nf.Templates = (function () {
                             updateTop('templates');
                         }
 
-                        if 
(nf.Common.isDefinedAndNotNull(response.banners.footerText) && 
response.banners.footerText !== '') {
+                        if 
(common.isDefinedAndNotNull(response.banners.footerText) && 
response.banners.footerText !== '') {
                             // update the footer text and show it
                             var bannerFooter = 
$('#banner-footer').text(response.banners.footerText).show();
 
@@ -97,7 +122,7 @@ nf.Templates = (function () {
 
                     deferred.resolve();
                 }).fail(function (xhr, status, error) {
-                    nf.Common.handleAjaxError(xhr, status, error);
+                    errorHandler.handleAjaxError(xhr, status, error);
                     deferred.reject();
                 });
             } else {
@@ -106,21 +131,21 @@ nf.Templates = (function () {
         }).promise();
     };
 
-    return {
+    var nfTemplates = {
         /**
          * Initializes the templates page.
          */
         init: function () {
-            nf.Storage.init();
+            storage.init();
 
             // load the current user
             loadCurrentUser().done(function () {
 
                 // create the templates table
-                nf.TemplatesTable.init();
+                templatesTable.init();
 
                 // load the table
-                nf.TemplatesTable.loadTemplatesTable().done(function () {
+                templatesTable.loadTemplatesTable().done(function () {
                     // once the table is initialized, finish initializing the 
page
                     initializeTemplatesPage().done(function () {
                         var setBodySize = function () {
@@ -137,7 +162,7 @@ nf.Templates = (function () {
                             }
 
                             // configure the initial grid height
-                            nf.TemplatesTable.resetTableSize();
+                            templatesTable.resetTableSize();
                         };
 
                         // get the about details
@@ -155,15 +180,15 @@ nf.Templates = (function () {
 
                             // set the initial size
                             setBodySize();
-                        }).fail(nf.Common.handleAjaxError);
+                        }).fail(errorHandler.handleAjaxError);
 
                         $(window).on('resize', function (e) {
                             setBodySize();
                             // resize dialogs when appropriate
                             var dialogs = $('.dialog');
                             for (var i = 0, len = dialogs.length; i < len; 
i++) {
-                                if ($(dialogs[i]).is(':visible')){
-                                    setTimeout(function(dialog){
+                                if ($(dialogs[i]).is(':visible')) {
+                                    setTimeout(function (dialog) {
                                         dialog.modal('resize');
                                     }, 50, $(dialogs[i]));
                                 }
@@ -172,8 +197,8 @@ nf.Templates = (function () {
                             // resize grids when appropriate
                             var gridElements = $('*[class*="slickgrid_"]');
                             for (var j = 0, len = gridElements.length; j < 
len; j++) {
-                                if ($(gridElements[j]).is(':visible')){
-                                    setTimeout(function(gridElement){
+                                if ($(gridElements[j]).is(':visible')) {
+                                    setTimeout(function (gridElement) {
                                         
gridElement.data('gridInstance').resizeCanvas();
                                     }, 50, $(gridElements[j]));
                                 }
@@ -183,12 +208,12 @@ nf.Templates = (function () {
                             var tabsContainers = $('.tab-container');
                             var tabsContents = [];
                             for (var k = 0, len = tabsContainers.length; k < 
len; k++) {
-                                if ($(tabsContainers[k]).is(':visible')){
+                                if ($(tabsContainers[k]).is(':visible')) {
                                     tabsContents.push($('#' + 
$(tabsContainers[k]).attr('id') + '-content'));
                                 }
                             }
                             $.each(tabsContents, function (index, tabsContent) 
{
-                                nf.Common.toggleScrollable(tabsContent.get(0));
+                                common.toggleScrollable(tabsContent.get(0));
                             });
                         });
                     });
@@ -196,4 +221,6 @@ nf.Templates = (function () {
             });
         }
     };
-}());
\ No newline at end of file
+
+    return nfTemplates;
+}));
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/nifi/blob/dc934cbb/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users-table.js
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users-table.js
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users-table.js
index 4a1f78d..13cff49 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users-table.js
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users-table.js
@@ -15,9 +15,34 @@
  * limitations under the License.
  */
 
-/* global nf, Slick */
-
-nf.UsersTable = (function () {
+/* global nf, define, module, require, exports */
+
+(function (root, factory) {
+    if (typeof define === 'function' && define.amd) {
+        define(['jquery',
+                'Slick',
+                'nf.Common',
+                'nf.Client',
+                'nf.ErrorHandler'],
+            function ($, Slick, common, client, errorHandler) {
+                return (nf.UsersTable = factory($, Slick, common, client, 
errorHandler));
+            });
+    } else if (typeof exports === 'object' && typeof module === 'object') {
+        module.exports = (nf.UsersTable =
+            factory(require('jquery'),
+                require('Slick'),
+                require('nf.Common'),
+                require('nf.Client'),
+                require('nf.ErrorHandler')));
+    } else {
+        nf.UsersTable = factory(root.$,
+            root.Slick,
+            root.nf.Common,
+            root.nf.Client,
+            root.nf.ErrorHandler);
+    }
+}(this, function ($, Slick, common, client, errorHandler) {
+    'use strict';
 
     /**
      * Configuration object used to hold a number of configuration items.
@@ -51,11 +76,11 @@ nf.UsersTable = (function () {
                         // update the user
                         $.ajax({
                             type: 'DELETE',
-                            url: user.uri + '?' + 
$.param(nf.Client.getRevision(user)),
+                            url: user.uri + '?' + 
$.param(client.getRevision(user)),
                             dataType: 'json'
                         }).done(function () {
-                            nf.UsersTable.loadUsersTable();
-                        }).fail(nf.Common.handleAjaxError);
+                            self.loadUsersTable();
+                        }).fail(errorHandler.handleAjaxError);
 
                         // hide the dialog
                         $('#user-delete-dialog').modal('hide');
@@ -144,7 +169,7 @@ nf.UsersTable = (function () {
 
         // build the request entity
         var updatedGroupEntity = {
-            'revision': nf.Client.getRevision(groupEntity),
+            'revision': client.getRevision(groupEntity),
             'component': $.extend({}, groupEntity.component, {
                 'users': groupMembers
             })
@@ -182,7 +207,7 @@ nf.UsersTable = (function () {
 
         // build the request entity
         var updatedGroupEntity = {
-            'revision': nf.Client.getRevision(groupEntity),
+            'revision': client.getRevision(groupEntity),
             'component': $.extend({}, groupEntity.component, {
                 'users': groupMembers
             })
@@ -208,7 +233,7 @@ nf.UsersTable = (function () {
         // get the grid and data
         var usersGrid = $('#users-table').data('gridInstance');
         var usersData = usersGrid.getData();
-        
+
         // create the user
         var userXhr = $.ajax({
             type: 'POST',
@@ -225,16 +250,16 @@ nf.UsersTable = (function () {
                 var groupEntity = usersData.getItemById(selectedGroup.id)
                 xhrs.push(addUserToGroup(groupEntity, userEntity));
             });
-            
+
             $.when.apply(window, xhrs).always(function () {
-                nf.UsersTable.loadUsersTable().done(function () {
+                self.loadUsersTable().done(function () {
                     // select the new user
                     var row = usersData.getRowById(userEntity.id);
                     usersGrid.setSelectedRows([row]);
                     usersGrid.scrollRowIntoView(row);
                 });
-            }).fail(nf.Common.handleAjaxError);
-        }).fail(nf.Common.handleAjaxError);
+            }).fail(errorHandler.handleAjaxError);
+        }).fail(errorHandler.handleAjaxError);
     };
 
     /**
@@ -251,7 +276,7 @@ nf.UsersTable = (function () {
         var userEntity = usersData.getItemById(userId);
 
         var updatedUserEntity = {
-            'revision': nf.Client.getRevision(userEntity),
+            'revision': client.getRevision(userEntity),
             'component': {
                 'id': userId,
                 'identity': userIdentity
@@ -268,11 +293,11 @@ nf.UsersTable = (function () {
         });
 
         userXhr.done(function (updatedUserEntity) {
-        
+
             // determine what to add/remove
             var groupsAdded = [];
             var groupsRemoved = [];
-            $.each(updatedUserEntity.component.userGroups, function(_, 
currentGroup) {
+            $.each(updatedUserEntity.component.userGroups, function (_, 
currentGroup) {
                 var isSelected = $.grep(selectedGroups, function (group) {
                     return group.id === currentGroup.id;
                 });
@@ -282,7 +307,7 @@ nf.UsersTable = (function () {
                     groupsRemoved.push(currentGroup);
                 }
             });
-            $.each(selectedGroups, function(_, selectedGroup) {
+            $.each(selectedGroups, function (_, selectedGroup) {
                 var isSelected = 
$.grep(updatedUserEntity.component.userGroups, function (group) {
                     return group.id === selectedGroup.id;
                 });
@@ -305,9 +330,9 @@ nf.UsersTable = (function () {
             });
 
             $.when.apply(window, xhrs).always(function () {
-                nf.UsersTable.loadUsersTable();
-            }).fail(nf.Common.handleAjaxError);
-        }).fail(nf.Common.handleAjaxError);
+                self.loadUsersTable();
+            }).fail(errorHandler.handleAjaxError);
+        }).fail(errorHandler.handleAjaxError);
     };
 
     /**
@@ -324,7 +349,7 @@ nf.UsersTable = (function () {
             dataType: 'json',
             contentType: 'application/json'
         }).done(function (groupEntity) {
-            nf.UsersTable.loadUsersTable().done(function () {
+            self.loadUsersTable().done(function () {
                 // add the user
                 var usersGrid = $('#users-table').data('gridInstance');
                 var usersData = usersGrid.getData();
@@ -334,7 +359,7 @@ nf.UsersTable = (function () {
                 usersGrid.setSelectedRows([row]);
                 usersGrid.scrollRowIntoView(row);
             });
-        }).fail(nf.Common.handleAjaxError);
+        }).fail(errorHandler.handleAjaxError);
     };
 
     var updateGroup = function (groupId, groupIdentity, selectedUsers) {
@@ -344,7 +369,7 @@ nf.UsersTable = (function () {
         var groupEntity = usersData.getItemById(groupId);
 
         var updatedGroupoEntity = {
-            'revision': nf.Client.getRevision(groupEntity),
+            'revision': client.getRevision(groupEntity),
             'component': {
                 'id': groupId,
                 'identity': groupIdentity,
@@ -360,8 +385,8 @@ nf.UsersTable = (function () {
             dataType: 'json',
             contentType: 'application/json'
         }).done(function (groupEntity) {
-            nf.UsersTable.loadUsersTable();
-        }).fail(nf.Common.handleAjaxError);
+            self.loadUsersTable();
+        }).fail(errorHandler.handleAjaxError);
     };
 
     /**
@@ -385,7 +410,7 @@ nf.UsersTable = (function () {
                         // see if we should create or update this user
                         if ($.trim(userId) === '') {
                             var tenantEntity = {
-                                'revision': nf.Client.getRevision({
+                                'revision': client.getRevision({
                                     'revision': {
                                         'version': 0
                                     }
@@ -499,7 +524,7 @@ nf.UsersTable = (function () {
      */
     var globalResourceParser = function (dataContext) {
         return 'Global policy to ' +
-            
nf.Common.getPolicyTypeListing(nf.Common.substringAfterFirst(dataContext.component.resource,
 '/')).text;
+            
common.getPolicyTypeListing(common.substringAfterFirst(dataContext.component.resource,
 '/')).text;
     };
 
     /**
@@ -514,13 +539,13 @@ nf.UsersTable = (function () {
 
         //determine policy type
         if (resource.startsWith('/policies')) {
-            resource = nf.Common.substringAfterFirst(resource, '/policies');
+            resource = common.substringAfterFirst(resource, '/policies');
             policyLabel += 'Admin policy for ';
         } else if (resource.startsWith('/data-transfer')) {
-            resource = nf.Common.substringAfterFirst(resource, 
'/data-transfer');
+            resource = common.substringAfterFirst(resource, '/data-transfer');
             policyLabel += 'Site to site policy for ';
         } else if (resource.startsWith('/data')) {
-            resource = nf.Common.substringAfterFirst(resource, '/data');
+            resource = common.substringAfterFirst(resource, '/data');
             policyLabel += 'Data policy for ';
         } else {
             policyLabel += 'Component policy for ';
@@ -567,7 +592,7 @@ nf.UsersTable = (function () {
             // if the user has permission to the policy
             if (dataContext.permissions.canRead === true) {
                 // check if Global policy
-                if 
(nf.Common.isUndefinedOrNull(dataContext.component.componentReference)) {
+                if 
(common.isUndefinedOrNull(dataContext.component.componentReference)) {
                     return globalResourceParser(dataContext);
                 }
                 // not a global policy... check if user has access to the 
component reference
@@ -582,7 +607,7 @@ nf.UsersTable = (function () {
             var markup = '';
 
             if (dataContext.permissions.canRead === true) {
-                if 
(nf.Common.isDefinedAndNotNull(dataContext.component.componentReference)) {
+                if 
(common.isDefinedAndNotNull(dataContext.component.componentReference)) {
                     if (dataContext.component.resource.indexOf('/processors') 
>= 0) {
                         markup += '<div title="Go To" class="pointer 
go-to-component fa fa-long-arrow-right" style="float: left;"></div>';
                     } else if 
(dataContext.component.resource.indexOf('/controller-services') >= 0) {
@@ -622,13 +647,34 @@ nf.UsersTable = (function () {
         };
 
         var userPoliciesColumns = [
-            {id: 'policy', name: 'Policy', sortable: true, resizable: true, 
formatter: policyDisplayNameFormatter, width: 150},
-            {id: 'action', name: 'Action', sortable: true, resizable: false, 
formatter: actionFormatter, width: 50}
+            {
+                id: 'policy',
+                name: 'Policy',
+                sortable: true,
+                resizable: true,
+                formatter: policyDisplayNameFormatter,
+                width: 150
+            },
+            {
+                id: 'action',
+                name: 'Action',
+                sortable: true,
+                resizable: false,
+                formatter: actionFormatter,
+                width: 50
+            }
         ];
 
         // add the actions if we're in the shell
         if (top !== window) {
-            userPoliciesColumns.push({id: 'actions', name: '&nbsp;', sortable: 
false, resizable: false, formatter: actionsFormatter, width: 25});
+            userPoliciesColumns.push({
+                id: 'actions',
+                name: '&nbsp;',
+                sortable: false,
+                resizable: false,
+                formatter: actionsFormatter,
+                width: 25
+            });
         }
 
         var userPoliciesOptions = {
@@ -737,12 +783,12 @@ nf.UsersTable = (function () {
         var membersGroupsFormatter = function (row, cell, value, columnDef, 
dataContext) {
             if (dataContext.type === 'group') {
                 return 'Members: <b>' + 
dataContext.component.users.map(function (user) {
-                    return user.component.identity;
-                }).join('</b>, <b>') + '</b>';
+                        return user.component.identity;
+                    }).join('</b>, <b>') + '</b>';
             } else {
                 return 'Member of: <b>' + 
dataContext.component.userGroups.map(function (group) {
-                    return group.component.identity;
-                }).join('</b>, <b>') + '</b>';
+                        return group.component.identity;
+                    }).join('</b>, <b>') + '</b>';
             }
         };
 
@@ -751,12 +797,12 @@ nf.UsersTable = (function () {
             var markup = '';
 
             // ensure user can modify the user
-            if (nf.Common.canModifyTenants()) {
+            if (common.canModifyTenants()) {
                 markup += '<div title="Edit" class="pointer edit-user fa 
fa-pencil" style="margin-right: 3px;"></div>';
                 markup += '<div title="Remove" class="pointer delete-user fa 
fa-trash"></div>';
             }
 
-            if (!nf.Common.isEmpty(dataContext.component.accessPolicies)) {
+            if (!common.isEmpty(dataContext.component.accessPolicies)) {
                 markup += '<div title="View User Policies" class="pointer 
view-user-policies fa fa-key" style="margin-left: 3px;"></div>';
             }
 
@@ -765,10 +811,32 @@ nf.UsersTable = (function () {
 
         // initialize the templates table
         var usersColumns = [
-            {id: 'identity', name: 'User', sortable: true, resizable: true, 
formatter: identityFormatter},
-            {id: 'membersGroups', name: '&nbsp;', sortable: true, 
defaultSortAsc: false, resizable: true, formatter: membersGroupsFormatter},
-            {id: 'actions', name: '&nbsp;', sortable: false, resizable: false, 
formatter: actionFormatter, width: 100, maxWidth: 100}
+            {
+                id: 'identity',
+                name: 'User',
+                sortable: true,
+                resizable: true,
+                formatter: identityFormatter
+            },
+            {
+                id: 'membersGroups',
+                name: '&nbsp;',
+                sortable: true,
+                defaultSortAsc: false,
+                resizable: true,
+                formatter: membersGroupsFormatter
+            },
+            {
+                id: 'actions',
+                name: '&nbsp;',
+                sortable: false,
+                resizable: false,
+                formatter: actionFormatter,
+                width: 100,
+                maxWidth: 100
+            }
         ];
+
         var usersOptions = {
             forceFitColumns: true,
             enableTextSelectionOnCells: true,
@@ -854,15 +922,15 @@ nf.UsersTable = (function () {
     var userSort = function (sortDetails, data) {
         // defines a function for sorting
         var comparer = function (a, b) {
-            if(a.permissions.canRead && b.permissions.canRead) {
-                var aString = 
nf.Common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? 
a.component[sortDetails.columnId] : '';
-                var bString = 
nf.Common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? 
b.component[sortDetails.columnId] : '';
+            if (a.permissions.canRead && b.permissions.canRead) {
+                var aString = 
common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? 
a.component[sortDetails.columnId] : '';
+                var bString = 
common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? 
b.component[sortDetails.columnId] : '';
                 return aString === bString ? 0 : aString > bString ? 1 : -1;
             } else {
-                if (!a.permissions.canRead && !b.permissions.canRead){
+                if (!a.permissions.canRead && !b.permissions.canRead) {
                     return 0;
                 }
-                if(a.permissions.canRead){
+                if (a.permissions.canRead) {
                     return 1;
                 } else {
                     return -1;
@@ -883,10 +951,10 @@ nf.UsersTable = (function () {
     var userPolicySort = function (sortDetails, data) {
         // defines a function for sorting
         var comparer = function (a, b) {
-            if(a.permissions.canRead && b.permissions.canRead) {
+            if (a.permissions.canRead && b.permissions.canRead) {
                 if (sortDetails.columnId === 'action') {
-                    var aString = 
nf.Common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? 
a.component[sortDetails.columnId] : '';
-                    var bString = 
nf.Common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? 
b.component[sortDetails.columnId] : '';
+                    var aString = 
common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? 
a.component[sortDetails.columnId] : '';
+                    var bString = 
common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? 
b.component[sortDetails.columnId] : '';
                     return aString === bString ? 0 : aString > bString ? 1 : 
-1;
                 } else if (sortDetails.columnId === 'policy') {
                     var aString = '';
@@ -895,7 +963,7 @@ nf.UsersTable = (function () {
                     // if the user has permission to the policy
                     if (a.permissions.canRead === true) {
                         // check if Global policy
-                        if 
(nf.Common.isUndefinedOrNull(a.component.componentReference)) {
+                        if 
(common.isUndefinedOrNull(a.component.componentReference)) {
                             aString = globalResourceParser(a);
                         } else {
                             // not a global policy... check if user has access 
to the component reference
@@ -908,9 +976,9 @@ nf.UsersTable = (function () {
                     // if the user has permission to the policy
                     if (b.permissions.canRead === true) {
                         // check if Global policy
-                        if 
(nf.Common.isUndefinedOrNull(b.component.componentReference)) {
+                        if 
(common.isUndefinedOrNull(b.component.componentReference)) {
                             bString = globalResourceParser(b);
-                        }else {
+                        } else {
                             // not a global policy... check if user has access 
to the component reference
                             bString = componentResourceParser(b);
                         }
@@ -921,10 +989,10 @@ nf.UsersTable = (function () {
                     return aString === bString ? 0 : aString > bString ? 1 : 
-1;
                 }
             } else {
-                if (!a.permissions.canRead && !b.permissions.canRead){
+                if (!a.permissions.canRead && !b.permissions.canRead) {
                     return 0;
                 }
-                if(a.permissions.canRead){
+                if (a.permissions.canRead) {
                     return 1;
                 } else {
                     return -1;
@@ -953,7 +1021,7 @@ nf.UsersTable = (function () {
         var usersGrid = $('#users-table').data('gridInstance');
 
         // ensure the grid has been initialized
-        if (nf.Common.isDefinedAndNotNull(usersGrid)) {
+        if (common.isDefinedAndNotNull(usersGrid)) {
             var usersData = usersGrid.getData();
 
             // update the search criteria
@@ -998,7 +1066,7 @@ nf.UsersTable = (function () {
 
         // add a row for each user
         var count = 0;
-        $.each(usersData.getItems(), function(_, user) {
+        $.each(usersData.getItems(), function (_, user) {
             if (user.type === 'user') {
                 // checkbox
                 var checkbox = $('<div class="user-check nf-checkbox 
checkbox-unchecked"></div>').addClass('group-user-' + user.id);
@@ -1031,14 +1099,14 @@ nf.UsersTable = (function () {
 
         // add a row for each user
         var count = 0;
-        $.each(usersData.getItems(), function(_, group) {
+        $.each(usersData.getItems(), function (_, group) {
             if (group.type === 'group') {
                 // checkbox
                 var checkbox = $('<div class="group-check nf-checkbox 
checkbox-unchecked"></div>').addClass('user-group-' + group.id);
 
                 // group id
                 var groupId = $('<span class="group-id 
hidden"></span>').text(group.id);
-                
+
                 // icon
                 var groupIcon = $('<div class="fa fa-users" style="margin-top: 
6px;"></div>');
 
@@ -1127,7 +1195,7 @@ nf.UsersTable = (function () {
         userPoliciesData.beginUpdate();
 
         // set the rows
-        if (nf.Common.isDefinedAndNotNull(user.component.accessPolicies)) {
+        if (common.isDefinedAndNotNull(user.component.accessPolicies)) {
             userPoliciesData.setItems(user.component.accessPolicies);
         }
 
@@ -1146,7 +1214,7 @@ nf.UsersTable = (function () {
         userPoliciesGrid.resizeCanvas();
     };
 
-    return {
+    var nfUsersTable = {
         init: function () {
             initUserDialog();
             initUserPoliciesDialog();
@@ -1154,7 +1222,7 @@ nf.UsersTable = (function () {
             initUserDeleteDialog();
             initUsersTable();
 
-            if (nf.Common.canModifyTenants()) {
+            if (common.canModifyTenants()) {
                 $('#new-user-button').on('click', function () {
                     buildUsersList();
                     buildGroupsList();
@@ -1179,7 +1247,7 @@ nf.UsersTable = (function () {
             var usersTable = $('#users-table');
             if (usersTable.is(':visible')) {
                 var grid = usersTable.data('gridInstance');
-                if (nf.Common.isDefinedAndNotNull(grid)) {
+                if (common.isDefinedAndNotNull(grid)) {
                     grid.resizeCanvas();
                 }
             }
@@ -1242,7 +1310,9 @@ nf.UsersTable = (function () {
                 usersGrid.getSelectionModel().setSelectedRows([]);
 
                 $('#total-users').text(usersData.getLength());
-            }).fail(nf.Common.handleAjaxError);
+            }).fail(errorHandler.handleAjaxError);
         }
     };
-}());
\ No newline at end of file
+
+    return nfUsersTable;
+}));
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/nifi/blob/dc934cbb/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users.js
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users.js
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users.js
index 34476a2..8cad6cf 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users.js
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users.js
@@ -14,18 +14,50 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-$(document).ready(function () {
-    // initialize the counters page
-    nf.Users.init();
-
-    //alter styles if we're not in the shell
-    if (top === window) {
-        $('#users').css('top', 20);
-        $('#users-refresh-container').css('bottom', 20);
+
+/* global nf, top, define, module, require, exports */
+
+(function (root, factory) {
+    if (typeof define === 'function' && define.amd) {
+        define(['jquery',
+                'nf.Common',
+                'nf.UsersTable',
+                'nf.ErrorHandler',
+                'nf.Storage',
+                'nf.Client'],
+            function ($, common, usersTable, errorHandler, storage, client) {
+                return (nf.Users = factory($, common, usersTable, 
errorHandler, storage, client));
+            });
+    } else if (typeof exports === 'object' && typeof module === 'object') {
+        module.exports = (nf.Users =
+            factory(require('jquery'),
+                require('nf.Common'),
+                require('nf.UsersTable'),
+                require('nf.ErrorHandler'),
+                require('nf.Storage'),
+                require('nf.Client')));
+    } else {
+        nf.Users =
+            factory(root.$,
+                root.nf.Common,
+                root.nf.UsersTable,
+                root.nf.ErrorHandler,
+                root.nf.Storage,
+                root.nf.Client);
     }
-});
+}(this, function ($, common, usersTable, errorHandler, storage, client) {
+    'use strict';
+
+    $(document).ready(function () {
+        // initialize the counters page
+        nfUsers.init();
 
-nf.Users = (function () {
+        //alter styles if we're not in the shell
+        if (top === window) {
+            $('#users').css('top', 20);
+            $('#users-refresh-container').css('bottom', 20);
+        }
+    });
 
     /**
      * Configuration object used to hold a number of configuration items.
@@ -47,14 +79,14 @@ nf.Users = (function () {
             url: config.urls.currentUser,
             dataType: 'json'
         }).done(function (currentUser) {
-            nf.Common.setCurrentUser(currentUser);
-        }).fail(nf.Common.handleAjaxError);
+            common.setCurrentUser(currentUser);
+        }).fail(errorHandler.handleAjaxError);
     };
 
     var initializeUsersPage = function () {
         // define mouse over event for the refresh button
-        nf.Common.addHoverEffect('#user-refresh-button', 'button-refresh', 
'button-refresh-hover').click(function () {
-            nf.UsersTable.loadUsersTable();
+        common.addHoverEffect('#user-refresh-button', 'button-refresh', 
'button-refresh-hover').click(function () {
+            usersTable.loadUsersTable();
         });
 
         // get the banners if we're not in the shell
@@ -66,8 +98,8 @@ nf.Users = (function () {
                     dataType: 'json'
                 }).done(function (bannerResponse) {
                     // ensure the banners response is specified
-                    if (nf.Common.isDefinedAndNotNull(bannerResponse.banners)) 
{
-                        if 
(nf.Common.isDefinedAndNotNull(bannerResponse.banners.headerText) && 
bannerResponse.banners.headerText !== '') {
+                    if (common.isDefinedAndNotNull(bannerResponse.banners)) {
+                        if 
(common.isDefinedAndNotNull(bannerResponse.banners.headerText) && 
bannerResponse.banners.headerText !== '') {
                             // update the header text
                             var bannerHeader = 
$('#banner-header').text(bannerResponse.banners.headerText).show();
 
@@ -81,7 +113,7 @@ nf.Users = (function () {
                             updateTop('users');
                         }
 
-                        if 
(nf.Common.isDefinedAndNotNull(bannerResponse.banners.footerText) && 
bannerResponse.banners.footerText !== '') {
+                        if 
(common.isDefinedAndNotNull(bannerResponse.banners.footerText) && 
bannerResponse.banners.footerText !== '') {
                             // update the footer text and show it
                             var bannerFooter = 
$('#banner-footer').text(bannerResponse.banners.footerText).show();
 
@@ -97,7 +129,7 @@ nf.Users = (function () {
 
                     deferred.resolve();
                 }).fail(function (xhr, status, error) {
-                    nf.Common.handleAjaxError(xhr, status, error);
+                    errorHandler.handleAjaxError(xhr, status, error);
                     deferred.reject();
                 });
             } else {
@@ -106,30 +138,30 @@ nf.Users = (function () {
         });
     };
 
-    return {
+    var nfUsers = {
         /**
          * Initializes the counters page.
          */
         init: function () {
-            nf.Storage.init();
+            storage.init();
 
             // initialize the client
-            nf.Client.init();
+            client.init();
 
             // load the users authorities
             ensureAccess().done(function () {
                 // create the counters table
-                nf.UsersTable.init();
+                usersTable.init();
 
                 // load the users table
-                nf.UsersTable.loadUsersTable().done(function () {
+                usersTable.loadUsersTable().done(function () {
                     // finish initializing users page
                     initializeUsersPage().done(function () {
                         // listen for browser resize events to update the page 
size
-                        $(window).resize(nf.UsersTable.resetTableSize);
-                        
+                        $(window).resize(usersTable.resetTableSize);
+
                         // configure the initial grid height
-                        nf.UsersTable.resetTableSize();
+                        usersTable.resetTableSize();
 
                         // get the about details
                         $.ajax({
@@ -143,15 +175,15 @@ nf.Users = (function () {
                             // set the document title and the about title
                             document.title = countersTitle;
                             $('#users-header-text').text(countersTitle);
-                        }).fail(nf.Common.handleAjaxError);
+                        }).fail(errorHandler.handleAjaxError);
                     });
 
                     $(window).on('resize', function (e) {
                         // resize dialogs when appropriate
                         var dialogs = $('.dialog');
                         for (var i = 0, len = dialogs.length; i < len; i++) {
-                            if ($(dialogs[i]).is(':visible')){
-                                setTimeout(function(dialog){
+                            if ($(dialogs[i]).is(':visible')) {
+                                setTimeout(function (dialog) {
                                     dialog.modal('resize');
                                 }, 50, $(dialogs[i]));
                             }
@@ -160,8 +192,8 @@ nf.Users = (function () {
                         // resize grids when appropriate
                         var gridElements = $('*[class*="slickgrid_"]');
                         for (var j = 0, len = gridElements.length; j < len; 
j++) {
-                            if ($(gridElements[j]).is(':visible')){
-                                setTimeout(function(gridElement){
+                            if ($(gridElements[j]).is(':visible')) {
+                                setTimeout(function (gridElement) {
                                     
gridElement.data('gridInstance').resizeCanvas();
                                 }, 50, $(gridElements[j]));
                             }
@@ -171,4 +203,6 @@ nf.Users = (function () {
             });
         }
     };
-}());
\ No newline at end of file
+
+    return nfUsers;
+}));
\ No newline at end of file

Reply via email to