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:
parent
2a39fd09eb
commit
4a76174118
4 changed files with 56 additions and 11 deletions
|
@ -22,6 +22,7 @@ class HeraldTranscriptListController extends HeraldController {
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
|
||||||
|
// Get one page of data together with the pager.
|
||||||
// Pull these objects manually since the serialized fields are gigantic.
|
// Pull these objects manually since the serialized fields are gigantic.
|
||||||
$transcript = new HeraldTranscript();
|
$transcript = new HeraldTranscript();
|
||||||
|
|
||||||
|
@ -32,18 +33,31 @@ class HeraldTranscriptListController extends HeraldController {
|
||||||
$where_clause = qsprintf(
|
$where_clause = qsprintf(
|
||||||
$conn_r,
|
$conn_r,
|
||||||
'WHERE objectPHID = %s',
|
'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(
|
$data = queryfx_all(
|
||||||
$conn_r,
|
$conn_r,
|
||||||
'SELECT id, objectPHID, time, duration, dryRun FROM %T
|
'SELECT id, objectPHID, time, duration, dryRun FROM %T
|
||||||
%Q
|
%Q
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC
|
||||||
LIMIT 100',
|
%Q',
|
||||||
$transcript->getTableName(),
|
$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);
|
$filter);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Render the table.
|
||||||
$handles = array();
|
$handles = array();
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$phids = ipull($data, 'objectPHID', 'objectPHID');
|
$phids = ipull($data, 'objectPHID', 'objectPHID');
|
||||||
|
@ -118,10 +133,11 @@ class HeraldTranscriptListController extends HeraldController {
|
||||||
'action',
|
'action',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Render the whole page.
|
||||||
$panel = new AphrontPanelView();
|
$panel = new AphrontPanelView();
|
||||||
$panel->setHeader('Herald Transcripts');
|
$panel->setHeader('Herald Transcripts');
|
||||||
$panel->appendChild($table);
|
$panel->appendChild($table);
|
||||||
|
$panel->appendChild($pager);
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildStandardPageResponse(
|
||||||
$panel,
|
$panel,
|
||||||
|
|
|
@ -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', 'applications/phid/handle/data');
|
||||||
phutil_require_module('phabricator', 'storage/qsprintf');
|
phutil_require_module('phabricator', 'storage/qsprintf');
|
||||||
phutil_require_module('phabricator', 'storage/queryfx');
|
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/control/table');
|
||||||
phutil_require_module('phabricator', 'view/layout/panel');
|
phutil_require_module('phabricator', 'view/layout/panel');
|
||||||
|
|
||||||
|
|
|
@ -19,17 +19,41 @@
|
||||||
class PhabricatorMetaMTAListController extends PhabricatorMetaMTAController {
|
class PhabricatorMetaMTAListController extends PhabricatorMetaMTAController {
|
||||||
|
|
||||||
public function processRequest() {
|
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) {
|
if ($related_phid) {
|
||||||
$mails = id(new PhabricatorMetaMTAMail())->loadAllWhere(
|
$where_clause = qsprintf(
|
||||||
'relatedPHID = %s ORDER BY id DESC LIMIT 100',
|
$conn_r,
|
||||||
|
'WHERE relatedPHID = %s',
|
||||||
$related_phid);
|
$related_phid);
|
||||||
} else {
|
} else {
|
||||||
$mails = id(new PhabricatorMetaMTAMail())->loadAllWhere(
|
$where_clause = 'WHERE 1 = 1';
|
||||||
'1 = 1 ORDER BY id DESC LIMIT 100');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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();
|
$rows = array();
|
||||||
foreach ($mails as $mail) {
|
foreach ($mails as $mail) {
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
|
@ -71,10 +95,12 @@ class PhabricatorMetaMTAListController extends PhabricatorMetaMTAController {
|
||||||
'action',
|
'action',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Render the whole page.
|
||||||
$panel = new AphrontPanelView();
|
$panel = new AphrontPanelView();
|
||||||
$panel->appendChild($table);
|
$panel->appendChild($table);
|
||||||
$panel->setHeader('MetaMTA Messages');
|
$panel->setHeader('MetaMTA Messages');
|
||||||
$panel->setCreateButton('Send New Message', '/mail/send/');
|
$panel->setCreateButton('Send New Message', '/mail/send/');
|
||||||
|
$panel->appendChild($pager);
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildStandardPageResponse(
|
||||||
$panel,
|
$panel,
|
||||||
|
|
|
@ -8,11 +8,13 @@
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'applications/metamta/controller/base');
|
phutil_require_module('phabricator', 'applications/metamta/controller/base');
|
||||||
phutil_require_module('phabricator', 'applications/metamta/storage/mail');
|
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/control/table');
|
||||||
phutil_require_module('phabricator', 'view/layout/panel');
|
phutil_require_module('phabricator', 'view/layout/panel');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'markup');
|
phutil_require_module('phutil', 'markup');
|
||||||
phutil_require_module('phutil', 'utils');
|
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('PhabricatorMetaMTAListController.php');
|
phutil_require_source('PhabricatorMetaMTAListController.php');
|
||||||
|
|
Loading…
Reference in a new issue