mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
parent
17f8ef1dd0
commit
087b09d363
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Icinga\Module\Director\Controllers;
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Web\Controller;
|
||||
|
||||
class PhperrorController extends Controller
|
||||
@ -19,4 +20,20 @@ class PhperrorController extends Controller
|
||||
$this->view->title = $this->translate('Unsatisfied dependencies');
|
||||
$this->view->message = sprintf($msg, PHP_VERSION);
|
||||
}
|
||||
|
||||
public function dependenciesAction()
|
||||
{
|
||||
$this->setAutorefreshInterval(15);
|
||||
$this->view->dependencies = $this->Module()->getDependencies();
|
||||
$this->view->modules = Icinga::app()->getModuleManager();
|
||||
$this->getTabs()->add('error', array(
|
||||
'label' => $this->translate('Error'),
|
||||
'url' => $this->getRequest()->getUrl()
|
||||
))->activate('error');
|
||||
$msg = $this->translate(
|
||||
"Icinga Director depends on the following modules, please install/upgrade as required"
|
||||
);
|
||||
$this->view->title = $this->translate('Unsatisfied dependencies');
|
||||
$this->view->message = sprintf($msg, PHP_VERSION);
|
||||
}
|
||||
}
|
||||
|
71
application/views/scripts/phperror/dependencies.phtml
Normal file
71
application/views/scripts/phperror/dependencies.phtml
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
use Icinga\Application\Modules\Manager;
|
||||
|
||||
?>
|
||||
<div class="controls">
|
||||
<?= $this->tabs ?>
|
||||
<h1><?= $this->escape($this->title) ?></h1>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<p class="error"><?= $this->escape($this->message) ?></p>
|
||||
<table class="common-table table-row-selectable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= $this->translate('Module name') ?></th>
|
||||
<th><?= $this->translate('Required') ?></th>
|
||||
<th><?= $this->translate('Installed') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-base-target="_next">
|
||||
<?php
|
||||
|
||||
foreach ($this->dependencies as $module => $required) {
|
||||
/** @var Manager $this->modules */
|
||||
if ($modules->hasEnabled($module)) {
|
||||
$installed = $modules->getModule($module, false)->getVersion();
|
||||
$installed = \ltrim($installed, 'v'); // v0.6.0 VS 0.6.0
|
||||
if (\preg_match('/^([<>=]+)\s*v?(\d+\.\d+\.\d+)$/', $required, $match)) {
|
||||
$operator = $match[1];
|
||||
$vRequired = $match[2];
|
||||
if (\version_compare($installed, $vRequired, $operator)) {
|
||||
$icon = 'ok';
|
||||
} else {
|
||||
$icon = 'cancel';
|
||||
}
|
||||
} else {
|
||||
$icon = 'cancel';
|
||||
}
|
||||
$link = $this->qlink(
|
||||
$module,
|
||||
'config/module',
|
||||
['name' => $module],
|
||||
['class' => "icon-$icon"]
|
||||
);
|
||||
} elseif ($modules->hasInstalled($module)) {
|
||||
$installed = $this->translate('disabled');
|
||||
$link = $this->qlink($module, 'config/module', ['name' => $module], ['class' => 'icon-cancel']);
|
||||
} else {
|
||||
$installed = $this->translate('missing');
|
||||
$link = sprintf(
|
||||
'<a href="#" class="icon-cancel">%s</a> (<a href="https://github.com/Icinga/icingaweb2-module-%s"'
|
||||
. ' target="_blank" rel="noreferrer">%s</a>)',
|
||||
$this->escape($module),
|
||||
$this->escape($module),
|
||||
$this->translate('more')
|
||||
);
|
||||
}
|
||||
|
||||
\printf(
|
||||
'<tr><td>%s</a></td><td>%s</td><td>%s</td></tr>',
|
||||
$link,
|
||||
$this->escape($required),
|
||||
$this->escape($installed)
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
@ -1,6 +1,6 @@
|
||||
Name: Icinga Director
|
||||
Version: master
|
||||
Depends: monitoring
|
||||
Depends: reactbundle (>=0.6.0), ipl (>=0.3.0), incubator (>=0.3.0)
|
||||
Description: Director - Config tool for Icinga 2
|
||||
Icinga Director is a configuration tool that has been designed to make
|
||||
Icinga 2 configuration easy and understandable.
|
||||
|
23
run-missingdeps.php
Normal file
23
run-missingdeps.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Exception\IcingaException;
|
||||
use Icinga\Web\Url;
|
||||
|
||||
if (Icinga::app()->isCli()) {
|
||||
throw new IcingaException(
|
||||
"Missing dependencies, please check "
|
||||
);
|
||||
} else {
|
||||
$request = Icinga::app()->getRequest();
|
||||
$path = $request->getPathInfo();
|
||||
if (! preg_match('#^/director#', $path)) {
|
||||
return;
|
||||
}
|
||||
if (preg_match('#^/director/phperror/dependencies#', $path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
header('Location: ' . Url::fromPath('director/phperror/dependencies'));
|
||||
exit;
|
||||
}
|
17
run.php
17
run.php
@ -65,3 +65,20 @@ $this->provideHook('cube/Actions', 'CubeLinks');
|
||||
|
||||
require_once __DIR__ . '/library/vendor/ipl/Loader/CompatLoader.php';
|
||||
CompatLoader::delegateLoadingToIcingaWeb($this->app);
|
||||
|
||||
$modules = $this->app->getModuleManager();
|
||||
foreach ($this->getDependencies() as $module => $required) {
|
||||
if ($modules->hasEnabled($module)) {
|
||||
$installed = $modules->getModule($module, false)->getVersion();
|
||||
$installed = \ltrim($installed, 'v'); // v0.6.0 VS 0.6.0
|
||||
if (preg_match('/^([<>=]+)\s*v?(\d+\.\d+\.\d+)$/', $required, $match)) {
|
||||
$operator = $match[1];
|
||||
$vRequired = $match[2];
|
||||
if (\version_compare($installed, $vRequired, $operator)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
include __DIR__ . '/run-missingdeps.php';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user