From 8279f71266f7b99ec3bc6999485a9dcb84f601f1 Mon Sep 17 00:00:00 2001 From: Kyle Johnson Date: Thu, 8 Jan 2015 16:06:13 -0500 Subject: [PATCH] Rewrite of Log view to use dir-paginate --- web/api/app/Controller/LogsController.php | 9 +-- web/api/app/View/Logs/json/index.ctp | 5 ++ web/skins/bootstrap/js/app.js | 4 +- web/skins/bootstrap/js/controllers.js | 16 ++++- web/skins/bootstrap/views/log.php | 88 ++--------------------- 5 files changed, 27 insertions(+), 95 deletions(-) create mode 100644 web/api/app/View/Logs/json/index.ctp diff --git a/web/api/app/Controller/LogsController.php b/web/api/app/Controller/LogsController.php index 76d9b7f0f..bb8f47b80 100644 --- a/web/api/app/Controller/LogsController.php +++ b/web/api/app/Controller/LogsController.php @@ -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')); } /** diff --git a/web/api/app/View/Logs/json/index.ctp b/web/api/app/View/Logs/json/index.ctp new file mode 100644 index 000000000..32cbd51f8 --- /dev/null +++ b/web/api/app/View/Logs/json/index.ctp @@ -0,0 +1,5 @@ +Paginator->params(); + echo json_encode($array); +?> diff --git a/web/skins/bootstrap/js/app.js b/web/skins/bootstrap/js/app.js index bf830d84d..3038d6c53 100644 --- a/web/skins/bootstrap/js/app.js +++ b/web/skins/bootstrap/js/app.js @@ -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); } }; }); diff --git a/web/skins/bootstrap/js/controllers.js b/web/skins/bootstrap/js/controllers.js index 7d528ca13..264aedfa7 100644 --- a/web/skins/bootstrap/js/controllers.js +++ b/web/skins/bootstrap/js/controllers.js @@ -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) { diff --git a/web/skins/bootstrap/views/log.php b/web/skins/bootstrap/views/log.php index c53093b2d..a307ab3e8 100644 --- a/web/skins/bootstrap/views/log.php +++ b/web/skins/bootstrap/views/log.php @@ -1,33 +1,4 @@ - + @@ -38,17 +9,6 @@ xhtmlHeaders(__FILE__, $SLANG['SystemLog'] );
-
-
-
-
-
-
-
-
-
-
-
@@ -75,22 +35,11 @@ xhtmlHeaders(__FILE__, $SLANG['SystemLog'] );
-
-
- - - - - - - - -
: : : : :
-
+ @@ -102,7 +51,7 @@ xhtmlHeaders(__FILE__, $SLANG['SystemLog'] ); - + @@ -115,35 +64,6 @@ xhtmlHeaders(__FILE__, $SLANG['SystemLog'] ); -
-
-
-
-
-
-
-
- - - - -
-
- - - - - -
-
- : -
- - - -
-
-
- +
{{ log.Log.TimeKey }} {{ log.Log.Component }} {{ log.Log.Pid }}