Initial commit
This commit is contained in:
commit
880e39de2e
511 files changed
+38363
No files matched your search
@@ -0,0 +1,126 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* MODULE DESCRIPTION:
|
||||
*
|
||||
* TODO: Write description here.
|
||||
*/
|
||||
angular.module('portal.dashboard.userBank', ['ui.router'])
|
||||
.controller('UserBankCtrl', UserBankCtrlController);
|
||||
|
||||
function UserBankCtrlController($scope, cache, accountStores, accountProvider, $mdDialog, uiGridConstants, portalUtils, Constants) {
|
||||
|
||||
$scope.confirmQuestionBox = true;
|
||||
$scope.Constants = Constants;
|
||||
$scope.users = [];
|
||||
|
||||
$scope.mCache = cache.request([new accountStores.Account(), new accountStores.UserPool()]).then(function(){
|
||||
$scope.userRole = $scope.mCache.account.data.role;
|
||||
$scope.users = $scope.mCache.userPool.data.values;
|
||||
});
|
||||
|
||||
$scope.userGrid = {
|
||||
data: 'users',
|
||||
paginationPageSizes: [28, 56, 84, 102],
|
||||
paginationPageSize: 28,
|
||||
enableHorizontalScrollbar: uiGridConstants.scrollbars.NEVER,
|
||||
toggleModifierKeysToMultiSelect : true,
|
||||
enableRowHeaderSelection: true,
|
||||
enableColumnMenus: true,
|
||||
enableGridMenu: true,
|
||||
exporterCsvFilename: 'Files.csv',
|
||||
exporterMenuCsv: true,
|
||||
multiSelect: true,
|
||||
noUnselect: false,
|
||||
onRegisterApi: function (gridApi) {
|
||||
gridApi.selection.setModifierKeysToMultiSelect(true);
|
||||
$scope.userGridApi = gridApi;
|
||||
},
|
||||
columnDefs: [
|
||||
{field: 'username', displayName: 'User Name', width: '*'},
|
||||
{field: 'firstName', displayName: 'First Name', width: '*', },
|
||||
{field: 'lastName', displayName: 'Last Name', width: '**'},
|
||||
{field: 'role', displayName: 'Role', width: '**' },
|
||||
{field: 'id', displayName: 'Actions', width: '100', enableColumnMenu: false, enableFiltering: false, enableHiding: false,
|
||||
cellTemplate: 'main/user-bank/cell-templates/user-actions.html'}
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
$scope.mCache.unlisten();
|
||||
});
|
||||
|
||||
$scope.toggleFiltering = function() {
|
||||
$scope.userGrid.enableFiltering = !$scope.userGrid.enableFiltering;
|
||||
$scope.userGridApi.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );
|
||||
};
|
||||
|
||||
var originatorEv;
|
||||
$scope.openMenu = function($mdOpenMenu, ev) {
|
||||
originatorEv = ev;
|
||||
$mdOpenMenu(ev);
|
||||
};
|
||||
|
||||
$scope.delete = function(entity) {
|
||||
if ($scope.confirmQuestionBox) {
|
||||
portalUtils.confirmBox('deleteUser', 'Delete User', ['Are you sure you want to delete the user', entity.email],
|
||||
true, function(value) {
|
||||
if (value.confirm) {
|
||||
$scope.confirmQuestionBox = !value.checkbox;
|
||||
$scope.deleteUser(entity);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$scope.deleteUser(entity);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$scope.deleteUser = function(entity) {
|
||||
accountProvider.deleteUser(entity).then(function() {
|
||||
portalUtils.toast('User deleted successfully', ['top', 'left'], 2000);
|
||||
new accountStores.UserPool().refresh();
|
||||
}).catch(function(err){
|
||||
portalUtils.toast('Unable to delete user: ' + err.message, ['top', 'left'], 4000);
|
||||
new accountStores.UserPool().refresh();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.edit = function(entity) {
|
||||
$mdDialog.show({
|
||||
templateUrl: 'common/partials/add-user/add-user.html',
|
||||
controller: 'AddUserCtrl',
|
||||
escapeToClose: false,
|
||||
locals: {
|
||||
modalInstance: {
|
||||
header: 'Edit User',
|
||||
account: entity,
|
||||
requirePassword: false,
|
||||
}
|
||||
}
|
||||
}).then(function(){
|
||||
new accountStores.UserPool().refresh();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.addUser = function() {
|
||||
$mdDialog.show({
|
||||
templateUrl: 'common/partials/add-user/add-user.html',
|
||||
controller: 'AddUserCtrl',
|
||||
escapeToClose: false,
|
||||
locals: {
|
||||
modalInstance: {
|
||||
header: 'Add User',
|
||||
requirePassword: true
|
||||
}
|
||||
}
|
||||
}).then(function(){
|
||||
new accountStores.UserPool().refresh();
|
||||
});
|
||||
};
|
||||
|
||||
} //end RepoBankCtrlController function
|
||||
|
||||
})();
|
||||
Reference in new issue
Block a user