1 appDS2.controller('profileSearchCtrlDS2', function($scope, $log, $modal, ProfileServiceDS2){
2 $scope.showInput = true;
3 $scope.totalPages1 = 0;
4 $scope.viewPerPage1 = 8;
5 $scope.currentPage1 = 1;
6 $scope.showLoader = false;
10 $scope.$watch('viewPerPage1', function(val) {
11 $scope.showLoader = true;
12 ProfileServiceDS2.getProfilePagination($scope.currentPage1, val).then(function(data){
14 $scope.data = JSON.parse(j.data);
15 $scope.tableData =JSON.parse($scope.data.profileList);
16 $scope.totalPages1 =JSON.parse($scope.data.totalPage);
17 $scope.showLoader = false;
19 console.log("watch of viewPerPage1 failed");
25 $scope.customHandler = function(num) {
26 $scope.currentPage1 = num;
27 $scope.showLoader = true;
28 ProfileServiceDS2.getProfilePagination($scope.currentPage1,$scope.viewPerPage1).then(function(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 $scope.showLoader = false;
35 console.log("customHandler failed");
41 $scope.editRow = function(profileId){
42 window.location = 'userProfile#/profile/' + profileId;
45 var ModalInstanceCtrl = function ($scope, $log, $modalInstance, items) {
48 $scope.toggleUserStatus = function(id) {
50 $log.debug('profileSearchCtrlDS2:ModalInstanceCtrl:toggleUserStatus: data is ' + id);
51 ProfileServiceDS2.toggleProfileStatus(id);
52 $modalInstance.close();
55 $scope.cancelUserStatusToggle = function(rowData) {
57 $log.debug('profileSearchCtrlDS2:ModalInstanceCtrl: cancelUserStatusToggle: data is ' + JSON.stringify(rowData));
58 // Undo the toggle of the checkbox
59 rowData.active = ! rowData.active;
60 $modalInstance.dismiss('cancel');
65 // user activation/deactivation
66 $scope.toggleProfileActive = function(rowData) {
68 $log.debug('profileSearchCtrlDS2:toggleProfileActive: id is ' + rowData.id
69 + ', active is ' + rowData.active);
70 var toggleType = null;
71 // The checkbox is already in the desired state,
72 // so the sense of the "if" is reversed here.
74 toggleType = "activate";
76 toggleType = "deactivate";
77 var modalInstance = $modal.open({
78 templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-profile/modals/profile-confirm-toggle.html',
79 controller: ModalInstanceCtrl,
80 sizeClass: 'modal-small',