Merge branch 'feature/better-import-table'

This commit is contained in:
Markus Frosch 2016-11-11 11:30:56 +01:00
commit 1a51e55563
3 changed files with 26 additions and 0 deletions

View File

@ -10,6 +10,7 @@ class ImportedrowsTable extends QuickTable
{
protected $columns;
/** @var ImportRun */
protected $importRun;
public function setImportRun(ImportRun $run)
@ -28,6 +29,12 @@ class ImportedrowsTable extends QuickTable
{
if ($this->columns === null) {
$cols = $this->importRun->listColumnNames();
$keyColumn = $this->importRun->importSource()->get('key_column');
if ($keyColumn !== null && ($pos = array_search($keyColumn, $cols)) !== false) {
unset($cols[$pos]);
array_unshift($cols, $keyColumn);
}
} else {
$cols = $this->columns;
}

View File

@ -10,6 +10,7 @@ use Icinga\Module\Director\Web\Table\QuickTable;
class ImportsourceHookTable extends QuickTable
{
/** @var ImportSource */
protected $source;
protected $dataCache;
@ -27,6 +28,13 @@ class ImportsourceHookTable extends QuickTable
);
sort($this->columnCache);
// prioritize key column
$keyColumn = $this->source->get('key_column');
if ($keyColumn !== null && ($pos = array_search($keyColumn, $this->columnCache)) !== false) {
unset($this->columnCache[$pos]);
array_unshift($this->columnCache, $keyColumn);
}
}
return $this->columnCache;

View File

@ -12,6 +12,9 @@ class ImportRun extends DbObject
protected $autoincKeyName = 'id';
/** @var ImportSource */
protected $importSource = null;
protected $defaultProperties = array(
'id' => null,
'source_id' => null,
@ -125,4 +128,12 @@ class ImportRun extends DbObject
return $result;
}
public function importSource()
{
if ($this->importSource === null) {
$this->importSource = ImportSource::load($this->get('source_id'), $this->connection);
}
return $this->importSource;
}
}