summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-06-22 12:03:38 -0400
committerEudyptula <eitan@mosenkis.net>2009-06-22 12:03:38 -0400
commit1e127b6757ed929be2d051cf15d8cb0815f7a305 (patch)
treea3f20ac5953f136ea778454de78fd1ceeaadba72 /frontend
parentFinished frontend restructuring (diff)
downloadingenue-1e127b6757ed929be2d051cf15d8cb0815f7a305.tar.gz
ingenue-1e127b6757ed929be2d051cf15d8cb0815f7a305.tar.bz2
ingenue-1e127b6757ed929be2d051cf15d8cb0815f7a305.zip
Added pagination to frontend log viewer; updated todo
Diffstat (limited to 'frontend')
-rw-r--r--frontend/pages/logview.php49
-rw-r--r--frontend/routing.csv1
2 files changed, 36 insertions, 14 deletions
diff --git a/frontend/pages/logview.php b/frontend/pages/logview.php
index 798bb85..176556a 100644
--- a/frontend/pages/logview.php
+++ b/frontend/pages/logview.php
@@ -5,7 +5,7 @@ function init_logview() {
$S['title']='Log Viewer';
}
function body_logview() {
- global $S, $request;
+ global $S, $request, $conf;
if (isset($request['task']) && is_numeric($request['task'])) {
$r=$S['pdo']->query('SELECT * FROM `tasks` WHERE `id`='.$request['task']);
if ($r->rowCount() == 0) {
@@ -24,19 +24,40 @@ function body_logview() {
echo '<span style="color: yellow">[running]</span>';
}
echo '</h3>';
- if (isset($request['task']) && is_numeric($request['task'])) {
- $s=$S['pdo']->query('SELECT * FROM `buildlogs` WHERE `task`='.$task->id.' ORDER BY `order` ASC');
- if ($s->rowCount()) {
- echo '<div style="font-family: monospace">';
- while ($entry=$s->fetch(PDO::FETCH_ASSOC)) {
- $entry=new sql_buildlog_entry($entry);
- $text=str_replace(array("\n", "\t"), array("<br/>\n", str_repeat('&nbsp;', 4)), htmlentities($entry->text));
- echo '<a name="entry_'.$task->id.'_'.$entry->order.'"'.($entry->stream=='stderr'?' style="color: red" ':'').' title="'.strtoupper($entry->stream).', entry #'.$entry->order.' @ '.date('D j M Y @ H:i:s', $entry->timestamp).' UTC">'.$text.'</a>';
- }
- echo '<a name="end">&nbsp;</a>';
- echo '</div>';
+ $page=isset($request['page']) && is_numeric($request['page'])?$request['page']:1;
+ $count=$S['pdo']->query('SELECT COUNT(*) FROM `buildlogs` WHERE `task`='.$task->id)->fetch(PDO::FETCH_COLUMN);
+ $pager='';
+ if ($count > $conf['logview_max']) {
+ $pager='<form action="'.url('logs/task'.$task->id).'" method="post" onsubmit="window.location.href=\''.url('logs/task'.$task->id).'/\'+this.page.value; return false">Page: ';
+ if ($page > 1) {
+ $pager.='<input type="button" value="&lt;&lt;" onclick="this.form.page.value='.($page-1).'; this.form.onsubmit()" /> '."\n";
+ }
+ $pager.='<select name="page">';
+ for ($i=1; ($i-1)*$conf['logview_max']<$count; $i++) {
+ $pager.="<option value=\"$i\"".($i==$page?'selected="selected"':'').">$i</option>\n";
+ }
+ $pager.='</select> <input type="submit" value="Go" />';
+ if ($page*$conf['logview_max']<$count) {
+ $pager.=' <input type="button" value="&gt;&gt;" onclick="this.form.page.value='.($page+1).'; this.form.onsubmit()" />'."\n";
+ }
+ $pager.='</form>';
+ echo $pager;
+ }
+ $r=$S['pdo']->query('SELECT * FROM `buildlogs` WHERE `task`='.$task->id.' ORDER BY `order` ASC LIMIT '.$conf['logview_max'].' OFFSET '.($page-1)*$conf['logview_max']);
+ if ($r->rowCount()) {
+ echo '<div style="font-family: monospace">';
+ while ($entry=$r->fetch(PDO::FETCH_ASSOC)) {
+ $entry=new sql_buildlog_entry($entry);
+ $text=str_replace(array("\n", "\t"), array("<br/>\n", str_repeat('&nbsp;', 4)), htmlentities($entry->text));
+ echo '<a name="entry_'.$task->id.'_'.$entry->order.'"'.($entry->stream=='stderr'?' style="color: red" ':'').' title="'.strtoupper($entry->stream).', entry #'.$entry->order.' @ '.date('D j M Y @ H:i:s', $entry->timestamp).' UTC">'.$text.'</a>';
+ }
+ echo '</div>';
+ echo $pager;
+ } else {
+ if ($count) {
+ echo print_error("There aren't $page pages. Try an <a href=\"".url('logs/task'.$task->id)."\">earlier page</a>.");
} else {
- echo '<b>No output</b>';
+ echo print_warning('No output');
}
}
} elseif (isset($request['build']) && preg_match('/[a-z0-9]{6}/', $request['build'])) {
@@ -48,7 +69,7 @@ function body_logview() {
$i=0;
while ($task=$r->fetch(PDO::FETCH_ASSOC)) {
$task=new sql_task($task);
- echo '<a href="'.url('logs/task'.$task->id).'#end">Task #'.++$i.'</a>: '.htmlentities($task->command).'<br/>';
+ echo '<a href="'.url('logs/task'.$task->id).'">Task #'.++$i.'</a>: '.htmlentities($task->command).'<br/>';
}
} else {
$r=$S['pdo']->query('SELECT * FROM `builds` ORDER BY `ctime` ASC');
diff --git a/frontend/routing.csv b/frontend/routing.csv
index e5cc44c..3d21751 100644
--- a/frontend/routing.csv
+++ b/frontend/routing.csv
@@ -15,6 +15,7 @@
^logs$ logview
^logs/build([a-z0-9]{6})$ logview build
^logs/task([0-9]+)$ logview task
+^logs/task([0-9]+)/([0-9]+)$ logview task page
# Build creation
^create$ wizard
^create/([a-zA-Z0-9]{6})$ wizard build