diff options
author | 2009-06-22 12:03:38 -0400 | |
---|---|---|
committer | 2009-06-22 12:03:38 -0400 | |
commit | 1e127b6757ed929be2d051cf15d8cb0815f7a305 (patch) | |
tree | a3f20ac5953f136ea778454de78fd1ceeaadba72 | |
parent | Finished frontend restructuring (diff) | |
download | ingenue-1e127b6757ed929be2d051cf15d8cb0815f7a305.tar.gz ingenue-1e127b6757ed929be2d051cf15d8cb0815f7a305.tar.bz2 ingenue-1e127b6757ed929be2d051cf15d8cb0815f7a305.zip |
Added pagination to frontend log viewer; updated todo
-rw-r--r-- | frontend/pages/logview.php | 49 | ||||
-rw-r--r-- | frontend/routing.csv | 1 | ||||
-rw-r--r-- | shared/config.php | 1 | ||||
-rw-r--r-- | todo | 4 |
4 files changed, 38 insertions, 17 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(' ', 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"> </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="<<" 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=">>" 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(' ', 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 diff --git a/shared/config.php b/shared/config.php index 1eeb4ee..3b62b3f 100644 --- a/shared/config.php +++ b/shared/config.php @@ -14,4 +14,5 @@ $conf['check_email_dns']=true; // Use DNS to check the domain of submitted email $conf['pkgdir_root']='/home/eitan/soc/tinderbox'; // The directory to recursively search for pkgdirs in $conf['emerge_default_opts']='-t -K --color=n --root-deps=rdeps'; // DON'T CHANGE UNLESS YOU KNOW WHAT YOU'RE DOING $conf['portdir']='/usr/portage'; // The directory conatining the portage tree to use (/usr/portage unless you have a reason to think otherwise) +$conf['logview_max']=1000; ?> @@ -5,8 +5,6 @@ Move more functions into corresponding classes Give profiles an auto_increment ID so they can have their directories moved without breaking the db Have backend handle builds that it finds to already be running Add a PID file so backend can't start twice -Add pagination to log viewer Add extra package adding in frontend Implement extra packages in backend -Move the wizard steps into their own directory and just leave pages/wizard.php to handle everything (this will be a step towards backend modularity) -Plan out how the frontend should handle different distro modules +Plan out how the backend should handle different distro modules |