[icinga-checkins] icinga.org: icingaweb2-module-director/feature/service-sets-12891: config/ file(s), deployment: improve usability

git at icinga.org git at icinga.org
Fri Nov 11 10:44:28 CET 2016


Module: icingaweb2-module-director
Branch: feature/service-sets-12891
Commit: 9292bb85249f54c3717f2685ca9d6d1821419d5d
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=9292bb85249f54c3717f2685ca9d6d1821419d5d

Author: Thomas Gelf <thomas at gelf.net>
Date:   Wed Nov  9 20:37:33 2016 +0100

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 91a30f8..6f94afa 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 44aa133..df7434e 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 5a458cd..61c586f 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) {



More information about the icinga-checkins mailing list