mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 16:24:05 +02:00
IcingaServiceSet*: Improve Table and view
Add filter and pagination, and some nice display features. refs #12891
This commit is contained in:
parent
c50b1b09a2
commit
b08f3df882
@ -6,35 +6,50 @@ use Icinga\Module\Director\Web\Table\IcingaObjectTable;
|
|||||||
|
|
||||||
class IcingaServiceSetTable extends IcingaObjectTable
|
class IcingaServiceSetTable extends IcingaObjectTable
|
||||||
{
|
{
|
||||||
|
protected $searchColumns = array(
|
||||||
|
'name',
|
||||||
|
);
|
||||||
|
|
||||||
public function getColumns()
|
public function getColumns()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'id' => 'sset.id',
|
'id' => 'sset.id',
|
||||||
'name' => 'sset.object_name',
|
'name' => 'sset.object_name',
|
||||||
'object_type' => 'sset.object_type',
|
'object_type' => 'sset.object_type',
|
||||||
|
'assign_filter' => 'sset.assign_filter',
|
||||||
'description' => 'sset.description',
|
'description' => 'sset.description',
|
||||||
'host_name' => 'h.object_name',
|
'count_hosts' => 'count(ssetobj.id)',
|
||||||
|
'count_services' => 'count(s.id)',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getRowClasses($row)
|
||||||
|
{
|
||||||
|
$class = parent::getRowClasses($row);
|
||||||
|
|
||||||
|
if ($row->object_type === 'template' && $row->assign_filter !== null) {
|
||||||
|
$class = 'icinga-apply';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getTitles()
|
public function getTitles()
|
||||||
{
|
{
|
||||||
$view = $this->view();
|
$view = $this->view();
|
||||||
return array(
|
return array(
|
||||||
'name' => $view->translate('Service set'),
|
'name' => $view->translate('Service set'),
|
||||||
|
'count_services' => $view->translate('# Services'),
|
||||||
|
'count_hosts' => $view->translate('# Hosts'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getActionUrl($row)
|
protected function getActionUrl($row)
|
||||||
{
|
{
|
||||||
// TODO: Remove once we got a separate apply table
|
|
||||||
if ($row->object_type === 'apply') {
|
if ($row->object_type === 'apply') {
|
||||||
$params['id'] = $row->id;
|
$params['id'] = $row->id;
|
||||||
} else {
|
} else {
|
||||||
$params = array('name' => $row->name);
|
$params = array('name' => $row->name);
|
||||||
if ($row->host_name) {
|
|
||||||
$params['host'] = $row->host_name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->url('director/serviceset', $params);
|
return $this->url('director/serviceset', $params);
|
||||||
@ -46,10 +61,33 @@ class IcingaServiceSetTable extends IcingaObjectTable
|
|||||||
array('sset' => 'icinga_service_set'),
|
array('sset' => 'icinga_service_set'),
|
||||||
array()
|
array()
|
||||||
)->joinLeft(
|
)->joinLeft(
|
||||||
array('h' => 'icinga_host'),
|
array('ssih' => 'icinga_service_set_inheritance'),
|
||||||
'h.id = sset.host_id',
|
'ssih.parent_service_set_id = sset.id',
|
||||||
array()
|
array()
|
||||||
)->where('sset.object_type = ?', 'template')->order('sset.object_name');
|
)->joinLeft(
|
||||||
|
array('ssetobj' => 'icinga_service_set'),
|
||||||
|
'ssetobj.id = ssih.service_set_id',
|
||||||
|
array()
|
||||||
|
)->joinLeft(
|
||||||
|
array('s' => 'icinga_service'),
|
||||||
|
's.service_set_id = sset.id',
|
||||||
|
array()
|
||||||
|
)->group('sset.id')
|
||||||
|
->where('sset.object_type = ?', 'template')->order('sset.object_name');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function count()
|
||||||
|
{
|
||||||
|
$db = $this->db();
|
||||||
|
$sub = clone($this->getBaseQuery());
|
||||||
|
$sub->columns($this->getColumns());
|
||||||
|
$this->applyFiltersToQuery($sub);
|
||||||
|
$query = $db->select()->from(
|
||||||
|
array('sub' => $sub),
|
||||||
|
'COUNT(*)'
|
||||||
|
);
|
||||||
|
|
||||||
|
return $db->fetchOne($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBaseQuery()
|
public function getBaseQuery()
|
||||||
|
@ -8,6 +8,8 @@ use Icinga\Exception\NotFoundError;
|
|||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Module\Director\Objects\IcingaObject;
|
use Icinga\Module\Director\Objects\IcingaObject;
|
||||||
use Icinga\Module\Director\Web\Table\IcingaObjectTable;
|
use Icinga\Module\Director\Web\Table\IcingaObjectTable;
|
||||||
|
use Icinga\Module\Director\Web\Table\QuickTable;
|
||||||
|
use Icinga\Web\Widget\FilterEditor;
|
||||||
|
|
||||||
abstract class ObjectsController extends ActionController
|
abstract class ObjectsController extends ActionController
|
||||||
{
|
{
|
||||||
@ -218,9 +220,7 @@ abstract class ObjectsController extends ActionController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->view->title = $this->translate('Icinga ' . $Type . ' Sets');
|
$this->view->title = $this->translate('Icinga ' . $Type . ' Sets');
|
||||||
$this->view->table = $this
|
$table = $this->loadTable('Icinga' . $Type . 'Set')->setConnection($this->db());
|
||||||
->loadTable('Icinga' . $Type . 'Set')
|
|
||||||
->setConnection($this->db());
|
|
||||||
|
|
||||||
$this->view->addLink = $this->view->qlink(
|
$this->view->addLink = $this->view->qlink(
|
||||||
$this->translate('Add'),
|
$this->translate('Add'),
|
||||||
@ -232,6 +232,7 @@ abstract class ObjectsController extends ActionController
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->provideFilterEditorForTable($table);
|
||||||
$this->getTabs()->activate('sets');
|
$this->getTabs()->activate('sets');
|
||||||
$this->setViewScript('objects/table');
|
$this->setViewScript('objects/table');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user