Rewrite of Log view to use dir-paginate
This commit is contained in:
parent
c42ad0ba13
commit
8279f71266
|
@ -16,7 +16,8 @@ class LogsController extends AppController {
|
||||||
public $components = array('Paginator', 'RequestHandler');
|
public $components = array('Paginator', 'RequestHandler');
|
||||||
public $paginate = array(
|
public $paginate = array(
|
||||||
'limit' => 100,
|
'limit' => 100,
|
||||||
'order' => array( 'Log.TimeKey' => 'asc' )
|
'order' => array( 'Log.TimeKey' => 'asc' ),
|
||||||
|
'paramType' => 'querystring'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,11 +30,7 @@ class LogsController extends AppController {
|
||||||
$this->Paginator->settings = $this->paginate;
|
$this->Paginator->settings = $this->paginate;
|
||||||
|
|
||||||
$logs = $this->Paginator->paginate('Log');
|
$logs = $this->Paginator->paginate('Log');
|
||||||
|
$this->set(compact('logs'));
|
||||||
$this->set(array(
|
|
||||||
'logs' => $logs,
|
|
||||||
'_serialize' => array('logs')
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?php
|
||||||
|
$array['logs'] = $logs;
|
||||||
|
$array['pagination'] = $this->Paginator->params();
|
||||||
|
echo json_encode($array);
|
||||||
|
?>
|
|
@ -41,8 +41,8 @@ ZoneMinder.factory('Header', function($http) {
|
||||||
|
|
||||||
ZoneMinder.factory('Log', function($http) {
|
ZoneMinder.factory('Log', function($http) {
|
||||||
return {
|
return {
|
||||||
getLogs: function(callback) {
|
get: function(page) {
|
||||||
$http.get('/api/logs.json').success(callback);
|
return $http.get('/api/logs.json?page='+page);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,9 +18,19 @@ ZoneMinder.controller('FooterController', function($scope, Footer) {
|
||||||
});
|
});
|
||||||
|
|
||||||
ZoneMinder.controller('LogController', function($scope, Log) {
|
ZoneMinder.controller('LogController', function($scope, Log) {
|
||||||
Log.getLogs(function(results) {
|
getLogsPage(1);
|
||||||
$scope.logs = results.logs;
|
|
||||||
});
|
$scope.pageChanged = function(newPage) {
|
||||||
|
getLogsPage(newPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLogsPage(pageNumber) {
|
||||||
|
Log.get(pageNumber).then(function(results) {
|
||||||
|
$scope.logs = results.data.logs;
|
||||||
|
$scope.totalLogs = results.data.pagination.count;
|
||||||
|
$scope.logsPerPage = results.data.pagination.limit;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ZoneMinder.controller('EventsController', function($scope, Events, $modal) {
|
ZoneMinder.controller('EventsController', function($scope, Events, $modal) {
|
||||||
|
|
|
@ -1,33 +1,4 @@
|
||||||
<?php
|
<?php xhtmlHeaders(__FILE__, $SLANG['SystemLog'] ); ?>
|
||||||
//
|
|
||||||
// ZoneMinder web log view file, $Date: 2010-02-23 09:10:36 +0000 (Tue, 23 Feb 2010) $, $Revision: 3030 $
|
|
||||||
// Copyright (C) 2001-2008 Philip Coombes
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU General Public License
|
|
||||||
// as published by the Free Software Foundation; either version 2
|
|
||||||
// of the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
//
|
|
||||||
|
|
||||||
if ( !canView( 'System' ) )
|
|
||||||
{
|
|
||||||
$view = "error";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$focusWindow = true;
|
|
||||||
|
|
||||||
xhtmlHeaders(__FILE__, $SLANG['SystemLog'] );
|
|
||||||
?>
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<?php include("header.php"); ?>
|
<?php include("header.php"); ?>
|
||||||
|
@ -38,17 +9,6 @@ xhtmlHeaders(__FILE__, $SLANG['SystemLog'] );
|
||||||
|
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
|
|
||||||
<div id="filter-buttons">
|
|
||||||
<div class="btn-group btn-group-justified">
|
|
||||||
<div class="btn-group"><input class="btn btn-default btn-block" type="button" value="<?= $SLANG['More'] ?>" onclick="expandLog()"/></div>
|
|
||||||
<div class="btn-group"><input class="btn btn-default btn-block" type="button" value="<?= $SLANG['Clear'] ?>" onclick="clearLog()"/></div>
|
|
||||||
</div>
|
|
||||||
<div class="btn-group btn-group-justified">
|
|
||||||
<div class="btn-group"><input class="btn btn-default btn-block" type="button" value="<?= $SLANG['Refresh'] ?>" onclick="refreshLog()"/></div>
|
|
||||||
<div class="btn-group"><input class="btn btn-default btn-block" type="button" value="<?= $SLANG['Export'] ?>" onclick="exportLog()"/></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="filters">
|
<div id="filters">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="sr-only" for="filter[Component]">Component</label>
|
<label class="sr-only" for="filter[Component]">Component</label>
|
||||||
|
@ -75,22 +35,11 @@ xhtmlHeaders(__FILE__, $SLANG['SystemLog'] );
|
||||||
<select class="form-control" id="filter[Line]" onchange="filterLog(this)"><option value="">Line</option></select>
|
<select class="form-control" id="filter[Line]" onchange="filterLog(this)"><option value="">Line</option></select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input class="btn btn-default" type="reset" value="<?= $SLANG['Reset'] ?>" onclick="resetLog()"/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<div id="headerControl">
|
<dir-pagination-controls on-page-change="pageChanged(newPageNumber)"></dir-pagination-controls>
|
||||||
<table id="logSummary" cellspacing="0">
|
|
||||||
<tr>
|
|
||||||
<td><?= $SLANG['Updated'] ?>: <span id="lastUpdate"></span></td>
|
|
||||||
<td><?= $SLANG['State'] ?>: <span id="logState"></span></td>
|
|
||||||
<td><?= $SLANG['Total'] ?>: <span id="totalLogs"></span></td>
|
|
||||||
<td><?= $SLANG['Available'] ?>: <span id="availLogs"></span></td>
|
|
||||||
<td><?= $SLANG['Displaying'] ?>: <span id="displayLogs"></span></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table class="table table-striped table-condensed">
|
<table class="table table-striped table-condensed">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -102,7 +51,7 @@ xhtmlHeaders(__FILE__, $SLANG['SystemLog'] );
|
||||||
<th><?= $SLANG['File'] ?></th>
|
<th><?= $SLANG['File'] ?></th>
|
||||||
<th><?= $SLANG['Line'] ?></th>
|
<th><?= $SLANG['Line'] ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr ng-repeat="log in logs">
|
<tr dir-paginate="log in logs| itemsPerPage: logsPerPage" total-items="totalLogs">
|
||||||
<td>{{ log.Log.TimeKey }}</td>
|
<td>{{ log.Log.TimeKey }}</td>
|
||||||
<td>{{ log.Log.Component }}</td>
|
<td>{{ log.Log.Component }}</td>
|
||||||
<td>{{ log.Log.Pid }}</td>
|
<td>{{ log.Log.Pid }}</td>
|
||||||
|
@ -115,35 +64,6 @@ xhtmlHeaders(__FILE__, $SLANG['SystemLog'] );
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="exportLog" class="overlay">
|
</div>
|
||||||
<div class="overlayHeader">
|
|
||||||
<div class="overlayTitle"><?= $SLANG['ExportLog'] ?></div>
|
|
||||||
</div>
|
|
||||||
<div class="overlayBody">
|
|
||||||
<div class="overlayContent">
|
|
||||||
<form id="exportForm" action="" method="post">
|
|
||||||
<fieldset>
|
|
||||||
<legend><?= $SLANG['SelectLog'] ?></legend>
|
|
||||||
<label for="selectorAll">All</label><input type="radio" id="selectorAll" name="selector" value="all"/>
|
|
||||||
<label for="selectorFilter">Filter</label><input type="radio" id="selectorFilter" name="selector" value="filter"/>
|
|
||||||
<label for="selectorCurrent">Current</label><input type="radio" id="selectorCurrent" name="selector" value="current" title="<?= $SLANG['ChooseLogSelection'] ?>" data-validators="validate-one-required"/>
|
|
||||||
</fieldset>
|
|
||||||
<fieldset>
|
|
||||||
<legend><?= $SLANG['SelectFormat'] ?></legend>
|
|
||||||
<label for="formatText">Text</label><input type="radio" id="formatText" name="format" value="text"/>
|
|
||||||
<label for="formatTSV">TSV</label><input type="radio" id="formatTSV" name="format" value="tsv"/>
|
|
||||||
<label for="formatXML">HTML</label><input type="radio" id="formatHTML" name="format" value="html"/>
|
|
||||||
<label for="formatXML">XML</label><input type="radio" id="formatXML" name="format" value="xml" title="<?= $SLANG['ChooseLogFormat'] ?>" class="validate-one-required"/>
|
|
||||||
</fieldset>
|
|
||||||
<div id="exportError">
|
|
||||||
<?= $SLANG['ExportFailed'] ?>: <span id="exportErrorText"></span>
|
|
||||||
</div>
|
|
||||||
<input type="button" id="exportButton" value="<?= $SLANG['Export'] ?>" onclick="exportRequest()"/>
|
|
||||||
<input type="button" value="<?= $SLANG['Cancel'] ?>" class="overlayCloser"/>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue