Differential D18519 Diff 44486 src/applications/config/controller/PhabricatorConfigClusterSearchController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/controller/PhabricatorConfigClusterSearchController.php
<?php | <?php | ||||
final class PhabricatorConfigClusterSearchController | final class PhabricatorConfigClusterSearchController | ||||
extends PhabricatorConfigController { | extends PhabricatorConfigController { | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$nav = $this->buildSideNavView(); | $nav = $this->buildSideNavView(); | ||||
$nav->selectFilter('cluster/search/'); | $nav->selectFilter('cluster/search/'); | ||||
$title = pht('Cluster Search'); | $title = pht('Cluster Search'); | ||||
$doc_href = PhabricatorEnv::getDoclink('Cluster: Search'); | $doc_href = PhabricatorEnv::getDoclink('Cluster: Search'); | ||||
$header = id(new PHUIHeaderView()) | $button = id(new PHUIButtonView()) | ||||
->setHeader($title) | |||||
->setProfileHeader(true) | |||||
->addActionLink( | |||||
id(new PHUIButtonView()) | |||||
->setIcon('fa-book') | ->setIcon('fa-book') | ||||
->setHref($doc_href) | ->setHref($doc_href) | ||||
->setTag('a') | ->setTag('a') | ||||
->setText(pht('Documentation'))); | ->setText(pht('Documentation')); | ||||
$crumbs = $this | $header = $this->buildHeaderView($title, $button); | ||||
->buildApplicationCrumbs($nav) | |||||
->addTextCrumb($title) | |||||
->setBorder(true); | |||||
$search_status = $this->buildClusterSearchStatus(); | $search_status = $this->buildClusterSearchStatus(); | ||||
$content = id(new PhabricatorConfigPageView()) | $content = id(new PHUITwoColumnView()) | ||||
->setHeader($header) | ->setHeader($header) | ||||
->setContent($search_status); | ->setNavigation($nav) | ||||
->setFixed(true) | |||||
->setMainColumn($search_status); | |||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle($title) | ->setTitle($title) | ||||
->setCrumbs($crumbs) | ->appendChild($content); | ||||
->setNavigation($nav) | |||||
->appendChild($content) | |||||
->addClass('white-background'); | |||||
} | } | ||||
private function buildClusterSearchStatus() { | private function buildClusterSearchStatus() { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$services = PhabricatorSearchService::getAllServices(); | $services = PhabricatorSearchService::getAllServices(); | ||||
Javelin::initBehavior('phabricator-tooltips'); | Javelin::initBehavior('phabricator-tooltips'); | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | foreach ($service->getHosts() as $host) { | ||||
$row[] = $status_view; | $row[] = $status_view; | ||||
$rows[] = $row; | $rows[] = $row; | ||||
} | } | ||||
$table = id(new AphrontTableView($rows)) | $table = id(new AphrontTableView($rows)) | ||||
->setNoDataString(pht('No search servers are configured.')) | ->setNoDataString(pht('No search servers are configured.')) | ||||
->setHeaders($head); | ->setHeaders($head); | ||||
$view = id(new PHUIObjectBoxView()) | $view = $this->buildConfigBoxView(pht('Search Servers'), $table); | ||||
->setHeaderText($service->getDisplayName()) | |||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | |||||
->setTable($table); | |||||
if ($stats_view) { | $stats = null; | ||||
$view->addPropertyList($stats_view); | if ($stats_view->hasAnyProperties()) { | ||||
$stats = $this->buildConfigBoxView( | |||||
pht('%s Stats', $service->getDisplayName()), | |||||
$stats_view); | |||||
} | } | ||||
return $view; | |||||
return array($stats, $view); | |||||
} | } | ||||
private function renderIndexStats($stats) { | private function renderIndexStats($stats) { | ||||
$view = id(new PHUIPropertyListView()); | $view = id(new PHUIPropertyListView()); | ||||
if ($stats !== false) { | if ($stats !== false) { | ||||
foreach ($stats as $label => $val) { | foreach ($stats as $label => $val) { | ||||
$view->addProperty($label, $val); | $view->addProperty($label, $val); | ||||
} | } | ||||
} | } | ||||
return $view; | return $view; | ||||
} | } | ||||
} | } |