From 4510ab3c42360958acc0de94cc4bba114686236f Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sat, 31 Oct 2015 00:01:25 +0100 Subject: [PATCH] SyncruleTable: provide sync state classes --- application/tables/SyncruleTable.php | 29 +++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/application/tables/SyncruleTable.php b/application/tables/SyncruleTable.php index 0744197d..2d5ca031 100644 --- a/application/tables/SyncruleTable.php +++ b/application/tables/SyncruleTable.php @@ -3,6 +3,9 @@ namespace Icinga\Module\Director\Tables; use Icinga\Module\Director\Web\Table\QuickTable; +use Icinga\Module\Director\Import\Sync; +use Icinga\Module\Director\Objects\SyncRule; +use Exception; class SyncruleTable extends QuickTable { @@ -20,7 +23,12 @@ class SyncruleTable extends QuickTable protected function getActionUrl($row) { - return $this->url('director/syncrule/add', array('id' => $row->id)); + return $this->url('director/syncrule/edit', array('id' => $row->id)); + } + + protected function listTableClasses() + { + return array_merge(array('syncrules'), parent::listTableClasses()); } protected function renderAdditionalActions($row) @@ -33,6 +41,25 @@ class SyncruleTable extends QuickTable ); } + protected function getRowClasses($row) + { + try { + // $mod = Sync::hasModifications( + $mod = Sync::getExpectedModifications( + SyncRule::load($row->id, $this->connection()) + ); + if (count($mod) > 0) { + $row->rule_name = $row->rule_name . ' (' . count($mod) . ')'; + return 'pending-changes'; + } else { + return 'in-sync'; + } + } catch (Exception $e) { + $row->rule_name = $row->rule_name . ' (' . $e->getMessage() . ')'; + return 'failing'; + } + } + public function getTitles() { $view = $this->view();