57e2e80b8090b1f69f4016accee6aa74e56594e4
[portal/sdk.git] /
1 appDS2.controller('profileSearchCtrlDS2', function($scope, $http,ProfileServiceDS2){
2     $scope.showInput = true;
3     $scope.totalPages1 = 5;
4     $scope.viewPerPage1 = 8;
5     $scope.currentPage1 = 1;
6     $scope.showLoader = false;
7
8         $scope.$watch('viewPerPage1', function(val) {
9                 $scope.showLoader = true;
10                 ProfileServiceDS2.getProfilePagination($scope.currentPage1, val).then(function(data){
11                 var j = data;
12                 $scope.data = JSON.parse(j.data);
13                 $scope.tableData =JSON.parse($scope.data.profileList);                  
14                 $scope.totalPages1 =JSON.parse($scope.data.totalPage);
15                 for(x in $scope.tableData){
16                                 if($scope.tableData[x].active_yn=='Y')
17                                         $scope.tableData[x].active_yn=true;
18                                 else
19                                         $scope.tableData[x].active_yn=false;
20                         }
21                 $scope.showLoader = false;
22         },function(error){
23                 console.log("failed");
24                 reloadPageOnce();
25         });
26                 
27         });
28             
29         $scope.customHandler = function(num) {
30                 $scope.currentPage1 = num;       
31                 $scope.showLoader = true;
32                 ProfileServiceDS2.getProfilePagination($scope.currentPage1,$scope.viewPerPage1).then(function(data){
33                         var j = data;
34                         $scope.data = JSON.parse(j.data);
35                         $scope.tableData =JSON.parse($scope.data.profileList);
36                         $scope.totalPages1 =JSON.parse($scope.data.totalPage);
37                         for(x in $scope.tableData){
38                                         if($scope.tableData[x].active_yn=='Y')
39                                                 $scope.tableData[x].active_yn=true;
40                                         else
41                                                 $scope.tableData[x].active_yn=false;
42                                 }
43                         $scope.showLoader = false;
44                 },function(error){
45                         console.log("failed");
46                         reloadPageOnce();
47                 });
48
49             };
50
51         $scope.editRow = function(profileId){
52         window.location = 'userProfile#/profile/' + profileId;
53     };
54    
55         $scope.toggleProfileActive = function(rowData) {
56         modalService.popupConfirmWinWithCancel("Confirm","You are about to change user's active status. Do you want to continue?",
57                         function(){ 
58                         $http.get("profile/toggleProfileActive?profile_id="+rowData.id).success(function(){});
59         },
60         function(){
61                 rowData.active=!rowData.active;
62         })
63     };
64 });