From 667a84d6a847559092bbceb94e303831cfc977c7 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 11 Sep 2015 15:23:06 +0200 Subject: [PATCH] RenderStateBadges: add and use new helper method --- .../views/helpers/RenderStateBadges.php | 32 +++++++++++++++++++ .../views/scripts/process/toplevel.phtml | 11 +++++-- public/css/module.less | 10 ++++++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 application/views/helpers/RenderStateBadges.php diff --git a/application/views/helpers/RenderStateBadges.php b/application/views/helpers/RenderStateBadges.php new file mode 100644 index 0000000..1ee80cc --- /dev/null +++ b/application/views/helpers/RenderStateBadges.php @@ -0,0 +1,32 @@ + '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 .= '' + . $cnt . ''; + } + + if ($html !== '') { + $html = '
' . $html . '
'; + } + + return $html; + } +} diff --git a/application/views/scripts/process/toplevel.phtml b/application/views/scripts/process/toplevel.phtml index 0f8046a..f9e08f6 100644 --- a/application/views/scripts/process/toplevel.phtml +++ b/application/views/scripts/process/toplevel.phtml @@ -27,10 +27,17 @@ if ($count < 20) { bp->getChildren() as $name => $node): ?>
- escape($node->getAlias()) ?> + - escape($node->getAlias()) ?> + +escape($node->getAlias()) ?>renderStateBadges($node->getStateSummary()); +} + +?>
diff --git a/public/css/module.less b/public/css/module.less index fd52c9a..d532904 100644 --- a/public/css/module.less +++ b/public/css/module.less @@ -451,3 +451,13 @@ table.sourcecode { } } +.badges { + display: block; + padding: 0.5em; + + .badge { + border: 1px solid white; + margin: 0; + margin-right: 1px; + } +}