Skip to content

Commit

Permalink
NotificationTable: simplify it, provide templates
Browse files Browse the repository at this point in the history
fixes #13263
  • Loading branch information
Thomas-Gelf committed Dec 14, 2016
1 parent 4c5adda commit 30c2dfa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 60 deletions.
63 changes: 3 additions & 60 deletions application/tables/IcingaNotificationTable.php
Expand Up @@ -2,12 +2,12 @@

namespace Icinga\Module\Director\Tables;

use Icinga\Module\Director\Web\Table\IcingaObjectTable;
use Icinga\Module\Director\Web\Table\QuickTable;

class IcingaNotificationTable extends IcingaObjectTable
class IcingaNotificationTable extends QuickTable
{
protected $searchColumns = array(
'user',
'notification',
);

public function getColumns()
Expand All @@ -19,11 +19,6 @@ public function getColumns()
);
}

protected function listTableClasses()
{
return array_merge(array('assignment-table'), parent::listTableClasses());
}

protected function getActionUrl($row)
{
return $this->url('director/notification', array('id' => $row->id));
Expand All @@ -37,58 +32,6 @@ public function getTitles()
);
}

protected function renderRow($row)
{
$v = $this->view();
$extra = $this->appliedOnes($row->id);
$htm = " <tr" . $this->getRowClassesString($row) . ">\n";
$htm .= '<td>' . $v->qlink($row->notification, $this->getActionUrl($row));
if (empty($extra)) {
$htm .= ' ' . $v->qlink(
'Create apply-rule',
'director/notification/add',
array('apply' => $row->notification, 'type' => 'apply'),
array('class' => 'icon-plus')
);

} else {
$htm .= '. Related apply rules: <ul class="apply-rules">';
foreach ($extra as $id => $notification) {
$htm .= '<li>'
. $v->qlink($notification, 'director/notification', array('id' => $id))
. '</li>';
}
$htm .= '</ul>';
$htm .= $v->qlink(
'Add more',
'director/notification/add',
array('apply' => $row->notification),
array('class' => 'icon-plus')
);
}
$htm .= '</td>';
return $htm . " </tr>\n";
}

protected function appliedOnes($id)
{
$db = $this->db();
$query = $db->select()->from(
array('s' => 'icinga_notification'),
array(
'id' => 's.id',
'objectname' => 's.object_name',
)
)->join(
array('i' => 'icinga_notification_inheritance'),
'i.notification_id = s.id',
array()
)->where('i.parent_notification_id = ?', $id)
->where('s.object_type = ?', 'apply');


return $db->fetchPairs($query);
}

public function getUnfilteredQuery()
{
Expand Down
7 changes: 7 additions & 0 deletions application/tables/IcingaNotificationTemplateTable.php
@@ -0,0 +1,7 @@
<?php

namespace Icinga\Module\Director\Tables;

class IcingaNotificationTemplateTable extends IcingaNotificationTable
{
}

0 comments on commit 30c2dfa

Please sign in to comment.