data: introduce new controller

This commit is contained in:
Thomas Gelf 2016-02-28 16:59:40 +01:00
parent df133e7981
commit 13258e96cf
5 changed files with 78 additions and 57 deletions

View File

@ -0,0 +1,73 @@
<?php
namespace Icinga\Module\Director\Controllers;
use Icinga\Module\Director\Web\Controller\ActionController;
class DataController extends ActionController
{
public function listsAction()
{
$this->view->addLink = $this->view->icon('plus')
. ' '
. $this->view->qlink(
$this->translate('Add list'),
'director/datalist/add'
);
$this->setDataTabs()->activate('datalist');
$this->view->title = $this->translate('Data lists');
$this->prepareAndRenderTable('datalist');
}
public function fieldsAction()
{
$this->view->addLink = $this->view->icon('plus')
. ' '
. $this->view->qlink(
$this->translate('Add field'),
'director/datafield/add'
);
$this->setDataTabs()->activate('datafield');
$this->view->title = $this->translate('Data fields');
$this->prepareAndRenderTable('datafield');
}
public function listentryAction()
{
$listId = $this->params->get('list_id');
$this->view->lastId = $listId;
$this->view->addLink = $this->view->icon('plus')
. ' '
. $this->view->qlink(
$this->translate('Add entry'),
'director/datalistentry/add' . '?list_id=' . $listId
);
$this->view->title = $this->translate('List entries');
$this->getTabs()->add('editlist', array(
'url' => 'director/datalist/edit' . '?id=' . $listId,
'label' => $this->translate('Edit list'),
))->add('datalistentry', array(
'url' => 'director/datalistentry' . '?list_id=' . $listId,
'label' => $this->view->title,
))->activate('datalistentry');
$this->prepareAndRenderTable('datalistEntry');
}
protected function prepareTable($name)
{
$table = $this->loadTable($name)->setConnection($this->db());
$this->view->filterEditor = $table->getFilterEditor($this->getRequest());
$this->view->table = $this->applyPaginationLimits($table);
return $this;
}
protected function prepareAndRenderTable($name)
{
$this->prepareTable($name)->render('objects/table', null, 'objects');
}
}

View File

@ -30,7 +30,7 @@ class DatalistController extends ActionController
'url' => 'director/datalist/edit' . '?id=' . $id, 'url' => 'director/datalist/edit' . '?id=' . $id,
'label' => $this->view->title, 'label' => $this->view->title,
))->add('entries', array( ))->add('entries', array(
'url' => 'director/list/datalistentry' . '?list_id=' . $id, 'url' => 'director/data/listentry' . '?list_id=' . $id,
'label' => $this->translate('List entries'), 'label' => $this->translate('List entries'),
))->activate('editlist'); ))->activate('editlist');
} else { } else {
@ -42,7 +42,7 @@ class DatalistController extends ActionController
} }
$form = $this->view->form = $this->loadForm('directorDatalist') $form = $this->view->form = $this->loadForm('directorDatalist')
->setSuccessUrl('director/list/datalist') ->setSuccessUrl('director/data/lists')
->setDb($this->db()); ->setDb($this->db());
if ($edit) { if ($edit) {

View File

@ -7,58 +7,6 @@ use Exception;
class ListController extends ActionController class ListController extends ActionController
{ {
public function datalistAction()
{
$this->view->addLink = $this->view->icon('plus')
. ' '
. $this->view->qlink(
$this->translate('Add list'),
'director/datalist/add'
);
$this->setConfigTabs()->activate('datalist');
$this->view->title = $this->translate('Data lists');
$this->prepareAndRenderTable('datalist');
}
public function datalistentryAction()
{
$listId = $this->params->get('list_id');
$this->view->lastId = $listId;
$this->view->addLink = $this->view->icon('plus')
. ' '
. $this->view->qlink(
$this->translate('Add entry'),
'director/datalistentry/add' . '?list_id=' . $listId
);
$this->view->title = $this->translate('List entries');
$this->getTabs()->add('editlist', array(
'url' => 'director/datalist/edit' . '?id=' . $listId,
'label' => $this->translate('Edit list'),
))->add('datalistentry', array(
'url' => 'director/datalistentry' . '?list_id=' . $listId,
'label' => $this->view->title,
))->activate('datalistentry');
$this->prepareAndRenderTable('datalistEntry');
}
public function datafieldAction()
{
$this->view->addLink = $this->view->icon('plus')
. ' '
. $this->view->qlink(
$this->translate('Add field'),
'director/datafield/add'
);
$this->setConfigTabs()->activate('datafield');
$this->view->title = $this->translate('Data fields');
$this->prepareAndRenderTable('datafield');
}
public function importsourceAction() public function importsourceAction()
{ {
$this->view->addLink = $this->view->icon('plus') $this->view->addLink = $this->view->icon('plus')

View File

@ -21,7 +21,7 @@ class DatalistTable extends QuickTable
protected function getActionUrl($row) protected function getActionUrl($row)
{ {
return $this->url('director/list/datalistentry', array('list_id' => $row->id)); return $this->url('director/data/listentry', array('list_id' => $row->id));
} }
public function getTitles() public function getTitles()

View File

@ -105,8 +105,8 @@ $all = array(
$this->translate('Do more with your data') => array( $this->translate('Do more with your data') => array(
array('database', $this->translate('Import data sources'), 'director/list/importsource', $this->translate('Define and manage imports from various data sources')), array('database', $this->translate('Import data sources'), 'director/list/importsource', $this->translate('Define and manage imports from various data sources')),
array('flapping', $this->translate('Synchronize'), 'director/list/importsource', $this->translate('Define how imported data should be synchronized with Icinga')), array('flapping', $this->translate('Synchronize'), 'director/list/importsource', $this->translate('Define how imported data should be synchronized with Icinga')),
array('sort-name-up', $this->translate('Provide data lists'), 'director/list/datalist', $this->translate('Provide data lists to make life easier for your users')), array('sort-name-up', $this->translate('Provide data lists'), 'director/data/lists', $this->translate('Provide data lists to make life easier for your users')),
array('edit', $this->translate('Define data fields'), 'director/list/datafield', $this->translate('Data fields make sure that configuration fits your rules')), array('edit', $this->translate('Define data fields'), 'director/data/fields', $this->translate('Data fields make sure that configuration fits your rules')),
) )
); );
?> ?>