mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 23:04:51 +02:00
Don't fail to render the whole dashboard in case of a broken dashlet
This commit is contained in:
parent
705f3a49d9
commit
5f441f3ad1
@ -69,6 +69,19 @@ class Dashlet extends UserWidget
|
|||||||
</div>
|
</div>
|
||||||
EOD;
|
EOD;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The template string used for rendering this widget in case of an error
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $errorTemplate = <<<'EOD'
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1 title="{TOOLTIP}">{TITLE}</h1>
|
||||||
|
<p class="error-message">{ERROR_MESSAGE}</p>
|
||||||
|
</div>
|
||||||
|
EOD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new dashlet displaying the given url in the provided pane
|
* Create a new dashlet displaying the given url in the provided pane
|
||||||
*
|
*
|
||||||
@ -80,12 +93,6 @@ EOD;
|
|||||||
{
|
{
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
$this->pane = $pane;
|
$this->pane = $pane;
|
||||||
if (! $url) {
|
|
||||||
throw new IcingaException(
|
|
||||||
'Cannot create dashboard dashlet "%s" without valid URL',
|
|
||||||
$title
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,6 +214,25 @@ EOD;
|
|||||||
}
|
}
|
||||||
|
|
||||||
$view = $this->view();
|
$view = $this->view();
|
||||||
|
|
||||||
|
if (! $this->url) {
|
||||||
|
$searchTokens = array(
|
||||||
|
'{TOOLTIP}',
|
||||||
|
'{TITLE}',
|
||||||
|
'{ERROR_MESSAGE}'
|
||||||
|
);
|
||||||
|
|
||||||
|
$replaceTokens = array(
|
||||||
|
sprintf($view->translate('Show %s', 'dashboard.dashlet.tooltip'), $view->escape($this->getTitle())),
|
||||||
|
$view->escape($this->getTitle()),
|
||||||
|
$view->escape(
|
||||||
|
sprintf($view->translate('Cannot create dashboard dashlet "%s" without valid URL'), $this->title)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return str_replace($searchTokens, $replaceTokens, $this->errorTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
$url = $this->getUrl();
|
$url = $this->getUrl();
|
||||||
$url->setParam('view', 'compact');
|
$url->setParam('view', 'compact');
|
||||||
$iframeUrl = clone $url;
|
$iframeUrl = clone $url;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user