RenderStateBadges: add and use new helper method

This commit is contained in:
Thomas Gelf 2015-09-11 15:23:06 +02:00
parent 289658e112
commit 667a84d6a8
3 changed files with 51 additions and 2 deletions

View 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;
}
}

View file

@ -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>

View file

@ -451,3 +451,13 @@ table.sourcecode {
}
}
.badges {
display: block;
padding: 0.5em;
.badge {
border: 1px solid white;
margin: 0;
margin-right: 1px;
}
}