mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-27 07:44:05 +02:00
Merge branch 'feature/better-import-table'
This commit is contained in:
commit
1a51e55563
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user