diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:43:12 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:43:12 +0000 |
commit | cd989f9c3aff968e19a3aeabc4eb9085787a6673 (patch) | |
tree | fbff2135e7013f196b891bbde54618eb050e4aaf /library/Director/Web/Table/BranchedIcingaCommandArgumentTable.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-director-cd989f9c3aff968e19a3aeabc4eb9085787a6673.tar.xz icingaweb2-module-director-cd989f9c3aff968e19a3aeabc4eb9085787a6673.zip |
Adding upstream version 1.10.2.upstream/1.10.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Director/Web/Table/BranchedIcingaCommandArgumentTable.php')
-rw-r--r-- | library/Director/Web/Table/BranchedIcingaCommandArgumentTable.php | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/library/Director/Web/Table/BranchedIcingaCommandArgumentTable.php b/library/Director/Web/Table/BranchedIcingaCommandArgumentTable.php new file mode 100644 index 0000000..3d5dbcb --- /dev/null +++ b/library/Director/Web/Table/BranchedIcingaCommandArgumentTable.php @@ -0,0 +1,78 @@ +<?php + +namespace Icinga\Module\Director\Web\Table; + +use gipfl\IcingaWeb2\Data\SimpleQueryPaginationAdapter; +use gipfl\IcingaWeb2\Table\QueryBasedTable; +use Icinga\Data\DataArray\ArrayDatasource; +use Icinga\Module\Director\Db\Branch\Branch; +use Icinga\Module\Director\Objects\IcingaCommand; +use gipfl\IcingaWeb2\Link; + +class BranchedIcingaCommandArgumentTable extends QueryBasedTable +{ + /** @var IcingaCommand */ + protected $command; + + /** @var Branch */ + protected $branch; + + protected $searchColumns = [ + 'ca.argument_name', + 'ca.argument_value', + ]; + + public function __construct(IcingaCommand $command, Branch $branch) + { + $this->command = $command; + $this->branch = $branch; + $this->getAttributes()->set('data-base-target', '_self'); + } + + public function renderRow($row) + { + return $this::row([ + Link::create($row->argument_name, 'director/command/arguments', [ + 'argument' => $row->argument_name, + 'uuid' => $this->command->getUniqueId()->toString(), + ]), + $row->argument_value + ]); + } + + public function getColumnsToBeRendered() + { + return [ + $this->translate('Argument'), + $this->translate('Value'), + ]; + } + + protected function getPaginationAdapter() + { + return new SimpleQueryPaginationAdapter($this->getQuery()); + } + + public function getQuery() + { + return $this->prepareQuery(); + } + + protected function fetchQueryRows() + { + return $this->getQuery()->fetchAll(); + } + + protected function prepareQuery() + { + $list = []; + foreach ($this->command->arguments()->toPlainObject() as $name => $argument) { + $new = (object) []; + $new->argument_name = $name; + $new->argument_value = isset($argument->value) ? $argument->value : null; + $list[] = $new; + } + + return (new ArrayDatasource($list))->select(); + } +} |