From 6626554a4907b5e9e0bac2f599f836513ef5e598 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 23 Mar 2016 01:31:33 +0100 Subject: [PATCH] config/files: improve look & feel --- application/controllers/ConfigController.php | 73 ++++++++++++++----- .../tables/GeneratedConfigFileTable.php | 23 ++++-- application/views/scripts/config/file.phtml | 3 + application/views/scripts/config/files.phtml | 2 + 4 files changed, 78 insertions(+), 23 deletions(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 7a192217..7ee73a0d 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -121,6 +121,10 @@ class ConfigController extends ActionController ->setConnection($this->db()) ->setConfigChecksum($checksum); + if ($deploymentId) { + $this->view->table->setDeploymentId($deploymentId); + } + $this->view->config = IcingaConfig::load( Util::hex2binary($this->params->get('checksum')), $this->db() @@ -130,6 +134,18 @@ class ConfigController extends ActionController // Show a single file public function fileAction() { + $tabs = $this->configTabs()->add('file', array( + 'label' => $this->translate('Rendered file'), + 'url' => $this->getRequest()->getUrl(), + ))->activate('file'); + + $this->view->addLink = $this->view->qlink( + $this->translate('back'), + 'director/config/files', + $this->getConfigTabParams(), + array('class' => 'icon-left-big') + ); + $this->view->config = IcingaConfig::load(Util::hex2binary($this->params->get('config_checksum')), $this->db()); $filename = $this->view->filename = $this->params->get('file_path'); $this->view->title = sprintf( @@ -141,23 +157,7 @@ class ConfigController extends ActionController public function showAction() { - $tabs = $this->getTabs(); - - if ($deploymentId = $this->params->get('deployment_id')) { - $tabs->add('deployment', array( - 'label' => $this->translate('Deployment'), - 'url' => 'director/deployment/show', - 'urlParams' => array( - 'id' => $deploymentId - ) - )); - } - - $tabs->add('config', array( - 'label' => $this->translate('Config'), - 'url' => $this->getRequest()->getUrl(), - ))->activate('config'); - + $this->configTabs()->activate('config'); $this->view->config = IcingaConfig::load(Util::hex2binary($this->params->get('checksum')), $this->db()); } @@ -190,4 +190,43 @@ class ConfigController extends ActionController ); return $this->view->tabs; } + + protected function configTabs() + { + $tabs = $this->getTabs(); + + if ($deploymentId = $this->params->get('deployment_id')) { + $tabs->add('deployment', array( + 'label' => $this->translate('Deployment'), + 'url' => 'director/deployment/show', + 'urlParams' => array( + 'id' => $deploymentId + ) + )); + } + + $tabs->add('config', array( + 'label' => $this->translate('Config'), + 'url' => 'director/config/files', + 'urlParams' => $this->getConfigTabParams() + )); + + return $tabs; + } + + protected function getConfigTabParams() + { + $params = array( + 'checksum' => $this->params->get( + 'config_checksum', + $this->params->get('checksum') + ) + ); + + if ($deploymentId = $this->params->get('deployment_id')) { + $params['deployment_id'] = $deploymentId; + } + + return $params; + } } diff --git a/application/tables/GeneratedConfigFileTable.php b/application/tables/GeneratedConfigFileTable.php index fc178cee..0f0efcc7 100644 --- a/application/tables/GeneratedConfigFileTable.php +++ b/application/tables/GeneratedConfigFileTable.php @@ -6,6 +6,8 @@ use Icinga\Module\Director\Web\Table\QuickTable; class GeneratedConfigFileTable extends QuickTable { + protected $deploymentId; + public function getColumns() { $columns = array( @@ -27,13 +29,22 @@ class GeneratedConfigFileTable extends QuickTable protected function getActionUrl($row) { - return $this->url( - 'director/config/file', - array( - 'config_checksum' => $row->config_checksum, - 'file_path' => $row->file_path - ) + $params = array( + 'config_checksum' => $row->config_checksum, + 'file_path' => $row->file_path ); + + if ($this->deploymentId) { + $params['deployment_id'] = $this->deploymentId; + } + + return $this->url('director/config/file', $params); + } + + public function setDeploymentId($id) + { + $this->deploymentId = $id; + return $this; } public function getTitles() diff --git a/application/views/scripts/config/file.phtml b/application/views/scripts/config/file.phtml index 3e728268..468bf95c 100644 --- a/application/views/scripts/config/file.phtml +++ b/application/views/scripts/config/file.phtml @@ -1,6 +1,9 @@
tabs ?>

+ +addLink ?> +
diff --git a/application/views/scripts/config/files.phtml b/application/views/scripts/config/files.phtml index cddc2d47..d9663b8a 100644 --- a/application/views/scripts/config/files.phtml +++ b/application/views/scripts/config/files.phtml @@ -37,6 +37,8 @@ +
table->render() ?> +