1616
1717( function ( ) {
1818 'use strict' ;
19-
19+
2020 angular . module ( 'MfnWebConsole.pages.profile' )
2121 . controller ( 'ProfileCtrl' , ProfileCtrl ) ;
2222
23-
23+
2424
2525 /** @ngInject */
2626 function ProfileCtrl ( $scope , $http , sharedProperties , sharedData , toastr , $cookies , $uibModal ) {
27-
2827 var urlPath = sharedProperties . getUrlPath ( ) ;
2928
3029 $scope . workflows = sharedData . getWorkflows ( ) ;
3130 $scope . currentWorkflow = "" ;
3231 $scope . workflowUndeploymentModal = "" ;
33-
32+
3433 $scope . email = $cookies . get ( 'email' ) ;
3534 $scope . name = $cookies . get ( 'name' ) ;
3635 var token = $cookies . get ( 'token' ) ;
37-
36+
3837 $scope . updateProfile = function ( ) {
39-
38+
4039 var newName = $ ( "#inputName" ) . val ( ) ;
4140 var password = $ ( "#currentPassword" ) . val ( ) ;
42-
41+
4342 // name change
4443 if ( newName && newName != $scope . name ) {
4544 if ( ! password ) {
6665 }
6766
6867 $scope . removeAccount = function ( ) {
69-
70- var password = $ ( "#currentPassword" ) . val ( ) ;
71-
68+
69+ var password = $ ( "#currentPassword" ) . val ( ) ;
70+
7271 if ( ! password ) {
7372 $scope . errorMessage = "Please enter your password."
7473 $uibModal . open ( {
133132 $ ( "#inputConfirmPassword" ) . val ( "" ) ;
134133 changePassword ( password , newPassword ) ;
135134 }
136-
137135 }
138136 $ ( "#currentPassword" ) . val ( "" ) ;
139-
140137 }
141138
142139 function changeName ( password , newName ) {
143-
140+
144141 var req = {
145142 method : 'POST' ,
146143 url : urlPath ,
147144 headers : {
148145 'Content-Type' : 'application/json'
149146 } ,
150-
151147 data : JSON . stringify ( { "action" : "changeName" , "data" : { "user" : { "email" : $scope . email , "password" : password , "new_name" : newName } } } )
152-
153148 }
154-
149+
155150 $http ( req ) . then ( function successCallback ( response ) {
156-
157151 if ( response . data . status == "success" ) {
158152 console . log ( "Message:" + response . data . data . message ) ;
159153 $cookies . put ( 'name' , newName ) ;
187181 templateUrl : 'app/pages/workflows/modals/errorModal.html' ,
188182 size : 'md' ,
189183 } ) ;
190-
191184 } ) ;
192-
193185 }
194186
195187 function deleteAccount ( password ) {
196188
197189 if ( $scope . workflowUndeploymentModal ) {
198190 $scope . workflowUndeploymentModal . dismiss ( ) ;
199191 }
200-
192+
201193 var req = {
202194 method : 'POST' ,
203195 url : urlPath ,
204196 headers : {
205197 'Content-Type' : 'application/json'
206198 } ,
207-
199+
208200 data : JSON . stringify ( { "action" : "deleteAccount" , "data" : { "user" : { "password" : password , "token" : token } } } )
209-
201+
210202 }
211-
203+
212204 $http ( req ) . then ( function successCallback ( response ) {
213-
205+
214206 if ( response . data . status == "success" ) {
215207 console . log ( "Message:" + response . data . data . message ) ;
216208 $scope . logOut ( ) ;
217-
209+
218210 } else {
219211 console . log ( "Failure status returned by deleteAccount request" ) ;
220212 console . log ( "Message:" + response . data . data . message ) ;
225217 templateUrl : 'app/pages/workflows/modals/errorModal.html' ,
226218 size : 'md' ,
227219 } ) ;
228-
220+
229221 }
230222 } , function errorCallback ( response ) {
231223 console . log ( "Error occurred during deleteAccount request" ) ;
241233 templateUrl : 'app/pages/workflows/modals/errorModal.html' ,
242234 size : 'md' ,
243235 } ) ;
244-
236+
245237 } ) ;
246-
238+
247239 }
248240
249241 function checkDeployedWorkflows ( password ) {
256248 } ,
257249 data : JSON . stringify ( { "action" : "getWorkflows" , "data" : { "user" : { "token" : token } } } )
258250 }
259-
251+
260252 $http ( req ) . then ( function successCallback ( response ) {
261-
253+
262254 if ( response . data . status == "success" ) {
263-
255+
264256 $scope . workflows = response . data . data . workflows ;
265257 sharedData . setWorkflows ( response . data . data . workflows ) ;
266258 var deployedWorkflows = false ;
274266 if ( ! deployedWorkflows ) {
275267 deleteAccount ( password ) ;
276268 }
277-
269+
278270 } else {
279271 console . log ( "Failure status returned by getWorkflows" ) ;
280272 console . log ( "Message:" + response . data . data . message ) ;
330322 } ,
331323 data : JSON . stringify ( { "action" : "undeployWorkflow" , "data" : { "user" : { "token" : token } , "workflow" : { "id" : $scope . workflows [ index ] . id } } } )
332324 }
333-
325+
334326 $http ( req ) . then ( function successCallback ( response ) {
335327
336328 if ( response . data . status == "success" ) {
337329 setTimeout ( function ( ) { $scope . workflows [ index ] . status = 'undeployed' ; checkDeployedWorkflows ( password ) ; } , 2000 ) ;
338-
330+
339331 } else {
340332 console . log ( "Failure status returned by undeployWorkflow" ) ;
341333 console . log ( "Message:" + response . data . data . message ) ;
370362 }
371363
372364 function changePassword ( password , newPassword ) {
373-
365+
374366 var req = {
375367 method : 'POST' ,
376368 url : urlPath ,
377369 headers : {
378370 'Content-Type' : 'application/json'
379371 } ,
380-
372+
381373 data : JSON . stringify ( { "action" : "changePassword" , "data" : { "user" : { "email" : $scope . email , "password" : password , "new_password" : newPassword } } } )
382-
374+
383375 }
384-
376+
385377 $http ( req ) . then ( function successCallback ( response ) {
386-
378+
387379 if ( response . data . status == "success" ) {
388380 console . log ( "Message:" + response . data . data . message ) ;
389381 toastr . success ( 'Your password has been updated successfully.' ) ;
397389 templateUrl : 'app/pages/workflows/modals/errorModal.html' ,
398390 size : 'md' ,
399391 } ) ;
400-
401392 }
402393 } , function errorCallback ( response ) {
403394 console . log ( "Error occurred during changePassword request" ) ;
413404 templateUrl : 'app/pages/workflows/modals/errorModal.html' ,
414405 size : 'md' ,
415406 } ) ;
416-
417407 } ) ;
418-
419408 }
420-
421- }
409+ }
422410
423411} ) ( ) ;
0 commit comments