icingaweb2/application/controllers/SearchController.php

45 lines
1.4 KiB
PHP
Raw Normal View History

2014-02-25 11:56:58 +01:00
<?php
/**
* Icinga (http://www.icinga.org)
*
* @copyright 2014 Icinga Development Team <info@icinga.org>
* @license http://www.icinga.org/license/gpl2 GPL, version 2
*/
use Icinga\Web\Controller\ActionController;
use Icinga\Application\Icinga;
use Icinga\Web\Widget;
use Icinga\Web\Url;
/**
* Search controller
*/
class SearchController extends ActionController
{
public function indexAction()
{
2014-03-09 01:56:05 +01:00
// $this->setAutorefreshInterval(10);
2014-02-25 11:56:58 +01:00
$search = $this->_request->getParam('q');
$dashboard = Widget::create('dashboard')->createPane('Search');
$pane = $dashboard->getPane('Search');
$suffix = strlen($search) ? ': ' . rtrim($search, '*') . '*' : '';
$pane->addComponent('Hosts' . $suffix, Url::fromPath('monitoring/list/hosts', array(
2014-02-25 11:56:58 +01:00
'host_name' => $search . '*',
'sort' => 'host_severity',
'limit' => 10,
)));
$pane->addComponent('Services' . $suffix, Url::fromPath('monitoring/list/services', array(
'service_description' => $search . '*',
2014-02-25 11:56:58 +01:00
'sort' => 'service_severity',
'limit' => 10,
)));
$pane->addComponent('Hostgroups' . $suffix, Url::fromPath('monitoring/list/hostgroups', array(
'hostgroup' => $search . '*',
2014-02-25 11:56:58 +01:00
'limit' => 10,
)));
$dashboard->activate('Search');
$this->view->dashboard = $dashboard;
$this->view->tabs = $dashboard->getTabs();
}
}