Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
54 changes: 54 additions & 0 deletions application/controllers/HostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,24 @@ public function historyAction(): Generator
]
);
$viewModeSwitcher = $this->createViewModeSwitcher($paginationControl, $limitControl, true);
$searchBar = $this->createSearchBar($history, [
$limitControl->getLimitParam(),
$sortControl->getSortParam(),
$viewModeSwitcher->getViewModeParam(),
'name'
]);

if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) {
if ($searchBar->hasBeenSubmitted()) {
$filter = $this->getFilter();
} else {
$this->addControl($searchBar);
$this->sendMultipartUpdate();
return;
}
} else {
$filter = $searchBar->getFilter();
}

$history->peekAhead();

Expand All @@ -160,12 +178,14 @@ public function historyAction(): Generator
}

$history->filter(Filter::lessThanOrEqual('event_time', $before));
$this->filter($history, $filter);

yield $this->export($history);

$this->addControl($sortControl);
$this->addControl($limitControl);
$this->addControl($viewModeSwitcher);
$this->addControl($searchBar);

$historyList = (new LoadMoreObjectList($history->execute()))
->setViewMode($viewModeSwitcher->getViewMode())
Expand All @@ -181,6 +201,10 @@ public function historyAction(): Generator
} else {
$this->addContent($historyList);
}

if (! $searchBar->hasBeenSubmitted() && $searchBar->hasBeenSent()) {
$this->sendMultipartUpdate();
}
}

public function servicesAction(): Generator
Expand Down Expand Up @@ -218,6 +242,27 @@ public function servicesAction(): Generator
['service.state.severity DESC', 'service.state.last_state_change DESC']
);

$searchBar = $this->createSearchBar($services, [
$limitControl->getLimitParam(),
$sortControl->getSortParam(),
$viewModeSwitcher->getViewModeParam(),
'name'
]);

if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) {
if ($searchBar->hasBeenSubmitted()) {
$filter = $this->getFilter();
} else {
$this->addControl($searchBar);
$this->sendMultipartUpdate();
return;
}
} else {
$filter = $searchBar->getFilter();
}

$services->filter($filter);

yield $this->export($services);

$serviceList = (new ObjectList($services))
Expand All @@ -228,9 +273,18 @@ public function servicesAction(): Generator
$this->addControl($sortControl);
$this->addControl($limitControl);
$this->addControl($viewModeSwitcher);
$this->addControl($searchBar);
$continueWith = $this->createContinueWith(
Links::servicesDetails()->setFilter(Filter::equal('host.name', $this->host->name)),
$searchBar
);

$this->addContent($serviceList);

if (! $searchBar->hasBeenSubmitted() && $searchBar->hasBeenSent()) {
$this->sendMultipartUpdate($continueWith);
}

$this->setAutorefreshInterval(10);
}

Expand Down
27 changes: 26 additions & 1 deletion application/controllers/ServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function init(): void
$this->service = $service;
$this->loadTabsForObject($service);

$this->addControl(new ObjectHeader($service));
$this->addControl((new ObjectHeader($service))->setAttributes(['data-base-target' => '_next']));

$this->setTitleTab($this->getRequest()->getActionName());
$this->setTitle(
Expand Down Expand Up @@ -299,6 +299,25 @@ public function historyAction(): Generator
]
);
$viewModeSwitcher = $this->createViewModeSwitcher($paginationControl, $limitControl, true);
$searchBar = $this->createSearchBar($history, [
$limitControl->getLimitParam(),
$sortControl->getSortParam(),
$viewModeSwitcher->getViewModeParam(),
'name',
'host.name'
]);

if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) {
if ($searchBar->hasBeenSubmitted()) {
$filter = $this->getFilter();
} else {
$this->addControl($searchBar);
$this->sendMultipartUpdate();
return;
}
} else {
$filter = $searchBar->getFilter();
}

$history->peekAhead();

Expand All @@ -310,12 +329,14 @@ public function historyAction(): Generator
}

$history->filter(Filter::lessThanOrEqual('event_time', $before));
$this->filter($history, $filter);

yield $this->export($history);

$this->addControl($sortControl);
$this->addControl($limitControl);
$this->addControl($viewModeSwitcher);
$this->addControl($searchBar);

$historyList = (new LoadMoreObjectList($history->execute()))
->setViewMode($viewModeSwitcher->getViewMode())
Expand All @@ -331,6 +352,10 @@ public function historyAction(): Generator
} else {
$this->addContent($historyList);
}

if (! $searchBar->hasBeenSubmitted() && $searchBar->hasBeenSent()) {
$this->sendMultipartUpdate();
}
}

