From 164ebf1745517bb2bc9be8eedb5bdf709168d801 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Thu, 1 Nov 2018 11:20:41 -0400 Subject: #733 remove getMonitor dependency for monitor view, show the right loading message --- www/js/MonitorCtrl.js | 30 ++++++++++++++---------------- www/js/app.js | 4 ++-- www/templates/monitors.html | 2 +- 3 files changed, 17 insertions(+), 19 deletions(-) (limited to 'www') diff --git a/www/js/MonitorCtrl.js b/www/js/MonitorCtrl.js index 0ed5883c..7fc2cec2 100644 --- a/www/js/MonitorCtrl.js +++ b/www/js/MonitorCtrl.js @@ -6,11 +6,12 @@ // refer to comments in EventCtrl for the modal stuff. They are almost the same angular.module('zmApp.controllers') - .controller('zmApp.MonitorCtrl', ['$ionicPopup', 'zm', '$scope', 'NVRDataModel', 'message', '$ionicSideMenuDelegate', '$ionicLoading', '$ionicModal', '$state', '$http', '$rootScope', '$timeout', '$ionicHistory', '$ionicPlatform', '$translate', '$q', - function ($ionicPopup, zm, $scope, NVRDataModel, message, $ionicSideMenuDelegate, $ionicLoading, $ionicModal, $state, $http, $rootScope, $timeout, $ionicHistory, $ionicPlatform, $translate, $q) { + .controller('zmApp.MonitorCtrl', ['$ionicPopup', 'zm', '$scope', 'NVRDataModel', '$ionicSideMenuDelegate', '$ionicLoading', '$ionicModal', '$state', '$http', '$rootScope', '$timeout', '$ionicHistory', '$ionicPlatform', '$translate', '$q', + function ($ionicPopup, zm, $scope, NVRDataModel, $ionicSideMenuDelegate, $ionicLoading, $ionicModal, $state, $http, $rootScope, $timeout, $ionicHistory, $ionicPlatform, $translate, $q) { var loginData; + $scope.monitorLoadStatus = "..."; // -------------------------------------------------------- // Handling of back button in case modal is open should @@ -269,24 +270,15 @@ angular.module('zmApp.controllers') $scope.$on('$ionicView.afterEnter', function () { // console.log("**VIEW ** Monitor Ctrl Entered"); + + NVRDataModel.debug ("Monitor Control afterEnter"); $scope.monitors = []; - $scope.monitors = message; + $scope.monitorLoadStatus = $translate.instant ('kPleaseWait')+'...'; + //console.log (">>>>>>>>>>>> MONITOR CTRL " + JSON.stringify($scope.monitors)); - if ($scope.monitors.length == 0) { - $rootScope.zmPopup = $ionicPopup.alert({ - title: $translate.instant('kNoMonitors'), - template: $translate.instant('kPleaseCheckCredentials') - }); - $ionicHistory.nextViewOptions({ - disableBack: true - }); - $state.go("app.login", { - "wizard": false - }); - return; - } + loginData = NVRDataModel.getLogin(); monitorStateCheck(); @@ -416,6 +408,11 @@ angular.module('zmApp.controllers') .then (function (data) { $scope.monitors = data; + + if (!$scope.monitors.length) { + $scope.monitorLoadStatus = $translate.instant ('kNoMonitors'); + } + if (!$scope.monitors[0].Monitor_Status ) { NVRDataModel.debug ("no Monitor_Status found reverting to daemonCheck..."); forceDaemonCheck(); @@ -428,6 +425,7 @@ angular.module('zmApp.controllers') }, function (err) { NVRDataModel.debug ("Monitor fetch error, reverting to daemonCheck..."); + $scope.monitorLoadStatus = $translate.instant ('kNoMonitors'); forceDaemonCheck(); }); diff --git a/www/js/app.js b/www/js/app.js index 74f7d0cf..696006dd 100755 --- a/www/js/app.js +++ b/www/js/app.js @@ -2539,12 +2539,12 @@ angular.module('zmApp', [ data: { requireLogin: true }, - resolve: { + /*resolve: { message: function (NVRDataModel) { // console.log("Inside app.montage resolve"); return NVRDataModel.getMonitors(0); } - }, + },*/ url: "/monitors", cache: false, templateUrl: "templates/monitors.html", diff --git a/www/templates/monitors.html b/www/templates/monitors.html index 0f9df892..5da6b8db 100644 --- a/www/templates/monitors.html +++ b/www/templates/monitors.html @@ -64,7 +64,7 @@ - {{'kNoMonitors' | translate}} + {{monitorLoadStatus}} -- cgit v1.2.3