Blame view
app/partials/accountSetting/accountSetting.Controller.js
13.3 KB
3a9f4472b
|
1 2 3 4 5 6 7 |
(function() { 'use strict' angular.module('acufuel') .controller('AccountSettingController', [ '$scope', '$filter', '$rootScope', '$state', 'AccountSettingService', AccountSettingController]); function AccountSettingController($scope, $filter, $rootScope, $state, AccountSettingService) { |
bb639860c
|
8 9 |
$scope.addArray = []; $scope.userData = {}; |
f746aee1b
|
10 11 12 |
getAdditionalAccounts(); function getAdditionalAccounts() { |
1b71872b2
|
13 14 |
AccountSettingService.getAdditionalAccounts().then(function(result) { $scope.additionalAccounts = result; |
f746aee1b
|
15 16 17 |
}) } |
bb639860c
|
18 |
$scope.userid = JSON.parse(localStorage.getItem('userProfileId')); |
9aea92263
|
19 20 21 |
//call this function after upload data function getLoginUserData(){ |
a63845a90
|
22 |
console.log("===call---") |
9aea92263
|
23 24 25 26 27 28 29 30 31 32 33 34 |
if($scope.userid && $scope.userid != null && $scope.userid != undefined){ var id = $scope.userid; AccountSettingService.loginUserData(id).then(function(result) { if(result.userTimeZone.slice(0,1)==="P"){ result.userTimeZone = result.userTimeZone.replace("P","+"); }else if(result.userTimeZone.slice(0,1)==="M"){ result.userTimeZone = result.userTimeZone.replace("M","-"); } $scope.userData = result; |
0fbec5870
|
35 |
console.log("===userData===",userData) |
9aea92263
|
36 37 38 39 |
$scope.userData.status = $scope.userData.account.user.status.toLowerCase(); $scope.userData.userType = $scope.userData.userType.type.toLowerCase(); }) } |
bb639860c
|
40 |
} |
9aea92263
|
41 |
getLoginUserData(); |
3a9f4472b
|
42 |
AccountSettingService.getProducts().then(function(result) { |
bb639860c
|
43 44 45 46 47 48 49 50 51 |
$scope.productList = result; for(var i=0;i<$scope.productList.length;i++){ var obj = { id : $scope.productList[i].id, name : $scope.productList[i].name, status : $scope.productList[i].status } $scope.addArray.push(obj); } |
3a9f4472b
|
52 |
}) |
bb639860c
|
53 54 55 56 57 58 59 60 61 |
$scope.productData = {}; $scope.productData.productList = []; $scope.checkProduct = function(productlist, product, index){ $scope.addArray[index].id = productlist[index].id; $scope.addArray[index].name = productlist[index].name; $scope.addArray[index].status = productlist[index].status; $scope.productData.productList = $scope.addArray; |
9aea92263
|
62 |
// console.log($scope.productData) |
bb639860c
|
63 64 65 |
} $scope.updateUser = function(){ |
1b71872b2
|
66 |
|
9aea92263
|
67 68 69 70 71 72 73 74 75 76 77 |
window.localStorage.setItem('userTimeZone',JSON.stringify($scope.userData.userTimeZone)); //Database not save the = and - sign of timezone offset if($scope.userData.userTimeZone.slice(0,1)==="+"){ $scope.userData.userTimeZone = $scope.userData.userTimeZone.replace("+","P"); }else if($scope.userData.userTimeZone.slice(0,1)==="-"){ $scope.userData.userTimeZone = $scope.userData.userTimeZone.replace("-","M"); } |
1b71872b2
|
78 79 |
var updateData = "companyName=" + $scope.userData.companyName + "&username=" + $scope.userData.username + "&firstName=" + $scope.userData.firstName + "&lastName=" + $scope.userData.lastName + "&phone=" + $scope.userData.phone + "&mobile=" + $scope.userData.mobile |
9aea92263
|
80 |
+ "&status=" + $scope.userData.status + "&userType=" + $scope.userData.userType + "&userTypeId=" + $scope.userData.userType.id + "&userProfileId=" + $scope.userid + "&userTimeZone=" + $scope.userData.userTimeZone; |
bb639860c
|
81 |
|
0fbec5870
|
82 |
console.log("======updateData===",updateData) |
bb639860c
|
83 |
AccountSettingService.updateUserProfile(updateData).then(function(result) { |
9aea92263
|
84 |
|
bb639860c
|
85 86 87 |
AccountSettingService.updateProducts($scope.productData).then(function(result) { toastr.success(''+result.success+'', { closeButton: true |
3c77051a2
|
88 89 |
}); window.localStorage.setItem('currentUserName', JSON.stringify($scope.userData.firstName +' '+ $scope.userData.lastName)); |
8041a48e1
|
90 |
window.localStorage.setItem('companyName', JSON.stringify($scope.userData.companyName)); |
3c77051a2
|
91 |
$scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName')); |
9aea92263
|
92 93 94 95 |
$scope.companyName= JSON.parse(localStorage.getItem('companyName')); $scope.userTimeZone = JSON.parse(localStorage.getItem('userTimeZone')); //console.log("====value after update===",$scope.userTimeZone ) window.localStorage.removeItem('userTime'); |
3c77051a2
|
96 |
$scope.testFunction(); |
9aea92263
|
97 |
getLoginUserData(); |
bb639860c
|
98 |
}) |
1b71872b2
|
99 |
|
bb639860c
|
100 101 |
}) } |
4c25c98b5
|
102 103 104 |
$scope.accountdata = {}; $scope.accountdata.userName = ''; $scope.accountdata.status = true; |
ae523d5ef
|
105 106 107 |
$scope.addAccount = function(){ $('#demo-modal').css('display', 'block'); |
ab1d9513c
|
108 |
$scope.accountdata.status = true; |
ae523d5ef
|
109 |
} |
f746aee1b
|
110 |
$scope.cancelAddAccount = function(){ |
1b71872b2
|
111 |
$scope.accountdata = {}; |
ae523d5ef
|
112 113 |
$('#demo-modal').css('display', ''); } |
3e6e9e0f4
|
114 115 |
$scope.checkEmail = function(email, type) { |
9aea92263
|
116 |
//console.log(type) |
3e6e9e0f4
|
117 118 119 120 121 122 123 124 125 126 127 |
AccountSettingService.checkEmail(email).then(function(result) { if(result.status == 'ACTIVE'){ toastr.error('Email already exists.', { closeButton: true }) if(type == 'additional'){ $scope.accountdata.userName = ''; } } }) } |
4c25c98b5
|
128 |
|
f746aee1b
|
129 |
$scope.additionalAccnObj = {}; |
ae523d5ef
|
130 |
$scope.createAddAccount = function(){ |
ab1d9513c
|
131 |
$scope.accountdata.status = true; |
4c25c98b5
|
132 133 |
if ($scope.accountdata.userName === '') { toastr.error('Please enter all the fields.', { |
ae523d5ef
|
134 135 |
closeButton: true }) |
4c25c98b5
|
136 137 |
}else{ if (validateEmail($scope.accountdata.userName)) { |
9aea92263
|
138 |
//console.log("checkbox",$scope.accountdata.allowEpd ,$scope.accountdata.allowFma) |
4c25c98b5
|
139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
AccountSettingService.addAdditionalAccount($scope.accountdata).then(function(result) { getAdditionalAccounts(); $scope.accountdata = {}; $('#demo-modal').css('display', ''); toastr.success(''+result.success+'', { closeButton: true }) }) }else{ toastr.error('Please enter valid email.', { closeButton: true }) } } |
1b71872b2
|
153 |
|
ae523d5ef
|
154 |
} |
4c25c98b5
|
155 156 157 158 159 160 161 162 |
/*Validate Email */ function validateEmail(email) { var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); } $scope.changeStatus = function(id, index){ |
f746aee1b
|
163 164 165 166 167 168 169 |
event.stopPropagation(); var id = id; var statusData = "status=" + $scope.additionalAccounts[index].status + "&id=" + $scope.additionalAccounts[index].id + "&firstName=" + $scope.additionalAccounts[index].firstName + "&lastName=" + $scope.additionalAccounts[index].lastName + "&username=" + $scope.additionalAccounts[index].userName + "&password=" + $scope.additionalAccounts[index].password + "&allowEpd=" + $scope.additionalAccounts[index].allowEpd + "&allowFma=" + $scope.additionalAccounts[index].allowFma; AccountSettingService.updateStatus(statusData).then(function(result) { if(result.success){ |
1b71872b2
|
170 |
toastr.success('Updated Successfully', { |
f746aee1b
|
171 172 173 174 175 176 177 |
closeButton: true }) } }) } var deleteAccnId = ""; $scope.deleteAdditionalAccount = function(id) { |
1b71872b2
|
178 |
$('#delete1').css('display', 'block'); |
f746aee1b
|
179 |
deleteAccnId = id; |
1b71872b2
|
180 |
|
f746aee1b
|
181 182 183 |
} $scope.accnDelete = function(){ |
1b71872b2
|
184 185 186 |
AccountSettingService.deleteAccount(deleteAccnId).then(function(result) { getAdditionalAccounts(); $('#delete1').css('display', 'none'); |
f746aee1b
|
187 |
if(result.success){ |
1b71872b2
|
188 |
toastr.success('Deleted Successfully', { |
f746aee1b
|
189 190 191 192 193 |
closeButton: true }) } }) } |
9aea92263
|
194 |
|
f746aee1b
|
195 196 |
$scope.cancelDelete = function(){ |
1b71872b2
|
197 |
$('#delete1').css('display', 'none'); |
f746aee1b
|
198 |
} |
9b112a598
|
199 200 |
$scope.resetPassword = function(email) { |
9aea92263
|
201 |
//console.log("emailid",email) |
9b112a598
|
202 203 204 205 206 207 208 209 210 211 |
AccountSettingService.resetPassword(email).then(function(result){ if(typeof result == 'object') { toastr.info("Password generated successfully. Please check your email for new password"); //localStorage.setItem('requiredChangePwd', "Y"); //$state.go('login'); } else { toastr.info("Error in generating password"); } }) } |
9aea92263
|
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
$scope.timeZoneList = [{name:'(GMT-12:00) International Date Line West',value:'-12.00'}, {name:'(GMT-11:00) Midway Island, Samoa',value:'-11.00'}, {name:'(GMT-10:00) Hawaii',value :'-10.00'}, {name:'(GMT-09:30) Pacific/Marquesas (French Polynesia)',value :'-09.30'}, {name:'(GMT-09:00) Pacific/Gambier(French Polynesia)(US)',value :'-09.00'}, {name:'(GMT-08:00) Alaska',value :'-08.00'}, {name:'(GMT-07:00) Arizona,(US and Canada)',value :'-07.00'}, {name:'(GMT-06:00) (Central America),Chihuahua,Saskatchewan,Ecuador',value :'-06.00'}, {name:'(GMT-05:00) Central Time (US and Canada) Bogota, Mexico City,Lima,Brazil, Quito',value :'-05.00'}, {name:'(GMT-04:00) Eastern Time (US and Canada),Caracas, La Paz,Indiana (East)',value :'-04.00'}, {name:'(GMT-03:00) Atlantic Time (Canada),Santiago,Brasilia,Buenos Aires',value :'-03.00'}, {name:'(GMT-02:30) Newfoundland and Labrador,(Canada)',value :'-02.30'}, {name:'(GMT-02:00) Mid-Atlantic,Greenland',value :'-02.00'}, {name:'(GMT-01:00) Cape Verde Islands',value :'-01.00'}, {name:'(GMT) Azores,Dublin, Edinburgh, Lisbon, London',value :'00.00'}, {name:'(GMT+01:00) West Central Africa,Canary Islands,Casablanca, Monrovia',value :'+01.00'}, {name:'(GMT+02:00) Brussels,Amsterdam,Harare,Madrid,Paris,Cairo,Belgrade',value :'+02.00'}, {name:'(GMT+03:00) Moscow,Jerusalem,St.Petersburg, Athens,Baghdad,Kuwait,Helsinki,Nairobi',value :'+03.00'}, {name:'(GMT+04:00) Armenia,Azerbaijan,UAE,(Russia)',value :'+04.00'}, {name:'(GMT+04:30) Kabul,(Afghanistan)',value :'+04.30'}, {name:'(GMT+05:00) Islamabad, Karachi, Tashkent (Pakistan)',value :'+05.00'}, {name:'(GMT+05:30) Chennai,New Delhi(India),(Sri Lanka)',value :'+05.30'}, {name:'(GMT+05:45) Kathmandu (Nepal)',value :'+05.45'}, {name:'(GMT+06:00) Astana,Kazakhstan,Dhaka(Bangladesh),(Bhutan),(Russia)',value :'+06.00'}, {name:'(GMT+06:30) Yangon Rangoon (Myanmar)',value :'+06.30'}, {name:'(GMT+07:00) Laos,Krasnoyarsk,Hanoi,Bangkok(Thailand),Jakarta(Indonesia)',value :'+07.00'}, {name:'(GMT+08:00) Perth(Western Australia),Beijing(China),Kuala Lumpur(Singapore),(Malaysia)',value :'+08.00'}, {name:'(GMT+08:45) Australia/Eucla',value :'+08.45'}, {name:'(GMT+09:00) Japan/North Korea/South Korea/East Timor',value :'+09.00'}, {name:'(GMT+09:30) Adelaide/Darwin(Australia)',value :'+09.30' }, {name:'(GMT+10:00) Guam, Port Moresby,Hobart,Vladivostok,Brisbane,Melbourne(Australia),Papua New Guinea',value :'+10.00'}, {name:'(GMT+10:30) Australia/Lord_Howe',value :'+10.30'}, {name:'(GMT+11:00) Magadan, Solomon Islands, New Caledonia',value :'+11.00'}, {name:'(GMT+12:00) Auckland, Wellington,Fiji Islands, Kamchatka, Marshall Islands',value :'+12.00'}, {name:'(GMT+12:45) Pacific/Chatham, New Zealand',value :'+12.45'}, {name:'(GMT+13:00) Nuku alofa,Samoa,Tonga',value :'+13.00'}, {name:'(GMT+14:00) Pacific/Kiritimati',value :'+14.00'}] |
9b112a598
|
250 |
|
9aea92263
|
251 |
|
3a9f4472b
|
252 253 |
} })(); |