Skip to content

Commit 3663a7a

Browse files
authored
(Host|Service) Detail view: Introduce parents and children tab (#1098)
2 parents 7847f6e + 667fd2f commit 3663a7a

11 files changed

+697
-83
lines changed

Diff for: application/controllers/HostController.php

+324-37
Large diffs are not rendered by default.

Diff for: application/controllers/ServiceController.php

+298-29
Large diffs are not rendered by default.

Diff for: library/Icingadb/Data/CsvResultSetUtils.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use DateTime;
88
use DateTimeZone;
9+
use Icinga\Module\Icingadb\Model\DependencyNode;
910
use Icinga\Module\Icingadb\Model\Host;
1011
use Icinga\Module\Icingadb\Model\Service;
1112
use ipl\Orm\Model;
@@ -67,7 +68,8 @@ protected function extractKeysAndValues(Model $model, string $path = ''): array
6768

6869
public static function stream(Query $query): void
6970
{
70-
if ($query->getModel() instanceof Host || $query->getModel() instanceof Service) {
71+
$model = $query->getModel();
72+
if ($model instanceof Host || $model instanceof Service || $model instanceof DependencyNode) {
7173
$query->setResultSetClass(VolatileCsvResults::class);
7274
} else {
7375
$query->setResultSetClass(__CLASS__);

Diff for: library/Icingadb/Data/JsonResultSetUtils.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use DateTime;
88
use DateTimeZone;
9+
use Icinga\Module\Icingadb\Model\DependencyNode;
910
use Icinga\Module\Icingadb\Model\Host;
1011
use Icinga\Module\Icingadb\Model\Service;
1112
use Icinga\Util\Json;
@@ -61,7 +62,8 @@ protected function createObject(Model $model): array
6162

6263
public static function stream(Query $query): void
6364
{
64-
if ($query->getModel() instanceof Host || $query->getModel() instanceof Service) {
65+
$model = $query->getModel();
66+
if ($model instanceof Host || $model instanceof Service || $model instanceof DependencyNode) {
6567
$query->setResultSetClass(VolatileJsonResults::class);
6668
} else {
6769
$query->setResultSetClass(__CLASS__);

Diff for: library/Icingadb/Model/DependencyNode.php

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public function getSearchColumns(): array
8383
];
8484
}
8585

86+
public function getDefaultSort(): array
87+
{
88+
return ['severity DESC', 'last_state_change DESC'];
89+
}
90+
8691
public function createBehaviors(Behaviors $behaviors): void
8792
{
8893
$behaviors->add(new Binary([

Diff for: library/Icingadb/Model/UnreachableParent.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ private static function selectNodes(Connection $db, Model $root): Select
137137
'service_id' => new Expression("COALESCE(%s, $binaryCast)", ['service_id']),
138138
'redundancy_group_id' => new Expression($binaryCast),
139139
'is_group_member' => new Expression($booleanCast)
140-
]);
140+
])
141+
->disableDefaultSort();
141142
if ($root instanceof Host) {
142143
$rootQuery->filter(Filter::all(
143144
Filter::equal('host_id', $root->id),

Diff for: library/Icingadb/Widget/Detail/RedundancyGroupHeader.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Icinga\Module\Icingadb\Model\RedundancyGroupSummary;
99
use Icinga\Module\Icingadb\Widget\DependencyNodeStatistics;
1010
use ipl\Html\BaseHtmlElement;
11+
use ipl\Html\Html;
1112
use ipl\Html\HtmlElement;
1213
use ipl\Html\Text;
1314
use ipl\Web\Widget\StateBall;
@@ -37,14 +38,18 @@ protected function assembleVisual(BaseHtmlElement $visual): void
3738

3839
protected function assembleTitle(BaseHtmlElement $title): void
3940
{
40-
$title->addHtml($this->createSubject());
41+
$subject = $this->createSubject();
4142
if ($this->object->state->failed) {
42-
$text = $this->translate('has no working objects');
43+
$title->addHtml(Html::sprintf(
44+
$this->translate('%s has no working objects', '<groupname> has ...'),
45+
$subject
46+
));
4347
} else {
44-
$text = $this->translate('has working objects');
48+
$title->addHtml(Html::sprintf(
49+
$this->translate('%s has working objects', '<groupname> has ...'),
50+
$subject
51+
));
4552
}
46-
47-
$title->addHtml(HtmlElement::create('span', null, Text::create($text)));
4853
}
4954

5055
protected function createStatistics(): BaseHtmlElement

Diff for: library/Icingadb/Widget/ItemList/DependencyNodeList.php

+10-1
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;

Diff for: library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Icinga\Module\Icingadb\Model\RedundancyGroupState;
1313
use Icinga\Module\Icingadb\Widget\DependencyNodeStatistics;
1414
use ipl\Html\BaseHtmlElement;
15+
use ipl\Html\Html;
1516
use ipl\Stdlib\Filter;
1617
use ipl\Web\Url;
1718
use ipl\Web\Widget\Link;
@@ -80,14 +81,18 @@ protected function assembleCaption(BaseHtmlElement $caption): void
8081

8182
protected function assembleTitle(BaseHtmlElement $title): void
8283
{
83-
$title->addHtml($this->createSubject());
84+
$subject = $this->createSubject();
8485
if ($this->state->failed) {
85-
$text = $this->translate('has no working objects');
86+
$title->addHtml(Html::sprintf(
87+
$this->translate('%s has no working objects', '<groupname> has ...'),
88+
$subject
89+
));
8690
} else {
87-
$text = $this->translate('has working objects');
91+
$title->addHtml(Html::sprintf(
92+
$this->translate('%s has working objects', '<groupname> has ...'),
93+
$subject
94+
));
8895
}
89-
90-
$title->addHtml(HtmlElement::create('span', null, Text::create($text)));
9196
}
9297

9398
protected function assemble(): void
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+
}

Diff for: public/css/list/redundancy-group-list-item.less

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
.redundancy-group-list-item {
2-
.caption {
3-
display: flex;
4-
justify-content: end;
2+
.caption .object-statistics {
3+
justify-self: end;
4+
}
5+
}
6+
7+
.item-list.minimal > .redundancy-group-list-item {
8+
.caption .object-statistics {
9+
font-size: 0.75em;
10+
}
11+
}
12+
13+
.item-list.default-layout > .redundancy-group-list-item {
14+
.title > .subject {
15+
margin-right: .28125em;
516
}
617
}

0 commit comments

Comments
 (0)