Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / almanac / view / AlmanacBindingTableView.php
bloba74cb4f9c31780f6a8563fd32f38d843d6fae9d8
1 <?php
3 final class AlmanacBindingTableView extends AphrontView {
5 private $bindings;
6 private $noDataString;
8 private $hideServiceColumn;
10 public function setNoDataString($no_data_string) {
11 $this->noDataString = $no_data_string;
12 return $this;
15 public function getNoDataString() {
16 return $this->noDataString;
19 public function setBindings(array $bindings) {
20 $this->bindings = $bindings;
21 return $this;
24 public function getBindings() {
25 return $this->bindings;
28 public function setHideServiceColumn($hide_service_column) {
29 $this->hideServiceColumn = $hide_service_column;
30 return $this;
33 public function getHideServiceColumn() {
34 return $this->hideServiceColumn;
37 public function render() {
38 $bindings = $this->getBindings();
39 $viewer = $this->getUser();
41 $phids = array();
42 foreach ($bindings as $binding) {
43 $phids[] = $binding->getServicePHID();
44 $phids[] = $binding->getDevicePHID();
45 $phids[] = $binding->getInterface()->getNetworkPHID();
47 $handles = $viewer->loadHandles($phids);
49 $icon_disabled = id(new PHUIIconView())
50 ->setIcon('fa-ban')
51 ->addSigil('has-tooltip')
52 ->setMetadata(
53 array(
54 'tip' => pht('Disabled'),
55 ));
57 $icon_active = id(new PHUIIconView())
58 ->setIcon('fa-check')
59 ->setColor('green')
60 ->addSigil('has-tooltip')
61 ->setMetadata(
62 array(
63 'tip' => pht('Active'),
64 ));
66 $icon_device_disabled = id(new PHUIIconView())
67 ->setIcon('fa-times')
68 ->setColor('grey')
69 ->addSigil('has-tooltip')
70 ->setMetadata(
71 array(
72 'tip' => pht('Device Disabled'),
73 ));
75 $rows = array();
76 foreach ($bindings as $binding) {
77 $addr = $binding->getInterface()->getAddress();
78 $port = $binding->getInterface()->getPort();
80 $device = $binding->getDevice();
81 if ($device->isDisabled()) {
82 $binding_icon = $icon_device_disabled;
83 } else if ($binding->getIsDisabled()) {
84 $binding_icon = $icon_disabled;
85 } else {
86 $binding_icon = $icon_active;
89 $rows[] = array(
90 $binding->getID(),
91 $binding_icon,
92 $handles->renderHandle($binding->getServicePHID()),
94 $handles->renderHandle($binding->getDevicePHID()),
95 $handles->renderHandle($binding->getInterface()->getNetworkPHID()),
96 $binding->getInterface()->renderDisplayAddress(),
97 phutil_tag(
98 'a',
99 array(
100 'class' => 'small button button-grey',
101 'href' => '/almanac/binding/'.$binding->getID().'/',
103 pht('Details')),
107 $table = id(new AphrontTableView($rows))
108 ->setNoDataString($this->getNoDataString())
109 ->setHeaders(
110 array(
111 pht('ID'),
112 null,
113 pht('Service'),
114 pht('Device'),
115 pht('Network'),
116 pht('Interface'),
117 null,
119 ->setColumnClasses(
120 array(
122 'icon',
126 'wide',
127 'action',
129 ->setColumnVisibility(
130 array(
131 true,
132 true,
133 !$this->getHideServiceColumn(),
136 return $table;