public function completeAction(): void
Expand Down
4 changes: 4 additions & 0 deletions library/Icingadb/Hook/ActionsHook/ObjectActionsHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ final public static function loadActions(Model $object): HtmlElement
continue;
}

if (! $link->hasAttribute('data-base-target') && ! $link->hasAttribute('target')) {
$link->setAttribute('data-base-target', '_next');
}

// It may be ValidHtml, but modules shouldn't be able to break our views.
// That's why it needs to be rendered instantly, as any error will then
// be caught here.
Expand Down
3 changes: 1 addition & 2 deletions library/Icingadb/Widget/Detail/HostDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public function __construct(Host $object, ServicestateSummary $serviceSummary)
protected function createServiceStatistics(): array
{
if ($this->serviceSummary->services_total > 0) {
$services = new ServiceStatistics($this->serviceSummary);
$services->setBaseFilter(Filter::equal('host.name', $this->object->name));
$services = new ServiceStatistics($this->serviceSummary, $this->object);
} else {
$services = new EmptyState(t('This host has no services'));
}
Expand Down
21 changes: 17 additions & 4 deletions library/Icingadb/Widget/Detail/ObjectDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,11 @@ protected function createGroups(): array

$hostgroupList = new TagList();
foreach ($hostgroups as $hostgroup) {
$hostgroupList->addLink($hostgroup->display_name, Links::hostgroup($hostgroup));
$hostgroupList->addLink(
$hostgroup->display_name,
Links::hostgroup($hostgroup),
['data-base-target' => '_next']
);
}

$groups[] = $hostgroupList->hasContent()
Expand All @@ -320,7 +324,11 @@ protected function createGroups(): array

$servicegroupList = new TagList();
foreach ($servicegroups as $servicegroup) {
$servicegroupList->addLink($servicegroup->display_name, Links::servicegroup($servicegroup));
$servicegroupList->addLink(
$servicegroup->display_name,
Links::servicegroup($servicegroup),
['data-base-target' => '_next']
);
}

$groups[] = $servicegroupList->hasContent()
Expand Down Expand Up @@ -389,13 +397,18 @@ protected function createNotifications(): array
$usergroupList = new TagList();

foreach ($users as $user) {
$userList->addLink([new Icon(Icons::USER), $user->display_name], Links::user($user));
$userList->addLink(
[new Icon(Icons::USER), $user->display_name],
Links::user($user),
['data-base-target' => '_next']
);
}

foreach ($usergroups as $usergroup) {
$usergroupList->addLink(
[new Icon(Icons::USERGROUP), $usergroup->display_name],
Links::usergroup($usergroup)
Links::usergroup($usergroup),
['data-base-target' => '_next']
);
}

Expand Down
23 changes: 20 additions & 3 deletions library/Icingadb/Widget/Detail/ServiceStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,37 @@
namespace Icinga\Module\Icingadb\Widget\Detail;

use Icinga\Chart\Donut;
use Icinga\Module\Icingadb\Common\HostLinks;
use Icinga\Module\Icingadb\Common\Links;
use Icinga\Module\Icingadb\Widget\ServiceStateBadges;
use ipl\Html\ValidHtml;
use ipl\Web\Url;
use ipl\Web\Widget\VerticalKeyValue;
use ipl\Html\HtmlString;
use ipl\Web\Widget\Link;

class ServiceStatistics extends ObjectStatistics
{
protected $summary;
private $url;

public function __construct($summary)
public function __construct($summary, $host = null)
{
$this->summary = $summary;

$this->setUrl($host !== null ? HostLinks::services($host) : Links::services());
}

protected function getUrl(): Url
{
return $this->url;
}

protected function setUrl($url): self
{
$this->url = $url;

return $this;
}

protected function createDonut(): ValidHtml
Expand All @@ -38,7 +55,7 @@ protected function createDonut(): ValidHtml

protected function createTotal(): ValidHtml
{
$url = Links::services();
$url = $this->getUrl();
if ($this->hasBaseFilter()) {
$url->setFilter($this->getBaseFilter());
}
Expand All @@ -59,6 +76,6 @@ protected function createBadges(): ValidHtml
$badges->setBaseFilter($this->getBaseFilter());
}

return $badges;
return $badges->setUrl($this->getUrl());
}
}
4 changes: 2 additions & 2 deletions library/Icingadb/Widget/TagList.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class TagList extends BaseHtmlElement

protected $tag = 'div';

public function addLink($content, $url): self
public function addLink($content, $url, $attributes = null): self
{
$this->content[] = new Link($content, $url);
$this->content[] = new Link($content, $url, $attributes);

return $this;
}
Expand Down
Loading