Tactical overview: always show the problems amount

refs #3226
This commit is contained in:
Alexander A. Klimov 2018-01-17 15:01:02 +01:00
parent 4f706d9423
commit 0ad153a223
3 changed files with 55 additions and 19 deletions

View File

@ -22,6 +22,13 @@ class Donut
*/ */
protected $labelBigUrl; protected $labelBigUrl;
/**
* Whether the big label shall be eye-catching
*
* @var bool
*/
protected $labelBigEyeCatching = true;
/** /**
* Small label in the lower part of the donuts hole * Small label in the lower part of the donuts hole
* *
@ -180,6 +187,30 @@ class Donut
return $this->labelBigUrl; return $this->labelBigUrl;
} }
/**
* Get whether the big label shall be eye-catching
*
* @return bool
*/
public function getLabelBigEyeCatching()
{
return $this->labelBigEyeCatching;
}
/**
* Set whether the big label shall be eye-catching
*
* @param bool $labelBigEyeCatching
*
* @return $this
*/
public function setLabelBigEyeCatching($labelBigEyeCatching = true)
{
$this->labelBigEyeCatching = $labelBigEyeCatching;
return $this;
}
/** /**
* Set the text of the small label * Set the text of the small label
* *
@ -279,7 +310,10 @@ class Donut
'content' => array($svg) 'content' => array($svg)
); );
if ($this->getLabelBig() || $this->getLabelSmall()) { $labelBig = (string) $this->getLabelBig();
$labelSmall = (string) $this->getLabelSmall();
if ($labelBig !== '' || $labelSmall !== '') {
$labels = array( $labels = array(
'tag' => 'div', 'tag' => 'div',
'attributes' => array( 'attributes' => array(
@ -288,19 +322,21 @@ class Donut
'content' => array() 'content' => array()
); );
if ($this->getLabelBig()) { if ($labelBig !== '') {
$labels['content'][] = $labels['content'][] =
array( array(
'tag' => 'a', 'tag' => 'a',
'attributes' => array( 'attributes' => array(
'href' => $this->getLabelBigUrl() ? $this->getLabelBigUrl()->getAbsoluteUrl() : null, 'href' => $this->getLabelBigUrl() ? $this->getLabelBigUrl()->getAbsoluteUrl() : null,
'class' => 'donut-label-big' 'class' => $this->labelBigEyeCatching
? 'donut-label-big donut-label-big-eye-catching'
: 'donut-label-big'
), ),
'content' => $this->shortenLabel($this->getLabelBig()) 'content' => $this->shortenLabel($labelBig)
); );
} }
if ($this->getLabelSmall()) { if ($labelSmall !== '') {
$labels['content'][] = array( $labels['content'][] = array(
'tag' => 'p', 'tag' => 'p',
'attributes' => array( 'attributes' => array(
@ -308,7 +344,7 @@ class Donut
'x' => '50%', 'x' => '50%',
'y' => '50%' 'y' => '50%'
), ),
'content' => $this->getLabelSmall() 'content' => $labelSmall
); );
} }

View File

@ -61,12 +61,10 @@ class TacticalController extends Controller
->addSlice($summary->hosts_unreachable_handled, array('class' => 'slice-state-unreachable-handled')) ->addSlice($summary->hosts_unreachable_handled, array('class' => 'slice-state-unreachable-handled'))
->addSlice($summary->hosts_unreachable_unhandled, array('class' => 'slice-state-unreachable')) ->addSlice($summary->hosts_unreachable_unhandled, array('class' => 'slice-state-unreachable'))
->addSlice($summary->hosts_pending, array('class' => 'slice-state-pending')) ->addSlice($summary->hosts_pending, array('class' => 'slice-state-pending'))
->addSlice($summary->hosts_not_checked, array('class' => 'slice-state-not-checked')); ->addSlice($summary->hosts_not_checked, array('class' => 'slice-state-not-checked'))
if ($summary->hosts_down_unhandled > 0) { ->setLabelBig($summary->hosts_down_unhandled)
$hostSummaryChart ->setLabelBigEyeCatching($summary->hosts_down_unhandled > 0)
->setLabelBig($summary->hosts_down_unhandled) ->setLabelSmall($this->translate('hosts down'));
->setLabelSmall($this->translate('hosts down'));
}
$serviceSummaryChart = new Donut(); $serviceSummaryChart = new Donut();
$serviceSummaryChart $serviceSummaryChart
@ -78,12 +76,10 @@ class TacticalController extends Controller
->addSlice($summary->services_unknown_handled, array('class' => 'slice-state-unknown-handled')) ->addSlice($summary->services_unknown_handled, array('class' => 'slice-state-unknown-handled'))
->addSlice($summary->services_unknown_unhandled, array('class' => 'slice-state-unknown')) ->addSlice($summary->services_unknown_unhandled, array('class' => 'slice-state-unknown'))
->addSlice($summary->services_pending, array('class' => 'slice-state-pending')) ->addSlice($summary->services_pending, array('class' => 'slice-state-pending'))
->addSlice($summary->services_not_checked, array('class' => 'slice-state-not-checked')); ->addSlice($summary->services_not_checked, array('class' => 'slice-state-not-checked'))
if ($summary->services_critical_unhandled > 0) { ->setLabelBig($summary->services_critical_unhandled)
$serviceSummaryChart ->setLabelBigEyeCatching($summary->services_critical_unhandled > 0)
->setLabelBig($summary->services_critical_unhandled) ->setLabelSmall($this->translate('services critical'));
->setLabelSmall($this->translate('services critical'));
}
$this->view->hostStatusSummaryChart = $hostSummaryChart $this->view->hostStatusSummaryChart = $hostSummaryChart
->setLabelBigUrl($this->view->url( ->setLabelBigUrl($this->view->url(

View File

@ -420,7 +420,7 @@ ul.tree li a.error:hover {
} }
.donut-label-big { .donut-label-big {
color: @color-critical; color: @gray-light;
font-size: 6em; font-size: 6em;
line-height: 0; line-height: 0;
text-anchor: middle; text-anchor: middle;
@ -429,6 +429,10 @@ ul.tree li a.error:hover {
} }
} }
.donut-label-big-eye-catching {
color: @color-critical;
}
.donut-label-small { .donut-label-small {
fill: @text-color; fill: @text-color;
font-size: 1.2em; font-size: 1.2em;