config/files: improve look & feel

This commit is contained in:
Thomas Gelf 2016-03-23 01:31:33 +01:00
parent 715e02b605
commit 6626554a49
4 changed files with 78 additions and 23 deletions

View File

@ -121,6 +121,10 @@ class ConfigController extends ActionController
->setConnection($this->db()) ->setConnection($this->db())
->setConfigChecksum($checksum); ->setConfigChecksum($checksum);
if ($deploymentId) {
$this->view->table->setDeploymentId($deploymentId);
}
$this->view->config = IcingaConfig::load( $this->view->config = IcingaConfig::load(
Util::hex2binary($this->params->get('checksum')), Util::hex2binary($this->params->get('checksum')),
$this->db() $this->db()
@ -130,6 +134,18 @@ class ConfigController extends ActionController
// Show a single file // Show a single file
public function fileAction() 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()); $this->view->config = IcingaConfig::load(Util::hex2binary($this->params->get('config_checksum')), $this->db());
$filename = $this->view->filename = $this->params->get('file_path'); $filename = $this->view->filename = $this->params->get('file_path');
$this->view->title = sprintf( $this->view->title = sprintf(
@ -141,23 +157,7 @@ class ConfigController extends ActionController
public function showAction() public function showAction()
{ {
$tabs = $this->getTabs(); $this->configTabs()->activate('config');
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->view->config = IcingaConfig::load(Util::hex2binary($this->params->get('checksum')), $this->db()); $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; 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;
}
} }

View File

@ -6,6 +6,8 @@ use Icinga\Module\Director\Web\Table\QuickTable;
class GeneratedConfigFileTable extends QuickTable class GeneratedConfigFileTable extends QuickTable
{ {
protected $deploymentId;
public function getColumns() public function getColumns()
{ {
$columns = array( $columns = array(
@ -27,13 +29,22 @@ class GeneratedConfigFileTable extends QuickTable
protected function getActionUrl($row) protected function getActionUrl($row)
{ {
return $this->url( $params = array(
'director/config/file', 'config_checksum' => $row->config_checksum,
array( 'file_path' => $row->file_path
'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() public function getTitles()

View File

@ -1,6 +1,9 @@
<div class="controls"> <div class="controls">
<?= $this->tabs ?> <?= $this->tabs ?>
<h1><?= $title ?></h1> <h1><?= $title ?></h1>
<span data-base-target="_self">
<?= $this->addLink ?>
</span>
</div> </div>
<div class="content"> <div class="content">

View File

@ -37,6 +37,8 @@
</table> </table>
<?php if (count($table)): ?> <?php if (count($table)): ?>
<div data-base-target="_self">
<?= $this->table->render() ?> <?= $this->table->render() ?>
</div>
<?php endif ?> <?php endif ?>
</div> </div>