[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.
This commit is contained in:
parent
003b8c79b6
commit
2a24f90ed0
@ -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');
|
||||
}
|
||||
|
||||
@ -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');
|
||||
|
||||
?>
|
||||
|
||||
@ -1,6 +1,25 @@
|
||||
<article class="module width_3_quarter">
|
||||
<header><h3>{count($WORKERS)} Current Active Pool Workers</h3></header>
|
||||
<table class="tablesorter" cellspacing="0">
|
||||
<header><h3>{$GLOBAL.workers} Current Active Pool Workers</h3></header>
|
||||
<form action="{$smarty.server.PHP_SELF}">
|
||||
<input type="hidden" name="page" value="{$smarty.request.page|escape}" />
|
||||
<input type="hidden" name="action" value="{$smarty.request.action|escape}" />
|
||||
<table cellspacing="0" class="tablesorter">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="left">
|
||||
{if $smarty.request.start|default:"0" > 0}
|
||||
<a href="{$smarty.server.PHP_SELF}?page={$smarty.request.page|escape}&action={$smarty.request.action|escape}&start={$smarty.request.start|escape|default:"0" - $LIMIT}{if $FILTERS|default:""}{$FILTERS}{/if}"><i class="icon-left-open"></i></a>
|
||||
{else}
|
||||
<i class="icon-left-open"></i>
|
||||
{/if}
|
||||
</td>
|
||||
<td align="right">
|
||||
<a href="{$smarty.server.PHP_SELF}?page={$smarty.request.page|escape}&action={$smarty.request.action|escape}&start={$smarty.request.start|escape|default:"0" + $LIMIT}{if $FILTERS|default:""}{$FILTERS}{/if}"><i class="icon-right-open"></i></a>
|
||||
</td>
|
||||
</tbody>
|
||||
</form>
|
||||
</table>
|
||||
<table class="tablesorter" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="left">Worker Name</th>
|
||||
@ -14,7 +33,7 @@
|
||||
</thead>
|
||||
{nocache}
|
||||
{section worker $WORKERS}
|
||||
<tbody>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="left">{$WORKERS[worker].username|escape}</td>
|
||||
<td align="left">{$WORKERS[worker].password|escape}</td>
|
||||
@ -28,6 +47,6 @@
|
||||
</tr>
|
||||
{/section}
|
||||
{/nocache}
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
</article>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user