2011-03-25 05:32:26 +01:00
|
|
|
<?php
|
|
|
|
|
2014-02-21 21:51:25 +01:00
|
|
|
final class HeraldTranscriptListController extends HeraldController
|
|
|
|
implements PhabricatorApplicationSearchResultsControllerInterface {
|
2011-03-25 05:32:26 +01:00
|
|
|
|
2014-02-21 21:51:25 +01:00
|
|
|
private $queryKey;
|
2011-03-25 05:32:26 +01:00
|
|
|
|
2014-02-21 21:51:25 +01:00
|
|
|
public function buildSideNavView($for_app = false) {
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$nav = new AphrontSideNavFilterView();
|
|
|
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
2011-03-25 05:32:26 +01:00
|
|
|
|
2014-02-21 21:51:25 +01:00
|
|
|
if ($for_app) {
|
|
|
|
$nav->addFilter('new', pht('Create Rule'));
|
|
|
|
}
|
2011-04-07 23:24:54 +02:00
|
|
|
|
2014-02-21 21:51:25 +01:00
|
|
|
id(new HeraldTranscriptSearchEngine())
|
2013-10-05 00:17:18 +02:00
|
|
|
->setViewer($user)
|
2014-02-21 21:51:25 +01:00
|
|
|
->addNavigationItems($nav->getMenu());
|
|
|
|
|
|
|
|
$nav->selectFilter(null);
|
|
|
|
|
|
|
|
return $nav;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildApplicationCrumbs() {
|
|
|
|
$crumbs = parent::buildApplicationCrumbs();
|
|
|
|
|
|
|
|
$crumbs->addTextCrumb(
|
|
|
|
pht('Transcripts'),
|
|
|
|
$this->getApplicationURI('transcript/'));
|
|
|
|
return $crumbs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->queryKey = idx($data, 'queryKey');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$controller = id(new PhabricatorApplicationSearchController($request))
|
|
|
|
->setQueryKey($this->queryKey)
|
|
|
|
->setSearchEngine(new HeraldTranscriptSearchEngine())
|
|
|
|
->setNavigation($this->buildSideNavView());
|
|
|
|
|
|
|
|
return $this->delegateToController($controller);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function renderResultsList(
|
|
|
|
array $transcripts,
|
|
|
|
PhabricatorSavedQuery $query) {
|
|
|
|
assert_instances_of($transcripts, 'HeraldTranscript');
|
|
|
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
2011-03-25 05:32:26 +01:00
|
|
|
|
2011-04-09 01:15:00 +02:00
|
|
|
// Render the table.
|
2011-03-25 05:32:26 +01:00
|
|
|
$handles = array();
|
2013-10-05 00:17:18 +02:00
|
|
|
if ($transcripts) {
|
|
|
|
$phids = mpull($transcripts, 'getObjectPHID', 'getObjectPHID');
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($phids);
|
2011-03-25 05:32:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$rows = array();
|
2013-10-05 00:17:18 +02:00
|
|
|
foreach ($transcripts as $xscript) {
|
2011-03-25 05:32:26 +01:00
|
|
|
$rows[] = array(
|
2014-02-21 21:51:25 +01:00
|
|
|
phabricator_date($xscript->getTime(), $viewer),
|
|
|
|
phabricator_time($xscript->getTime(), $viewer),
|
2013-10-05 00:17:18 +02:00
|
|
|
$handles[$xscript->getObjectPHID()]->renderLink(),
|
|
|
|
$xscript->getDryRun() ? pht('Yes') : '',
|
|
|
|
number_format((int)(1000 * $xscript->getDuration())).' ms',
|
2013-01-18 03:57:09 +01:00
|
|
|
phutil_tag(
|
2011-03-25 05:32:26 +01:00
|
|
|
'a',
|
|
|
|
array(
|
2013-10-05 00:17:18 +02:00
|
|
|
'href' => '/herald/transcript/'.$xscript->getID().'/',
|
2011-03-25 05:32:26 +01:00
|
|
|
'class' => 'button small grey',
|
|
|
|
),
|
2013-05-20 17:24:07 +02:00
|
|
|
pht('View Transcript')),
|
2011-03-25 05:32:26 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = new AphrontTableView($rows);
|
|
|
|
$table->setHeaders(
|
|
|
|
array(
|
2013-05-20 17:24:07 +02:00
|
|
|
pht('Date'),
|
|
|
|
pht('Time'),
|
|
|
|
pht('Object'),
|
|
|
|
pht('Dry Run'),
|
|
|
|
pht('Duration'),
|
|
|
|
pht('View'),
|
2011-03-25 05:32:26 +01:00
|
|
|
));
|
|
|
|
$table->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'',
|
|
|
|
'right',
|
|
|
|
'wide wrap',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'action',
|
|
|
|
));
|
|
|
|
|
2011-04-09 01:15:00 +02:00
|
|
|
// Render the whole page.
|
2011-03-25 05:32:26 +01:00
|
|
|
$panel = new AphrontPanelView();
|
2013-01-19 21:15:41 +01:00
|
|
|
$panel->setHeader(pht('Herald Transcripts'));
|
2011-03-25 05:32:26 +01:00
|
|
|
$panel->appendChild($table);
|
2013-01-19 21:15:41 +01:00
|
|
|
$panel->setNoBackground();
|
2011-03-25 05:32:26 +01:00
|
|
|
|
2014-02-21 21:51:25 +01:00
|
|
|
return $panel;
|
2013-01-21 16:46:13 +01:00
|
|
|
|
2011-03-25 05:32:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|