From f41411c39a3ba4106bc2887eab1078c8811e65d5 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 2 Dec 2015 03:28:11 +0100 Subject: [PATCH] ImportsourceTable: add revalidation stub and icons --- application/tables/ImportsourceTable.php | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/application/tables/ImportsourceTable.php b/application/tables/ImportsourceTable.php index 0d334b27..2fad4985 100644 --- a/application/tables/ImportsourceTable.php +++ b/application/tables/ImportsourceTable.php @@ -3,9 +3,14 @@ namespace Icinga\Module\Director\Tables; use Icinga\Module\Director\Web\Table\QuickTable; +use Icinga\Module\Director\Import\Import; +use Icinga\Module\Director\Objects\ImportSource; +use Exception; class ImportsourceTable extends QuickTable { + protected $revalidate = false; + protected $searchColumns = array( 'source_name', ); @@ -32,6 +37,34 @@ class ImportsourceTable extends QuickTable ); } + protected function listTableClasses() + { + return array_merge(array('syncstate'), parent::listTableClasses()); + } + + protected function getRowClasses($row) + { + if (! $this->revalidate) { + return array(); + } + try { + $import = new Import(ImportSource::load($row->id,$this->connection())); + if ($import->providesChanges()) { + $row->source_name = sprintf( + '%s (%s)', + $row->source_name, + $this->view()->translate('has changes') + ); + return 'pending-changes'; + } else { + return 'in-sync'; + } + } catch (Exception $e) { + $row->source_name = $row->source_name . ' (' . $e->getMessage() . ')'; + return 'failing'; + } + } + public function getBaseQuery() { $db = $this->connection()->getConnection();