cingaServiceTable: byebye apply
This commit is contained in:
parent
7fd4e5b033
commit
ffb3748b1c
|
@ -2,10 +2,9 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Director\Tables;
|
namespace Icinga\Module\Director\Tables;
|
||||||
|
|
||||||
use Icinga\Module\Director\Web\Table\IcingaObjectTable;
|
use Icinga\Module\Director\Web\Table\QuickTable;
|
||||||
|
|
||||||
// TODO: quickform once apply has been moved elsewhere
|
class IcingaServiceTable extends QuickTable
|
||||||
class IcingaServiceTable extends IcingaObjectTable
|
|
||||||
{
|
{
|
||||||
protected $searchColumns = array(
|
protected $searchColumns = array(
|
||||||
'service',
|
'service',
|
||||||
|
@ -17,9 +16,15 @@ class IcingaServiceTable extends IcingaObjectTable
|
||||||
'id' => 's.id',
|
'id' => 's.id',
|
||||||
'service' => 's.object_name',
|
'service' => 's.object_name',
|
||||||
'object_type' => 's.object_type',
|
'object_type' => 's.object_type',
|
||||||
|
'check_command_id' => 's.check_command_id',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function listTableClasses()
|
||||||
|
{
|
||||||
|
return array_merge(array('assignment-table'), parent::listTableClasses());
|
||||||
|
}
|
||||||
|
|
||||||
protected function getActionUrl($row)
|
protected function getActionUrl($row)
|
||||||
{
|
{
|
||||||
// TODO: Remove once we got a separate apply table
|
// TODO: Remove once we got a separate apply table
|
||||||
|
@ -33,6 +38,41 @@ class IcingaServiceTable extends IcingaObjectTable
|
||||||
return $this->url('director/service', $params);
|
return $this->url('director/service', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function renderRow($row)
|
||||||
|
{
|
||||||
|
$v = $this->view();
|
||||||
|
$extra = $this->appliedOnes($row->id);
|
||||||
|
$htm = " <tr" . $this->getRowClassesString($row) . ">\n";
|
||||||
|
$htm .= '<td>' . $v->qlink($row->service, $this->getActionUrl($row));
|
||||||
|
if (empty($extra)) {
|
||||||
|
if ($row->check_command_id) {
|
||||||
|
$htm .= ' ' . $v->qlink(
|
||||||
|
'Create apply-rule',
|
||||||
|
'director/service/apply',
|
||||||
|
array('template' => $row->service),
|
||||||
|
array('class' => 'icon-plus')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$htm .= '. Related apply rules: <ul class="apply-rules">';
|
||||||
|
foreach ($extra as $id => $service) {
|
||||||
|
$htm .= '<li>'
|
||||||
|
. $v->qlink($service, 'director/service', array('id' => $id))
|
||||||
|
. '</li>';
|
||||||
|
}
|
||||||
|
$htm .= '</ul>';
|
||||||
|
$htm .= $v->qlink(
|
||||||
|
'Add more',
|
||||||
|
'director/service/apply',
|
||||||
|
array('template' => $row->service),
|
||||||
|
array('class' => 'icon-plus')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$htm .= '</td>';
|
||||||
|
return $htm . " </tr>\n";
|
||||||
|
}
|
||||||
|
|
||||||
public function getTitles()
|
public function getTitles()
|
||||||
{
|
{
|
||||||
$view = $this->view();
|
$view = $this->view();
|
||||||
|
@ -52,12 +92,29 @@ class IcingaServiceTable extends IcingaObjectTable
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function appliedOnes($id)
|
||||||
|
{
|
||||||
|
$db = $this->connection()->getConnection();
|
||||||
|
$query = $db->select()->from(
|
||||||
|
array('s' => 'icinga_service'),
|
||||||
|
array(
|
||||||
|
'id' => 's.id',
|
||||||
|
'objectname' => 's.object_name',
|
||||||
|
)
|
||||||
|
)->join(
|
||||||
|
array('i' => 'icinga_service_inheritance'),
|
||||||
|
'i.service_id = s.id',
|
||||||
|
array()
|
||||||
|
)->where('i.parent_service_id = ?', $id)->where('s.object_type = ?', 'apply');
|
||||||
|
|
||||||
|
return $db->fetchPairs($query);
|
||||||
|
}
|
||||||
|
|
||||||
public function getBaseQuery()
|
public function getBaseQuery()
|
||||||
{
|
{
|
||||||
// TODO: remove apply
|
|
||||||
return $this->getUnfilteredQuery()->where(
|
return $this->getUnfilteredQuery()->where(
|
||||||
's.object_type IN (?)',
|
's.object_type IN (?)',
|
||||||
array('template', 'apply')
|
array('template')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue