PageSourceSearch

https://fxboss.firstcitizens.com/app/components/admin/manage_users.js?v=31082026-1758

js firstcitizens.com collected 2026-09-24 21:51:34 UTC 5,273 bytes, 175 lines download raw bytes

1var app = angular.module('bossApp');
2app.controller('manageUserCtrl', ['$scope', '$http', '$state','UserNewEditService','$location','LegalEntityService','$rootScope','SearchService',
3function($scope, $http, $state,UserNewEditService,$location,LegalEntityService,$rootScope,SearchService) {
4    $scope.loadingTable = true;
5	/**
6	* Get Loggedin user details.
7	*/
8	$scope.search = {};
9	$scope.loggedInUser = angular.copy($rootScope.currentUser);
10	/*** 
11	** Get Legal Entity for logged user.
12	*/
13	LegalEntityService.getLE().then(function(data){
14			$scope.le = angular.copy(data.legalEntity);
15			$scope.loadUserList();
16	});
17	/**
18	* Load User List for this particular Entity.
19	*/
20	$scope.loadUserList= function(){
21		UserNewEditService.getUserList().then(function(data){
22			$scope.loadData(data);
23		});
24	}
25	$scope.loadData= function(data){
26		var responseObj = data.responseObj;
27			var _userList = [];
28			for(var i in responseObj){
29				responseObj[i]["isActive"] = (responseObj[i].status=="Active")?true:false
30				_userList.push(responseObj[i]);
31			}
32			$scope.userList = _userList;
33			//pagination
34			$scope.tableViewby = "10";
35			$scope.tableTotalItems = ($scope.userList!=undefined)?$scope.userList.length:0; 
36			$scope.tableCurrentPage = 1;
37			$scope.tableItemsPerPage = $scope.tableViewby;
38			$scope.loadingTable = false;
39	}
40	
41	
42
43
44
45	$scope.setTableItemsPerPage = function(num) {
46		$scope.tableItemsPerPage = num;
47		$scope.tableCurrentPage = 1; //reset to first paghe
48	}
49	/***
50	* Enable 2FA for Approval.
51	*/
52	$scope.isTwoFARequiredForApproval = function(_user,index,actionSource) {
53		if(!$scope.le.isDualApproveNewUserRequired){
54			// If dual aproval is false toggle the Btn.
55			$scope.saveUser(_user);
56		}else if($scope.le.isDualApproveNewUserRequired){
57			// If dual approval is true check if 2FA is set to true.
58			if($scope.le.is2FARequiredToApproveUser){
59				// If 2fa is set to true enable 2fa component.
60				_user.enableTwoFAComponent = angular.copy(!_user.enableTwoFAComponent);
61				if("Cancel" != actionSource)
62					_user.isActive = angular.copy(!$scope.userList[index].isActive);
63			}else{
64				// If 2fa is set to false save the user.
65				$scope.saveUser(_user);
66			}
67		}
68	}
69	$scope.isAllowedToApprove = function(_user){
70		var result = false;
71		if($scope.le.isDualApproveNewUserRequired){
72			if($scope.loggedInUser.userId.toLowerCase() == _user.modifiedBy.toLowerCase()){
73				_user.disabledMsg = "Same user is not allowed to Approve/Suspend.";
74				result = true;
75			}
76		}else{
77			_user.disabledMsg = "";
78		}
79		if(!result){
80			
81			// Add Validation Based On Entitlement if User does not have add/suspend user entitlement display appropriate error message.
82			let _allowedToApprove = $rootScope.entitlements.filter(function (key,value) {return (key == "FXWEB_ACTIVATE_USER");});
83			let _allowedToSuspend = $rootScope.entitlements.filter(function (key,value) {return (key == "FXWEB_SUSPEND_USER");});
84			if(_allowedToApprove.length==0 && _user.status!='Active'){
85				_user.disabledMsg = "You don't have permission to activate any user.";
86				result = true;
87			}
88			if(!result && (_allowedToSuspend.length==0 && _user.status=='Active')){
89				_user.disabledMsg = "You don't have permission to suspend any user.";
90				result = true;
91			}
92		}
93		
94		return result;
95	}
96	$scope.twoFAComponentCallBack = function(_sourceObject){
97		$scope.saveUser(_sourceObject);
98	}
99	/**
100	* Toggle user status active/Inactive. 
101	*/
102	$scope.saveUser = function(_user){
103		UserNewEditService.approveUser(_user).then(function(response){
104			$scope.loadUserList();
105		});
106	}
107	/**
108	* Delete User
109	*/
110	$scope.deleteUser = function(_userId){
111		UserNewEditService.deleteUser(_userId).then(function(response){
112			$scope.loadUserList();
113		});
114	}
115	/***
116	* Smart-Simple Toggle ng-repeat.
117	*/
118	$scope.toggleFilter = function(item) {
119      item.toggle = angular.copy(!item.toggle);
120    }
121	
122	
123	
124	/**
125	* Advanced Search Filter.
126	*/
127	$scope.toggleSmartSearch = false;
128	$scope.searchTooltipText = "Open Advanced Search.";
129	$scope.displayAdvancedSearch = function(){
130		$scope.toggleSmartSearch = angular.copy(!$scope.toggleSmartSearch);
131		var _toggle = angular.copy($scope.toggleSmartSearch);
132		$scope.searchTooltipText = (_toggle)?"Close Advanced Search.":"Open Advanced Search.";
133		
134	}
135	$scope.advancedSearch = function(search){
136		$scope.search = search;
137		if(isSearchFieldsValid(search)){
138			SearchService.searchUsers(search).then(function(response){
139				$scope.loadData(response);
140			});
141		}else{
142			$scope.loadUserList(); // load user data from cache.
143		}
144	}
145	$scope.resetSearchCriteria = function(){
146		$scope.search = {}; // remove all search criteria.
147		$scope.loadUserList(); // load user data from cache.
148	}
149	function isSearchFieldsValid(search){
150		var isValid = false;
151		if(search){
152			if(search.userid || search.name || search.email || search.phonenumber){
153				isValid = true;	
154			}
155		}
156		return isValid;
157	}
158	
159	
160	$scope.isEligibleToEdit = function(row, currentUser, entitlements){
161		
162		if(row.userId.toLowerCase() == currentUser.userId.toLowerCase()) {
163			return false;
164		}
165		
166		if(entitlements && (entitlements.indexOf('FXWEB_UPDATE_USER')!= -1 
167			|| entitlements.indexOf('FXWEB_SUSPEND_USER')!= -1
168			|| entitlements.indexOf('FXWEB_ACTIVATE_USER')!= -1)){
169			return true
170		}
171		
172		return false;
173	}
174	
175}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.