From 30c2dfad75c771b3bcd6f138fa52c40e10d7ef5f Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 14 Dec 2016 14:57:52 +0100 Subject: [PATCH] NotificationTable: simplify it, provide templates fixes #13263 --- .../tables/IcingaNotificationTable.php | 63 +------------------ .../IcingaNotificationTemplateTable.php | 7 +++ 2 files changed, 10 insertions(+), 60 deletions(-) create mode 100644 application/tables/IcingaNotificationTemplateTable.php diff --git a/application/tables/IcingaNotificationTable.php b/application/tables/IcingaNotificationTable.php index ed63231b..6804c6a5 100644 --- a/application/tables/IcingaNotificationTable.php +++ b/application/tables/IcingaNotificationTable.php @@ -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() @@ -19,11 +19,6 @@ class IcingaNotificationTable extends IcingaObjectTable ); } - protected function listTableClasses() - { - return array_merge(array('assignment-table'), parent::listTableClasses()); - } - protected function getActionUrl($row) { return $this->url('director/notification', array('id' => $row->id)); @@ -37,58 +32,6 @@ class IcingaNotificationTable extends IcingaObjectTable ); } - protected function renderRow($row) - { - $v = $this->view(); - $extra = $this->appliedOnes($row->id); - $htm = " getRowClassesString($row) . ">\n"; - $htm .= '' . $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: '; - $htm .= $v->qlink( - 'Add more', - 'director/notification/add', - array('apply' => $row->notification), - array('class' => 'icon-plus') - ); - } - $htm .= ''; - return $htm . " \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() { diff --git a/application/tables/IcingaNotificationTemplateTable.php b/application/tables/IcingaNotificationTemplateTable.php new file mode 100644 index 00000000..ec32fb0c --- /dev/null +++ b/application/tables/IcingaNotificationTemplateTable.php @@ -0,0 +1,7 @@ +