Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / app / fusion / scripts / controllers / profile-search-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('profileSearchCtrl', function($scope, $http,ProfileService,modalService){
21
22     $scope.showInput = true;
23     $scope.totalPages1 = 5;
24     $scope.viewPerPage1 = 8;
25     $scope.currentPage1 = 1;
26
27         $scope.$watch('viewPerPage1', function(val) {
28                 ProfileService.getProfilePagination($scope.currentPage1, val).then(function(data){
29                 var j = data;
30                 $scope.data = JSON.parse(j.data);
31                 $scope.tableData =JSON.parse($scope.data.profileList);
32                 $scope.totalPages1 =JSON.parse($scope.data.totalPage);
33                 for(x in $scope.tableData){
34                                 if($scope.tableData[x].active_yn=='Y')
35                                         $scope.tableData[x].active_yn=true;
36                                 else
37                                         $scope.tableData[x].active_yn=false;
38                         }
39         },function(error){
40                 console.log("failed");
41                 reloadPageOnce();
42         });
43                 
44         });
45             
46         $scope.customHandler = function(num) {
47                 $scope.currentPage1 = num;              
48                 ProfileService.getProfilePagination($scope.currentPage1,$scope.viewPerPage1).then(function(data){
49                         var j = data;
50                         $scope.data = JSON.parse(j.data);
51                         $scope.tableData =JSON.parse($scope.data.profileList);
52                         $scope.totalPages1 =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                 },function(error){
60                         console.log("failed");
61                         reloadPageOnce();
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 });