summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2017-02-11 15:03:34 -0500
committerPliable Pixels <pliablepixels@gmail.com>2017-02-11 15:03:34 -0500
commit9cf314cc8ca5f57148bfa8d503bc9698bfec9ac4 (patch)
tree895b290ad2fd7858a93a5d014032c321e037716e /www
parentfe2504f6311c25689888e7d5b398087d55df99d8 (diff)
server logs and other tweaks
Diffstat (limited to 'www')
-rwxr-xr-xwww/js/DataModel.js2
-rw-r--r--www/js/LogCtrl.js63
-rw-r--r--www/templates/log.html24
3 files changed, 82 insertions, 7 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js
index 558e116a..28372d56 100755
--- a/www/js/DataModel.js
+++ b/www/js/DataModel.js
@@ -559,7 +559,7 @@ angular.module('zmApp.controllers')
{
//console.log ("************* AUGH");
- return $http.get(urls[0].url).then(function()
+ return $http({method:'GET', timeout:5000, url:urls[0].url}).then(function()
{
log("Success: reachability on " + urls[0].url);
$ionicLoading.hide();
diff --git a/www/js/LogCtrl.js b/www/js/LogCtrl.js
index ed35f6a9..af7b037e 100644
--- a/www/js/LogCtrl.js
+++ b/www/js/LogCtrl.js
@@ -2,7 +2,7 @@
/* jslint browser: true*/
/* global saveAs, cordova,StatusBar,angular,console,moment */
-angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$rootScope', 'zm', '$ionicModal', 'NVRDataModel', '$ionicSideMenuDelegate', '$fileLogger', '$cordovaEmailComposer', '$ionicPopup', '$timeout', '$ionicHistory', '$state', '$interval', '$ionicLoading', '$translate', function($scope, $rootScope, zm, $ionicModal, NVRDataModel, $ionicSideMenuDelegate, $fileLogger, $cordovaEmailComposer, $ionicPopup, $timeout, $ionicHistory, $state, $interval, $ionicLoading, $translate)
+angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$rootScope', 'zm', '$ionicModal', 'NVRDataModel', '$ionicSideMenuDelegate', '$fileLogger', '$cordovaEmailComposer', '$ionicPopup', '$timeout', '$ionicHistory', '$state', '$interval', '$ionicLoading', '$translate', '$http',function($scope, $rootScope, zm, $ionicModal, NVRDataModel, $ionicSideMenuDelegate, $fileLogger, $cordovaEmailComposer, $ionicPopup, $timeout, $ionicHistory, $state, $interval, $ionicLoading, $translate, $http)
{
$scope.openMenu = function()
{
@@ -30,6 +30,17 @@ angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$roo
loadLogs();
}
+ $scope.flipLogs = function()
+ {
+ if ($scope.logEntity == 'ZoneMinder')
+ $scope.logEntity = $rootScope.appName;
+ else
+ $scope.logEntity = 'ZoneMinder';
+ console.log ("Flipped");
+ loadLogs();
+
+ };
+
$scope.deleteLogs = function()
{
@@ -169,6 +180,42 @@ angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$roo
NVRDataModel.debug("Email sent callback called");
}
+ function loadZMlogs()
+ {
+ var ld = NVRDataModel.getLogin();
+ var lapi = ld.apiurl + "/logs.json?sort=TimeKey&direction=desc&page="+$scope.zmPage;
+ $http.get (lapi)
+ .then (function (success) {
+ $ionicLoading.hide();
+ $scope.zmMaxPage = success.data.pagination.pageCount;
+ console.log ("PAGES="+$scope.zmMaxPage);
+ var tLogs = "";
+ console.log (JSON.stringify(success));
+ for (var i=0; i< success.data.logs.length; i++)
+ {
+ tLogs = tLogs + moment.unix(success.data.logs[i].Log.TimeKey).format ("MM/DD/YY hh:mm:ss") +" "+
+ success.data.logs[i].Log.Code+" " +
+ success.data.logs[i].Log.Message+"\n";
+ }
+ $scope.log.logString = tLogs;
+ },
+ function (error) {
+ NVRDataModel.log ("Error getting ZM logs:"+JSON.stringify(error));
+ $scope.log.logString = "Error getting log: " + JSON.stringify(error);
+
+
+ } );
+
+ }
+
+ $scope.changePage = function(p)
+ {
+ $scope.zmPage = $scope.zmPage + p;
+ if ($scope.zmPage < 1) $scope.zmPage = 1;
+ if ($scope.zmPage > $scope.zmMaxPage) $scope.zmPage = $scope.zmMaxPage;
+ loadLogs();
+ };
+
function loadLogs()
{
//console.log ("GETTING LOGS");
@@ -178,9 +225,12 @@ angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$roo
template: $translate.instant('kLoading'),
noBackdrop: true,
duration: zm.loadingTimeout
+
});
- $fileLogger.getLogfile().then(function(l)
+ if ($scope.logEntity == $rootScope.appName)
+ {
+ $fileLogger.getLogfile().then(function(l)
{
$scope.log.logString = l.split('\n').reverse().join('\n');
@@ -191,7 +241,11 @@ angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$roo
{
$scope.log.logString = "Error getting log: " + JSON.stringify(error);
$ionicLoading.hide();
- });
+ });
+ }
+ else
+ loadZMlogs();
+
}
//-------------------------------------------------------------------------
@@ -205,6 +259,9 @@ angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$roo
{
//console.log("**VIEW ** Log Ctrl Entered");
NVRDataModel.setAwake(false);
+ $scope.logEntity = $rootScope.appName;
+ $scope.zmPage = 1;
+ $scope.zmMaxPage = 1;
$scope.log = {
logString: ""
diff --git a/www/templates/log.html b/www/templates/log.html
index f4e32d66..c664901d 100644
--- a/www/templates/log.html
+++ b/www/templates/log.html
@@ -1,10 +1,11 @@
-<ion-view view-title="{{'kLogs' | translate}}">
+<ion-view view-title="{{logEntity}} {{'kLogs' | translate}}">
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-navicon" ng-click="openMenu()"></button>
<button data-badge="{{$root.alarmCount}}" class="animated infinite tada button button-icon button-clear ion-ios-bell notification-badge" ng-click="handleAlarms();" ng-if="$root.isAlarm"></button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
- <a class="button button-icon icon ion-trash-a" ng-href="" ng-click="deleteLogs()"></a>
+ <a class="button button-icon icon ion-arrow-swap" ng-href="" ng-click="flipLogs()"></a>
+ <a ng-if="logEntity == $root.appName" class="button button-icon icon ion-trash-a" ng-href="" ng-click="deleteLogs()"></a>
<div ng-if="$root.platformOS!='desktop'">
<a style="" class="button button-icon icon ion-email" ng-href="" ng-click="sendEmail(log.logString)"> </a>
</div>
@@ -13,8 +14,25 @@
</div>
</ion-nav-buttons>
<ion-content scroll-sista delegate-handle="none" overflow-scroll="false" mouse-wheel-scroll>
+
+ <div ng-if="logEntity=='ZoneMinder'">
+
+ <button class="button button-small button-stable icon ion-chevron-left" ng-click="changePage(1)">
+ </button>
+ <button class="button button-small button-stable icon ion-chevron-right" ng-click="changePage(-1)">
+ </button>
+ </div>
+
+ <div ng-if="logEntity==$root.appName">
<b>{{$root.appName}} {{'kVersion'|translate}}: {{zmAppVersion}} ({{$root.platformOS}})</b>
+ </div>
+
+ <div ng-if="logEntity!=$root.appName">
+ <b>ZoneMinder</b>
+ </div>
+
+
<br/>
- <!-- don't indent here -- its a pre-->
+ <!-- don't indent here its a pre-->
<pre>{{log.logString}}</pre>
</ion-content>