mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +01:00
Fix XHProf index page
Summary: Ref T2870. This resolves a few issues: - No proper Application. Define one. - Routes are in the default controller. Move them to the application. - UI doesn't work on mobile. - Overescaping in the link column. Test Plan: Old page: {F38444} New page: {F38445} Reviewers: btrahan, chad Reviewed By: chad CC: aran, AnhNhan, edward Maniphest Tasks: T2870 Differential Revision: https://secure.phabricator.com/D5531
This commit is contained in:
parent
c73e888ad4
commit
0f9bfa3bfd
5 changed files with 78 additions and 97 deletions
|
@ -738,6 +738,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorApplicationTransactions' => 'applications/transactions/application/PhabricatorApplicationTransactions.php',
|
||||
'PhabricatorApplicationUIExamples' => 'applications/uiexample/application/PhabricatorApplicationUIExamples.php',
|
||||
'PhabricatorApplicationUninstallController' => 'applications/meta/controller/PhabricatorApplicationUninstallController.php',
|
||||
'PhabricatorApplicationXHProf' => 'applications/xhprof/application/PhabricatorApplicationXHProf.php',
|
||||
'PhabricatorApplicationsController' => 'applications/meta/controller/PhabricatorApplicationsController.php',
|
||||
'PhabricatorApplicationsListController' => 'applications/meta/controller/PhabricatorApplicationsListController.php',
|
||||
'PhabricatorAuditActionConstants' => 'applications/audit/constants/PhabricatorAuditActionConstants.php',
|
||||
|
@ -1473,7 +1474,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorXHProfProfileView' => 'applications/xhprof/view/PhabricatorXHProfProfileView.php',
|
||||
'PhabricatorXHProfSample' => 'applications/xhprof/storage/PhabricatorXHProfSample.php',
|
||||
'PhabricatorXHProfSampleListController' => 'applications/xhprof/controller/PhabricatorXHProfSampleListController.php',
|
||||
'PhabricatorXHProfSampleListView' => 'applications/xhprof/view/PhabricatorXHProfSampleListView.php',
|
||||
'PhameBasicBlogSkin' => 'applications/phame/skins/PhameBasicBlogSkin.php',
|
||||
'PhameBasicTemplateBlogSkin' => 'applications/phame/skins/PhameBasicTemplateBlogSkin.php',
|
||||
'PhameBlog' => 'applications/phame/storage/PhameBlog.php',
|
||||
|
@ -2420,6 +2420,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorApplicationTransactions' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationUIExamples' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationUninstallController' => 'PhabricatorApplicationsController',
|
||||
'PhabricatorApplicationXHProf' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationsController' => 'PhabricatorController',
|
||||
'PhabricatorApplicationsListController' => 'PhabricatorApplicationsController',
|
||||
'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController',
|
||||
|
@ -3127,7 +3128,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorXHProfProfileView' => 'AphrontView',
|
||||
'PhabricatorXHProfSample' => 'PhabricatorXHProfDAO',
|
||||
'PhabricatorXHProfSampleListController' => 'PhabricatorXHProfController',
|
||||
'PhabricatorXHProfSampleListView' => 'AphrontView',
|
||||
'PhameBasicBlogSkin' => 'PhameBlogSkin',
|
||||
'PhameBasicTemplateBlogSkin' => 'PhameBasicBlogSkin',
|
||||
'PhameBlog' =>
|
||||
|
|
|
@ -68,11 +68,6 @@ class AphrontDefaultApplicationConfiguration
|
|||
),
|
||||
),
|
||||
|
||||
'/xhprof/' => array(
|
||||
'list/(?P<view>[^/]+)/' => 'PhabricatorXHProfSampleListController',
|
||||
'profile/(?P<phid>[^/]+)/' => 'PhabricatorXHProfProfileController',
|
||||
),
|
||||
|
||||
'/~/' => array(
|
||||
'' => 'DarkConsoleController',
|
||||
'data/(?P<key>[^/]+)/' => 'DarkConsoleDataController',
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorApplicationXHProf extends PhabricatorApplication {
|
||||
|
||||
public function getBaseURI() {
|
||||
return '/xhprof/';
|
||||
}
|
||||
|
||||
public function getShortDescription() {
|
||||
return pht('PHP Profiling Tool');
|
||||
}
|
||||
|
||||
public function getIconName() {
|
||||
return 'xhprof';
|
||||
}
|
||||
|
||||
public function getTitleGlyph() {
|
||||
return "\xE2\x98\x84";
|
||||
}
|
||||
|
||||
public function getApplicationGroup() {
|
||||
return self::GROUP_DEVELOPER;
|
||||
}
|
||||
|
||||
public function getRoutes() {
|
||||
return array(
|
||||
'/xhprof/' => array(
|
||||
'' => 'PhabricatorXHProfSampleListController',
|
||||
'list/(?P<view>[^/]+)/' => 'PhabricatorXHProfSampleListController',
|
||||
'profile/(?P<phid>[^/]+)/' => 'PhabricatorXHProfProfileController',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -6,11 +6,12 @@ final class PhabricatorXHProfSampleListController
|
|||
private $view;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->view = $data['view'];
|
||||
$this->view = idx($data, 'view', 'all');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$pager = new AphrontPagerView();
|
||||
$pager->setOffset($request->getInt('page'));
|
||||
|
@ -39,7 +40,7 @@ final class PhabricatorXHProfSampleListController
|
|||
}
|
||||
|
||||
$samples = id(new PhabricatorXHProfSample())->loadAllWhere(
|
||||
'%Q ORDER BY dateCreated DESC LIMIT %d, %d',
|
||||
'%Q ORDER BY id DESC LIMIT %d, %d',
|
||||
$clause,
|
||||
$pager->getOffset(),
|
||||
$pager->getPageSize() + 1);
|
||||
|
@ -47,19 +48,46 @@ final class PhabricatorXHProfSampleListController
|
|||
$samples = $pager->sliceResults($samples);
|
||||
$pager->setURI($request->getRequestURI(), 'page');
|
||||
|
||||
$table = new PhabricatorXHProfSampleListView();
|
||||
$table->setUser($request->getUser());
|
||||
$table->setSamples($samples);
|
||||
$table->setShowType($show_type);
|
||||
$list = new PhabricatorObjectItemListView();
|
||||
foreach ($samples as $sample) {
|
||||
$file_phid = $sample->getFilePHID();
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader('XHProf Samples');
|
||||
$panel->appendChild($table);
|
||||
$panel->appendChild($pager);
|
||||
$item = id(new PhabricatorObjectItemView())
|
||||
->setObjectName($sample->getID())
|
||||
->setHeader($sample->getRequestPath())
|
||||
->setHref($this->getApplicationURI('profile/'.$file_phid.'/'))
|
||||
->addAttribute(
|
||||
number_format($sample->getUsTotal())." \xCE\xBCs");
|
||||
|
||||
if ($sample->getController()) {
|
||||
$item->addAttribute($sample->getController());
|
||||
}
|
||||
|
||||
$item->addAttribute($sample->getHostName());
|
||||
|
||||
$rate = $sample->getSampleRate();
|
||||
if ($rate == 0) {
|
||||
$item->addIcon('flag-6', pht('Manual Run'));
|
||||
} else {
|
||||
$item->addIcon('flag-7', pht('Sampled (1/%d)', $rate));
|
||||
}
|
||||
|
||||
$item->addIcon(
|
||||
'none',
|
||||
phabricator_datetime($sample->getDateCreated(), $user));
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
$list->setPager($pager);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$panel,
|
||||
array('title' => 'XHProf Samples'));
|
||||
$list,
|
||||
array(
|
||||
'title' => pht('XHProf Samples'),
|
||||
'device' => true,
|
||||
'dust' => true,
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorXHProfSampleListView extends AphrontView {
|
||||
|
||||
private $samples;
|
||||
private $showType = false;
|
||||
|
||||
public function setSamples(array $samples) {
|
||||
assert_instances_of($samples, 'PhabricatorXHProfSample');
|
||||
$this->samples = $samples;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setShowType($show_type) {
|
||||
$this->showType = $show_type;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$rows = array();
|
||||
|
||||
if (!$this->user) {
|
||||
throw new Exception("Call setUser() before rendering!");
|
||||
}
|
||||
|
||||
$user_phids = mpull($this->samples, 'getUserPHID');
|
||||
$users = id(new PhabricatorObjectHandleData($user_phids))
|
||||
->setViewer($this->getUser())
|
||||
->loadObjects();
|
||||
foreach ($this->samples as $sample) {
|
||||
$sample_link = phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/xhprof/profile/'.$sample->getFilePHID().'/',
|
||||
),
|
||||
$sample->getFilePHID());
|
||||
if ($this->showType) {
|
||||
if ($sample->getSampleRate() == 0) {
|
||||
$sample_link .= ' (manual run)';
|
||||
} else {
|
||||
$sample_link .= ' (sampled)';
|
||||
}
|
||||
}
|
||||
$rows[] = array(
|
||||
$sample_link,
|
||||
phabricator_datetime($sample->getDateCreated(), $this->user),
|
||||
number_format($sample->getUsTotal())." \xCE\xBCs",
|
||||
$sample->getHostname(),
|
||||
$sample->getRequestPath(),
|
||||
$sample->getController(),
|
||||
idx($users, $sample->getUserPHID()),
|
||||
);
|
||||
}
|
||||
|
||||
$table = new AphrontTableView($rows);
|
||||
$table->setHeaders(
|
||||
array(
|
||||
'Sample',
|
||||
'Date',
|
||||
'Wall Time',
|
||||
'Hostname',
|
||||
'Request Path',
|
||||
'Controller',
|
||||
'User',
|
||||
));
|
||||
$table->setColumnClasses(
|
||||
array(
|
||||
'',
|
||||
'',
|
||||
'right',
|
||||
'wide wrap',
|
||||
'',
|
||||
'',
|
||||
));
|
||||
|
||||
return $table->render();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue