From 9292bb85249f54c3717f2685ca9d6d1821419d5d Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 9 Nov 2016 20:37:33 +0100 Subject: [PATCH] config/file(s), deployment: improve usability * mark formerly chosen file when navigating back * autorefresh improvements fixes #13119 --- application/controllers/ConfigController.php | 12 +++++++----- application/tables/GeneratedConfigFileTable.php | 17 +++++++++++++++++ public/js/module.js | 11 +++++++++++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 91a30f8c..6f94afa1 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -22,10 +22,12 @@ class ConfigController extends ActionController public function deploymentsAction() { $this->assertPermission('director/deploy'); - $this->setAutorefreshInterval(5); try { if ($this->db()->hasUncollectedDeployments()) { + $this->setAutorefreshInterval(5); $this->api()->collectLogFiles($this->db()); + } else { + $this->setAutorefreshInterval(10); } } catch (Exception $e) { // No problem, Icinga might be reloading @@ -132,7 +134,6 @@ class ConfigController extends ActionController { $this->assertPermission('director/showconfig'); - $this->setAutorefreshInterval(10); $this->view->title = $this->translate('Generated config'); $tabs = $this->getTabs(); @@ -163,6 +164,7 @@ class ConfigController extends ActionController $this->view->table = $this ->loadTable('GeneratedConfigFile') + ->setActiveFilename($this->params->get('active_file')) ->setConnection($this->db()) ->setConfigChecksum($checksum); @@ -180,7 +182,7 @@ class ConfigController extends ActionController public function fileAction() { $this->assertPermission('director/showconfig'); - + $filename = $this->view->filename = $this->params->get('file_path'); $fileOnly = $this->params->get('fileOnly'); $this->view->highlight = $this->params->get('highlight'); $this->view->highlightSeverity = $this->params->get('highlightSeverity'); @@ -198,6 +200,7 @@ class ConfigController extends ActionController array('class' => 'icon-left-big') ); } else { + $params['active_file'] = $filename; $this->view->addLink = $this->view->qlink( $this->translate('back'), 'director/config/files', @@ -207,7 +210,6 @@ class ConfigController extends ActionController } $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( $this->translate('Config file "%s"'), $filename @@ -338,7 +340,7 @@ class ConfigController extends ActionController if ($this->hasPermission('director/deploy') && $deploymentId = $this->params->get('deployment_id')) { $tabs->add('deployment', array( 'label' => $this->translate('Deployment'), - 'url' => 'director/deployment/show', + 'url' => 'director/deployment', 'urlParams' => array( 'id' => $deploymentId ) diff --git a/application/tables/GeneratedConfigFileTable.php b/application/tables/GeneratedConfigFileTable.php index 44aa1335..df7434ef 100644 --- a/application/tables/GeneratedConfigFileTable.php +++ b/application/tables/GeneratedConfigFileTable.php @@ -8,6 +8,8 @@ class GeneratedConfigFileTable extends QuickTable { protected $deploymentId; + protected $activeFile; + public function getColumns() { $columns = array( @@ -29,6 +31,21 @@ class GeneratedConfigFileTable extends QuickTable return $columns; } + public function setActiveFilename($filename) + { + $this->activeFile = $filename; + return $this; + } + + protected function getRowClasses($row) + { + if ($row->file_path === $this->activeFile) { + return 'active'; + } + + return parent::getRowClasses($row); + } + protected function getActionUrl($row) { $params = array( diff --git a/public/js/module.js b/public/js/module.js index 5a458cd9..61c586f1 100644 --- a/public/js/module.js +++ b/public/js/module.js @@ -240,6 +240,7 @@ this.putFocusOnFirstObjectTypeElement($container); this.highlightFormErrors($container); this.scrollHighlightIntoView($container); + this.scrollActiveRowIntoView($container); this.hideInactiveFormDescriptions($container); if (iid = $container.data('activeExtensibleEntry')) { $('#' + iid).focus(); @@ -275,6 +276,16 @@ } }, + scrollActiveRowIntoView: function ($container) { + $tr = $container.find('table.table-row-selectable > tbody > tr.active'); + $content = $container.find('> div.content'); + if ($tr.length) { + $container.animate({ + scrollTop: $tr.offset().top - $content.offset().top + }, 500); + } + }, + backupAllExtensibleSetDefaultValues: function($container) { var self = this; $container.find('.extensible-set').each(function (idx, eSet) {