mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-27 15:54:03 +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;
|
protected $columns;
|
||||||
|
|
||||||
|
/** @var ImportRun */
|
||||||
protected $importRun;
|
protected $importRun;
|
||||||
|
|
||||||
public function setImportRun(ImportRun $run)
|
public function setImportRun(ImportRun $run)
|
||||||
@ -28,6 +29,12 @@ class ImportedrowsTable extends QuickTable
|
|||||||
{
|
{
|
||||||
if ($this->columns === null) {
|
if ($this->columns === null) {
|
||||||
$cols = $this->importRun->listColumnNames();
|
$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 {
|
} else {
|
||||||
$cols = $this->columns;
|
$cols = $this->columns;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ use Icinga\Module\Director\Web\Table\QuickTable;
|
|||||||
|
|
||||||
class ImportsourceHookTable extends QuickTable
|
class ImportsourceHookTable extends QuickTable
|
||||||
{
|
{
|
||||||
|
/** @var ImportSource */
|
||||||
protected $source;
|
protected $source;
|
||||||
|
|
||||||
protected $dataCache;
|
protected $dataCache;
|
||||||
@ -27,6 +28,13 @@ class ImportsourceHookTable extends QuickTable
|
|||||||
);
|
);
|
||||||
|
|
||||||
sort($this->columnCache);
|
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;
|
return $this->columnCache;
|
||||||
|
@ -12,6 +12,9 @@ class ImportRun extends DbObject
|
|||||||
|
|
||||||
protected $autoincKeyName = 'id';
|
protected $autoincKeyName = 'id';
|
||||||
|
|
||||||
|
/** @var ImportSource */
|
||||||
|
protected $importSource = null;
|
||||||
|
|
||||||
protected $defaultProperties = array(
|
protected $defaultProperties = array(
|
||||||
'id' => null,
|
'id' => null,
|
||||||
'source_id' => null,
|
'source_id' => null,
|
||||||
@ -125,4 +128,12 @@ class ImportRun extends DbObject
|
|||||||
|
|
||||||
return $result;
|
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