670e8fc16431be860abcda0747ed4868992660d4
[portal/sdk.git] /
1 appDS2.controller("collaborateListControllerDS2", function ($scope,$http, $modal,AdminService) { 
2           
3         $scope.showInput = true;
4         $scope.totalPages1 = 5;
5         $scope.viewPerPage1 = 8;
6         $scope.currentPage1 = 1;
7         $scope.showLoader = false;
8         $scope.firstPlay = true;
9         // Start with empty list to silence error in console
10         $scope.tableData = [];
11         $scope.tableCollbItems = [];
12         // $scope.totalPages1 = 20;
13         $scope.$watch('viewPerPage1', function(val) {
14                 $scope.showLoader = true;
15                 AdminService.getCollaborateList($scope.currentPage1, val).then(function(data){
16                         var j = data;   
17                         $scope.data = JSON.parse(j.data);
18                         $scope.tableData = $scope.data;
19                         var totalItems = $scope.tableData.length;
20                         //console.log(totalItems);
21                         $scope.totalPages1  = Math.ceil(totalItems / $scope.viewPerPage1);
22                         $scope.showLoader = false;
23                         $scope.currentPage1=1;
24                         var endIndex = 1 * $scope.viewPerPage1;
25                         var startIndex = endIndex - $scope.viewPerPage1;
26                         $scope.tableCollbItems = $scope.tableData.slice(startIndex, endIndex);
27                 },function(error){
28                         console.log("failed");
29                         reloadPageOnce();
30                 });
31         });
32             
33         $scope.customHandler1 = function(num) {
34                 $scope.currentPage1=num;
35                 var endIndex = num * $scope.viewPerPage1;
36                 var startIndex = endIndex - $scope.viewPerPage1;
37                 $scope.tableCollbItems = $scope.tableData.slice(startIndex, endIndex);
38         };
39                 
40         $scope.openCollaboration = function(chatId){
41                 openInNewTab('openCollaboration?chat_id=' + chatId);
42         }
43            
44         $scope.toggleProfileActive = function(profileId) {
45                 modalService.popupConfirmWin("Confirm","You are about to change user's active status. Do you want to continue?",
46                                 function(){
47                         $http.get("profile/toggleProfileActive?profile_id="+profileId).success(function(){});   
48                 })
49         };       
50
51 });
52
53 function openInNewTab(url) {
54         var win = window.open(url, '_blank');
55         win.focus();  
56 };
57
58 function downloadScreenCaptureExtenstion() {
59           
60         var chromeURL = 'https://chrome.google.com/webstore/detail/icgmlogfeajbfdffajhoebcfbibfhaen';
61         var firefoxURL = 'https://addons.mozilla.org/en-US/firefox/addon/screen-capturing-capability';
62         var url;
63           
64         if(isChrome)
65                 url = chromeURL;
66         else if(isFirefox)
67                 url =   firefoxURL;
68           
69         var win = window.open(url);
70         win.focus();
71 };