summaryrefslogtreecommitdiff
path: root/www/js/MontageCtrl.js
blob: 115bd513114066be2e143356414be5c99ff862af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', function ($scope, $rootScope, ZMDataModel, message,$ionicSideMenuDelegate) {
    
    
    $scope.openMenu = function () {
    $ionicSideMenuDelegate.toggleLeft();
  }

    //var monsize =3;
    console.log("********* Inside Montage Ctrl");
    $scope.LoginData = ZMDataModel.getLogin();
    $scope.slider = {};
    $scope.slider.monsize = ZMDataModel.getMontageSize();
    $scope.$on('$ionicView.afterEnter', function () {
        $rootScope.rand = Math.floor((Math.random() * 100000) + 1);
        //console.log("*********IN VIEW, generated " + $rootScope.rand);

        console.log("Rootscoxxpe Montage is " + ZMDataModel.getMontageSize() + " and slider montage is " + $scope.slider.monsize);
    });





    $scope.$watch('slider.monsize', function () {
        console.log('Slider has changed');
        ZMDataModel.setMontageSize($scope.slider.monsize);
        console.log("Rootscope Montage is " + ZMDataModel.getMontageSize() + " and slider montage is " + $scope.slider.monsize);
        //$rootScope.montageSize = $scope.slider.monsize;
    });

    $scope.monitors = [];
    console.log("Inside MontageCtrl waiting for monitors to load...");

    $scope.monitors = message;
    console.log("I have received the monitors inside Montage and there are " + $scope.monitors.length);
    // console.log("***CALLING FACTORY");
    //ZMHttpFactory.getMonitors().then(function(data) //{
    //                                  $scope.monitors = data;
    // console.log("I GOT " + $scope.monitors);
    //    });

    $scope.doRefresh = function () {
        console.log("***Pull to Refresh");
        $scope.monitors = [];

        var refresh = ZMDataModel.getMonitors(1);
        refresh.then(function (data) {
            $scope.monitors = data;
            $scope.$broadcast('scroll.refreshComplete');
        });

    };
});