mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-20 23:00:16 -05:00
Node: remove implementation-specific logic
This commit is contained in:
parent
a97073334c
commit
64bab3f8da
5 changed files with 17 additions and 14 deletions
|
|
@ -21,6 +21,8 @@ class BpNode extends Node
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected $className = 'process';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
BusinessProcess $bp,
|
BusinessProcess $bp,
|
||||||
$object
|
$object
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ class HostNode extends Node
|
||||||
{
|
{
|
||||||
protected $hostname;
|
protected $hostname;
|
||||||
|
|
||||||
|
protected $className = 'host';
|
||||||
|
|
||||||
public function __construct(BusinessProcess $bp, $object)
|
public function __construct(BusinessProcess $bp, $object)
|
||||||
{
|
{
|
||||||
$this->name = $object->hostname . ';Hoststatus';
|
$this->name = $object->hostname . ';Hoststatus';
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ class ImportedNode extends Node
|
||||||
|
|
||||||
protected $importedNode;
|
protected $importedNode;
|
||||||
|
|
||||||
|
protected $className = 'subtree';
|
||||||
|
|
||||||
public function __construct(BusinessProcess $bp, $object)
|
public function __construct(BusinessProcess $bp, $object)
|
||||||
{
|
{
|
||||||
$this->name = $object->name;
|
$this->name = $object->name;
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,8 @@ abstract class Node
|
||||||
|
|
||||||
protected $missing = false;
|
protected $missing = false;
|
||||||
|
|
||||||
|
protected $className = 'unknown';
|
||||||
|
|
||||||
protected static $state_names = array(
|
protected static $state_names = array(
|
||||||
'OK',
|
'OK',
|
||||||
'WARNING',
|
'WARNING',
|
||||||
|
|
@ -327,32 +329,25 @@ abstract class Node
|
||||||
{
|
{
|
||||||
return md5($prefix . (string) $this);
|
return md5($prefix . (string) $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getObjectClassName()
|
||||||
|
{
|
||||||
|
return $this->className;
|
||||||
|
}
|
||||||
|
|
||||||
public function renderHtml($view, $prefix = '')
|
public function renderHtml($view, $prefix = '')
|
||||||
{
|
{
|
||||||
$id = $this->getId($prefix);
|
$id = $this->getId($prefix);
|
||||||
$state = strtolower($this->getStateName());
|
$state = strtolower($this->getStateName());
|
||||||
if ($this->isMissing()) $state = 'missing';
|
if ($this->isMissing()) $state = 'missing';
|
||||||
$handled = $this->isAcknowledged() || $this->isInDowntime();
|
$handled = $this->isAcknowledged() || $this->isInDowntime();
|
||||||
if ($this instanceof BpNode) {
|
|
||||||
$typeClass = 'process';
|
|
||||||
} elseif ($this instanceof HostNode) {
|
|
||||||
$typeClass = 'host';
|
|
||||||
} elseif ($this instanceof ServiceNode) {
|
|
||||||
$typeClass = 'service';
|
|
||||||
} elseif ($this instanceof ImportedNode) {
|
|
||||||
$typeClass = 'subtree';
|
|
||||||
} else {
|
|
||||||
// WTF?
|
|
||||||
var_dump($this); exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$html = sprintf(
|
$html = sprintf(
|
||||||
'<table class="bp %s%s%s%s" id="%s"><tbody><tr>',
|
'<table class="bp %s%s%s%s" id="%s"><tbody><tr>',
|
||||||
$state === 'ok' ? 'ok' : 'problem ' . $state,
|
$state === 'ok' ? 'ok' : 'problem ' . $state,
|
||||||
$handled ? ' handled' : '',
|
$handled ? ' handled' : '',
|
||||||
($this->hasChildren() ? ' operator ' : ' node '),
|
($this->hasChildren() ? ' operator ' : ' node '),
|
||||||
$typeClass,
|
$this->getObjectClassName(),
|
||||||
$id
|
$id
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ class ServiceNode extends Node
|
||||||
|
|
||||||
protected $service;
|
protected $service;
|
||||||
|
|
||||||
|
protected $className = 'service';
|
||||||
|
|
||||||
public function __construct(BusinessProcess $bp, $object)
|
public function __construct(BusinessProcess $bp, $object)
|
||||||
{
|
{
|
||||||
$this->name = $object->hostname . ';' . $object->service;
|
$this->name = $object->hostname . ';' . $object->service;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue