IcingaAppliedServiceTable: base on ipl
This commit is contained in:
parent
24cee68044
commit
f2ad5884ea
|
@ -8,6 +8,7 @@ use Icinga\Module\Director\Web\Controller\ObjectController;
|
|||
use Icinga\Module\Director\Objects\IcingaServiceSet;
|
||||
use Icinga\Module\Director\Objects\IcingaService;
|
||||
use Icinga\Module\Director\Objects\IcingaHost;
|
||||
use Icinga\Module\Director\Web\Table\IcingaAppliedServiceTable;
|
||||
use ipl\Html\Link;
|
||||
|
||||
class ServiceController extends ObjectController
|
||||
|
@ -165,31 +166,30 @@ class ServiceController extends ObjectController
|
|||
}
|
||||
|
||||
$this->content()->add($form);
|
||||
// $this->setViewScript('object/form');
|
||||
}
|
||||
|
||||
public function assignAction()
|
||||
{
|
||||
// TODO: figure out whether and where we link to this
|
||||
/** @var IcingaService $service */
|
||||
$service = $this->object;
|
||||
$this->view->stayHere = true;
|
||||
|
||||
$this->view->actionLinks = $this->view->qlink(
|
||||
$this->actions()->add(new Link(
|
||||
$this->translate('back'),
|
||||
$this->getRequest()->getUrl()->without('rule_id'),
|
||||
null,
|
||||
array('class' => 'icon-left-big')
|
||||
);
|
||||
));
|
||||
|
||||
$this->getTabs()->activate('applied');
|
||||
$this->view->title = sprintf(
|
||||
$this->tabs()->activate('applied');
|
||||
$this->addTitle(
|
||||
$this->translate('Apply: %s'),
|
||||
$service->object_name
|
||||
$service->getObjectName()
|
||||
);
|
||||
$this->view->table = $this->loadTable('IcingaAppliedService')
|
||||
->setService($service)
|
||||
->setConnection($this->db());
|
||||
$table = (new IcingaAppliedServiceTable($this->db()))
|
||||
->setService($service);
|
||||
$table->attributes()->set('data-base-target', '_self');
|
||||
|
||||
$this->setViewScript('objects/table');
|
||||
$this->content()->add($table);
|
||||
}
|
||||
|
||||
public function loadForm($name)
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Tables;
|
||||
|
||||
use Icinga\Module\Director\Objects\IcingaService;
|
||||
use Icinga\Module\Director\Web\Table\QuickTable;
|
||||
|
||||
class IcingaAppliedServiceTable extends QuickTable
|
||||
{
|
||||
protected $service;
|
||||
|
||||
protected $searchColumns = array(
|
||||
'service',
|
||||
);
|
||||
|
||||
public function getColumns()
|
||||
{
|
||||
return array(
|
||||
'id' => 's.id',
|
||||
'service' => 's.object_name',
|
||||
'object_type' => 's.object_type',
|
||||
'display_name' => 's.display_name',
|
||||
);
|
||||
}
|
||||
|
||||
public function setService(IcingaService $service)
|
||||
{
|
||||
$this->service = $service;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getActionUrl($row)
|
||||
{
|
||||
if ($row->object_type === 'apply') {
|
||||
$params['id'] = $row->id;
|
||||
}
|
||||
|
||||
return $this->url('director/service', $params);
|
||||
}
|
||||
|
||||
public function getTitles()
|
||||
{
|
||||
$view = $this->view();
|
||||
return array(
|
||||
'service' => $view->translate('Servicename'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getUnfilteredQuery()
|
||||
{
|
||||
return $this->db()->select()->from(
|
||||
array('s' => 'icinga_service'),
|
||||
array()
|
||||
)->joinLeft(
|
||||
array('si' => 'icinga_service_inheritance'),
|
||||
's.id = si.service_id',
|
||||
array()
|
||||
);
|
||||
}
|
||||
|
||||
public function getBaseQuery()
|
||||
{
|
||||
return $this->getUnfilteredQuery()->where(
|
||||
'si.parent_service_id = ?',
|
||||
$this->service->id
|
||||
)->where('s.object_type = ?', 'apply');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Web\Table;
|
||||
|
||||
use Icinga\Module\Director\Objects\IcingaService;
|
||||
use ipl\Html\Link;
|
||||
use ipl\Web\Table\ZfQueryBasedTable;
|
||||
|
||||
class IcingaAppliedServiceTable extends ZfQueryBasedTable
|
||||
{
|
||||
protected $service;
|
||||
|
||||
protected $searchColumns = array(
|
||||
'service',
|
||||
);
|
||||
|
||||
public function setService(IcingaService $service)
|
||||
{
|
||||
$this->service = $service;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function renderRow($row)
|
||||
{
|
||||
return $this::row(
|
||||
new Link($row->service, 'director/service', ['id' => $row->id])
|
||||
);
|
||||
}
|
||||
|
||||
public function getColumnsToBeRendered()
|
||||
{
|
||||
return [$this->translate('Servicename')];
|
||||
}
|
||||
|
||||
public function prepareQuery()
|
||||
{
|
||||
return $this->db()->select()->from(
|
||||
array('s' => 'icinga_service'),
|
||||
array()
|
||||
)->joinLeft(
|
||||
array('si' => 'icinga_service_inheritance'),
|
||||
's.id = si.service_id',
|
||||
array()
|
||||
)->where(
|
||||
'si.parent_service_id = ?',
|
||||
$this->service->id
|
||||
)->where('s.object_type = ?', 'apply');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue