ImportsourceTable: add revalidation stub and icons

This commit is contained in:
Thomas Gelf 2015-12-02 03:28:11 +01:00
parent 12b5e0223e
commit f41411c39a
1 changed files with 33 additions and 0 deletions

View File

@ -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();