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:
@@ -738,6 +738,7 @@ phutil_register_library_map(array(
|
|||||||
'PhabricatorApplicationTransactions' => 'applications/transactions/application/PhabricatorApplicationTransactions.php',
|
'PhabricatorApplicationTransactions' => 'applications/transactions/application/PhabricatorApplicationTransactions.php',
|
||||||
'PhabricatorApplicationUIExamples' => 'applications/uiexample/application/PhabricatorApplicationUIExamples.php',
|
'PhabricatorApplicationUIExamples' => 'applications/uiexample/application/PhabricatorApplicationUIExamples.php',
|
||||||
'PhabricatorApplicationUninstallController' => 'applications/meta/controller/PhabricatorApplicationUninstallController.php',
|
'PhabricatorApplicationUninstallController' => 'applications/meta/controller/PhabricatorApplicationUninstallController.php',
|
||||||
|
'PhabricatorApplicationXHProf' => 'applications/xhprof/application/PhabricatorApplicationXHProf.php',
|
||||||
'PhabricatorApplicationsController' => 'applications/meta/controller/PhabricatorApplicationsController.php',
|
'PhabricatorApplicationsController' => 'applications/meta/controller/PhabricatorApplicationsController.php',
|
||||||
'PhabricatorApplicationsListController' => 'applications/meta/controller/PhabricatorApplicationsListController.php',
|
'PhabricatorApplicationsListController' => 'applications/meta/controller/PhabricatorApplicationsListController.php',
|
||||||
'PhabricatorAuditActionConstants' => 'applications/audit/constants/PhabricatorAuditActionConstants.php',
|
'PhabricatorAuditActionConstants' => 'applications/audit/constants/PhabricatorAuditActionConstants.php',
|
||||||
@@ -1473,7 +1474,6 @@ phutil_register_library_map(array(
|
|||||||
'PhabricatorXHProfProfileView' => 'applications/xhprof/view/PhabricatorXHProfProfileView.php',
|
'PhabricatorXHProfProfileView' => 'applications/xhprof/view/PhabricatorXHProfProfileView.php',
|
||||||
'PhabricatorXHProfSample' => 'applications/xhprof/storage/PhabricatorXHProfSample.php',
|
'PhabricatorXHProfSample' => 'applications/xhprof/storage/PhabricatorXHProfSample.php',
|
||||||
'PhabricatorXHProfSampleListController' => 'applications/xhprof/controller/PhabricatorXHProfSampleListController.php',
|
'PhabricatorXHProfSampleListController' => 'applications/xhprof/controller/PhabricatorXHProfSampleListController.php',
|
||||||
'PhabricatorXHProfSampleListView' => 'applications/xhprof/view/PhabricatorXHProfSampleListView.php',
|
|
||||||
'PhameBasicBlogSkin' => 'applications/phame/skins/PhameBasicBlogSkin.php',
|
'PhameBasicBlogSkin' => 'applications/phame/skins/PhameBasicBlogSkin.php',
|
||||||
'PhameBasicTemplateBlogSkin' => 'applications/phame/skins/PhameBasicTemplateBlogSkin.php',
|
'PhameBasicTemplateBlogSkin' => 'applications/phame/skins/PhameBasicTemplateBlogSkin.php',
|
||||||
'PhameBlog' => 'applications/phame/storage/PhameBlog.php',
|
'PhameBlog' => 'applications/phame/storage/PhameBlog.php',
|
||||||
@@ -2420,6 +2420,7 @@ phutil_register_library_map(array(
|
|||||||
'PhabricatorApplicationTransactions' => 'PhabricatorApplication',
|
'PhabricatorApplicationTransactions' => 'PhabricatorApplication',
|
||||||
'PhabricatorApplicationUIExamples' => 'PhabricatorApplication',
|
'PhabricatorApplicationUIExamples' => 'PhabricatorApplication',
|
||||||
'PhabricatorApplicationUninstallController' => 'PhabricatorApplicationsController',
|
'PhabricatorApplicationUninstallController' => 'PhabricatorApplicationsController',
|
||||||
|
'PhabricatorApplicationXHProf' => 'PhabricatorApplication',
|
||||||
'PhabricatorApplicationsController' => 'PhabricatorController',
|
'PhabricatorApplicationsController' => 'PhabricatorController',
|
||||||
'PhabricatorApplicationsListController' => 'PhabricatorApplicationsController',
|
'PhabricatorApplicationsListController' => 'PhabricatorApplicationsController',
|
||||||
'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController',
|
'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController',
|
||||||
@@ -3127,7 +3128,6 @@ phutil_register_library_map(array(
|
|||||||
'PhabricatorXHProfProfileView' => 'AphrontView',
|
'PhabricatorXHProfProfileView' => 'AphrontView',
|
||||||
'PhabricatorXHProfSample' => 'PhabricatorXHProfDAO',
|
'PhabricatorXHProfSample' => 'PhabricatorXHProfDAO',
|
||||||
'PhabricatorXHProfSampleListController' => 'PhabricatorXHProfController',
|
'PhabricatorXHProfSampleListController' => 'PhabricatorXHProfController',
|
||||||
'PhabricatorXHProfSampleListView' => 'AphrontView',
|
|
||||||
'PhameBasicBlogSkin' => 'PhameBlogSkin',
|
'PhameBasicBlogSkin' => 'PhameBlogSkin',
|
||||||
'PhameBasicTemplateBlogSkin' => 'PhameBasicBlogSkin',
|
'PhameBasicTemplateBlogSkin' => 'PhameBasicBlogSkin',
|
||||||
'PhameBlog' =>
|
'PhameBlog' =>
|
||||||
|
|||||||
@@ -68,11 +68,6 @@ class AphrontDefaultApplicationConfiguration
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
'/xhprof/' => array(
|
|
||||||
'list/(?P<view>[^/]+)/' => 'PhabricatorXHProfSampleListController',
|
|
||||||
'profile/(?P<phid>[^/]+)/' => 'PhabricatorXHProfProfileController',
|
|
||||||
),
|
|
||||||
|
|
||||||
'/~/' => array(
|
'/~/' => array(
|
||||||
'' => 'DarkConsoleController',
|
'' => 'DarkConsoleController',
|
||||||
'data/(?P<key>[^/]+)/' => 'DarkConsoleDataController',
|
'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;
|
private $view;
|
||||||
|
|
||||||
public function willProcessRequest(array $data) {
|
public function willProcessRequest(array $data) {
|
||||||
$this->view = $data['view'];
|
$this->view = idx($data, 'view', 'all');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
$user = $request->getUser();
|
||||||
|
|
||||||
$pager = new AphrontPagerView();
|
$pager = new AphrontPagerView();
|
||||||
$pager->setOffset($request->getInt('page'));
|
$pager->setOffset($request->getInt('page'));
|
||||||
@@ -39,7 +40,7 @@ final class PhabricatorXHProfSampleListController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$samples = id(new PhabricatorXHProfSample())->loadAllWhere(
|
$samples = id(new PhabricatorXHProfSample())->loadAllWhere(
|
||||||
'%Q ORDER BY dateCreated DESC LIMIT %d, %d',
|
'%Q ORDER BY id DESC LIMIT %d, %d',
|
||||||
$clause,
|
$clause,
|
||||||
$pager->getOffset(),
|
$pager->getOffset(),
|
||||||
$pager->getPageSize() + 1);
|
$pager->getPageSize() + 1);
|
||||||
@@ -47,19 +48,46 @@ final class PhabricatorXHProfSampleListController
|
|||||||
$samples = $pager->sliceResults($samples);
|
$samples = $pager->sliceResults($samples);
|
||||||
$pager->setURI($request->getRequestURI(), 'page');
|
$pager->setURI($request->getRequestURI(), 'page');
|
||||||
|
|
||||||
$table = new PhabricatorXHProfSampleListView();
|
$list = new PhabricatorObjectItemListView();
|
||||||
$table->setUser($request->getUser());
|
foreach ($samples as $sample) {
|
||||||
$table->setSamples($samples);
|
$file_phid = $sample->getFilePHID();
|
||||||
$table->setShowType($show_type);
|
|
||||||
|
|
||||||
$panel = new AphrontPanelView();
|
$item = id(new PhabricatorObjectItemView())
|
||||||
$panel->setHeader('XHProf Samples');
|
->setObjectName($sample->getID())
|
||||||
$panel->appendChild($table);
|
->setHeader($sample->getRequestPath())
|
||||||
$panel->appendChild($pager);
|
->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(
|
return $this->buildStandardPageResponse(
|
||||||
$panel,
|
$list,
|
||||||
array('title' => 'XHProf Samples'));
|
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user