Skip to content

Commit

Permalink
server logs and other tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
pliablepixels committed Feb 11, 2017
1 parent fe2504f commit 9cf314c
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 9 deletions.
3 changes: 1 addition & 2 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget android-packageName="com.pliablepixels.zmninja_pro" id="com.pliablepixels.zmninjapro" ios-CFBundleIdentifier="com.pliablepixels.zmninja-pro" version="1.2.36" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget android-packageName="com.pliablepixels.zmninja_pro" id="com.pliablepixels.zmninjapro" ios-CFBundleIdentifier="com.pliablepixels.zmninja-pro" version="1.2.37" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>zmNinja</name>
<description>
High performance ZoneMinder client
Expand All @@ -11,7 +11,6 @@
<access origin="*" subdomains="true" />
<access launch-external="yes" origin="mailto:*" />
<allow-navigation href="*" />
<allow-navigation href="http://10.6.1.6:8100" />
<allow-intent href="*" />
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
<preference name="iosPersistentFileLocation" value="Library" />
Expand Down
2 changes: 1 addition & 1 deletion www/js/DataModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
63 changes: 60 additions & 3 deletions www/js/LogCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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()
{

Expand Down Expand Up @@ -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");
Expand All @@ -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');
Expand All @@ -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();

}

//-------------------------------------------------------------------------
Expand All @@ -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: ""
Expand Down
24 changes: 21 additions & 3 deletions www/templates/log.html
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -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>

1 comment on commit 9cf314c

@pliablepixels
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.