mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-20 23:00:16 -05:00
That way it's no longer directly based on Icinga\Web\Url and runs through. Also fixed wrong expectations in HostNodeTest
86 lines
2 KiB
PHP
86 lines
2 KiB
PHP
<?php
|
|
|
|
namespace Icinga\Module\Businessprocess;
|
|
|
|
use Icinga\Module\Businessprocess\Web\Component\Link;
|
|
use Icinga\Module\Businessprocess\Web\Url;
|
|
|
|
class ServiceNode extends MonitoredNode
|
|
{
|
|
protected $hostname;
|
|
|
|
protected $service;
|
|
|
|
protected $className = 'service';
|
|
|
|
public function __construct(BusinessProcess $bp, $object)
|
|
{
|
|
$this->name = $object->hostname . ';' . $object->service;
|
|
$this->hostname = $object->hostname;
|
|
$this->service = $object->service;
|
|
$this->bp = $bp;
|
|
if (isset($object->state)) {
|
|
$this->setState($object->state);
|
|
} else {
|
|
$this->setState(0)->setMissing();
|
|
}
|
|
}
|
|
|
|
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();
|
|
|
|
if (! $this->bp->isLocked()) {
|
|
|
|
$url = Url::fromPath('businessprocess/node/simulate', array(
|
|
'config' => $this->bp->getName(),
|
|
'node' => $this->name
|
|
));
|
|
|
|
$icons[] = $this->actionIcon(
|
|
$view,
|
|
'magic',
|
|
$url,
|
|
'Simulation'
|
|
);
|
|
}
|
|
|
|
return $icons;
|
|
}
|
|
|
|
public function getHostname()
|
|
{
|
|
return $this->hostname;
|
|
}
|
|
|
|
public function getServiceDescription()
|
|
{
|
|
return $this->service;
|
|
}
|
|
|
|
public function getAlias()
|
|
{
|
|
return $this->hostname . ': ' . $this->service;
|
|
}
|
|
}
|