Node: Introduce $icon property

This commit is contained in:
Johannes Meyer 2019-01-22 11:21:40 +01:00
parent 3ba4842933
commit 505471c519
5 changed files with 24 additions and 0 deletions

View file

@ -520,4 +520,10 @@ class BpNode extends Node
return 'min:' . $this->operator; return 'min:' . $this->operator;
} }
} }
public function getIcon()
{
$this->icon = $this->hasParents() ? 'cubes' : 'sitemap';
return parent::getIcon();
}
} }

View file

@ -32,6 +32,8 @@ class HostNode extends MonitoredNode
protected $className = 'host'; protected $className = 'host';
protected $icon = 'host';
public function __construct(BpConfig $bp, $object) public function __construct(BpConfig $bp, $object)
{ {
$this->name = $object->hostname . ';Hoststatus'; $this->name = $object->hostname . ';Hoststatus';

View file

@ -22,6 +22,8 @@ class ImportedNode extends Node
protected $className = 'subtree'; protected $className = 'subtree';
protected $icon = 'download';
/** @var BpConfig */ /** @var BpConfig */
private $config; private $config;

View file

@ -83,6 +83,13 @@ abstract class Node
// obsolete // obsolete
protected $duration; protected $duration;
/**
* This node's icon
*
* @var string
*/
protected $icon;
/** /**
* Last state change, unix timestamp * Last state change, unix timestamp
* *
@ -382,6 +389,11 @@ abstract class Node
return Html::tag('a', ['href' => '#'], $this->getAlias()); return Html::tag('a', ['href' => '#'], $this->getAlias());
} }
public function getIcon()
{
return Html::tag('i', ['class' => 'icon icon-' . ($this->icon ?: 'attention-circled')]);
}
public function operatorHtml() public function operatorHtml()
{ {
return ' '; return ' ';

View file

@ -12,6 +12,8 @@ class ServiceNode extends MonitoredNode
protected $className = 'service'; protected $className = 'service';
protected $icon = 'service';
public function __construct(BpConfig $bp, $object) public function __construct(BpConfig $bp, $object)
{ {
$this->name = $object->hostname . ';' . $object->service; $this->name = $object->hostname . ';' . $object->service;