config/file(s), deployment: improve usability

* mark formerly chosen file when navigating back
* autorefresh improvements

fixes #13119
This commit is contained in:
Thomas Gelf 2016-11-09 20:37:33 +01:00
parent 64f00940b1
commit 9292bb8524
3 changed files with 35 additions and 5 deletions

View File

@ -22,10 +22,12 @@ class ConfigController extends ActionController
public function deploymentsAction() public function deploymentsAction()
{ {
$this->assertPermission('director/deploy'); $this->assertPermission('director/deploy');
$this->setAutorefreshInterval(5);
try { try {
if ($this->db()->hasUncollectedDeployments()) { if ($this->db()->hasUncollectedDeployments()) {
$this->setAutorefreshInterval(5);
$this->api()->collectLogFiles($this->db()); $this->api()->collectLogFiles($this->db());
} else {
$this->setAutorefreshInterval(10);
} }
} catch (Exception $e) { } catch (Exception $e) {
// No problem, Icinga might be reloading // No problem, Icinga might be reloading
@ -132,7 +134,6 @@ class ConfigController extends ActionController
{ {
$this->assertPermission('director/showconfig'); $this->assertPermission('director/showconfig');
$this->setAutorefreshInterval(10);
$this->view->title = $this->translate('Generated config'); $this->view->title = $this->translate('Generated config');
$tabs = $this->getTabs(); $tabs = $this->getTabs();
@ -163,6 +164,7 @@ class ConfigController extends ActionController
$this->view->table = $this $this->view->table = $this
->loadTable('GeneratedConfigFile') ->loadTable('GeneratedConfigFile')
->setActiveFilename($this->params->get('active_file'))
->setConnection($this->db()) ->setConnection($this->db())
->setConfigChecksum($checksum); ->setConfigChecksum($checksum);
@ -180,7 +182,7 @@ class ConfigController extends ActionController
public function fileAction() public function fileAction()
{ {
$this->assertPermission('director/showconfig'); $this->assertPermission('director/showconfig');
$filename = $this->view->filename = $this->params->get('file_path');
$fileOnly = $this->params->get('fileOnly'); $fileOnly = $this->params->get('fileOnly');
$this->view->highlight = $this->params->get('highlight'); $this->view->highlight = $this->params->get('highlight');
$this->view->highlightSeverity = $this->params->get('highlightSeverity'); $this->view->highlightSeverity = $this->params->get('highlightSeverity');
@ -198,6 +200,7 @@ class ConfigController extends ActionController
array('class' => 'icon-left-big') array('class' => 'icon-left-big')
); );
} else { } else {
$params['active_file'] = $filename;
$this->view->addLink = $this->view->qlink( $this->view->addLink = $this->view->qlink(
$this->translate('back'), $this->translate('back'),
'director/config/files', '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()); $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->view->title = sprintf(
$this->translate('Config file "%s"'), $this->translate('Config file "%s"'),
$filename $filename
@ -338,7 +340,7 @@ class ConfigController extends ActionController
if ($this->hasPermission('director/deploy') && $deploymentId = $this->params->get('deployment_id')) { if ($this->hasPermission('director/deploy') && $deploymentId = $this->params->get('deployment_id')) {
$tabs->add('deployment', array( $tabs->add('deployment', array(
'label' => $this->translate('Deployment'), 'label' => $this->translate('Deployment'),
'url' => 'director/deployment/show', 'url' => 'director/deployment',
'urlParams' => array( 'urlParams' => array(
'id' => $deploymentId 'id' => $deploymentId
) )

View File

@ -8,6 +8,8 @@ class GeneratedConfigFileTable extends QuickTable
{ {
protected $deploymentId; protected $deploymentId;
protected $activeFile;
public function getColumns() public function getColumns()
{ {
$columns = array( $columns = array(
@ -29,6 +31,21 @@ class GeneratedConfigFileTable extends QuickTable
return $columns; 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) protected function getActionUrl($row)
{ {
$params = array( $params = array(

View File

@ -240,6 +240,7 @@
this.putFocusOnFirstObjectTypeElement($container); this.putFocusOnFirstObjectTypeElement($container);
this.highlightFormErrors($container); this.highlightFormErrors($container);
this.scrollHighlightIntoView($container); this.scrollHighlightIntoView($container);
this.scrollActiveRowIntoView($container);
this.hideInactiveFormDescriptions($container); this.hideInactiveFormDescriptions($container);
if (iid = $container.data('activeExtensibleEntry')) { if (iid = $container.data('activeExtensibleEntry')) {
$('#' + iid).focus(); $('#' + 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) { backupAllExtensibleSetDefaultValues: function($container) {
var self = this; var self = this;
$container.find('.extensible-set').each(function (idx, eSet) { $container.find('.extensible-set').each(function (idx, eSet) {