objects/tree: enable autorefresh...

...and some coding style fixes

fixes #12451
This commit is contained in:
Thomas Gelf 2016-08-23 15:11:42 +00:00
parent b5d6139893
commit 84b035ec24
2 changed files with 13 additions and 5 deletions

View File

@ -6,4 +6,13 @@ use Icinga\Module\Director\Web\Controller\ObjectsController;
class ServicesController extends ObjectsController
{
public function indexAction()
{
$r = $this->getRequest();
if ($r->getActionName() !== 'templates' && ! $this->getRequest()->isApiRequest()) {
$this->redirectNow('director/services/templates');
}
return parent::indexAction();
}
}

View File

@ -86,7 +86,7 @@ abstract class ObjectsController extends ActionController
if ($dummy->isGroup()) {
$this->getTabs()->activate('objectgroups');
$table = 'icinga' . ucfirst($type);
} else if ($dummy->isTemplate()) {
} elseif ($dummy->isTemplate()) {
$this->getTabs()->activate('templates');
$table = 'icinga' . ucfirst($type);
} else {
@ -110,8 +110,7 @@ abstract class ObjectsController extends ActionController
$addParams = array('type' => 'object');
$title = $this->translate('Icinga ' . ucfirst($ltype) . 's');
$addTitle = $this->translate('Add %s');
if (
$dummy->supportsImports()
if ($dummy->supportsImports()
&& array_key_exists('object_type', $table->getColumns())
&& ! in_array(ucfirst($type), $this->globalTypes)
) {
@ -204,6 +203,7 @@ abstract class ObjectsController extends ActionController
public function templatetreeAction()
{
$this->setAutorefreshInterval(10);
$this->getTabs()->activate('tree');
$this->view->tree = $this->db()->fetchTemplateTree(strtolower($this->getType()));
$this->view->objectTypeName = $this->getType();
@ -216,8 +216,7 @@ abstract class ObjectsController extends ActionController
$class = $this->getObjectClassname();
$this->dummy = $class::create(array());
if ($this->dummy->hasProperty('object_type')) {
if (
strpos($this->getRequest()->getControllerName(), 'template') !== false
if (strpos($this->getRequest()->getControllerName(), 'template') !== false
|| strpos($this->getRequest()->getActionName(), 'templates') !== false
) {
$this->dummy->object_type = 'template';