mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 13:54:26 +02:00
Merge pull request #3304 from Icinga/feature/detailview-improvement
Integrate DetailviewExtension into multi-select views
This commit is contained in:
commit
201cfa2330
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Controllers;
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Data\Filter\FilterEqual;
|
use Icinga\Data\Filter\FilterEqual;
|
||||||
use Icinga\Module\Monitoring\Controller;
|
use Icinga\Module\Monitoring\Controller;
|
||||||
@ -16,7 +17,9 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostCheckCommandForm;
|
|||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ToggleObjectFeaturesCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ToggleObjectFeaturesCommandForm;
|
||||||
|
use Icinga\Module\Monitoring\Hook\DetailviewExtensionHook;
|
||||||
use Icinga\Module\Monitoring\Object\HostList;
|
use Icinga\Module\Monitoring\Object\HostList;
|
||||||
|
use Icinga\Web\Hook;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
use Icinga\Web\Widget\Tabextension\MenuAction;
|
use Icinga\Web\Widget\Tabextension\MenuAction;
|
||||||
@ -160,6 +163,24 @@ class HostsController extends Controller
|
|||||||
$this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments');
|
$this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments');
|
||||||
$this->view->sendCustomNotificationLink = Url::fromRequest()
|
$this->view->sendCustomNotificationLink = Url::fromRequest()
|
||||||
->setPath('monitoring/hosts/send-custom-notification');
|
->setPath('monitoring/hosts/send-custom-notification');
|
||||||
|
|
||||||
|
$this->view->extensionsHtml = array();
|
||||||
|
foreach (Hook::all('Monitoring\DetailviewExtension') as $hook) {
|
||||||
|
/** @var DetailviewExtensionHook $hook */
|
||||||
|
try {
|
||||||
|
$html = $hook->setView($this->view)->getHtmlForObjects($this->hostList);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$html = $this->view->escape($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($html) {
|
||||||
|
$module = $this->view->escape($hook->getModule()->getName());
|
||||||
|
$this->view->extensionsHtml[] =
|
||||||
|
'<div class="icinga-module module-' . $module . '" data-icinga-module="' . $module . '">'
|
||||||
|
. $html
|
||||||
|
. '</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Controllers;
|
namespace Icinga\Module\Monitoring\Controllers;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Module\Monitoring\Controller;
|
use Icinga\Module\Monitoring\Controller;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
|
||||||
@ -15,7 +16,9 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceCheckCommandFor
|
|||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ToggleObjectFeaturesCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ToggleObjectFeaturesCommandForm;
|
||||||
|
use Icinga\Module\Monitoring\Hook\DetailviewExtensionHook;
|
||||||
use Icinga\Module\Monitoring\Object\ServiceList;
|
use Icinga\Module\Monitoring\Object\ServiceList;
|
||||||
|
use Icinga\Web\Hook;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||||
use Icinga\Web\Widget\Tabextension\MenuAction;
|
use Icinga\Web\Widget\Tabextension\MenuAction;
|
||||||
@ -162,6 +165,24 @@ class ServicesController extends Controller
|
|||||||
$this->view->sendCustomNotificationLink = Url::fromRequest()->setPath(
|
$this->view->sendCustomNotificationLink = Url::fromRequest()->setPath(
|
||||||
'monitoring/services/send-custom-notification'
|
'monitoring/services/send-custom-notification'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->view->extensionsHtml = array();
|
||||||
|
foreach (Hook::all('Monitoring\DetailviewExtension') as $hook) {
|
||||||
|
/** @var DetailviewExtensionHook $hook */
|
||||||
|
try {
|
||||||
|
$html = $hook->setView($this->view)->getHtmlForObjects($this->serviceList);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$html = $this->view->escape($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($html) {
|
||||||
|
$module = $this->view->escape($hook->getModule()->getName());
|
||||||
|
$this->view->extensionsHtml[] =
|
||||||
|
'<div class="icinga-module module-' . $module . '" data-icinga-module="' . $module . '">'
|
||||||
|
. $html
|
||||||
|
. '</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
<?php if ($hostCount === 0): ?>
|
<?php if ($hostCount === 0): ?>
|
||||||
<?= $this->translate('No hosts found matching the filter'); ?>
|
<?= $this->translate('No hosts found matching the filter'); ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
<?= $this->render('show/components/extensions.phtml') ?>
|
||||||
<h2><?= $this->translate('Problem Handling') ?></h2>
|
<h2><?= $this->translate('Problem Handling') ?></h2>
|
||||||
<table class="name-value-table">
|
<table class="name-value-table">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
<?php if ($serviceCount === 0): ?>
|
<?php if ($serviceCount === 0): ?>
|
||||||
<?= $this->translate('No services found matching the filter') ?>
|
<?= $this->translate('No services found matching the filter') ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
<?= $this->render('show/components/extensions.phtml') ?>
|
||||||
<h2> <?= $this->translate('Problem handling') ?> </h2>
|
<h2> <?= $this->translate('Problem handling') ?> </h2>
|
||||||
<table class="name-value-table">
|
<table class="name-value-table">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -7,6 +7,7 @@ use Icinga\Application\ClassLoader;
|
|||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Application\Modules\Module;
|
use Icinga\Application\Modules\Module;
|
||||||
use Icinga\Module\Monitoring\Object\MonitoredObject;
|
use Icinga\Module\Monitoring\Object\MonitoredObject;
|
||||||
|
use Icinga\Module\Monitoring\Object\ObjectList;
|
||||||
use Icinga\Web\View;
|
use Icinga\Web\View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,6 +57,19 @@ abstract class DetailviewExtensionHook
|
|||||||
*/
|
*/
|
||||||
abstract public function getHtmlForObject(MonitoredObject $object);
|
abstract public function getHtmlForObject(MonitoredObject $object);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shall return valid HTML to include in the detail view of a multi-select view
|
||||||
|
*
|
||||||
|
* @param ObjectList $objects A list of objects shown in the multi-select view
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getHtmlForObjects($objects)
|
||||||
|
{
|
||||||
|
// For compatibility empty by default
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get {@link view}
|
* Get {@link view}
|
||||||
*
|
*
|
||||||
|
@ -92,12 +92,15 @@ abstract class MonitoredObjectController extends Controller
|
|||||||
$html = $this->view->escape($e->getMessage());
|
$html = $this->view->escape($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($html) {
|
||||||
|
$module = $this->view->escape($hook->getModule()->getName());
|
||||||
$this->view->extensionsHtml[] =
|
$this->view->extensionsHtml[] =
|
||||||
'<div class="icinga-module module-' . $this->view->escape($hook->getModule()->getName()) . '">'
|
'<div class="icinga-module module-' . $module . '" data-icinga-module="' . $module . '">'
|
||||||
. $html
|
. $html
|
||||||
. '</div>';
|
. '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the history for a host or service
|
* Show the history for a host or service
|
||||||
|
Loading…
x
Reference in New Issue
Block a user