Skip to content

Commit 6452d5b

Browse files
committed
MacAddress: use IMEdge widget, if available
fixes #592
1 parent c3b9d0f commit 6452d5b

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

library/Vspheredb/Web/Table/HostPhysicalNicTable.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Icinga\Module\Vspheredb\Data\Anonymizer;
77
use Icinga\Module\Vspheredb\DbObject\HostSystem;
88
use Icinga\Module\Vspheredb\Format;
9+
use Icinga\Module\Vspheredb\Web\Widget\MacAddress;
910
use Icinga\Module\Vspheredb\Web\Widget\SubTitle;
1011
use ipl\Html\Html;
1112

@@ -59,11 +60,12 @@ protected function formatSimple($row)
5960
);
6061
}
6162
return Html::sprintf(
62-
'%s (%s: %s), %s%s',
63+
'%s (%s: %s), %s%s%s',
6364
Html::tag('strong', $row->device),
6465
$this->translate('driver'),
6566
$row->driver,
66-
isset($row->mac_address) ? Anonymizer::shuffleString($row->mac_address) . ', ' : '',
67+
isset($row->mac_address) ? MacAddress::showBinary(Anonymizer::shuffleString($row->mac_address)) : '',
68+
isset($row->mac_address) ? ', ' : '',
6769
$speedInfo
6870
);
6971
}

library/Vspheredb/Web/Table/VmNetworkAdapterTable.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Icinga\Module\Vspheredb\DbObject\VirtualMachine;
88
use Icinga\Module\Vspheredb\PerformanceData\IcingaRrd\RrdImg;
99
use Icinga\Module\Vspheredb\Web\Widget\GrafanaVmPanel;
10+
use Icinga\Module\Vspheredb\Web\Widget\MacAddress;
1011
use Icinga\Module\Vspheredb\Web\Widget\SubTitle;
1112
use ipl\Html\Html;
1213

@@ -107,10 +108,11 @@ protected function formatSimple($row)
107108
$mainIpInfo = '';
108109
$aIpInfo = '';
109110
}
111+
110112
return Html::sprintf(
111113
'%s (%s)%s %s%s%s %s',
112114
Html::tag('strong', $row->label),
113-
$row->mac_address,
115+
MacAddress::showBinary($row->mac_address),
114116
Html::tag('br'),
115117
$mainIpInfo,
116118
$aIpInfo,
@@ -124,7 +126,8 @@ protected function formatMultiLine($row)
124126
return [
125127
Html::tag('strong', $row->label),
126128
Html::tag('br'),
127-
$this->translate('MAC Address') . ': ' . $row->mac_address,
129+
$this->translate('MAC Address') . ': ',
130+
MacAddress::showBinary($row->mac_address),
128131
Html::tag('br'),
129132
$this->linkToPortGroup($row)
130133
];
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Icinga\Module\Vspheredb\Web\Widget;
4+
5+
use Icinga\Module\Imedge\Web\PublicWidget\MacAddress as MacAddressWidget;
6+
7+
class MacAddress
8+
{
9+
public static function show($value)
10+
{
11+
if ($value === null) {
12+
return null;
13+
}
14+
15+
if (class_exists(MacAddressWidget::class)) {
16+
return MacAddressWidget::show($value);
17+
}
18+
19+
return $value;
20+
}
21+
22+
public static function showBinary($value)
23+
{
24+
if ($value === null) {
25+
return null;
26+
}
27+
28+
if (class_exists(MacAddressWidget::class)) {
29+
return MacAddressWidget::showBinary($value);
30+
}
31+
32+
return $value;
33+
}
34+
}

0 commit comments

Comments
 (0)