Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/controller/AlmanacDeviceViewController.php
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | $can_edit = PhabricatorPolicyFilter::hasCapability( | ||||
$device, | $device, | ||||
PhabricatorPolicyCapability::CAN_EDIT); | PhabricatorPolicyCapability::CAN_EDIT); | ||||
$interfaces = id(new AlmanacInterfaceQuery()) | $interfaces = id(new AlmanacInterfaceQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withDevicePHIDs(array($device->getPHID())) | ->withDevicePHIDs(array($device->getPHID())) | ||||
->execute(); | ->execute(); | ||||
$phids = array(); | |||||
foreach ($interfaces as $interface) { | |||||
$phids[] = $interface->getNetworkPHID(); | |||||
$phids[] = $interface->getDevicePHID(); | |||||
} | |||||
$handles = $this->loadViewerHandles($phids); | |||||
$table = id(new AlmanacInterfaceTableView()) | $table = id(new AlmanacInterfaceTableView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setInterfaces($interfaces) | ->setInterfaces($interfaces) | ||||
->setHandles($handles) | |||||
->setCanEdit($can_edit); | ->setCanEdit($can_edit); | ||||
$header = id(new PHUIHeaderView()) | $header = id(new PHUIHeaderView()) | ||||
->setHeader(pht('Device Interfaces')) | ->setHeader(pht('Device Interfaces')) | ||||
->addActionLink( | ->addActionLink( | ||||
id(new PHUIButtonView()) | id(new PHUIButtonView()) | ||||
->setTag('a') | ->setTag('a') | ||||
->setHref($this->getApplicationURI("interface/edit/?deviceID={$id}")) | ->setHref($this->getApplicationURI("interface/edit/?deviceID={$id}")) | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | private function buildSSHKeysTable(AlmanacDevice $device) { | ||||
return id(new PHUIObjectBoxView()) | return id(new PHUIObjectBoxView()) | ||||
->setHeader($header) | ->setHeader($header) | ||||
->appendChild($table); | ->appendChild($table); | ||||
} | } | ||||
private function buildServicesTable(AlmanacDevice $device) { | private function buildServicesTable(AlmanacDevice $device) { | ||||
$viewer = $this->getViewer(); | |||||
// NOTE: We're loading all services so we can show hidden, locked services. | // NOTE: We're loading all services so we can show hidden, locked services. | ||||
// In general, we let you know about all the things the device is bound to, | // In general, we let you know about all the things the device is bound to, | ||||
// even if you don't have permission to see their details. This is similar | // even if you don't have permission to see their details. This is similar | ||||
// to exposing the existence of edges in other applications, with the | // to exposing the existence of edges in other applications, with the | ||||
// addition of always letting you see that locks exist. | // addition of always letting you see that locks exist. | ||||
$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 = $this->loadViewerHandles(mpull($services, 'getPHID')); | $handles = $viewer->loadHandles(mpull($services, 'getPHID')); | ||||
$icon_lock = id(new PHUIIconView()) | $icon_lock = id(new PHUIIconView()) | ||||
->setIconFont('fa-lock'); | ->setIconFont('fa-lock'); | ||||
$rows = array(); | $rows = array(); | ||||
foreach ($services as $service) { | foreach ($services as $service) { | ||||
$handle = $handles[$service->getPHID()]; | |||||
$rows[] = array( | $rows[] = array( | ||||
($service->getIsLocked() | ($service->getIsLocked() | ||||
? $icon_lock | ? $icon_lock | ||||
: null), | : null), | ||||
$handle->renderLink(), | $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( | ||||
array( | array( | ||||
null, | null, | ||||
Show All 15 Lines |