Fix inlinePie borders and SVG sizes
Add white border to inline piecharts in the list, to make them more visible on mouse hovering. Set a default image size for the loaded svg charts.
This commit is contained in:
parent
b712d9453b
commit
e8466ec7be
|
@ -33,14 +33,14 @@ class InlinePie extends AbstractWidget
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $template =<<<'EOD'
|
private $template =<<<'EOD'
|
||||||
<span sparkType="pie" class="sparkline {class}" {title} {size} sparkSliceColors="[{colors}]" values="{data}">
|
<span sparkType="pie" class="sparkline {class}" {title} sparkWidth={size} sparkHeight={size} sparkSliceColors="[{colors}]" values="{data}">
|
||||||
</span>
|
</span>
|
||||||
{noscript}
|
{noscript}
|
||||||
EOD;
|
EOD;
|
||||||
|
|
||||||
private $noscript =<<<'EOD'
|
private $noscript =<<<'EOD'
|
||||||
<noscript>
|
<noscript>
|
||||||
<img class="inlinepie {class}" {title} src="{url}" data-icinga-colors="{colors}" data-icinga-values="{data}"/>
|
<img width={size} height={size} class="inlinepie {class}" {title} src="{url}" data-icinga-colors="{colors}" data-icinga-values="{data}"/>
|
||||||
</noscript>
|
</noscript>
|
||||||
EOD;
|
EOD;
|
||||||
|
|
||||||
|
@ -216,8 +216,7 @@ EOD;
|
||||||
$template = str_replace('{class}', $this->class, $template);
|
$template = str_replace('{class}', $this->class, $template);
|
||||||
|
|
||||||
// style
|
// style
|
||||||
$template = str_replace('{size}',
|
$template = str_replace('{size}', isset($this->size) ? $this->size : 16, $template);
|
||||||
isset($this->size) ? 'sparkWidth="' . $this->size . '" sparkHeight="' . $this->size . '" ' : '', $template);
|
|
||||||
$template = str_replace('{title}', $this->title, $template);
|
$template = str_replace('{title}', $this->title, $template);
|
||||||
|
|
||||||
$template = str_replace('{colors}', implode(',', $this->colors), $template);
|
$template = str_replace('{colors}', implode(',', $this->colors), $template);
|
||||||
|
|
|
@ -18,11 +18,11 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function perfdata($perfdataStr, $compact = false, $color = Perfdata::PERFDATA_OK)
|
public function perfdata($perfdataStr, $compact = false, $limit = 0, $color = Perfdata::PERFDATA_OK)
|
||||||
{
|
{
|
||||||
$pieChartData = PerfdataSet::fromString($perfdataStr)->asArray();
|
$pieChartData = PerfdataSet::fromString($perfdataStr)->asArray();
|
||||||
|
|
||||||
$result = '';
|
$results = array();
|
||||||
$table = array(
|
$table = array(
|
||||||
'<td><b>' . implode(
|
'<td><b>' . implode(
|
||||||
'</b></td><td><b>',
|
'</b></td><td><b>',
|
||||||
|
@ -32,7 +32,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
||||||
foreach ($pieChartData as $perfdata) {
|
foreach ($pieChartData as $perfdata) {
|
||||||
|
|
||||||
if ($compact && $perfdata->isVisualizable()) {
|
if ($compact && $perfdata->isVisualizable()) {
|
||||||
$result .= $perfdata->asInlinePie($color)->render();
|
$results[] = $perfdata->asInlinePie($color)->render();
|
||||||
} else {
|
} else {
|
||||||
$row = '<tr>';
|
$row = '<tr>';
|
||||||
|
|
||||||
|
@ -56,8 +56,13 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($limit > 0) {
|
||||||
|
$table = array_slice ($table, 0, $limit);
|
||||||
|
$results = array_slice ($results, 0, $limit);
|
||||||
|
}
|
||||||
|
|
||||||
if ($compact) {
|
if ($compact) {
|
||||||
return $result;
|
return join('', $results);
|
||||||
} else {
|
} else {
|
||||||
$pieCharts = empty($table) ? '' : '<table class="perfdata">' . implode("\n", $table) . '</table>';
|
$pieCharts = empty($table) ? '' : '<table class="perfdata">' . implode("\n", $table) . '</table>';
|
||||||
return $pieCharts;
|
return $pieCharts;
|
||||||
|
|
|
@ -65,7 +65,7 @@ foreach ($services as $service):
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<?= $this->perfdata($service->service_perfdata, true) ?>
|
<div class="sparkline-box"><?= $this->perfdata($service->service_perfdata, true, 8) ?></div>
|
||||||
|
|
||||||
<?php if (!$service->service_handled && $service->service_state > 0): ?>
|
<?php if (!$service->service_handled && $service->service_state > 0): ?>
|
||||||
<?= $this->icon('attention-alt', $this->translate('Unhandled')) ?>
|
<?= $this->icon('attention-alt', $this->translate('Unhandled')) ?>
|
||||||
|
|
|
@ -285,6 +285,15 @@ li li .badge {
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sparkline-box {
|
||||||
|
position: relative;
|
||||||
|
top: -9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard .sparkline-box {
|
||||||
|
top: -3px;
|
||||||
|
}
|
||||||
|
|
||||||
.sparkline {
|
.sparkline {
|
||||||
width: 12px;
|
width: 12px;
|
||||||
height: 12px;
|
height: 12px;
|
||||||
|
|
|
@ -85,8 +85,7 @@
|
||||||
$menu.data('icinga-url', menuDataUrl);
|
$menu.data('icinga-url', menuDataUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
Navigation.prototype.setActiveByUrl = function(url)
|
Navigation.prototype.setActiveByUrl = function(url) {
|
||||||
{
|
|
||||||
this.resetActive();
|
this.resetActive();
|
||||||
this.setActive($('#menu [href="' + url + '"]'));
|
this.setActive($('#menu [href="' + url + '"]'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,12 @@
|
||||||
if ($spark.hasClass('sparkline-perfdata')) {
|
if ($spark.hasClass('sparkline-perfdata')) {
|
||||||
options = {
|
options = {
|
||||||
enableTagOptions: true,
|
enableTagOptions: true,
|
||||||
width: 12,
|
width: 16,
|
||||||
height: 12,
|
height: 16,
|
||||||
title: title,
|
title: title,
|
||||||
disableTooltips: true
|
disableTooltips: true,
|
||||||
|
borderWidth: 1.4,
|
||||||
|
borderColor: '#FFF'
|
||||||
};
|
};
|
||||||
$spark.sparkline('html', options);
|
$spark.sparkline('html', options);
|
||||||
} else if ($spark.hasClass('sparkline-multi')) {
|
} else if ($spark.hasClass('sparkline-multi')) {
|
||||||
|
|
Loading…
Reference in New Issue