Skip to content

Commit

Permalink
DependencyNodeList: Add viewModeSwicher functionality for hosts/ser…
Browse files Browse the repository at this point in the history
…vices

- Add missing relation `state.last_comment` for detailed view mode
  • Loading branch information
sukhwinder33445 committed Nov 19, 2024
1 parent f4b4d92 commit 6455e3b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions application/controllers/RedundancygroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,10 @@ private function fetchNodes(bool $fetchParents = false): Query
->with([
'host',
'host.state',
'host.state.last_comment',
'service',
'service.state',
'service.state.last_comment',
'service.host',
'service.host.state'
])
Expand Down
22 changes: 18 additions & 4 deletions library/Icingadb/Widget/ItemList/DependencyNodeList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Icinga\Module\Icingadb\Widget\ItemList;

use Icinga\Module\Icingadb\Model\DependencyNode;
use Icinga\Module\Icingadb\Model\Host;
use Icinga\Module\Icingadb\Model\UnreachableParent;
use ipl\Web\Common\BaseListItem;

Expand All @@ -30,10 +31,23 @@ protected function createListItem(object $data): BaseListItem
/** @var UnreachableParent|DependencyNode $data */
if ($data->redundancy_group_id !== null) {
return new RedundancyGroupListItem($data->redundancy_group, $this);
} elseif ($data->service_id !== null) {
return new ServiceListItem($data->service, $this);
} else {
return new HostListItem($data->host, $this);
}

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

switch ($this->getViewMode()) {
case 'minimal':
$class = $object instanceof Host ? HostListItemMinimal::class : ServiceListItemMinimal::class;
break;
case 'detailed':
$this->removeAttribute('class', 'default-layout');

$class = $object instanceof Host ? HostListItemDetailed::class : ServiceListItemDetailed::class;
break;
default:
$class = $object instanceof Host ? HostListItem::class : ServiceListItem::class;
}

return new $class($object, $this);
}
}

0 comments on commit 6455e3b

Please sign in to comment.