mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-27 15:54:03 +02:00
ImportRowModifier: Access sub values
This commit is contained in:
parent
46bea737c3
commit
cbd0b131fd
@ -3,8 +3,11 @@
|
||||
namespace Icinga\Module\Director\Controllers;
|
||||
|
||||
use dipl\Html\Html;
|
||||
use Icinga\Exception\NotFoundError;
|
||||
use Icinga\Module\Director\Hook\ImportSourceHook;
|
||||
use Icinga\Module\Director\Objects\IcingaHost;
|
||||
use Icinga\Module\Director\Objects\IcingaService;
|
||||
use Icinga\Module\Director\Objects\ImportSource;
|
||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Module\Director\Objects\HostApplyMatches;
|
||||
@ -383,4 +386,25 @@ class SuggestController extends ActionController
|
||||
|
||||
return $db->fetchAll($query);
|
||||
}
|
||||
|
||||
protected function suggestImportsourceproperties($sourceId = null)
|
||||
{
|
||||
if ($sourceId === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
$importSource = ImportSource::loadWithAutoIncId($sourceId, $this->db());
|
||||
$source = ImportSourceHook::loadByName($importSource->get('source_name'), $this->db());
|
||||
|
||||
$columns = array_merge(
|
||||
$source->listColumns(),
|
||||
$importSource->listProperties()
|
||||
);
|
||||
|
||||
return array_combine($columns, $columns);
|
||||
} catch (NotFoundError $e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,19 +26,13 @@ class ImportRowModifierForm extends DirectorObjectForm
|
||||
{
|
||||
$this->addHidden('source_id', $this->source->id);
|
||||
|
||||
$this->addElement('select', 'property_name', [
|
||||
$this->addElement('text', 'property_name', array(
|
||||
'label' => $this->translate('Property'),
|
||||
'description' => $this->translate('This must be an import source column (property)'),
|
||||
'required' => true,
|
||||
]);
|
||||
try {
|
||||
$sourceColumns = $this->enumSourceColumns();
|
||||
$this->getElement('property_name')->setOptions([
|
||||
'multiOptions' => $this->optionalEnum($sourceColumns)
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
$this->getElement('property_name')->addError($e->getMessage());
|
||||
}
|
||||
'class' => 'autosubmit director-suggest',
|
||||
'data-suggestion-context' => 'importsourceproperties!' . $this->source->id,
|
||||
));
|
||||
|
||||
$this->addElement('text', 'target_property', [
|
||||
'label' => $this->translate('Target property'),
|
||||
@ -104,22 +98,6 @@ class ImportRowModifierForm extends DirectorObjectForm
|
||||
$this->setButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws ConfigurationError
|
||||
*/
|
||||
protected function enumSourceColumns()
|
||||
{
|
||||
$columns = array_merge(
|
||||
$this->getImportSource()->listColumns(),
|
||||
$this->source->listModifierTargetProperties()
|
||||
);
|
||||
|
||||
$columns = array_combine($columns, $columns);
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ImportSourceHook
|
||||
* @throws ConfigurationError
|
||||
|
Loading…
x
Reference in New Issue
Block a user