BadgeNavigationItemRenderer: Round counts to the neareset base

refs 
This commit is contained in:
Johannes Meyer 2019-07-03 11:29:37 +02:00
parent e992eb6b26
commit f0b5d8fd8e
1 changed files with 6 additions and 0 deletions
library/Icinga/Web/Navigation/Renderer

View File

@ -113,6 +113,12 @@ abstract class BadgeNavigationItemRenderer extends NavigationItemRenderer
protected function renderBadge()
{
if ($count = $this->getCount()) {
if ($count > 1000000) {
$count = round($count, -6) / 1000000 . 'M';
} elseif ($count > 1000) {
$count = round($count, -3) / 1000 . 'k';
}
$view = $this->view();
return sprintf(
'<span title="%s" class="badge state-%s">%s</span>',