Skip to content

Commit

Permalink
Remove service_set_id is null condition to objects in ObjectTableSe…
Browse files Browse the repository at this point in the history
…rvice.php

For number of objects in ServiceTemplateUsageTable and objects in ObjectsTable to be consistent
`service_set_id is null` condition is removed in prepareQuery() in ObjectTableService.php and left join
on icinga_service_set is added to get the services from service set. Also, the header for object table is
changed from 'Host' to 'Host | Service Set'.
  • Loading branch information
raviks789 committed Aug 17, 2021
1 parent 1470a13 commit 84682a8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions library/Director/Web/Table/ObjectsTableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function getColumns()
return [
'object_name' => 'o.object_name',
'disabled' => 'o.disabled',
'host' => 'h.object_name',
'host_set' => 'CASE WHEN o.service_set_id IS NULL THEN h.object_name ELSE os.object_name END',
'host_object_type' => 'h.object_type',
'host_disabled' => 'h.disabled',
'id' => 'o.id',
Expand All @@ -43,7 +43,7 @@ public function assemble()
public function getColumnsToBeRendered()
{
return [
'host' => 'Host',
'host_set' => 'Host | Service Set',
'object_name' => 'Service Name'
];
}
Expand All @@ -52,16 +52,16 @@ public function renderRow($row)
{
$url = Url::fromPath('director/service/edit', [
'name' => $row->object_name,
'host' => $row->host,
'host_set' => $row->host_set,
'id' => $row->id,
]);

$caption = $row->host === null
$caption = $row->host_set === null
? Html::tag('span', ['class' => 'error'], '- none -')
: $row->host;
: $row->host_set;

$hostField = static::td(Link::create($caption, $url));
if ($row->host === null) {
if ($row->host_set === null) {
$hostField->getAttributes()->add('class', 'error');
}
$tr = static::tr([
Expand Down Expand Up @@ -90,7 +90,10 @@ public function prepareQuery()
['hsb' => 'icinga_host_service_blacklist'],
'hsb.service_id = o.id AND hsb.host_id = o.host_id',
[]
)->where('o.service_set_id IS NULL')
->order('o.object_name')->order('h.object_name');
)->joinLeft(
['os' => 'icinga_service_set'],
'os.id = o.service_set_id',
[]
)->order('o.object_name')->order('h.object_name');
}
}

0 comments on commit 84682a8

Please sign in to comment.