From b20e0e323bf95ad32520f012bb404efec7d9fed1 Mon Sep 17 00:00:00 2001 From: Arjun Roychowdhury Date: Sat, 31 Oct 2015 10:54:32 -0400 Subject: #59 desktop mode support --- www/js/DataModel.js | 2 ++ www/js/EventCtrl.js | 17 ++++++++++++++++- www/js/app.js | 37 ++++++++++++++++++++++++++++++++----- www/templates/events-modal.html | 2 +- www/templates/events.html | 10 +++++----- 5 files changed, 56 insertions(+), 12 deletions(-) diff --git a/www/js/DataModel.js b/www/js/DataModel.js index cafb3b36..3ea54158 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -334,6 +334,8 @@ angular.module('zmApp.controllers') }, getLogin: function () { + + return loginData; }, diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index 816d25e4..483e3d55 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -17,7 +17,8 @@ angular.module('zmApp.controllers') //--------------------------------------------------- var loginData = ZMDataModel.getLogin(); - + + $scope.hours = []; $scope.days = []; @@ -87,6 +88,11 @@ angular.module('zmApp.controllers') $scope.myfilter = ""; $scope.eventCommands = eventCommands; $scope.loginData = ZMDataModel.getLogin(); + $scope.playbackURL = $scope.loginData.url; + if ($rootScope.platformOS == "unknown") + { + $scope.playbackURL = zm.desktopUrl; + } $scope.mycarousel = { index: 0 @@ -1105,6 +1111,15 @@ angular.module('zmApp.controllers') $scope.eFramesNum = eframes; $scope.eventDur = Math.round(edur); $scope.loginData = ZMDataModel.getLogin(); + + $scope.playbackURL = $scope.loginData.url; + if ($rootScope.platformOS == "unknown") + { + $scope.playbackURL = zm.desktopUrl; + } + + + $scope.eventBasePath = basepath; $scope.relativePath = relativepath; $rootScope.rand = Math.floor(Math.random() * (999999 - 111111 + 1)) + 111111; diff --git a/www/js/app.js b/www/js/app.js index 0f65d43b..5e0a8a65 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -29,7 +29,7 @@ angular.module('zmApp', [ //----------------------------------------------- .constant('zm', { - minAppVersion: '1.28.107', // if ZM is less than this, the app won't work + minAppVersion: '1.28.105', // if ZM is less than this, the app won't work minEventServerVersion: '0.4', gcmSenderId:'710936220256', httpTimeout: 15000, @@ -57,7 +57,9 @@ angular.module('zmApp', [ montageScaleFrequency: 300, eventsListDetailsHeight: 200.0, eventsListScrubHeight: 300, - loginScreenString: "var currentView = 'login'" // Isn't there a better way? + loginScreenString: "var currentView = 'login'", // Isn't there a better way? + desktopUrl:"/zm", + desktopApiUrl: "/api/zm" }) //------------------------------------------------------------------ @@ -195,11 +197,33 @@ angular.module('zmApp', [ // That way the user can try again, and won't get stuck // Also remember you need to add it to .config //------------------------------------------------------------------ -.factory('timeoutHttpIntercept', function ($rootScope, $q, zm) { +.factory('timeoutHttpIntercept', [ '$rootScope', '$q', 'zm', '$injector', function ( $rootScope, $q, zm, $injector) { var zmCookie = ""; return { 'request': function (config) { + + + if ($rootScope.platformOS == "unknown") + { + var zmD = $injector.get('ZMDataModel'); + var ld = zmD.getLogin(); + + // This takes care of url and apiurl as they have + // the same base + if (config.url.indexOf(ld.url) > -1) + { + zmD.zmDebug("Running in desktop, removing URLs for proxy"); + zmD.zmDebug ("OLD URL " + config.url); + config.url = config.url.replace(ld.url,zm.desktopUrl); + zmD.zmDebug ("NEW URL " + config.url); + } + + + + } + + // config.withCredentials = true; if (zmCookie) { config.headers.Cookie = "ZMSESSID=" + zmCookie; @@ -240,7 +264,7 @@ angular.module('zmApp', [ }; -}) +}]) //----------------------------------------------------------------- // This service automatically logs into ZM at periodic intervals @@ -328,9 +352,10 @@ angular.module('zmApp', [ }); - + var loginData = ZMDataModel.getLogin(); + //ZMDataModel.zmDebug ("*** AUTH LOGIN URL IS " + loginData.url); $http({ method: 'POST', //withCredentials: true, @@ -969,6 +994,8 @@ angular.module('zmApp', [ $urlRouterProvider.otherwise(function ($injector, $location) { var $state = $injector.get("$state"); + //console.log ("******************* OTHERWISE PROBLEM"); + var $rootScope = $injector.get('$rootScope'); $state.go("zm-portal-login"); }); diff --git a/www/templates/events-modal.html b/www/templates/events-modal.html index 0266fab5..5b96c65f 100644 --- a/www/templates/events-modal.html +++ b/www/templates/events-modal.html @@ -15,7 +15,7 @@
  • diff --git a/www/templates/events.html b/www/templates/events.html index 86e96405..2d55b1f0 100644 --- a/www/templates/events.html +++ b/www/templates/events.html @@ -158,7 +158,7 @@

  • @@ -221,7 +221,7 @@ id="hour-{{$index}}"> - {{hour.monitor}} {{hour.events}} events @@ -237,7 +237,7 @@ id="day-{{$index}}"> - {{day.monitor}} {{day.events}} events @@ -254,7 +254,7 @@ id="week-{{$index}}"> - {{week.monitor}} {{week.events}} events @@ -270,7 +270,7 @@ id="month-{{$index}}"> - {{month.monitor}} {{month.events}} events -- cgit v1.2.3