2011-09-30 21:54:17 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group console
|
|
|
|
*/
|
2012-03-13 19:18:11 +01:00
|
|
|
final class DarkConsoleEventPlugin extends DarkConsolePlugin {
|
2011-09-30 21:54:17 +02:00
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
return 'Events';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription() {
|
|
|
|
return 'Information about Phabricator events and event listeners.';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function generateData() {
|
|
|
|
|
2011-11-10 02:23:33 +01:00
|
|
|
$listeners = PhutilEventEngine::getInstance()->getAllListeners();
|
2011-09-30 21:54:17 +02:00
|
|
|
foreach ($listeners as $key => $listener) {
|
|
|
|
$listeners[$key] = array(
|
|
|
|
'id' => $listener->getListenerID(),
|
|
|
|
'class' => get_class($listener),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$events = DarkConsoleEventPluginAPI::getEvents();
|
|
|
|
foreach ($events as $key => $event) {
|
|
|
|
$events[$key] = array(
|
|
|
|
'type' => $event->getType(),
|
|
|
|
'stopped' => $event->isStopped(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'listeners' => $listeners,
|
|
|
|
'events' => $events,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
public function renderPanel() {
|
2011-09-30 21:54:17 +02:00
|
|
|
$data = $this->getData();
|
|
|
|
|
|
|
|
$out = array();
|
|
|
|
|
2013-11-09 05:44:24 +01:00
|
|
|
$out[] = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array('class' => 'dark-console-panel-header'),
|
|
|
|
phutil_tag('h1', array(), pht('Registered Event Listeners')));
|
2011-09-30 21:54:17 +02:00
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($data['listeners'] as $listener) {
|
2013-02-13 23:50:15 +01:00
|
|
|
$rows[] = array($listener['id'], $listener['class']);
|
2011-09-30 21:54:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$table = new AphrontTableView($rows);
|
|
|
|
$table->setHeaders(
|
|
|
|
array(
|
|
|
|
'Internal ID',
|
|
|
|
'Listener Class',
|
|
|
|
));
|
|
|
|
$table->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'',
|
|
|
|
'wide',
|
|
|
|
));
|
|
|
|
|
|
|
|
$out[] = $table->render();
|
|
|
|
|
2013-11-09 05:44:24 +01:00
|
|
|
$out[] = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array('class' => 'dark-console-panel-header'),
|
|
|
|
phutil_tag('h1', array(), pht('Event Log')));
|
2011-09-30 21:54:17 +02:00
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($data['events'] as $event) {
|
|
|
|
$rows[] = array(
|
2013-02-13 23:50:15 +01:00
|
|
|
$event['type'],
|
2011-09-30 21:54:17 +02:00
|
|
|
$event['stopped'] ? 'STOPPED' : null,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = new AphrontTableView($rows);
|
|
|
|
$table->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'wide',
|
|
|
|
));
|
|
|
|
$table->setHeaders(
|
|
|
|
array(
|
|
|
|
'Event Type',
|
|
|
|
'Stopped',
|
|
|
|
));
|
|
|
|
|
|
|
|
$out[] = $table->render();
|
|
|
|
|
|
|
|
|
2013-02-13 23:50:15 +01:00
|
|
|
return phutil_implode_html("\n", $out);
|
2011-09-30 21:54:17 +02:00
|
|
|
}
|
|
|
|
}
|