1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-13 18:32:41 +01:00
phorge-phorge/src/applications/notification/controller/PhabricatorNotificationStatusController.php

69 lines
1.7 KiB
PHP
Raw Normal View History

<?php
final class PhabricatorNotificationStatusController
extends PhabricatorNotificationController {
public function processRequest() {
try {
$status = PhabricatorNotificationClient::getServerStatus();
$status = $this->renderServerStatus($status);
} catch (Exception $ex) {
$status = new AphrontErrorView();
$status->setTitle("Notification Server Issue");
$status->appendChild(hsprintf(
'Unable to determine server status. This probably means the server '.
'is not in great shape. The specific issue encountered was:'.
'<br />'.
'<br />'.
'<strong>%s</strong> %s',
get_class($ex),
phutil_escape_html_newlines($ex->getMessage())));
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Status'));
return $this->buildApplicationPage(
array(
$crumbs,
$status,
),
array(
'title' => pht('Notification Server Status'),
));
}
private function renderServerStatus(array $status) {
$rows = array();
foreach ($status as $key => $value) {
switch ($key) {
case 'uptime':
$value /= 1000;
$value = phabricator_format_relative_time_detailed($value);
break;
case 'log':
break;
default:
2013-02-13 23:50:15 +01:00
$value = number_format($value);
break;
}
2013-02-13 23:50:15 +01:00
$rows[] = array($key, $value);
}
$table = new AphrontTableView($rows);
$table->setColumnClasses(
array(
'header',
'wide',
));
$box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Server Status'))
->appendChild($table);
return $box;
}
}