CommandArgument: simple form and table

This commit is contained in:
Thomas Gelf 2015-06-01 16:29:03 +02:00
parent 825602f509
commit 5e21301eb5
2 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,36 @@
<?php
namespace Icinga\Module\Director\Forms;
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
class IcingaCommandArgumentForm extends DirectorObjectForm
{
public function setup()
{
$this->addElement('select', 'command_id', array(
'label' => $this->translate('Check command'),
'description' => $this->translate('Check command definition')
));
$this->addElement('text', 'argument_name', array(
'label' => $this->translate('Argument name'),
'required' => true,
'description' => $this->translate('e.g. -H or --hostname, empty means "skip_key"')
));
$this->addElement('text', 'argument_value', array(
'label' => $this->translate('Value'),
'description' => $this->translate('e.g. 5%, $hostname$, $lower$%:$upper$%')
));
/*
$this->optionalBoolean(
'required',
$this->translate('Required'),
$this->translate('Whether this is a mandatory parameter')
);
*/
$this->addElement('submit', $this->translate('Store'));
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace Icinga\Module\Director\Tables;
use Icinga\Module\Director\Web\Table\QuickTable;
class IcingaCommandArgumentTable extends QuickTable
{
public function getColumns()
{
return array(
'id' => 'ca.id',
'command' => 'c.object_name',
'argument_name' => 'ca.argument_name',
'argument_value' => 'ca.argument_value',
// 'required' => 'ca.required',
);
}
protected function getActionUrl($row)
{
return $this->url('director/object/commandargument', array('id' => $row->id));
}
public function getTitles()
{
$view = $this->view();
return array(
$view->translate('Command'),
$view->translate('Argument'),
$view->translate('Value'),
);
}
public function fetchData()
{
$db = $this->connection()->getConnection();
$query = $db->select()->from(
array('ca' => 'icinga_command_argument'),
$this->getColumns()
)->joinLeft(
array('c' => 'icinga_command'),
'ca.command_id = c.id',
array()
);
return $db->fetchAll($query);
}
}