Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/controller/AlmanacDeviceViewController.php
Show All 15 Lines | $device = id(new AlmanacDeviceQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withNames(array($name)) | ->withNames(array($name)) | ||||
->needProperties(true) | ->needProperties(true) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$device) { | if (!$device) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
// We rebuild locks on a device when viewing the detail page, so they | |||||
// automatically get corrected if they fall out of sync. | |||||
$device->rebuildDeviceLocks(); | |||||
$title = pht('Device %s', $device->getName()); | $title = pht('Device %s', $device->getName()); | ||||
$property_list = $this->buildPropertyList($device); | $property_list = $this->buildPropertyList($device); | ||||
$action_list = $this->buildActionList($device); | $action_list = $this->buildActionList($device); | ||||
$property_list->setActionList($action_list); | $property_list->setActionList($action_list); | ||||
$header = id(new PHUIHeaderView()) | $header = id(new PHUIHeaderView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setHeader($device->getName()) | ->setHeader($device->getName()) | ||||
->setPolicyObject($device); | ->setPolicyObject($device); | ||||
$box = id(new PHUIObjectBoxView()) | $box = id(new PHUIObjectBoxView()) | ||||
->setHeader($header) | ->setHeader($header) | ||||
->addPropertyList($property_list); | ->addPropertyList($property_list); | ||||
if ($device->getIsLocked()) { | if ($device->isClusterDevice()) { | ||||
$this->addLockMessage( | $this->addClusterMessage( | ||||
$box, | $box, | ||||
pht('This device is bound to a cluster service.'), | |||||
pht( | pht( | ||||
'This device is bound to a locked service, so it can not be '. | 'This device is bound to a cluster service. You do not have '. | ||||
'edited.')); | 'permission to manage cluster services, so the device can not '. | ||||
'be edited.')); | |||||
} | } | ||||
$interfaces = $this->buildInterfaceList($device); | $interfaces = $this->buildInterfaceList($device); | ||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
$crumbs->addTextCrumb($device->getName()); | $crumbs->addTextCrumb($device->getName()); | ||||
$timeline = $this->buildTransactionTimeline( | $timeline = $this->buildTransactionTimeline( | ||||
▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | private function buildServicesTable(AlmanacDevice $device) { | ||||
$services = id(new AlmanacServiceQuery()) | $services = id(new AlmanacServiceQuery()) | ||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
->withDevicePHIDs(array($device->getPHID())) | ->withDevicePHIDs(array($device->getPHID())) | ||||
->execute(); | ->execute(); | ||||
$handles = $viewer->loadHandles(mpull($services, 'getPHID')); | $handles = $viewer->loadHandles(mpull($services, 'getPHID')); | ||||
$icon_lock = id(new PHUIIconView()) | $icon_cluster = id(new PHUIIconView()) | ||||
->setIcon('fa-lock'); | ->setIcon('fa-sitemap'); | ||||
$rows = array(); | $rows = array(); | ||||
foreach ($services as $service) { | foreach ($services as $service) { | ||||
$rows[] = array( | $rows[] = array( | ||||
($service->getIsLocked() | ($service->isClusterService() | ||||
? $icon_lock | ? $icon_cluster | ||||
: null), | : null), | ||||
$handles->renderHandle($service->getPHID()), | $handles->renderHandle($service->getPHID()), | ||||
); | ); | ||||
} | } | ||||
$table = id(new AphrontTableView($rows)) | $table = id(new AphrontTableView($rows)) | ||||
->setNoDataString(pht('No services are bound to this device.')) | ->setNoDataString(pht('No services are bound to this device.')) | ||||
->setHeaders( | ->setHeaders( | ||||
Show All 17 Lines |