ad4f777e927eb688d42cf29dc2a363f82ea28207
[portal/sdk.git] /
1 app.controller('samplePageController', function($scope, $http,ProfileService,modalService){
2         $scope.tableData=[];
3         $scope.viewPerPage=20;
4         $scope.scrollViewPerPage=2;
5         $scope.currentPage=1;
6         $scope.totalPage;
7         $scope.searchCategory;
8         $scope.searchString="";
9         $scope.currentPageNum=1;
10         ProfileService.getProfilePagination(1,$scope.viewPerPage).then(function(data){
11                 var j = data;
12                 $scope.data = JSON.parse(j.data);
13                 $scope.tableData =JSON.parse($scope.data.profileList);
14                 $scope.totalPages =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.resetMenu();
22         },function(error){
23                 console.log("failed");
24                 reloadPageOnce();
25         });
26         
27         $scope.$watch('currentPageNum', function(val) {
28                 
29                 ProfileService.getProfilePagination(val,$scope.viewPerPage).then(function(data){
30                         var j = data;
31                         $scope.data = JSON.parse(j.data);
32                         $scope.tableData =JSON.parse($scope.data.profileList);
33                         $scope.totalPages =JSON.parse($scope.data.totalPage);
34                         for(x in $scope.tableData){
35                                 if($scope.tableData[x].active_yn=='Y')
36                                         $scope.tableData[x].active_yn=true;
37                                 else
38                                         $scope.tableData[x].active_yn=false;
39                         }
40                         //$scope.resetMenu();
41                 },function(error){
42                         console.log("failed");
43                 });
44         
45     });
46         
47         $scope.editRow = function(profileId){
48         window.location = 'userProfile#/profile/' + profileId;
49     }
50    
51         $scope.toggleProfileActive = function(rowData) {
52         modalService.popupConfirmWinWithCancel("Confirm","You are about to change user's active status. Do you want to continue?",
53                         function(){ 
54                         $http.get("profile/toggleProfileActive?profile_id="+rowData.id).success(function(){});
55         },
56         function(){
57                 rowData.active=!rowData.active;
58         })
59     };
60
61 });