Blame view
app/partials/accountSetting/accountSetting.Controller.js
13.4 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(){ |
9aea92263
|
22 23 24 |
if($scope.userid && $scope.userid != null && $scope.userid != undefined){ var id = $scope.userid; AccountSettingService.loginUserData(id).then(function(result) { |
239310627
|
25 |
if(result.userTimeZone != null){ |
9aea92263
|
26 27 28 29 30 31 32 33 |
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","-"); } |
239310627
|
34 35 |
} |
9aea92263
|
36 |
$scope.userData = result; |
938f3037d
|
37 |
//console.log("===userData===",$scope.userData) |
9aea92263
|
38 39 40 41 |
$scope.userData.status = $scope.userData.account.user.status.toLowerCase(); $scope.userData.userType = $scope.userData.userType.type.toLowerCase(); }) } |
bb639860c
|
42 |
} |
9aea92263
|
43 |
getLoginUserData(); |
3a9f4472b
|
44 |
AccountSettingService.getProducts().then(function(result) { |
bb639860c
|
45 46 47 48 49 50 51 52 53 |
$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
|
54 |
}) |
bb639860c
|
55 56 57 58 59 60 61 62 63 |
$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
|
64 |
// console.log($scope.productData) |
bb639860c
|
65 66 67 |
} $scope.updateUser = function(){ |
1b71872b2
|
68 |
|
9aea92263
|
69 70 71 72 73 74 75 76 77 78 79 |
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
|
80 81 |
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 |
7f6e3b1df
|
82 |
+ "&status=" + $scope.userData.status + "&userType=" + $scope.userData.userType + "&userTypeId=" + $scope.userData.userType.id + "&userProfileId=" + $scope.userid + "&userTimeZone=" + $scope.userData.userTimeZone + "&icao=" + $scope.userData.icao; |
bb639860c
|
83 |
|
938f3037d
|
84 |
// console.log("======updateData===",updateData) |
bb639860c
|
85 |
AccountSettingService.updateUserProfile(updateData).then(function(result) { |
9aea92263
|
86 |
|
bb639860c
|
87 88 89 |
AccountSettingService.updateProducts($scope.productData).then(function(result) { toastr.success(''+result.success+'', { closeButton: true |
3c77051a2
|
90 91 |
}); window.localStorage.setItem('currentUserName', JSON.stringify($scope.userData.firstName +' '+ $scope.userData.lastName)); |
8041a48e1
|
92 |
window.localStorage.setItem('companyName', JSON.stringify($scope.userData.companyName)); |
3c77051a2
|
93 |
$scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName')); |
9aea92263
|
94 95 96 97 |
$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
|
98 |
$scope.testFunction(); |
9aea92263
|
99 |
getLoginUserData(); |
bb639860c
|
100 |
}) |
1b71872b2
|
101 |
|
bb639860c
|
102 103 |
}) } |
4c25c98b5
|
104 105 106 |
$scope.accountdata = {}; $scope.accountdata.userName = ''; $scope.accountdata.status = true; |
ae523d5ef
|
107 108 109 |
$scope.addAccount = function(){ $('#demo-modal').css('display', 'block'); |
ab1d9513c
|
110 |
$scope.accountdata.status = true; |
ae523d5ef
|
111 |
} |
f746aee1b
|
112 |
$scope.cancelAddAccount = function(){ |
1b71872b2
|
113 |
$scope.accountdata = {}; |
ae523d5ef
|
114 115 |
$('#demo-modal').css('display', ''); } |
3e6e9e0f4
|
116 117 |
$scope.checkEmail = function(email, type) { |
9aea92263
|
118 |
//console.log(type) |
3e6e9e0f4
|
119 120 121 122 123 124 125 126 127 128 129 |
AccountSettingService.checkEmail(email).then(function(result) { if(result.status == 'ACTIVE'){ toastr.error('Email already exists.', { closeButton: true }) if(type == 'additional'){ $scope.accountdata.userName = ''; } } }) } |
4c25c98b5
|
130 |
|
f746aee1b
|
131 |
$scope.additionalAccnObj = {}; |
ae523d5ef
|
132 |
$scope.createAddAccount = function(){ |
ab1d9513c
|
133 |
$scope.accountdata.status = true; |
4c25c98b5
|
134 135 |
if ($scope.accountdata.userName === '') { toastr.error('Please enter all the fields.', { |
ae523d5ef
|
136 137 |
closeButton: true }) |
4c25c98b5
|
138 139 |
}else{ if (validateEmail($scope.accountdata.userName)) { |
9aea92263
|
140 |
//console.log("checkbox",$scope.accountdata.allowEpd ,$scope.accountdata.allowFma) |
4c25c98b5
|
141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
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
|
155 |
|
ae523d5ef
|
156 |
} |
4c25c98b5
|
157 158 159 160 161 162 163 164 |
/*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
|
165 166 167 168 169 170 171 |
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
|
172 |
toastr.success('Updated Successfully', { |
f746aee1b
|
173 174 175 176 177 178 179 |
closeButton: true }) } }) } var deleteAccnId = ""; $scope.deleteAdditionalAccount = function(id) { |
1b71872b2
|
180 |
$('#delete1').css('display', 'block'); |
f746aee1b
|
181 |
deleteAccnId = id; |
1b71872b2
|
182 |
|
f746aee1b
|
183 184 185 |
} $scope.accnDelete = function(){ |
1b71872b2
|
186 187 188 |
AccountSettingService.deleteAccount(deleteAccnId).then(function(result) { getAdditionalAccounts(); $('#delete1').css('display', 'none'); |
f746aee1b
|
189 |
if(result.success){ |
1b71872b2
|
190 |
toastr.success('Deleted Successfully', { |
f746aee1b
|
191 192 193 194 195 |
closeButton: true }) } }) } |
9aea92263
|
196 |
|
f746aee1b
|
197 198 |
$scope.cancelDelete = function(){ |
1b71872b2
|
199 |
$('#delete1').css('display', 'none'); |
f746aee1b
|
200 |
} |
9b112a598
|
201 202 |
$scope.resetPassword = function(email) { |
9aea92263
|
203 |
//console.log("emailid",email) |
9b112a598
|
204 205 206 207 208 209 210 211 212 213 |
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
|
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 250 251 |
$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
|
252 |
|
9aea92263
|
253 |
|
3a9f4472b
|
254 255 |
} })(); |