From 2a24f90ed00aa1862a35b0b8f83997f108258a78 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 23 Dec 2013 23:04:13 +0100 Subject: [PATCH] [ADDED] Pagination support on pool workers page Adds pagination support for the admin panel pool workers page. Will greatly increase loading times of this page if working as intended. Fixes another part of #1043. --- public/include/classes/worker.class.php | 6 ++-- .../include/pages/admin/poolworkers.inc.php | 11 +++++-- .../mpos/admin/poolworkers/default.tpl | 29 +++++++++++++++---- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/public/include/classes/worker.class.php b/public/include/classes/worker.class.php index 66a14365..2d0e606f 100644 --- a/public/include/classes/worker.class.php +++ b/public/include/classes/worker.class.php @@ -153,7 +153,7 @@ class Worker extends Base { * @param limit int * @return mixed array Workers and their settings or false **/ - public function getAllWorkers($iLimit=0, $interval=600) { + public function getAllWorkers($iLimit=0, $interval=600, $start=0) { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare(" SELECT id, username, password, monitor, @@ -191,8 +191,8 @@ class Worker extends Base { WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL ? SECOND) )) AS avg_difficulty FROM $this->table AS w - ORDER BY hashrate DESC LIMIT ?"); - if ($this->checkStmt($stmt) && $stmt->bind_param('iiiiiiiii', $interval, $interval, $interval, $interval, $interval, $interval, $interval, $interval, $iLimit) && $stmt->execute() && $result = $stmt->get_result()) + ORDER BY hashrate DESC LIMIT ?,?"); + if ($this->checkStmt($stmt) && $stmt->bind_param('iiiiiiiiii', $interval, $interval, $interval, $interval, $interval, $interval, $interval, $interval, $start, $iLimit) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_all(MYSQLI_ASSOC); return $this->sqlError('E0057'); } diff --git a/public/include/pages/admin/poolworkers.inc.php b/public/include/pages/admin/poolworkers.inc.php index 54ea4e3c..814d6c07 100644 --- a/public/include/pages/admin/poolworkers.inc.php +++ b/public/include/pages/admin/poolworkers.inc.php @@ -8,11 +8,16 @@ if (!$user->isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) { die("404 Page not found"); } - $iActiveWorkers = $worker->getCountAllActiveWorkers(); - $aWorkers = $worker->getAllWorkers($iActiveWorkers); +// Some defaults +$interval = 600; +$iActiveWorkers = $worker->getCountAllActiveWorkers(); +$iActiveWorkers > 30 ? $iLimit = 30 : $iLimit = $iActiveWorkers; +empty($_REQUEST['start']) ? $start = 0 : $start = $_REQUEST['start']; - $smarty->assign('WORKERS', $aWorkers); +$aWorkers = $worker->getAllWorkers($iLimit, $interval, $start); +$smarty->assign('LIMIT', $iLimit); +$smarty->assign('WORKERS', $aWorkers); $smarty->assign('CONTENT', 'default.tpl'); ?> diff --git a/public/templates/mpos/admin/poolworkers/default.tpl b/public/templates/mpos/admin/poolworkers/default.tpl index b9b7cc8a..3af8fece 100644 --- a/public/templates/mpos/admin/poolworkers/default.tpl +++ b/public/templates/mpos/admin/poolworkers/default.tpl @@ -1,6 +1,25 @@
-

{count($WORKERS)} Current Active Pool Workers

- +

{$GLOBAL.workers} Current Active Pool Workers

+ + + +
+ + + + + + +
+{if $smarty.request.start|default:"0" > 0} + +{else} + +{/if} + + +
+ @@ -14,7 +33,7 @@ {nocache} {section worker $WORKERS} - + @@ -28,6 +47,6 @@ {/section} {/nocache} - -
Worker Name
{$WORKERS[worker].username|escape} {$WORKERS[worker].password|escape}
+ +