@@ -235,7 +235,7 @@ private function getGraphConf($serviceName, $serviceCommand = null): ?self
235235 * @return bool
236236 * @throws \Icinga\Exception\ProgrammingError
237237 */
238- private function getMyPreviewHtml ($ serviceName , $ hostName , HtmlDocument $ previewHtml ): bool
238+ private function getMyPreviewHtml ($ serviceName , $ hostName , HtmlDocument $ previewHtml, $ imageFilter = "" ): bool
239239 {
240240 $ imgClass = $ this ->shadows ? "grafana-img grafana-img-shadows " : "grafana-img " ;
241241
@@ -249,7 +249,8 @@ private function getMyPreviewHtml($serviceName, $hostName, HtmlDocument $preview
249249 'panelid ' => $ this ->panelId ,
250250 'timerange ' => urlencode ($ this ->timerange ),
251251 'timerangeto ' => urlencode ($ this ->timerangeto ),
252- 'cachetime ' => $ this ->cacheTime
252+ 'cachetime ' => $ this ->cacheTime ,
253+ 'imagefilter ' => urlencode ($ imageFilter )
253254 ]
254255 );
255256 } else {
@@ -260,7 +261,8 @@ private function getMyPreviewHtml($serviceName, $hostName, HtmlDocument $preview
260261 'panelid ' => $ this ->panelId ,
261262 'timerange ' => urlencode ($ this ->timerange ),
262263 'timerangeto ' => urlencode ($ this ->timerangeto ),
263- 'cachetime ' => $ this ->cacheTime
264+ 'cachetime ' => $ this ->cacheTime ,
265+ 'imagefilter ' => urlencode ($ imageFilter )
264266 ]
265267 );
266268 }
@@ -458,12 +460,24 @@ public function getPreviewHtml(Model $object, $report = false)
458460 $ html = new HtmlDocument ();
459461 $ this ->panelId = $ panelid ;
460462
461- // The image value will be returned as reference
462- $ previewHtml = new HtmlDocument ();
463- $ res = $ this ->getMyPreviewHtml ($ serviceName , $ hostName , $ previewHtml );
463+ $ flattened_vars = $ object ->vars ;
464+ // The $object->vars array is flattened, we unflatten the subarray grafanaimagefiltersarray here:
465+ $ i = 0 ;
466+ $ info = [];
467+ while (isset ($ flattened_vars ['grafanaimagefiltersarray[ ' . $ i . '] ' ])) {
468+ $ info [$ i ] = $ flattened_vars ['grafanaimagefiltersarray[ ' . $ i . '] ' ];
469+ $ i ++;
470+ }
471+
472+ foreach ($ info as $ value ) {
464473
465- if ($ res ) {
466- $ html ->addHtml ($ previewHtml );
474+ // The image value will be returned as reference
475+ $ previewHtml = new HtmlDocument ();
476+ $ res = $ this ->getMyPreviewHtml ($ serviceName , $ hostName , $ previewHtml , $ value );
477+
478+ if ($ res ) {
479+ $ html ->addHtml ($ previewHtml );
480+ }
467481 }
468482
469483 $ returnHtml ->add ($ html );
0 commit comments