From 854ba20451d8bbea4de227f3d7b812a399175ade Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 29 Jun 2015 10:13:39 +0200 Subject: [PATCH] config: add tabs, less menu items --- application/controllers/ConfigController.php | 7 +++++-- application/controllers/ListController.php | 7 +++++++ application/views/scripts/list/table.phtml | 5 ++++- configuration.php | 12 +++++------- library/Director/ActionController.php | 12 ++++++++++++ 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index e5e5ce30..d192e7ce 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -4,6 +4,7 @@ use Icinga\Module\Director\ActionController; use Icinga\Module\Director\IcingaConfig\IcingaConfig; use Icinga\Module\Director\Util; +use Icinga\Web\Url; class Director_ConfigController extends ActionController { @@ -14,8 +15,10 @@ class Director_ConfigController extends ActionController public function storeAction() { - /** @var IcingaConfig $config */ $config = IcingaConfig::generate($this->db()); - $this->view->id = $config->getHexChecksum(); + $this->redirectNow( + Url::fromPath('director/config/show', + array('checksum' => $config->getHexChecksum())) + ); } } diff --git a/application/controllers/ListController.php b/application/controllers/ListController.php index 7ce29afc..b8b7223f 100644 --- a/application/controllers/ListController.php +++ b/application/controllers/ListController.php @@ -182,6 +182,7 @@ class Director_ListController extends ActionController public function activitylogAction() { + $this->setConfigTabs()->activate('activitylog'); $this->view->title = $this->translate('Activity Log'); $this->view->table = $this->loadTable('activityLog')->setConnection($this->db()); $this->render('table'); @@ -189,6 +190,12 @@ class Director_ListController extends ActionController public function generatedconfigAction() { + $this->view->addLink = $this->view->qlink( + $this->translate('Generate'), + 'director/config/store' + ); + + $this->setConfigTabs()->activate('generatedconfig'); $this->view->title = $this->translate('Generated Configs'); $this->view->table = $this->loadTable('generatedConfig')->setConnection($this->db()); $this->render('table'); diff --git a/application/views/scripts/list/table.phtml b/application/views/scripts/list/table.phtml index 1ad5c254..a0ca6479 100644 --- a/application/views/scripts/list/table.phtml +++ b/application/views/scripts/list/table.phtml @@ -1,6 +1,9 @@ -
+
+tabs ?>

escape($this->title) ?>

+ addLink ?> +
diff --git a/configuration.php b/configuration.php index 8406cccf..79b32d93 100644 --- a/configuration.php +++ b/configuration.php @@ -1,5 +1,8 @@ providePermission('director/templates', 'Allow to modify templates'); + $section = $this->menuSection($this->translate('Icinga Director')); $section->setIcon('cubes'); @@ -39,12 +42,7 @@ $section->add($this->translate('Endpoints')) ->setUrl('director/list/endpoints'); // INTERNAL -$section->add($this->translate('Activity Log')) - ->setUrl('director/list/activitylog') - ->setPriority(900); -$section->add($this->translate('Show configs')) +$section->add($this->translate('Config')) ->setUrl('director/list/generatedconfig') ->setPriority(902); -$section->add($this->translate('Store config')) - ->setUrl('director/config/store') - ->setPriority(902); + diff --git a/library/Director/ActionController.php b/library/Director/ActionController.php index 95f3871f..323ea5ae 100644 --- a/library/Director/ActionController.php +++ b/library/Director/ActionController.php @@ -33,6 +33,18 @@ abstract class ActionController extends Controller return TableLoader::load($name, $this->Module()); } + protected function setConfigTabs() + { + $this->view->tabs = Widget::create('tabs')->add('generatedconfig', array( + 'label' => $this->translate('Configs'), + 'url' => 'director/list/generatedconfig') + )->add('activitylog', array( + 'label' => $this->translate('Activity Log'), + 'url' => 'director/list/activitylog') + ); + return $this->view->tabs; + } + protected function setIcingaTabs() { $this->view->tabs = Widget::create('tabs')->add('services', array(