Changeset View
Changeset View
Standalone View
Standalone View
src/applications/daemon/view/PhabricatorDaemonLogListView.php
<?php | <?php | ||||
final class PhabricatorDaemonLogListView extends AphrontView { | final class PhabricatorDaemonLogListView extends AphrontView { | ||||
private $daemonLogs; | private $daemonLogs; | ||||
public function setDaemonLogs(array $daemon_logs) { | public function setDaemonLogs(array $daemon_logs) { | ||||
assert_instances_of($daemon_logs, 'PhabricatorDaemonLog'); | assert_instances_of($daemon_logs, 'PhabricatorDaemonLog'); | ||||
$this->daemonLogs = $daemon_logs; | $this->daemonLogs = $daemon_logs; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function render() { | public function render() { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$rows = array(); | $rows = array(); | ||||
$daemons = $this->daemonLogs; | |||||
$list = new PHUIObjectItemListView(); | foreach ($daemons as $daemon) { | ||||
$list->setFlush(true); | $id = $daemon->getID(); | ||||
foreach ($this->daemonLogs as $log) { | $host = $daemon->getHost(); | ||||
$id = $log->getID(); | $pid = $daemon->getPID(); | ||||
$epoch = $log->getDateCreated(); | $name = phutil_tag( | ||||
'a', | |||||
$item = id(new PHUIObjectItemView()) | array( | ||||
->setObjectName(pht('Daemon %s', $id)) | 'href' => "/daemon/log/{$id}/", | ||||
->setHeader($log->getDaemon()) | ), | ||||
->setHref("/daemon/log/{$id}/") | $daemon->getDaemon()); | ||||
->addIcon('none', phabricator_datetime($epoch, $viewer)); | |||||
$status = $log->getStatus(); | $status = $daemon->getStatus(); | ||||
switch ($status) { | switch ($status) { | ||||
case PhabricatorDaemonLog::STATUS_RUNNING: | case PhabricatorDaemonLog::STATUS_RUNNING: | ||||
$item->setStatusIcon('fa-rocket green'); | $status_icon = 'fa-rocket green'; | ||||
$item->addAttribute(pht('This daemon is running.')); | $status_label = pht('Running'); | ||||
$status_tip = pht('This daemon is running.'); | |||||
break; | break; | ||||
case PhabricatorDaemonLog::STATUS_DEAD: | case PhabricatorDaemonLog::STATUS_DEAD: | ||||
$item->setStatusIcon('fa-warning red'); | $status_icon = 'fa-warning red'; | ||||
$item->addAttribute( | $status_label = pht('Dead'); | ||||
pht( | $status_tip = pht( | ||||
'This daemon is lost or exited uncleanly, and is presumed '. | 'This daemon has been lost or exited uncleanly, and is '. | ||||
'dead.')); | 'presumed dead.'); | ||||
$item->addIcon('fa-times grey', pht('Dead')); | |||||
break; | break; | ||||
case PhabricatorDaemonLog::STATUS_EXITING: | case PhabricatorDaemonLog::STATUS_EXITING: | ||||
$item->addAttribute(pht('This daemon is exiting.')); | $status_icon = 'fa-check'; | ||||
$item->addIcon('fa-check', pht('Exiting')); | $status_label = pht('Shutting Down'); | ||||
$status_tip = pht('This daemon is shutting down.'); | |||||
break; | break; | ||||
case PhabricatorDaemonLog::STATUS_EXITED: | case PhabricatorDaemonLog::STATUS_EXITED: | ||||
$item->setDisabled(true); | $status_icon = 'fa-check grey'; | ||||
$item->addAttribute(pht('This daemon exited cleanly.')); | $status_label = pht('Exited'); | ||||
$item->addIcon('fa-check grey', pht('Exited')); | $status_tip = pht('This daemon exited cleanly.'); | ||||
break; | break; | ||||
case PhabricatorDaemonLog::STATUS_WAIT: | case PhabricatorDaemonLog::STATUS_WAIT: | ||||
$item->setStatusIcon('fa-clock-o blue'); | $status_icon = 'fa-clock-o blue'; | ||||
$item->addAttribute( | $status_label = pht('Waiting'); | ||||
pht( | $status_tip = pht( | ||||
'This daemon encountered an error recently and is waiting a '. | 'This daemon encountered an error recently and is waiting a '. | ||||
'moment to restart.')); | 'moment to restart.'); | ||||
$item->addIcon('fa-clock-o grey', pht('Waiting')); | |||||
break; | break; | ||||
case PhabricatorDaemonLog::STATUS_UNKNOWN: | case PhabricatorDaemonLog::STATUS_UNKNOWN: | ||||
default: | default: | ||||
$item->setStatusIcon('fa-warning orange'); | $status_icon = 'fa-warning orange'; | ||||
$item->addAttribute( | $status_label = pht('Unknown'); | ||||
pht( | $status_tip = pht( | ||||
'This daemon has not reported its status recently. It may '. | 'This daemon has not reported its status recently. It may '. | ||||
'have exited uncleanly.')); | 'have exited uncleanly.'); | ||||
$item->addIcon('fa-warning', pht('Unknown')); | |||||
break; | break; | ||||
} | } | ||||
$list->addItem($item); | $status = phutil_tag( | ||||
'span', | |||||
array( | |||||
'sigil' => 'has-tooltip', | |||||
'meta' => array( | |||||
'tip' => $status_tip, | |||||
), | |||||
), | |||||
array( | |||||
id(new PHUIIconView())->setIcon($status_icon), | |||||
' ', | |||||
$status_label, | |||||
)); | |||||
$launched = phabricator_datetime($daemon->getDateCreated(), $viewer); | |||||
$rows[] = array( | |||||
$id, | |||||
$host, | |||||
$pid, | |||||
$name, | |||||
$status, | |||||
$launched, | |||||
); | |||||
} | } | ||||
return $list; | $table = id(new AphrontTableView($rows)) | ||||
->setHeaders( | |||||
array( | |||||
pht('ID'), | |||||
pht('Host'), | |||||
pht('PPID'), | |||||
pht('Daemon'), | |||||
pht('Status'), | |||||
pht('Launched'), | |||||
)) | |||||
->setColumnClasses( | |||||
array( | |||||
null, | |||||
null, | |||||
null, | |||||
'pri', | |||||
'wide', | |||||
'right date', | |||||
)); | |||||
return $table; | |||||
} | } | ||||
} | } |