1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

Adding paging to transcript pages

Summary:
enable paging by adding a AphrontPagerView to the two
transcript page.

Test Plan:
test the paging on both pages. Also test it with a certain
phid is given.

Reviewed By: epriestley
Reviewers: epriestley, tuomaspelkonen
CC: epriestley, jungejason
Differential Revision: 116
This commit is contained in:
jungejason 2011-04-08 16:15:00 -07:00
parent 2a39fd09eb
commit 4a76174118
4 changed files with 56 additions and 11 deletions

View file

@ -22,6 +22,7 @@ class HeraldTranscriptListController extends HeraldController {
$request = $this->getRequest();
// Get one page of data together with the pager.
// Pull these objects manually since the serialized fields are gigantic.
$transcript = new HeraldTranscript();
@ -32,18 +33,31 @@ class HeraldTranscriptListController extends HeraldController {
$where_clause = qsprintf(
$conn_r,
'WHERE objectPHID = %s',
$phid
);
$phid);
}
$offset = $request->getInt('offset', 0);
$page_size = 100;
$limit_clause = qsprintf(
$conn_r,
'LIMIT %d, %d',
$offset, $page_size + 1);
$data = queryfx_all(
$conn_r,
'SELECT id, objectPHID, time, duration, dryRun FROM %T
%Q
ORDER BY id DESC
LIMIT 100',
%Q',
$transcript->getTableName(),
$where_clause);
$where_clause,
$limit_clause);
$pager = new AphrontPagerView();
$pager->getPageSize($page_size);
$pager->setHasMorePages(count($data) == $page_size + 1);
$pager->setOffset($offset);
$pager->setURI($request->getRequestURI(), 'offset');
/*
@ -73,6 +87,7 @@ class HeraldTranscriptListController extends HeraldController {
$filter);
*/
// Render the table.
$handles = array();
if ($data) {
$phids = ipull($data, 'objectPHID', 'objectPHID');
@ -118,10 +133,11 @@ class HeraldTranscriptListController extends HeraldController {
'action',
));
// Render the whole page.
$panel = new AphrontPanelView();
$panel->setHeader('Herald Transcripts');
$panel->appendChild($table);
$panel->appendChild($pager);
return $this->buildStandardPageResponse(
$panel,

View file

@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'applications/herald/storage/transcript/bas
phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'storage/qsprintf');
phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phabricator', 'view/control/pager');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel');

View file

@ -19,17 +19,41 @@
class PhabricatorMetaMTAListController extends PhabricatorMetaMTAController {
public function processRequest() {
$related_phid = $this->getRequest()->getStr('phid');
// Get a page of mails together with pager.
$request = $this->getRequest();
$offset = $request->getInt('offset', 0);
$related_phid = $request->getStr('phid');
$pager = new AphrontPagerView();
$pager->setOffset($offset);
$pager->setURI($request->getRequestURI(), 'offset');
$mail = new PhabricatorMetaMTAMail();
$conn_r = $mail->establishConnection('r');
if ($related_phid) {
$mails = id(new PhabricatorMetaMTAMail())->loadAllWhere(
'relatedPHID = %s ORDER BY id DESC LIMIT 100',
$where_clause = qsprintf(
$conn_r,
'WHERE relatedPHID = %s',
$related_phid);
} else {
$mails = id(new PhabricatorMetaMTAMail())->loadAllWhere(
'1 = 1 ORDER BY id DESC LIMIT 100');
$where_clause = 'WHERE 1 = 1';
}
$data = queryfx_all(
$conn_r,
'SELECT * FROM %T
%Q
ORDER BY id DESC
LIMIT %d, %d',
$mail->getTableName(),
$where_clause,
$pager->getOffset(), $pager->getPageSize() + 1);
$data = $pager->sliceResults($data);
$mails = $mail->loadAllFromArray($data);
// Render the details table.
$rows = array();
foreach ($mails as $mail) {
$rows[] = array(
@ -71,10 +95,12 @@ class PhabricatorMetaMTAListController extends PhabricatorMetaMTAController {
'action',
));
// Render the whole page.
$panel = new AphrontPanelView();
$panel->appendChild($table);
$panel->setHeader('MetaMTA Messages');
$panel->setCreateButton('Send New Message', '/mail/send/');
$panel->appendChild($pager);
return $this->buildStandardPageResponse(
$panel,

View file

@ -8,11 +8,13 @@
phutil_require_module('phabricator', 'applications/metamta/controller/base');
phutil_require_module('phabricator', 'applications/metamta/storage/mail');
phutil_require_module('phabricator', 'storage/qsprintf');
phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phabricator', 'view/control/pager');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorMetaMTAListController.php');