Skip to content

Commit c82ed41

Browse files
committed
Split state badges into two rows
Display unhandled and handled state badges on separate rows so the cube stays readable when many states are present. Adjust CSS grid layout accordingly.
1 parent b7971c9 commit c82ed41

4 files changed

Lines changed: 41 additions & 5 deletions

File tree

library/Cube/CubeRenderer/HostStatusCubeRenderer.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ protected function createIcingaDbCubeBadges(object $parts, object $facts): HtmlD
9191
$filter = $this->getBadgeFilter($facts);
9292
$mainBadge = $this->getMainBadge($parts);
9393

94+
$partsBottom = new stdClass();
95+
$bottomKeys = [
96+
'hosts_unreachable_unhandled',
97+
'hosts_unreachable_handled',
98+
'hosts_pending'
99+
];
100+
101+
foreach ($bottomKeys as $key) {
102+
if (property_exists($parts, $key)) {
103+
$partsBottom->$key = $parts->$key;
104+
unset($parts->$key);
105+
}
106+
}
107+
94108
$main = (new HostStateBadges($mainBadge))
95109
->setBaseFilter($filter)
96110
->addAttributes(new Attributes(['data-base-target' => '_next']));
@@ -99,6 +113,9 @@ protected function createIcingaDbCubeBadges(object $parts, object $facts): HtmlD
99113
'span',
100114
new Attributes(['class' => 'others']),
101115
(new HostStateBadges($parts))
116+
->setBaseFilter($filter)
117+
->addAttributes(new Attributes(['data-base-target' => '_next'])),
118+
(new HostStateBadges($partsBottom))
102119
->setBaseFilter($filter)
103120
->addAttributes(new Attributes(['data-base-target' => '_next']))
104121
);

library/Cube/CubeRenderer/ServiceStatusCubeRenderer.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ protected function createIcingaDbCubeBadges(object $parts, object $facts): HtmlD
103103
$filter = $this->getBadgeFilter($facts);
104104
$mainBadge = $this->getMainBadge($parts);
105105

106+
$partsBottom = new stdClass();
107+
$bottomKeys = [
108+
'services_unknown_unhandled',
109+
'services_unknown_handled',
110+
'services_pending'
111+
];
112+
113+
foreach ($bottomKeys as $key) {
114+
if (property_exists($parts, $key)) {
115+
$partsBottom->$key = $parts->$key;
116+
unset($parts->$key);
117+
}
118+
}
119+
106120
$main = (new ServiceStateBadges($mainBadge))
107121
->setBaseFilter($filter)
108122
->addAttributes(new Attributes(['data-base-target' => '_next']));
@@ -111,6 +125,9 @@ protected function createIcingaDbCubeBadges(object $parts, object $facts): HtmlD
111125
'span',
112126
new Attributes(['class' => 'others']),
113127
(new ServiceStateBadges($parts))
128+
->setBaseFilter($filter)
129+
->addAttributes(new Attributes(['data-base-target' => '_next'])),
130+
(new ServiceStateBadges($partsBottom))
114131
->setBaseFilter($filter)
115132
->addAttributes(new Attributes(['data-base-target' => '_next']))
116133
);

public/css/module.less

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ div.cube {
165165
display: flex;
166166
text-align: center;
167167
color: @text-color-on-icinga-blue;
168-
margin-bottom: 1em;
168+
margin-bottom: 0.5em;
169169

170170
> a:first-child {
171171
flex: 1;
@@ -284,7 +284,7 @@ div.cube {
284284
}
285285

286286
.state-badge {
287-
font-size: 2em;
287+
font-size: 1.6em;
288288

289289
&.handled {
290290
&.state-down {
@@ -308,10 +308,11 @@ div.cube {
308308
.others {
309309
display: flex;
310310
justify-content: center;
311+
align-items: center;
312+
flex-direction: column;
311313

312314
span {
313-
margin-top: 0.8em;
314-
font-size: 1em;
315+
font-size: 0.9em;
315316
&:not(.state-badge) {
316317
margin-left: 0.2em;
317318
}

public/css/state-badges.less

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
.state-badges {
55
padding: 0;
6-
margin: 0;
6+
margin: 0.1em 0;
7+
min-height: 2em;
78

89
ul {
910
padding: 0;

0 commit comments

Comments
 (0)