monitoring: Control features for multiple selected hosts

refs #8963
This commit is contained in:
Eric Lippmann 2016-01-27 17:42:51 +01:00
parent e45723c4db
commit dee6f4d797
2 changed files with 29 additions and 30 deletions

View File

@ -15,6 +15,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandFo
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostCheckCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ToggleObjectFeaturesCommandForm;
use Icinga\Module\Monitoring\Object\HostList;
use Icinga\Web\Url;
use Icinga\Web\Widget\Tabextension\DashboardAction;
@ -33,6 +34,22 @@ class HostsController extends Controller
$this->applyRestriction('monitoring/filter/objects', $hostList);
$hostList->addFilter(Filter::fromQueryString((string) $this->params));
$this->hostList = $hostList;
$this->hostList->setColumns(array(
'host_acknowledged',
'host_active_checks_enabled',
'host_display_name',
'host_event_handler_enabled',
'host_flap_detection_enabled',
'host_handled',
'host_in_downtime',
'host_is_flapping',
'host_last_state_change',
'host_name',
'host_notifications_enabled',
'host_passive_checks_enabled',
'host_problem',
'host_state'
));
$this->view->baseFilter = $this->hostList->getFilter();
$this->getTabs()->add(
'show',
@ -50,21 +67,6 @@ class HostsController extends Controller
protected function handleCommandForm(ObjectsCommandForm $form)
{
$this->hostList->setColumns(array(
'host_acknowledged',
'host_active_checks_enabled',
'host_display_name',
'host_handled',
'host_in_downtime',
'host_is_flapping',
'host_last_state_change',
'host_name',
'host_notifications_enabled',
'host_passive_checks_enabled',
'host_problem',
'host_state'
));
$form
->setObjects($this->hostList)
->setRedirectUrl(Url::fromPath('monitoring/hosts/show')->setParams($this->params))
@ -85,20 +87,6 @@ class HostsController extends Controller
->setObjects($this->hostList)
->handleRequest();
$this->view->checkNowForm = $checkNowForm;
$this->hostList->setColumns(array(
'host_acknowledged',
'host_active_checks_enabled',
'host_display_name',
'host_handled',
'host_in_downtime',
'host_is_flapping',
'host_last_state_change',
'host_name',
'host_notifications_enabled',
'host_passive_checks_enabled',
'host_problem',
'host_state'
));
$acknowledgedObjects = $this->hostList->getAcknowledgedObjects();
if (! empty($acknowledgedObjects)) {
@ -109,6 +97,16 @@ class HostsController extends Controller
$this->view->removeAckForm = $removeAckForm;
}
$featureStatus = $this->hostList->getFeatureStatus();
$toggleFeaturesForm = new ToggleObjectFeaturesCommandForm(array(
'backend' => $this->backend,
'objects' => $this->hostList
));
$toggleFeaturesForm
->load((object) $featureStatus)
->handleRequest();
$this->view->toggleFeaturesForm = $toggleFeaturesForm;
$hostStates = $this->hostList->getStateSummary();
$this->setAutorefreshInterval(15);

View File

@ -195,6 +195,7 @@
</tr>
</tbody>
</table>
<h2><?= $this->translate('Feature Commands') ?></h2>
<?= $toggleFeaturesForm ?>
<?php endif ?>
</div>