Path: blob/master/src/applications/almanac/view/AlmanacBindingTableView.php
12256 views
<?php12final class AlmanacBindingTableView extends AphrontView {34private $bindings;5private $noDataString;67private $hideServiceColumn;89public function setNoDataString($no_data_string) {10$this->noDataString = $no_data_string;11return $this;12}1314public function getNoDataString() {15return $this->noDataString;16}1718public function setBindings(array $bindings) {19$this->bindings = $bindings;20return $this;21}2223public function getBindings() {24return $this->bindings;25}2627public function setHideServiceColumn($hide_service_column) {28$this->hideServiceColumn = $hide_service_column;29return $this;30}3132public function getHideServiceColumn() {33return $this->hideServiceColumn;34}3536public function render() {37$bindings = $this->getBindings();38$viewer = $this->getUser();3940$phids = array();41foreach ($bindings as $binding) {42$phids[] = $binding->getServicePHID();43$phids[] = $binding->getDevicePHID();44$phids[] = $binding->getInterface()->getNetworkPHID();45}46$handles = $viewer->loadHandles($phids);4748$icon_disabled = id(new PHUIIconView())49->setIcon('fa-ban')50->addSigil('has-tooltip')51->setMetadata(52array(53'tip' => pht('Disabled'),54));5556$icon_active = id(new PHUIIconView())57->setIcon('fa-check')58->setColor('green')59->addSigil('has-tooltip')60->setMetadata(61array(62'tip' => pht('Active'),63));6465$icon_device_disabled = id(new PHUIIconView())66->setIcon('fa-times')67->setColor('grey')68->addSigil('has-tooltip')69->setMetadata(70array(71'tip' => pht('Device Disabled'),72));7374$rows = array();75foreach ($bindings as $binding) {76$addr = $binding->getInterface()->getAddress();77$port = $binding->getInterface()->getPort();7879$device = $binding->getDevice();80if ($device->isDisabled()) {81$binding_icon = $icon_device_disabled;82} else if ($binding->getIsDisabled()) {83$binding_icon = $icon_disabled;84} else {85$binding_icon = $icon_active;86}8788$rows[] = array(89$binding->getID(),90$binding_icon,91$handles->renderHandle($binding->getServicePHID()),9293$handles->renderHandle($binding->getDevicePHID()),94$handles->renderHandle($binding->getInterface()->getNetworkPHID()),95$binding->getInterface()->renderDisplayAddress(),96phutil_tag(97'a',98array(99'class' => 'small button button-grey',100'href' => '/almanac/binding/'.$binding->getID().'/',101),102pht('Details')),103);104}105106$table = id(new AphrontTableView($rows))107->setNoDataString($this->getNoDataString())108->setHeaders(109array(110pht('ID'),111null,112pht('Service'),113pht('Device'),114pht('Network'),115pht('Interface'),116null,117))118->setColumnClasses(119array(120'',121'icon',122'',123'',124'',125'wide',126'action',127))128->setColumnVisibility(129array(130true,131true,132!$this->getHideServiceColumn(),133));134135return $table;136}137138}139140141