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 $paginate = array(
|
||||
'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;
|
||||
|
||||
$logs = $this->Paginator->paginate('Log');
|
||||
|
||||
$this->set(array(
|
||||
'logs' => $logs,
|
||||
'_serialize' => array('logs')
|
||||
));
|
||||
$this->set(compact('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) {
|
||||
return {
|
||||
getLogs: function(callback) {
|
||||
$http.get('/api/logs.json').success(callback);
|
||||
get: function(page) {
|
||||
return $http.get('/api/logs.json?page='+page);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
@ -18,9 +18,19 @@ ZoneMinder.controller('FooterController', function($scope, Footer) {
|
|||
});
|
||||
|
||||
ZoneMinder.controller('LogController', function($scope, Log) {
|
||||
Log.getLogs(function(results) {
|
||||
$scope.logs = results.logs;
|
||||
});
|
||||
getLogsPage(1);
|
||||
|
||||
$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) {
|
||||
|
|
|
@ -1,33 +1,4 @@
|
|||
<?php
|
||||
//
|
||||
// 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'] );
|
||||
?>
|
||||
<?php xhtmlHeaders(__FILE__, $SLANG['SystemLog'] ); ?>
|
||||
<body>
|
||||
|
||||
<?php include("header.php"); ?>
|
||||
|
@ -38,17 +9,6 @@ xhtmlHeaders(__FILE__, $SLANG['SystemLog'] );
|
|||
|
||||
<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 class="form-group">
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<input class="btn btn-default" type="reset" value="<?= $SLANG['Reset'] ?>" onclick="resetLog()"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-10">
|
||||
<div id="headerControl">
|
||||
<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>
|
||||
<dir-pagination-controls on-page-change="pageChanged(newPageNumber)"></dir-pagination-controls>
|
||||
|
||||
<table class="table table-striped table-condensed">
|
||||
<tr>
|
||||
|
@ -102,7 +51,7 @@ xhtmlHeaders(__FILE__, $SLANG['SystemLog'] );
|
|||
<th><?= $SLANG['File'] ?></th>
|
||||
<th><?= $SLANG['Line'] ?></th>
|
||||
</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.Component }}</td>
|
||||
<td>{{ log.Log.Pid }}</td>
|
||||
|
@ -115,35 +64,6 @@ xhtmlHeaders(__FILE__, $SLANG['SystemLog'] );
|
|||
|
||||
</div>
|
||||
</div>
|
||||
<div id="exportLog" class="overlay">
|
||||
<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>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue