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-02-13 23:08:57 +01:00
|
|
|
$out[] =
|
2011-09-30 21:54:17 +02:00
|
|
|
'<div class="dark-console-panel-header">'.
|
|
|
|
'<h1>Registered Event Listeners</h1>'.
|
2013-02-13 23:08:57 +01:00
|
|
|
'</div>';
|
2011-09-30 21:54:17 +02:00
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($data['listeners'] as $listener) {
|
2013-02-13 23:08:57 +01:00
|
|
|
$rows[] = array(
|
|
|
|
phutil_escape_html($listener['id']),
|
|
|
|
phutil_escape_html($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-02-13 23:08:57 +01:00
|
|
|
$out[] =
|
2011-09-30 21:54:17 +02:00
|
|
|
'<div class="dark-console-panel-header">'.
|
|
|
|
'<h1>Event Log</h1>'.
|
2013-02-13 23:08:57 +01:00
|
|
|
'</div>';
|
2011-09-30 21:54:17 +02:00
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($data['events'] as $event) {
|
|
|
|
$rows[] = array(
|
2013-02-13 23:08:57 +01:00
|
|
|
phutil_escape_html($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:08:57 +01:00
|
|
|
return implode("\n", $out);
|
2011-09-30 21:54:17 +02:00
|
|
|
}
|
|
|
|
}
|