2016-10-20 09:15:42 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Tables;
|
|
|
|
|
|
|
|
use Icinga\Module\Director\Objects\IcingaHost;
|
2017-01-02 10:17:49 +01:00
|
|
|
use Icinga\Module\Director\Web\Table\QuickTable;
|
2016-10-20 09:15:42 +02:00
|
|
|
|
2017-01-02 10:17:49 +01:00
|
|
|
class IcingaHostServiceSetTable extends QuickTable
|
2016-10-20 09:15:42 +02:00
|
|
|
{
|
|
|
|
protected $title;
|
|
|
|
|
|
|
|
protected $host;
|
|
|
|
|
2017-01-02 10:17:49 +01:00
|
|
|
private $lastSetId;
|
|
|
|
|
2016-10-20 09:15:42 +02:00
|
|
|
public function getColumns()
|
|
|
|
{
|
|
|
|
return array(
|
2017-01-02 10:17:49 +01:00
|
|
|
'id' => 'pset.id',
|
|
|
|
'service_set_id' => 'sset.id',
|
|
|
|
'service_set_name' => 'sset.object_name',
|
|
|
|
'name' => 's.object_name',
|
|
|
|
'description' => 'sset.description',
|
|
|
|
'host_name' => 'h.object_name',
|
2016-10-20 09:15:42 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitles()
|
|
|
|
{
|
|
|
|
$view = $this->view();
|
|
|
|
return array(
|
2017-01-02 10:17:49 +01:00
|
|
|
'name' => $view->translate('Service'),
|
2016-10-20 09:15:42 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setTitle($title)
|
|
|
|
{
|
|
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-01-02 10:17:49 +01:00
|
|
|
protected function beginTableBody()
|
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function renderRow($row)
|
|
|
|
{
|
|
|
|
$html = '';
|
|
|
|
$view = $this->view();
|
|
|
|
if ($row->service_set_id !== $this->lastSetId) {
|
|
|
|
if ($this->lastSetId === null) {
|
|
|
|
$html .= "</tbody>\n";
|
|
|
|
}
|
|
|
|
$html .= parent::renderTitles((object) array(
|
|
|
|
'name' => sprintf($view->translate('Service set: %s'), $row->service_set_name)
|
|
|
|
));
|
|
|
|
$html .= "<tbody>\n";
|
|
|
|
$this->lastSetId = $row->service_set_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $html . parent::renderRow($row);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function renderTitles($row)
|
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2016-10-20 09:15:42 +02:00
|
|
|
public function setHost(IcingaHost $host)
|
|
|
|
{
|
|
|
|
$this->host = $host;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getActionUrl($row)
|
|
|
|
{
|
2017-01-02 10:17:49 +01:00
|
|
|
$params = array(
|
|
|
|
'name' => $row->host_name,
|
|
|
|
'service' => $row->name,
|
|
|
|
'serviceSet' => $row->id,
|
|
|
|
);
|
2016-10-20 09:15:42 +02:00
|
|
|
|
2017-01-02 10:17:49 +01:00
|
|
|
return $this->url('director/host/servicesetservice', $params);
|
2016-10-20 09:15:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getUnfilteredQuery()
|
|
|
|
{
|
2016-11-02 14:27:23 +01:00
|
|
|
return $this->db()->select()->from(
|
2017-01-02 10:17:49 +01:00
|
|
|
array('pset' => 'icinga_service_set'),
|
|
|
|
array()
|
|
|
|
)->join(
|
|
|
|
array('sseti' => 'icinga_service_set_inheritance'),
|
|
|
|
'pset.id = sseti.parent_service_set_id',
|
|
|
|
array()
|
|
|
|
)->join(
|
2016-10-20 09:15:42 +02:00
|
|
|
array('sset' => 'icinga_service_set'),
|
2017-01-02 10:17:49 +01:00
|
|
|
'sset.id = sseti.service_set_id',
|
2016-10-20 09:15:42 +02:00
|
|
|
array()
|
2017-01-02 10:17:49 +01:00
|
|
|
)->join(
|
2016-10-20 09:15:42 +02:00
|
|
|
array('h' => 'icinga_host'),
|
|
|
|
'h.id = sset.host_id',
|
|
|
|
array()
|
2017-01-02 10:17:49 +01:00
|
|
|
)->join(
|
|
|
|
array('s' => 'icinga_service'),
|
|
|
|
'pset.id = s.service_set_id',
|
|
|
|
array()
|
2016-10-20 09:15:42 +02:00
|
|
|
)->where('sset.host_id = ?', $this->host->id)->order('sset.object_name');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBaseQuery()
|
|
|
|
{
|
|
|
|
return $this->getUnfilteredQuery();
|
|
|
|
}
|
|
|
|
}
|