Node: node type class detection

Not so nice, but works for now
This commit is contained in:
Thomas Gelf 2015-02-13 01:56:19 +01:00
parent 99e03ef44f
commit 8f0b492b1b

View file

@ -267,11 +267,25 @@ abstract class Node
$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" 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 process' : ' node service', ($this->hasChildren() ? ' operator ' : ' node '),
$typeClass,
$id $id
); );