mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-01-06 13:39:34 -05:00
RenderStateBadges: add and use new helper method
This commit is contained in:
parent
289658e112
commit
667a84d6a8
3 changed files with 51 additions and 2 deletions
32
application/views/helpers/RenderStateBadges.php
Normal file
32
application/views/helpers/RenderStateBadges.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
class Zend_View_Helper_RenderStateBadges extends Zend_View_Helper_Abstract
|
||||
{
|
||||
protected $stateNames = array(
|
||||
0 => 'OK',
|
||||
1 => 'WARNING',
|
||||
2 => 'CRITICAL',
|
||||
3 => 'UNKNOWN',
|
||||
99 => 'PENDING',
|
||||
);
|
||||
|
||||
public function renderStateBadges($summary)
|
||||
{
|
||||
$html = '';
|
||||
|
||||
foreach ($summary as $state => $cnt) {
|
||||
if ($cnt === 0) continue;
|
||||
if ($state === 0) continue;
|
||||
$stateName = $this->stateNames[$state];
|
||||
$html .= '<span class="badge badge-' . strtolower($stateName)
|
||||
. '" title="' . mt('monitoring', $stateName) . '">'
|
||||
. $cnt . '</span>';
|
||||
}
|
||||
|
||||
if ($html !== '') {
|
||||
$html = '<div class="badges">' . $html . '</div>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
|
@ -27,10 +27,17 @@ if ($count < 20) {
|
|||
<?php foreach ($this->bp->getChildren() as $name => $node): ?>
|
||||
<div class="<?= strtolower($node->getStateName()) ?><?= $node->isHandled() ? ' handled' : '' ?>">
|
||||
<?php if ($node instanceof ImportedNode): ?>
|
||||
<a href="<?= $this->url('businessprocess/process/show', array('config' => $node->getConfigName(), 'node' => $name)) ?>"><?= $this->escape($node->getAlias()) ?></a>
|
||||
<a href="<?= $this->url('businessprocess/process/show', array('config' => $node->getConfigName(), 'node' => $name)) ?>">
|
||||
<?php else: ?>
|
||||
<a href="<?= $this->url('businessprocess/process/show', array('config' => $this->configName, 'node' => $name)) ?>"><?= $this->escape($node->getAlias()) ?></a>
|
||||
<a href="<?= $this->url('businessprocess/process/show', array('config' => $this->configName, 'node' => $name)) ?>">
|
||||
<?php endif ?>
|
||||
<?= $this->escape($node->getAlias()) ?><?php
|
||||
|
||||
if ($node instanceof BpNode) {
|
||||
echo $this->renderStateBadges($node->getStateSummary());
|
||||
}
|
||||
|
||||
?></a>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -451,3 +451,13 @@ table.sourcecode {
|
|||
}
|
||||
}
|
||||
|
||||
.badges {
|
||||
display: block;
|
||||
padding: 0.5em;
|
||||
|
||||
.badge {
|
||||
border: 1px solid white;
|
||||
margin: 0;
|
||||
margin-right: 1px;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue