mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-29 02:09:33 -05:00
MonitoredNode: add new simpler url/link helpers
This commit is contained in:
parent
a986859fdc
commit
01a982a0bc
3 changed files with 67 additions and 38 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Icinga\Module\Businessprocess;
|
||||
|
||||
use Icinga\Module\Businessprocess\Web\Component\Link;
|
||||
use Icinga\Module\Businessprocess\Html\Link;
|
||||
use Icinga\Module\Businessprocess\Web\Url;
|
||||
|
||||
class HostNode extends MonitoredNode
|
||||
|
|
@ -44,20 +44,9 @@ class HostNode extends MonitoredNode
|
|||
}
|
||||
}
|
||||
|
||||
public function renderLink($view)
|
||||
public function getAlias()
|
||||
{
|
||||
if ($this->isMissing()) {
|
||||
return '<span class="missing">' . $view->escape($this->hostname) . '</span>';
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'host' => $this->getHostname(),
|
||||
);
|
||||
|
||||
if ($this->bp->hasBackendName()) {
|
||||
$params['backend'] = $this->bp->getBackendName();
|
||||
}
|
||||
return Link::create($this->hostname, 'monitoring/host/show', $params)->render();
|
||||
return $this->getHostname();
|
||||
}
|
||||
|
||||
protected function getActionIcons($view)
|
||||
|
|
@ -86,4 +75,31 @@ class HostNode extends MonitoredNode
|
|||
{
|
||||
return $this->hostname;
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
$params = array(
|
||||
'host' => $this->getHostname(),
|
||||
);
|
||||
|
||||
if ($this->bp->hasBackendName()) {
|
||||
$params['backend'] = $this->bp->getBackendName();
|
||||
}
|
||||
|
||||
return Url::fromPath('monitoring/host/show', $params);
|
||||
}
|
||||
|
||||
public function getLink()
|
||||
{
|
||||
return Link::create($this->hostname, $this->getUrl());
|
||||
}
|
||||
|
||||
public function renderLink($view)
|
||||
{
|
||||
if ($this->isMissing()) {
|
||||
return '<span class="missing">' . $view->escape($this->hostname) . '</span>';
|
||||
}
|
||||
|
||||
return $this->getLink()->render();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,22 @@
|
|||
|
||||
namespace Icinga\Module\Businessprocess;
|
||||
|
||||
use Icinga\Module\Businessprocess\Web\Component\Container;
|
||||
use Icinga\Module\Businessprocess\Web\Component\Link;
|
||||
use Icinga\Module\Businessprocess\Html\Container;
|
||||
use Icinga\Module\Businessprocess\Html\Link;
|
||||
|
||||
abstract class MonitoredNode extends Node
|
||||
{
|
||||
abstract public function getUrl();
|
||||
|
||||
public function getLink()
|
||||
{
|
||||
if ($this->isMissing()) {
|
||||
return Link::create($this->getAlias(), '#');
|
||||
} else {
|
||||
return Link::create($this->getAlias(), $this->getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
protected function prepareActions(Container $actions)
|
||||
{
|
||||
$actions->add(
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Icinga\Module\Businessprocess;
|
||||
|
||||
use Icinga\Module\Businessprocess\Web\Component\Link;
|
||||
use Icinga\Module\Businessprocess\Html\Link;
|
||||
use Icinga\Module\Businessprocess\Web\Url;
|
||||
|
||||
class ServiceNode extends MonitoredNode
|
||||
|
|
@ -26,27 +26,6 @@ class ServiceNode extends MonitoredNode
|
|||
}
|
||||
}
|
||||
|
||||
public function renderLink($view)
|
||||
{
|
||||
if ($this->isMissing()) {
|
||||
return '<span class="missing">' . $view->escape($this->getAlias()) . '</span>';
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'host' => $this->getHostname(),
|
||||
'service' => $this->getServiceDescription()
|
||||
);
|
||||
if ($this->bp->hasBackendName()) {
|
||||
$params['backend'] = $this->bp->getBackendName();
|
||||
}
|
||||
|
||||
return Link::create(
|
||||
$this->getAlias(),
|
||||
'monitoring/service/show',
|
||||
$params
|
||||
)->render();
|
||||
}
|
||||
|
||||
protected function getActionIcons($view)
|
||||
{
|
||||
$icons = array();
|
||||
|
|
@ -83,4 +62,27 @@ class ServiceNode extends MonitoredNode
|
|||
{
|
||||
return $this->hostname . ': ' . $this->service;
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
$params = array(
|
||||
'host' => $this->getHostname(),
|
||||
'service' => $this->getServiceDescription()
|
||||
);
|
||||
|
||||
if ($this->bp->hasBackendName()) {
|
||||
$params['backend'] = $this->bp->getBackendName();
|
||||
}
|
||||
|
||||
return Url::fromPath('monitoring/service/show', $params);
|
||||
}
|
||||
|
||||
public function renderLink($view)
|
||||
{
|
||||
if ($this->isMissing()) {
|
||||
return '<span class="missing">' . $view->escape($this->getAlias()) . '</span>';
|
||||
}
|
||||
|
||||
return $this->getLink()->render();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue