mirror of
https://github.com/Icinga/icingaweb2.git
synced 2026-06-15 03:20:43 -04:00
Hopefully users will now always include the first message in reports and not only the stacktrace Hopefully users will now always include the first message in reports and not only the stacktrace……
119 lines
5.3 KiB
PHTML
119 lines
5.3 KiB
PHTML
<?php if (! $this->compact && ! $hideControls): ?>
|
|
<div class="controls">
|
|
<?= $tabs ?>
|
|
</div>
|
|
<?php endif ?>
|
|
<div class="content">
|
|
<div class="clipboard-wrapper">
|
|
<button type="button"
|
|
class="copy-to-clipboard"
|
|
data-icinga-clipboard
|
|
tabindex="-1"
|
|
data-copied-label="<?= $this->translate('Copied') ?>"
|
|
title="<?= $this->translate('Copy to clipboard') ?>"
|
|
>
|
|
<i class="icon fa fa-clone"></i>
|
|
</button>
|
|
<div class="error-message-wrapper" data-clipboard-source>
|
|
<?php
|
|
if (isset($stackTraces)) {
|
|
foreach ($messages as $i => $message) {
|
|
echo '<p class="error-message">' . nl2br($this->escape($message)) . '<br></p>'
|
|
. '<hr>'
|
|
. '<pre>' . $this->escape($stackTraces[$i]) . '<br></pre>';
|
|
}
|
|
} else {
|
|
foreach ($messages as $message) {
|
|
echo '<p class="error-message">' . nl2br($this->escape($message)) . '</p>';
|
|
}
|
|
}
|
|
|
|
$libraries = \Icinga\Application\Icinga::app()->getLibraries();
|
|
$coreReason = [];
|
|
$modReason = [];
|
|
|
|
if (isset($requiredVendor, $requiredProject) && $requiredVendor && $requiredProject) {
|
|
// TODO: I don't like this, can we define requirements somewhere else?
|
|
$coreDeps = ['icinga-php-library' => '>= 0.20.0', 'icinga-php-thirdparty' => '>= 0.15.0'];
|
|
|
|
foreach ($coreDeps as $libraryName => $requiredVersion) {
|
|
if (! $libraries->has($libraryName)) {
|
|
$coreReason[] = sprintf($this->translate(
|
|
'Library "%s" is required and missing. Please install a version of it matching the required one: %s'
|
|
), $libraryName, $requiredVersion);
|
|
} elseif (! $libraries->has($libraryName, $requiredVersion) && $libraries->get($libraryName)->isRequired($requiredVendor, $requiredProject)) {
|
|
$coreReason[] = sprintf($this->translate(
|
|
'Library "%s" is required and installed, but its version (%s) does not satisfy the required one: %s'
|
|
), $libraryName, $libraries->get($libraryName)->getVersion() ?: '-', $requiredVersion);
|
|
}
|
|
}
|
|
|
|
if (! empty($coreReason)) {
|
|
array_unshift($coreReason, $this->translate('You have unmet dependencies. Please check Icinga Web 2\'s installation instructions.'));
|
|
}
|
|
}
|
|
|
|
if (isset($module)) {
|
|
$manager = \Icinga\Application\Icinga::app()->getModuleManager();
|
|
if ($manager->hasUnmetDependencies($module->getName())) {
|
|
if (isset($requiredModule) && $requiredModule && isset($module->getRequiredModules()[$requiredModule])) {
|
|
if (! $manager->hasInstalled($requiredModule)) {
|
|
$modReason[] = sprintf($this->translate(
|
|
'Module "%s" is required and missing. Please install a version of it matching the required one: %s'
|
|
), $requiredModule, $module->getRequiredModules()[$requiredModule]);
|
|
} elseif (! $manager->hasEnabled($requiredModule)) {
|
|
$modReason[] = sprintf($this->translate(
|
|
'Module "%s" is required and installed, but not enabled. Please enable module "%1$s".'
|
|
), $requiredModule);
|
|
} elseif (! $manager->has($requiredModule, $module->getRequiredModules()[$requiredModule])) {
|
|
$modReason[] = sprintf($this->translate(
|
|
'Module "%s" is required and installed, but its version (%s) does not satisfy the required one: %s'
|
|
), $requiredModule, $manager->getModule($requiredModule, false)->getVersion(), $module->getRequiredModules()[$requiredModule]);
|
|
}
|
|
} elseif (isset($requiredVendor, $requiredProject) && $requiredVendor && $requiredProject) {
|
|
foreach ($module->getRequiredLibraries() as $libraryName => $requiredVersion) {
|
|
if (! $libraries->has($libraryName)) {
|
|
$modReason[] = sprintf($this->translate(
|
|
'Library "%s" is required and missing. Please install a version of it matching the required one: %s'
|
|
), $libraryName, $requiredVersion);
|
|
} elseif (! $libraries->has($libraryName, $requiredVersion) && $libraries->get($libraryName)->isRequired($requiredVendor, $requiredProject)) {
|
|
$modReason[] = sprintf($this->translate(
|
|
'Library "%s" is required and installed, but its version (%s) does not satisfy the required one: %s'
|
|
), $libraryName, $libraries->get($libraryName)->getVersion() ?: '-', $requiredVersion);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (! empty($modReason)) {
|
|
array_unshift($modReason, sprintf($this->translate(
|
|
'This error might have occurred because module "%s" has unmet dependencies.'
|
|
. ' Please check it\'s installation instructions and install missing dependencies.'
|
|
), $module->getName()));
|
|
}
|
|
}
|
|
}
|
|
|
|
// The following doesn't use ipl\Html because that's what the error possibly is about
|
|
?>
|
|
</div>
|
|
</div>
|
|
<?php if (! empty($coreReason)): ?>
|
|
<div class="error-reason">
|
|
<?php endif ?>
|
|
<?php foreach ($coreReason as $msg): ?>
|
|
<p><?= $msg ?></p>
|
|
<?php endforeach ?>
|
|
<?php if (! empty($coreReason)): ?>
|
|
</div>
|
|
<?php endif ?>
|
|
|
|
<?php if (! empty($modReason)): ?>
|
|
<div class="error-reason">
|
|
<?php endif ?>
|
|
<?php foreach ($modReason as $msg): ?>
|
|
<p><?= $msg ?></p>
|
|
<?php endforeach ?>
|
|
<?php if (! empty($modReason)): ?>
|
|
</div>
|
|
<?php endif ?>
|
|
</div>
|