[VID-3] Setting docker image tag
[vid.git] / vid / src / main / webapp / app / vid / scripts / controller / sample-page-controller.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 app.controller('samplePageController', function($scope, $http,ProfileService,modalService){
22         $scope.tableData=[];
23         $scope.viewPerPage=20;
24         $scope.scrollViewPerPage=2;
25         $scope.currentPage=1;
26         $scope.totalPage;
27         $scope.searchCategory;
28         $scope.searchString="";
29         $scope.currentPageNum=1;
30         ProfileService.getProfilePagination(1,$scope.viewPerPage).then(function(data){
31                 var j = data;
32                 $scope.data = JSON.parse(j.data);
33                 $scope.tableData =JSON.parse($scope.data.profileList);
34                 $scope.totalPages =JSON.parse($scope.data.totalPage);
35                 for(x in $scope.tableData){
36                         if($scope.tableData[x].active_yn=='Y')
37                                 $scope.tableData[x].active_yn=true;
38                         else
39                                 $scope.tableData[x].active_yn=false;
40                 }
41                 //$scope.resetMenu();
42         },function(error){
43                 console.log("failed");
44                 reloadPageOnce();
45         });
46         
47         $scope.$watch('currentPageNum', function(val) {
48                 
49                 ProfileService.getProfilePagination(val,$scope.viewPerPage).then(function(data){
50                         var j = data;
51                         $scope.data = JSON.parse(j.data);
52                         $scope.tableData =JSON.parse($scope.data.profileList);
53                         $scope.totalPages =JSON.parse($scope.data.totalPage);
54                         for(x in $scope.tableData){
55                                 if($scope.tableData[x].active_yn=='Y')
56                                         $scope.tableData[x].active_yn=true;
57                                 else
58                                         $scope.tableData[x].active_yn=false;
59                         }
60                         //$scope.resetMenu();
61                 },function(error){
62                         console.log("failed");
63                 });
64         
65     });
66         
67         $scope.editRow = function(profileId){
68         window.location = 'userProfile#/profile/' + profileId;
69     }
70    
71         $scope.toggleProfileActive = function(rowData) {
72         modalService.popupConfirmWinWithCancel("Confirm","You are about to change user's active status. Do you want to continue?",
73                         function(){ 
74                         $http.get("profile/toggleProfileActive?profile_id="+rowData.id).success(function(){});
75         },
76         function(){
77                 rowData.active=!rowData.active;
78         })
79     };
80
81 });