Merge branch 'master' into feature/deduplicate-puppet-code-6842
This commit is contained in:
commit
87c5af7df9
|
@ -45,7 +45,7 @@ object HostGroup "all-hosts" {
|
|||
assign where true
|
||||
}
|
||||
|
||||
local host_types = ["ok", "random", "down", "up", "unreachable", "pending"]
|
||||
var host_types = ["ok", "random", "down", "up", "unreachable", "pending"]
|
||||
|
||||
for (host_type in host_types) {
|
||||
object HostGroup "all-" + host_type use (host_type) {
|
||||
|
@ -54,7 +54,7 @@ for (host_type in host_types) {
|
|||
}
|
||||
}
|
||||
|
||||
local service_types = ["ok", "warning", "critical", "unknown", "flapping", "pending"]
|
||||
var service_types = ["ok", "warning", "critical", "unknown", "flapping", "pending"]
|
||||
|
||||
// Servicegroups
|
||||
for (service_type in service_types) {
|
||||
|
|
|
@ -31,7 +31,7 @@ if ( isset($pdf) )
|
|||
}
|
||||
|
||||
</script>
|
||||
<?= $this->img('img/logo_icinga_big_dark.png', array('align' => 'right', 'width' => '150')) ?>
|
||||
<?= $this->img('img/logo_icinga_big_dark.png', array('align' => 'right', 'width' => '75')) ?>
|
||||
<!--<div id="page-header">
|
||||
<table>
|
||||
<tr>
|
||||
|
|
|
@ -92,7 +92,7 @@ if (in_array($path, $special)) {
|
|||
header('Content-Type: image/svg+xml');
|
||||
$pie = new PieChart();
|
||||
$pie->initFromRequest();
|
||||
echo $pie->render();
|
||||
$pie->toSvg();
|
||||
|
||||
} elseif ($path === 'png/chart.php') {
|
||||
if (!array_key_exists('data', $_GET)) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Icinga\Chart;
|
||||
|
||||
use Exception;
|
||||
use Imagick;
|
||||
use Icinga\Chart\Legend;
|
||||
use Icinga\Chart\Palette;
|
||||
use Icinga\Chart\Primitive\Drawable;
|
||||
|
@ -110,12 +110,35 @@ abstract class Chart implements Drawable
|
|||
return $this->renderer->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return this graph rendered as PNG
|
||||
*
|
||||
* @param int $width The width of the PNG in pixel
|
||||
* @param int $height The height of the PNG in pixel
|
||||
*
|
||||
* @return string A PNG binary string
|
||||
*
|
||||
* @throws IcingaException In case ImageMagick is not available
|
||||
*/
|
||||
public function toPng($width, $height)
|
||||
{
|
||||
if (! class_exists('Imagick')) {
|
||||
throw new IcingaException('Cannot render PNGs without ImageMagick');
|
||||
}
|
||||
|
||||
$image = new Imagick();
|
||||
$image->readImageBlob($this->render());
|
||||
$image->setImageFormat('png24');
|
||||
$image->resizeImage($width, $height, imagick::FILTER_LANCZOS, 1);
|
||||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Align the chart to the top left corner instead of centering it
|
||||
*
|
||||
* @param bool $align
|
||||
*/
|
||||
public function alignTopLeft ($align = true)
|
||||
public function alignTopLeft($align = true)
|
||||
{
|
||||
$this->align = $align;
|
||||
}
|
||||
|
|
|
@ -5,17 +5,13 @@
|
|||
namespace Icinga\Chart\Inline;
|
||||
|
||||
use Icinga\Chart\PieChart as PieChartRenderer;
|
||||
use Imagick;
|
||||
use Exception;
|
||||
use Icinga\Exception\IcingaException;
|
||||
|
||||
/**
|
||||
* Draw an inline pie-chart directly from the available request parameters.
|
||||
*/
|
||||
class PieChart extends Inline
|
||||
{
|
||||
|
||||
public function render($output = true)
|
||||
protected function getChart()
|
||||
{
|
||||
$pie = new PieChartRenderer();
|
||||
$pie->alignTopLeft();
|
||||
|
@ -23,23 +19,24 @@ class PieChart extends Inline
|
|||
$pie->drawPie(array(
|
||||
'data' => $this->data, 'colors' => $this->colors, 'labels' => $this->labels
|
||||
));
|
||||
return $pie;
|
||||
}
|
||||
|
||||
public function toSvg($output = true)
|
||||
{
|
||||
if ($output) {
|
||||
echo $pie->render();
|
||||
echo $this->getChart()->render();
|
||||
} else {
|
||||
return $pie->render();
|
||||
return $this->getChart()->render();
|
||||
}
|
||||
}
|
||||
|
||||
public function toPng()
|
||||
public function toPng($output = true)
|
||||
{
|
||||
if (! class_exists('Imagick')) {
|
||||
// TODO: This is quick & dirty. 404?
|
||||
throw new IcingaException('Cannot render PNGs without Imagick');
|
||||
if ($output) {
|
||||
echo $this->getChart()->toPng($this->width, $this->height);
|
||||
} else {
|
||||
return $this->getChart()->toPng($this->width, $this->height);
|
||||
}
|
||||
$image = new Imagick();
|
||||
$image->readImageBlob($this->render(false));
|
||||
$image->setImageFormat('png24');
|
||||
$image->resizeImage($this->width, $this->height, imagick::FILTER_LANCZOS, 1);
|
||||
echo $image;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ class Pdf extends DOMPDF
|
|||
$html = $layout->render();
|
||||
$imgDir = Url::fromPath('img');
|
||||
$html = preg_replace('~src="' . $imgDir . '/~', 'src="' . Icinga::app()->getBootstrapDirectory() . '/img/', $html);
|
||||
$html = preg_replace('~src="/svg/chart.php(.*)"~', 'class="icon" src="http://master1.com/png/chart.php$1"', $html);
|
||||
$this->load_html($html);
|
||||
$this->render();
|
||||
$this->stream(
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
|
||||
namespace Icinga\Web\Widget\Chart;
|
||||
|
||||
use Icinga\Chart\PieChart;
|
||||
use Icinga\Web\Widget\AbstractWidget;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Util\Format;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Exception\IcingaException;
|
||||
|
||||
/**
|
||||
* A SVG-PieChart intended to be displayed as a small icon next to labels, to offer a better visualization of the
|
||||
|
@ -375,6 +377,22 @@ EOD;
|
|||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->view()->layout()->getLayout() === 'pdf') {
|
||||
$pie = new PieChart();
|
||||
$pie->alignTopLeft();
|
||||
$pie->disableLegend();
|
||||
$pie->drawPie(array(
|
||||
'data' => $this->data, 'colors' => $this->colors, 'labels' => $this->labels
|
||||
));
|
||||
|
||||
try {
|
||||
$png = $pie->toPng($this->width, $this->height);
|
||||
return '<img class="inlinepie" src="data:image/png;base64,' . base64_encode($png) . '" />';
|
||||
} catch (IcingaException $_) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
$template = $this->template;
|
||||
$template = str_replace('{url}', $this->url, $template);
|
||||
|
||||
|
|
|
@ -637,7 +637,7 @@ class FilterEditor extends AbstractWidget
|
|||
|
||||
public function renderSearch()
|
||||
{
|
||||
$html = ' <form method="post" class="inline" action="'
|
||||
$html = ' <form method="post" class="inline dontprint" action="'
|
||||
. $this->url()
|
||||
. '"><input type="text" name="q" style="width: 8em" class="search" value="" placeholder="'
|
||||
. t('Search...')
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
//define("DOMPDF_DPI", 72);
|
||||
//define("DOMPDF_ENABLE_PHP", true);
|
||||
//define("DOMPDF_ENABLE_REMOTE", true);
|
||||
//define("DOMPDF_ENABLE_CSS_FLOAT", true);
|
||||
define("DOMPDF_ENABLE_CSS_FLOAT", true);
|
||||
//define("DOMPDF_ENABLE_JAVASCRIPT", false);
|
||||
//define("DEBUGPNG", true);
|
||||
//define("DEBUGKEEPTEMP", true);
|
||||
|
|
|
@ -9,7 +9,7 @@ use Icinga\Module\Monitoring\Plugin\PerfdataSet;
|
|||
|
||||
class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
||||
{
|
||||
public function perfdata($perfdataStr, $compact = false, $float = false)
|
||||
public function perfdata($perfdataStr, $compact = false)
|
||||
{
|
||||
$pset = PerfdataSet::fromString($perfdataStr)->asArray();
|
||||
$onlyPieChartData = array_filter($pset, function ($e) { return $e->getPercentage() > 0; });
|
||||
|
@ -24,11 +24,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
|||
foreach ($onlyPieChartData as $perfdata) {
|
||||
$pieChart = $this->createInlinePie($perfdata);
|
||||
if ($compact) {
|
||||
if (! $float) {
|
||||
$result .= $pieChart->render();
|
||||
} else {
|
||||
$result .= '<div style="float: right;">' . $pieChart->render() . '</div>';
|
||||
}
|
||||
$result .= $pieChart->render();
|
||||
} else {
|
||||
if (! $perfdata->isPercentage()) {
|
||||
// TODO: Should we trust sprintf-style placeholders in perfdata titles?
|
||||
|
|
|
@ -67,7 +67,7 @@ foreach ($services as $service):
|
|||
</td>
|
||||
|
||||
<td>
|
||||
<?= $this->perfdata($service->service_perfdata, true, true) ?>
|
||||
<?= $this->perfdata($service->service_perfdata, true) ?>
|
||||
|
||||
<?php if (!$service->service_handled && $service->service_state > 0): ?>
|
||||
<?= $this->icon('attention-alt', $this->translate('Unhandled')) ?>
|
||||
|
|
|
@ -461,8 +461,8 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
mt('setup', 'PHP Module: GD'),
|
||||
mt(
|
||||
'setup',
|
||||
'In case you want icons and graphs being exported to PDF'
|
||||
. ' as well, you\'ll need the GD extension for PHP.'
|
||||
'In case you want icons being exported to PDF as'
|
||||
. ' well, you\'ll need the GD extension for PHP.'
|
||||
),
|
||||
Platform::extensionLoaded('gd'),
|
||||
Platform::extensionLoaded('gd') ? mt('setup', 'The PHP module GD is available') : (
|
||||
|
@ -470,6 +470,19 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
)
|
||||
);
|
||||
|
||||
$requirements->addOptional(
|
||||
mt('setup', 'PHP Module: Imagick'),
|
||||
mt(
|
||||
'setup',
|
||||
'In case you want graphs being exported to PDF as well'
|
||||
. ', you\'ll need the ImageMagick extension for PHP.'
|
||||
),
|
||||
Platform::extensionLoaded('imagick'),
|
||||
Platform::extensionLoaded('imagick') ? mt('setup', 'The PHP module Imagick is available') : (
|
||||
mt('setup', 'The PHP module Imagick is missing')
|
||||
)
|
||||
);
|
||||
|
||||
$requirements->addOptional(
|
||||
mt('setup', 'PHP Module: PDO-MySQL'),
|
||||
mt(
|
||||
|
|
|
@ -65,11 +65,12 @@ table.action td a:hover {
|
|||
text-decoration: underline;
|
||||
}
|
||||
|
||||
table.action div.inlinepie {
|
||||
table.action span.sparkline, table.action img.inlinepie {
|
||||
margin: 0.5em 0.25em 0.5em 0.25em;
|
||||
float:right;
|
||||
}
|
||||
|
||||
.dashboard table.action div.inlinepie {
|
||||
.dashboard table.action span.sparkline, .dashboard table.action img.inlinepie {
|
||||
margin: 0em 0.25em 0em 0.25em;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
.controls form, .controls .pagination, .controls > .tabs, .dontprint, .inlinepie {
|
||||
.controls form, .controls .pagination, .controls .widgetLimiter, .controls > .tabs, .dontprint {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
table.action img.inlinepie {
|
||||
width: 50%;
|
||||
height: 50%;
|
||||
}
|
||||
|
||||
@page {
|
||||
margin: 2cm;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue