mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-01-19 02:52:54 -05:00
Don't break impact-action page if bp has invalid config
- Add message for invalid config
This commit is contained in:
parent
6b4a3cbc0c
commit
834005f7b4
2 changed files with 53 additions and 1 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Icinga\Module\Businessprocess\Controllers;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Modules\Module;
|
||||
use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport;
|
||||
use Icinga\Module\Businessprocess\Renderer\Breadcrumb;
|
||||
|
|
@ -11,6 +12,8 @@ use Icinga\Module\Businessprocess\State\IcingaDbState;
|
|||
use Icinga\Module\Businessprocess\State\MonitoringState;
|
||||
use Icinga\Module\Businessprocess\Web\Controller;
|
||||
use Icinga\Module\Businessprocess\Web\Url;
|
||||
use ipl\Html\Html;
|
||||
use ipl\Web\Widget\Link;
|
||||
|
||||
class NodeController extends Controller
|
||||
{
|
||||
|
|
@ -24,9 +27,16 @@ class NodeController extends Controller
|
|||
$name = $this->params->get('name');
|
||||
$this->addTitle($this->translate('Business Impact (%s)'), $name);
|
||||
|
||||
$brokenFiles = [];
|
||||
$simulation = Simulation::fromSession($this->session());
|
||||
foreach ($this->storage()->listProcessNames() as $configName) {
|
||||
$config = $this->storage()->loadProcess($configName);
|
||||
try {
|
||||
$config = $this->storage()->loadProcess($configName);
|
||||
} catch (Exception $e) {
|
||||
$meta = $this->storage()->loadMetadata($configName);
|
||||
$brokenFiles[$meta->get('Title')] = $configName;
|
||||
continue;
|
||||
}
|
||||
|
||||
$parents = [];
|
||||
if ($config->hasNode($name)) {
|
||||
|
|
@ -108,5 +118,31 @@ class NodeController extends Controller
|
|||
if ($content->isEmpty()) {
|
||||
$content->add($this->translate('No impact detected. Is this node part of a business process?'));
|
||||
}
|
||||
|
||||
if (! empty($brokenFiles)) {
|
||||
$elem = Html::tag(
|
||||
'ul',
|
||||
['class' => 'broken-files'],
|
||||
tp(
|
||||
'The following business process has an invalid config file and therefore cannot be read:',
|
||||
'The following business processes have invalid config files and therefore cannot be read:',
|
||||
count($brokenFiles)
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($brokenFiles as $bpName => $fileName) {
|
||||
$elem->addHtml(
|
||||
Html::tag(
|
||||
'li',
|
||||
new Link(
|
||||
sprintf('%s (%s.conf)', $bpName, $fileName),
|
||||
(string) Url::fromPath('businessprocess/process/show', ['config' => $fileName])
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$content->addHtml($elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -288,6 +288,22 @@ ul.bp {
|
|||
}
|
||||
}
|
||||
|
||||
// ** Node inspect broken files **/
|
||||
ul.broken-files {
|
||||
.rounded-corners();
|
||||
padding: 1em;
|
||||
margin: 1em 0;
|
||||
border: 2px solid @state-warning;
|
||||
font-size: 1.25em;
|
||||
list-style: none;
|
||||
|
||||
li {
|
||||
padding-left: 1em;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
// ** END Node inspect broken files **/
|
||||
|
||||
/** BEGIN Dashboard **/
|
||||
.overview-dashboard {
|
||||
.header {
|
||||
|
|
|
|||
Loading…
Reference in a new issue