mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
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\IcingaServiceSet;
|
||||||
use Icinga\Module\Director\Objects\IcingaService;
|
use Icinga\Module\Director\Objects\IcingaService;
|
||||||
use Icinga\Module\Director\Objects\IcingaHost;
|
use Icinga\Module\Director\Objects\IcingaHost;
|
||||||
|
use Icinga\Module\Director\Web\Table\IcingaAppliedServiceTable;
|
||||||
use ipl\Html\Link;
|
use ipl\Html\Link;
|
||||||
|
|
||||||
class ServiceController extends ObjectController
|
class ServiceController extends ObjectController
|
||||||
@ -165,31 +166,30 @@ class ServiceController extends ObjectController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->content()->add($form);
|
$this->content()->add($form);
|
||||||
// $this->setViewScript('object/form');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function assignAction()
|
public function assignAction()
|
||||||
{
|
{
|
||||||
|
// TODO: figure out whether and where we link to this
|
||||||
|
/** @var IcingaService $service */
|
||||||
$service = $this->object;
|
$service = $this->object;
|
||||||
$this->view->stayHere = true;
|
$this->actions()->add(new Link(
|
||||||
|
|
||||||
$this->view->actionLinks = $this->view->qlink(
|
|
||||||
$this->translate('back'),
|
$this->translate('back'),
|
||||||
$this->getRequest()->getUrl()->without('rule_id'),
|
$this->getRequest()->getUrl()->without('rule_id'),
|
||||||
null,
|
null,
|
||||||
array('class' => 'icon-left-big')
|
array('class' => 'icon-left-big')
|
||||||
);
|
));
|
||||||
|
|
||||||
$this->getTabs()->activate('applied');
|
$this->tabs()->activate('applied');
|
||||||
$this->view->title = sprintf(
|
$this->addTitle(
|
||||||
$this->translate('Apply: %s'),
|
$this->translate('Apply: %s'),
|
||||||
$service->object_name
|
$service->getObjectName()
|
||||||
);
|
);
|
||||||
$this->view->table = $this->loadTable('IcingaAppliedService')
|
$table = (new IcingaAppliedServiceTable($this->db()))
|
||||||
->setService($service)
|
->setService($service);
|
||||||
->setConnection($this->db());
|
$table->attributes()->set('data-base-target', '_self');
|
||||||
|
|
||||||
$this->setViewScript('objects/table');
|
$this->content()->add($table);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadForm($name)
|
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');
|
|
||||||
}
|
|
||||||
}
|
|
49
library/Director/Web/Table/IcingaAppliedServiceTable.php
Normal file
49
library/Director/Web/Table/IcingaAppliedServiceTable.php
Normal file
@ -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…
x
Reference in New Issue
Block a user