service/assign: show already added ones
This commit is contained in:
parent
8f389cf51d
commit
381d44b4e3
|
@ -26,7 +26,10 @@ class ServiceController extends ObjectController
|
|||
->setIcingaObject($this->object)
|
||||
->setDb($this->db())
|
||||
->handleRequest();
|
||||
|
||||
$this->view->table = $this->loadTable('icingaObjectAssignment')
|
||||
->setObject($this->object);
|
||||
$this->view->title = 'Assign service to host';
|
||||
$this->render('object/form', null, true);
|
||||
$this->render('object/fields', null, true); // TODO: render table
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Tables;
|
||||
|
||||
use Icinga\Module\Director\Objects\IcingaObject;
|
||||
use Icinga\Module\Director\Web\Table\QuickTable;
|
||||
use Icinga\Web\Url;
|
||||
|
||||
// TODO: we need different ones
|
||||
class IcingaObjectAssignmentTable extends QuickTable
|
||||
{
|
||||
protected $object;
|
||||
|
||||
public function setObject(IcingaObject $object)
|
||||
{
|
||||
$this->object = $object;
|
||||
$this->setConnection($object->getConnection());
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected $searchColumns = array(
|
||||
'filter',
|
||||
);
|
||||
|
||||
public function getColumns()
|
||||
{
|
||||
return array(
|
||||
'id' => 'oa.id',
|
||||
'filter_string' => 'oa.filter_string',
|
||||
);
|
||||
}
|
||||
|
||||
protected function getActionUrl($row)
|
||||
{
|
||||
return Url::fromRequest()->with('field_id', $row->id);
|
||||
}
|
||||
|
||||
public function getTitles()
|
||||
{
|
||||
$view = $this->view();
|
||||
return array(
|
||||
'filter_string' => $view->translate('Filter string'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getBaseQuery()
|
||||
{
|
||||
$db = $this->connection()->getConnection();
|
||||
$otable = $this->object->getTableName() . '_assignment';
|
||||
$oname = $this->object->getShortTableName();
|
||||
|
||||
$query = $db->select()->from(
|
||||
array('oa' => $otable),
|
||||
array()
|
||||
)->where('oa.' . $oname . '_id = ?', $this->object->id)
|
||||
->order('oa.filter_string ASC');
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
|
@ -5,5 +5,5 @@
|
|||
|
||||
<div class="content">
|
||||
<?= $this->form ?>
|
||||
<?= $this->table ?>
|
||||
<?= $this->table->render() ?>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue