diff --git a/library/Bpapp/BusinessProcess.php b/library/Bpapp/BusinessProcess.php
index 7988f13..ed41d4c 100644
--- a/library/Bpapp/BusinessProcess.php
+++ b/library/Bpapp/BusinessProcess.php
@@ -234,4 +234,15 @@ class BusinessProcess
$this->warnings[] = $msg;
}
}
+
+ public function renderHtml($view)
+ {
+ $html = '
';
+ foreach ($this->getRootNodes() as $name => $node) {
+ // showNode($this, $node, $this->slas, $this->opened, 'bp_')
+ $html .= $node->renderHtml($view);
+ }
+ $html .= '
';
+ return $html;
+ }
}
diff --git a/library/Bpapp/HostNode.php b/library/Bpapp/HostNode.php
index fe70dc4..872268f 100644
--- a/library/Bpapp/HostNode.php
+++ b/library/Bpapp/HostNode.php
@@ -14,6 +14,19 @@ class HostNode extends Node
$this->setState($object->state);
}
+ public function renderLink($view)
+ {
+ if ($this->bp->isSimulationMode()) {
+ return $view->qlink($this->getHostname(), 'bpapp/host/simulate', array(
+ 'node' => $this->name
+ ));
+ } else {
+ return $view->qlink($this->getHostname(), 'monitoring/host/show', array(
+ 'host' => $this->getHostname
+ ));
+ }
+ }
+
public function getHostname()
{
return $this->hostname;
diff --git a/library/Bpapp/Node.php b/library/Bpapp/Node.php
index ea4498c..7ab0738 100644
--- a/library/Bpapp/Node.php
+++ b/library/Bpapp/Node.php
@@ -49,6 +49,11 @@ abstract class Node
return $this->missing;
}
+ public function hasInfoUrl()
+ {
+ return false;
+ }
+
public function addChild(Node $node)
{
if (array_key_exists((string) $node, $this->children)) {
@@ -175,6 +180,89 @@ abstract class Node
return array();
}
+ protected function renderHtmlForChildren($view)
+ {
+ $html = '';
+ if ($this->hasChildren()) {
+ foreach ($this->getChildren() as $name => $child) {
+ $html .= '| '
+ . $child->renderHtml($view)
+ . ' |
';
+ }
+ }
+
+ return $html;
+ }
+
+ protected function getId($prefix = '')
+ {
+ return md5($prefix . (string) $this);
+ }
+
+ public function renderHtml($view, $prefix = '')
+ {
+ $id = $this->getId($prefix);
+ $state = strtolower($this->getStateName());
+ $handled = $this->isAcknowledged() || $this->isInDowntime();
+ $html = sprintf(
+ '',
+ $state === 'ok' ? 'ok' : 'problem ' . $state,
+ $handled ? ' handled' : '',
+ $this->hasChildren() ? ' operator process' : ' node service',
+ $id
+ );
+
+ if ($this->hasChildren()) {
+ $html .= sprintf(
+ '| %s | ',
+ sprintf(' rowspan="%d"', $this->countChildren() + 1),
+ $this->operatorHtml()
+ );
+ }
+
+
+ $title = preg_replace('~()~', implode('', $this->getIcons($view)) . '$1', $this->renderLink($view));
+ if ($this->hasInfoUrl()) {
+ $title = ' '
+ . $view->icon('help')
+ . '' . $title;
+ }
+
+ $html .= sprintf(
+ '%s |
',
+ $title
+ );
+ foreach ($this->getChildren() as $name => $child) {
+ $html .= '| ' . $child->renderHtml($view, $id . '-') . ' |
';
+ }
+ $html .= '
';
+ return $html;
+ }
+
+ public function renderLink($view)
+ {
+ return '' . $this->name . '';
+ }
+
+ public function getIcons($view)
+ {
+ $icons = array();
+ if ($this->isInDowntime()) {
+ $icons[] = $view->icon('moon');
+ }
+ if ($this->isAcknowledged()) {
+ $icons[] = $view->icon('ok');
+ }
+ return $icons;
+ }
+
+ public function operatorHtml()
+ {
+ return ' ';
+ }
+
public function __toString()
{
return $this->name;
diff --git a/library/Bpapp/ServiceNode.php b/library/Bpapp/ServiceNode.php
index 9f93957..5f04cef 100644
--- a/library/Bpapp/ServiceNode.php
+++ b/library/Bpapp/ServiceNode.php
@@ -16,6 +16,20 @@ class ServiceNode extends Node
$this->setState($object->state);
}
+ public function renderLink($view)
+ {
+ if ($this->bp->isSimulationMode()) {
+ return $view->qlink($this->getAlias(), 'bpapp/node/simulate', array(
+ 'node' => $this->name
+ ));
+ } else {
+ return $view->qlink($this->getAlias(), 'monitoring/show/service', array(
+ 'host' => $this->getHostname(),
+ 'service' => $this->getServiceDescription()
+ ));
+ }
+ }
+
public function getHostname()
{
return $this->hostname;