Do not break overview page if existing business-process has invalid config

- Add icon and config file name to broken `business-process`
- Use font-awesome icon
This commit is contained in:
Sukhwinder Dhillon 2023-06-09 10:33:22 +02:00 committed by Johannes Meyer
parent 7298134f2f
commit 6b4a3cbc0c
2 changed files with 20 additions and 7 deletions

View file

@ -3,10 +3,12 @@
namespace Icinga\Module\Businessprocess\Web\Component;
use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Web\Url;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
use ipl\Html\Text;
use ipl\Web\Url;
use ipl\Web\Widget\Icon;
use ipl\Web\Widget\Link;
class BpDashboardTile extends BaseHtmlElement
{
@ -16,14 +18,10 @@ class BpDashboardTile extends BaseHtmlElement
public function __construct(BpConfig $bp, $title, $description, $icon, $url, $urlParams = null, $attributes = null)
{
if (! isset($attributes['href'])) {
$attributes['href'] = Url::fromPath($url, $urlParams ?: []);
}
$this->add(Html::tag(
'div',
['class' => 'bp-link', 'data-base-target' => '_main'],
Html::tag('a', $attributes, Html::tag('i', ['class' => 'icon icon-' . $icon]))
(new Link(new Icon($icon), Url::fromPath($url, $urlParams ?: []), $attributes))
->add(Html::tag('span', ['class' => 'header'], $title))
->add($description)
));

View file

@ -2,8 +2,10 @@
namespace Icinga\Module\Businessprocess\Web\Component;
use Exception;
use Icinga\Application\Modules\Module;
use Icinga\Authentication\Auth;
use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport;
use Icinga\Module\Businessprocess\State\IcingaDbState;
use Icinga\Module\Businessprocess\State\MonitoringState;
@ -92,7 +94,20 @@ class Dashboard extends BaseHtmlElement
$title = $name;
}
$bp = $storage->loadProcess($name);
try {
$bp = $storage->loadProcess($name);
} catch (Exception $e) {
$this->add(new BpDashboardTile(
new BpConfig(),
$title,
sprintf(t('File %s has invalid config'), $name . '.conf'),
'file-circle-xmark',
'businessprocess/process/show',
['config' => $name]
));
continue;
}
if (Module::exists('icingadb') &&
(! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())