Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / app / fusionapp / scripts / controller / sample-page-controller.js
1 /*-
2  * ================================================================================
3  * eCOMP Portal SDK
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
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  * ================================================================================
19  */
20 app.controller('samplePageController', function($scope, $http,ProfileService,modalService){
21         $scope.tableData=[];
22         $scope.viewPerPage=20;
23         $scope.scrollViewPerPage=2;
24         $scope.currentPage=1;
25         $scope.totalPage;
26         $scope.searchCategory;
27         $scope.searchString="";
28         $scope.currentPageNum=1;
29         ProfileService.getProfilePagination(1,$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                 reloadPageOnce();
44         });
45         
46         $scope.$watch('currentPageNum', function(val) {
47                 
48                 ProfileService.getProfilePagination(val,$scope.viewPerPage).then(function(data){
49                         var j = data;
50                         $scope.data = JSON.parse(j.data);
51                         $scope.tableData =JSON.parse($scope.data.profileList);
52                         $scope.totalPages =JSON.parse($scope.data.totalPage);
53                         for(x in $scope.tableData){
54                                 if($scope.tableData[x].active_yn=='Y')
55                                         $scope.tableData[x].active_yn=true;
56                                 else
57                                         $scope.tableData[x].active_yn=false;
58                         }
59                         //$scope.resetMenu();
60                 },function(error){
61                         console.log("failed");
62                 });
63         
64     });
65         
66         $scope.editRow = function(profileId){
67         window.location = 'userProfile#/profile/' + profileId;
68     }
69    
70         $scope.toggleProfileActive = function(rowData) {
71         modalService.popupConfirmWinWithCancel("Confirm","You are about to change user's active status. Do you want to continue?",
72                         function(){ 
73                         $http.get("profile/toggleProfileActive?profile_id="+rowData.id).success(function(){});
74         },
75         function(){
76                 rowData.active=!rowData.active;
77         })
78     };
79
80 });