Small cleanup
This commit is contained in:
parent
2a10f6184a
commit
241fda1196
|
@ -30,69 +30,12 @@
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\Controller;
|
use Icinga\Module\Monitoring\Controller;
|
||||||
use Icinga\Web\Hook;
|
use Icinga\Web\Hook;
|
||||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
|
||||||
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
|
||||||
use Icinga\Web\Widget\Tabs;
|
|
||||||
use Icinga\Module\Monitoring\Backend;
|
|
||||||
use Icinga\Application\Config as IcingaConfig;
|
use Icinga\Application\Config as IcingaConfig;
|
||||||
|
|
||||||
use Icinga\Filter\Filterable;
|
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
|
|
||||||
class ListController extends Controller
|
class ListController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The backend used for this controller
|
|
||||||
*
|
|
||||||
* @var Backend
|
|
||||||
*/
|
|
||||||
protected $backend;
|
|
||||||
/**
|
|
||||||
* Retrieve backend and hooks for this controller
|
|
||||||
*
|
|
||||||
* @see ActionController::init
|
|
||||||
*/
|
|
||||||
public function init()
|
|
||||||
{
|
|
||||||
$this->backend = Backend::createBackend($this->_getParam('backend'));
|
|
||||||
$this->view->grapher = Hook::get('grapher');
|
|
||||||
$this->createTabs();
|
|
||||||
$this->view->activeRowHref = $this->getParam('detail');
|
|
||||||
$this->view->compact = ($this->_request->getParam('view') === 'compact');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Overwrite the backend to use (used for testing)
|
|
||||||
*
|
|
||||||
* @param Backend $backend The Backend that should be used for querying
|
|
||||||
*/
|
|
||||||
public function setBackend($backend)
|
|
||||||
{
|
|
||||||
$this->backend = $backend;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply current users monitoring/filter restrictions to the given query
|
|
||||||
*
|
|
||||||
* @param $query Filterable Query that should be filtered
|
|
||||||
* @return Filterable
|
|
||||||
*/
|
|
||||||
protected function applyRestrictions(Filterable $query)
|
|
||||||
{
|
|
||||||
foreach ($this->getRestrictions('monitoring/filter') as $restriction) {
|
|
||||||
parse_str($restriction, $filter);
|
|
||||||
foreach ($filter as $k => $v) {
|
|
||||||
if ($query->isValidFilterTarget($k)) {
|
|
||||||
// TODO: This is NOT enough. We need to fix filters and get
|
|
||||||
// applyAuthFilters back.
|
|
||||||
$query->where($k, $v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function addTitleTab($action)
|
protected function addTitleTab($action)
|
||||||
{
|
{
|
||||||
$this->getTabs()->add($action, array(
|
$this->getTabs()->add($action, array(
|
||||||
|
@ -101,24 +44,6 @@ class ListController extends Controller
|
||||||
))->activate($action);
|
))->activate($action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return all tabs for this controller
|
|
||||||
*
|
|
||||||
* @return Tabs
|
|
||||||
*/
|
|
||||||
private function createTabs()
|
|
||||||
{
|
|
||||||
$tabs = $this->getTabs();
|
|
||||||
if (in_array($this->_request->getActionName(), array(
|
|
||||||
'hosts',
|
|
||||||
'services',
|
|
||||||
'eventhistory',
|
|
||||||
'notifications'
|
|
||||||
))) {
|
|
||||||
$tabs->extend(new OutputFormat())->extend(new DashboardAction());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function applicationlogAction()
|
public function applicationlogAction()
|
||||||
{
|
{
|
||||||
$this->addTitleTab('application log');
|
$this->addTitleTab('application log');
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
namespace Icinga\Protocol\File;
|
namespace Icinga\Protocol\File;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
namespace Icinga\Protocol\File;
|
namespace Icinga\Protocol\File;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue