Skip to content

Commit f4861b7

Browse files
Add view mode functionality for RedundancyGroup items
1 parent c5f1083 commit f4861b7

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed

library/Icingadb/Widget/ItemList/DependencyNodeList.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,23 @@ protected function getItemClass(): string
2828

2929
protected function createListItem(object $data): BaseListItem
3030
{
31+
$viewMode = $this->getViewMode();
3132
/** @var UnreachableParent|DependencyNode $data */
3233
if ($data->redundancy_group_id !== null) {
34+
if ($viewMode === 'minimal') {
35+
return new RedundancyGroupListItemMinimal($data->redundancy_group, $this);
36+
}
37+
38+
if ($viewMode === 'detailed') {
39+
$this->removeAttribute('class', 'default-layout');
40+
}
41+
3342
return new RedundancyGroupListItem($data->redundancy_group, $this);
3443
}
3544

3645
$object = $data->service_id !== null ? $data->service : $data->host;
3746

38-
switch ($this->getViewMode()) {
47+
switch ($viewMode) {
3948
case 'minimal':
4049
$class = $object instanceof Host ? HostListItemMinimal::class : ServiceListItemMinimal::class;
4150
break;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/* Icinga DB Web | (c) 2024 Icinga GmbH | GPLv2 */
4+
5+
namespace Icinga\Module\Icingadb\Widget\ItemList;
6+
7+
use Icinga\Module\Icingadb\Common\ListItemMinimalLayout;
8+
use ipl\Web\Widget\StateBall;
9+
10+
class RedundancyGroupListItemMinimal extends RedundancyGroupListItem
11+
{
12+
use ListItemMinimalLayout;
13+
14+
protected function getStateBallSize(): string
15+
{
16+
return StateBall::SIZE_BIG;
17+
}
18+
}
Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
1-
.redundancy-group-list-item {
2-
.caption {
3-
display: flex;
4-
justify-content: end;
1+
.item-list.detailed,
2+
.item-list.common,
3+
.item-list.minimal {
4+
.list-item.redundancy-group-list-item {
5+
.title > * {
6+
margin: 0 .28125em; // 0 calculated &nbsp; width
7+
8+
&:first-child {
9+
margin-left: 0;
10+
}
11+
12+
&:last-child {
13+
margin-right: 0;
14+
}
15+
}
16+
17+
.caption .object-statistics {
18+
justify-self: end;
19+
}
20+
}
21+
}
22+
23+
.item-list.minimal > .list-item.redundancy-group-list-item {
24+
.caption .object-statistics {
25+
font-size: 0.75em;
526
}
627
}

0 commit comments

Comments
 (0)