Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Host|Service) Detail view: Introduce parents and children tab #1098

Merged
merged 14 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
361 changes: 324 additions & 37 deletions application/controllers/HostController.php
nilmerg marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

327 changes: 298 additions & 29 deletions application/controllers/ServiceController.php

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion library/Icingadb/Data/CsvResultSetUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use DateTime;
use DateTimeZone;
use Icinga\Module\Icingadb\Model\DependencyNode;
use Icinga\Module\Icingadb\Model\Host;
use Icinga\Module\Icingadb\Model\Service;
use ipl\Orm\Model;
Expand Down Expand Up @@ -67,7 +68,8 @@ protected function extractKeysAndValues(Model $model, string $path = ''): array

public static function stream(Query $query): void
{
if ($query->getModel() instanceof Host || $query->getModel() instanceof Service) {
$model = $query->getModel();
if ($model instanceof Host || $model instanceof Service || $model instanceof DependencyNode) {
$query->setResultSetClass(VolatileCsvResults::class);
} else {
$query->setResultSetClass(__CLASS__);
Expand Down
4 changes: 3 additions & 1 deletion library/Icingadb/Data/JsonResultSetUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use DateTime;
use DateTimeZone;
use Icinga\Module\Icingadb\Model\DependencyNode;
use Icinga\Module\Icingadb\Model\Host;
use Icinga\Module\Icingadb\Model\Service;
use Icinga\Util\Json;
Expand Down Expand Up @@ -61,7 +62,8 @@ protected function createObject(Model $model): array

public static function stream(Query $query): void
{
if ($query->getModel() instanceof Host || $query->getModel() instanceof Service) {
$model = $query->getModel();
if ($model instanceof Host || $model instanceof Service || $model instanceof DependencyNode) {
$query->setResultSetClass(VolatileJsonResults::class);
} else {
$query->setResultSetClass(__CLASS__);
Expand Down
5 changes: 5 additions & 0 deletions library/Icingadb/Model/DependencyNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public function getSearchColumns(): array
];
}

public function getDefaultSort(): array
{
return ['severity DESC', 'last_state_change DESC'];
}

public function createBehaviors(Behaviors $behaviors): void
{
$behaviors->add(new Binary([
Expand Down
3 changes: 2 additions & 1 deletion library/Icingadb/Model/UnreachableParent.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ private static function selectNodes(Connection $db, Model $root): Select
'service_id' => new Expression("COALESCE(%s, $binaryCast)", ['service_id']),
'redundancy_group_id' => new Expression($binaryCast),
'is_group_member' => new Expression($booleanCast)
]);
])
->disableDefaultSort();
if ($root instanceof Host) {
$rootQuery->filter(Filter::all(
Filter::equal('host_id', $root->id),
Expand Down
15 changes: 10 additions & 5 deletions library/Icingadb/Widget/Detail/RedundancyGroupHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Icinga\Module\Icingadb\Model\RedundancyGroupSummary;
use Icinga\Module\Icingadb\Widget\DependencyNodeStatistics;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
use ipl\Html\HtmlElement;
use ipl\Html\Text;
use ipl\Web\Widget\StateBall;
Expand Down Expand Up @@ -37,14 +38,18 @@ protected function assembleVisual(BaseHtmlElement $visual): void

protected function assembleTitle(BaseHtmlElement $title): void
{
$title->addHtml($this->createSubject());
$subject = $this->createSubject();
if ($this->object->state->failed) {
$text = $this->translate('has no working objects');
$title->addHtml(Html::sprintf(
$this->translate('%s has no working objects', '<groupname> has ...'),
$subject
));
} else {
$text = $this->translate('has working objects');
$title->addHtml(Html::sprintf(
$this->translate('%s has working objects', '<groupname> has ...'),
$subject
));
}

$title->addHtml(HtmlElement::create('span', null, Text::create($text)));
}

protected function createStatistics(): BaseHtmlElement
Expand Down
11 changes: 10 additions & 1 deletion library/Icingadb/Widget/ItemList/DependencyNodeList.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,23 @@ protected function getItemClass(): string

protected function createListItem(object $data): BaseListItem
{
$viewMode = $this->getViewMode();
/** @var UnreachableParent|DependencyNode $data */
if ($data->redundancy_group_id !== null) {
if ($viewMode === 'minimal') {
return new RedundancyGroupListItemMinimal($data->redundancy_group, $this);
}

if ($viewMode === 'detailed') {
$this->removeAttribute('class', 'default-layout');
}

return new RedundancyGroupListItem($data->redundancy_group, $this);
}

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

switch ($this->getViewMode()) {
switch ($viewMode) {
case 'minimal':
$class = $object instanceof Host ? HostListItemMinimal::class : ServiceListItemMinimal::class;
break;
Expand Down
15 changes: 10 additions & 5 deletions library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Icinga\Module\Icingadb\Model\RedundancyGroupState;
use Icinga\Module\Icingadb\Widget\DependencyNodeStatistics;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
use ipl\Stdlib\Filter;
use ipl\Web\Url;
use ipl\Web\Widget\Link;
Expand Down Expand Up @@ -80,14 +81,18 @@ protected function assembleCaption(BaseHtmlElement $caption): void

protected function assembleTitle(BaseHtmlElement $title): void
{
$title->addHtml($this->createSubject());
$subject = $this->createSubject();
if ($this->state->failed) {
$text = $this->translate('has no working objects');
$title->addHtml(Html::sprintf(
$this->translate('%s has no working objects', '<groupname> has ...'),
$subject
));
} else {
$text = $this->translate('has working objects');
$title->addHtml(Html::sprintf(
$this->translate('%s has working objects', '<groupname> has ...'),
$subject
));
}

$title->addHtml(HtmlElement::create('span', null, Text::create($text)));
}

protected function assemble(): void
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/* Icinga DB Web | (c) 2024 Icinga GmbH | GPLv2 */

namespace Icinga\Module\Icingadb\Widget\ItemList;

use Icinga\Module\Icingadb\Common\ListItemMinimalLayout;
use ipl\Web\Widget\StateBall;

class RedundancyGroupListItemMinimal extends RedundancyGroupListItem
{
use ListItemMinimalLayout;

protected function getStateBallSize(): string
{
return StateBall::SIZE_BIG;
}
}
17 changes: 14 additions & 3 deletions public/css/list/redundancy-group-list-item.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
.redundancy-group-list-item {
.caption {
display: flex;
justify-content: end;
.caption .object-statistics {
justify-self: end;
}
}

.item-list.minimal > .redundancy-group-list-item {
.caption .object-statistics {
font-size: 0.75em;
}
}

.item-list.default-layout > .redundancy-group-list-item {
.title > .subject {
margin-right: .28125em;
}
}
Loading