From 46df428e28acb9e17a9b81039cc5c6a431329766 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Thu, 13 Nov 2014 12:50:39 +0100 Subject: [PATCH 1/6] Add selection count hint in grids with help for hosts and services refs #7654 --- .../scripts/list/components/selectioninfo.phtml | 6 ++++++ .../application/views/scripts/list/hosts.phtml | 1 + .../views/scripts/list/services.phtml | 1 + modules/monitoring/public/css/module.less | 4 ++++ public/js/icinga/events.js | 3 +++ public/js/icinga/ui.js | 16 ++++++++++++++++ 6 files changed, 31 insertions(+) create mode 100644 modules/monitoring/application/views/scripts/list/components/selectioninfo.phtml diff --git a/modules/monitoring/application/views/scripts/list/components/selectioninfo.phtml b/modules/monitoring/application/views/scripts/list/components/selectioninfo.phtml new file mode 100644 index 000000000..94a4b771a --- /dev/null +++ b/modules/monitoring/application/views/scripts/list/components/selectioninfo.phtml @@ -0,0 +1,6 @@ +translate('Press and hold the Ctrl key while clicking on rows to select multiple rows or press and hold the Shift key to select a range of rows.', 'multiselection'); +?> +
+ 0 translate('row(s) selected', 'multiselection') ?> icon('unhandled.png', $helpMessage) ?> +
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 5be77f89f..5109b57aa 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -16,6 +16,7 @@ if ($this->compact): ?> widget('limiter')->setMaxLimit($this->hosts->count()) ?> paginationControl($hosts, null, null, array('preserve' => $this->preserve)) ?> selectionToolbar('multi', $this->href('monitoring/hosts/show?' . $this->filter->toQueryString())) ?> +render('list/components/selectioninfo.phtml') ?>
diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 815d43074..e67be6d03 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -20,6 +20,7 @@ if (!$this->compact): ?> paginationControl($services, null, null, array('preserve' => $this->preserve)) ?> selectionToolbar('multi', $this->href('monitoring/services/show?' . $this->filter->toQueryString())) ?> +render('list/components/selectioninfo.phtml') ?>
diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 6e0124ccd..7b9b58a87 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -141,3 +141,7 @@ table.avp .customvar ul { padding: 0; padding-left: 1.5em; } + +div.selection-info { + padding-top:1em; +} diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index e2d5f03bd..4e4e41bc1 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -306,17 +306,20 @@ var query = icinga.ui.selectionDataToQuery(selectionData); icinga.loader.loadUrl(url + '?' + query, $target); icinga.ui.storeSelectionData(selectionData); + icinga.ui.provideSelectionCount(); } else if ($trs.length === 1) { // display a single row $tr = $trs.first(); icinga.loader.loadUrl($tr.attr('href'), $target); icinga.ui.storeSelectionData($tr.attr('href')); + icinga.ui.provideSelectionCount(); } else { // display nothing if ($target.attr('id') === 'col2') { icinga.ui.layout1col(); } icinga.ui.storeSelectionData(null); + icinga.ui.provideSelectionCount(); } return false; diff --git a/public/js/icinga/ui.js b/public/js/icinga/ui.js index ac98fb14c..ed7cda584 100644 --- a/public/js/icinga/ui.js +++ b/public/js/icinga/ui.js @@ -470,9 +470,25 @@ * (when only a single row was selected) or Null when nothing was selected. */ loadSelectionData: function() { + this.provideSelectionCount(); return selectionData; }, + /** + * Set the selections row count hint info + */ + provideSelectionCount: function() { + var $count = $('.selection-info-count'); + + if (typeof selectionData === 'string') { + $count.text(1); + } else if (selectionData.length > 1) { + $count.text(selectionData.length); + } else { + $count.text(0); + } + }, + /** * Focus the given table by deselecting all selections on all other tables. * From d0651e9e7fa8daac37e239bca7134ea5ae790011 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Thu, 13 Nov 2014 14:04:23 +0100 Subject: [PATCH 2/6] Rename 'service current state' to 'service detail information' header --- modules/monitoring/application/views/scripts/service/show.phtml | 2 +- modules/monitoring/application/views/scripts/show/service.phtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/service/show.phtml b/modules/monitoring/application/views/scripts/service/show.phtml index 5d0fd22c1..a5c95fd61 100644 --- a/modules/monitoring/application/views/scripts/service/show.phtml +++ b/modules/monitoring/application/views/scripts/service/show.phtml @@ -1,6 +1,6 @@
render('show/components/header.phtml') ?> -

translate("This service's current state") ?>

+

translate("Service detail information") ?>

render('show/components/output.phtml') ?> diff --git a/modules/monitoring/application/views/scripts/show/service.phtml b/modules/monitoring/application/views/scripts/show/service.phtml index f3cb1630c..126d60cb7 100644 --- a/modules/monitoring/application/views/scripts/show/service.phtml +++ b/modules/monitoring/application/views/scripts/show/service.phtml @@ -1,7 +1,7 @@ host_name !== false): ?>
render('show/components/header.phtml') ?> -

translate("This service's current state") ?>

+

translate("Service detail information") ?>

render('show/components/output.phtml') ?> From dc1960184d888e0fec54b825972566b0fd9a5c95 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Thu, 13 Nov 2014 14:18:19 +0100 Subject: [PATCH 3/6] Add hint in the grid if there are no active downtimes --- .../monitoring/application/views/scripts/list/downtimes.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 25a2529f6..15c7ec5da 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -14,8 +14,8 @@
filterEditor ?> - - translate('No downtimes matching the filter'); ?> + + translate('No active downtimes'); ?>
From 6be51d15654885ab100c8f626cc72bd2a14c7065 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 13 Nov 2014 14:25:51 +0100 Subject: [PATCH 4/6] Use Icinga\Web\Form\Element\Button instead of Zend's button Due to a bug in Zend prior to 1.12.2 we need our own button implementation to support earlier versions of the Zend Framework. The side effect is, that this button can also be used as submit button for our forms as isChecked will do its job now properly. --- library/Icinga/Web/Form/Element/Button.php | 81 ++++++++++++++++++++++ library/Icinga/Web/Wizard.php | 76 ++++++++++---------- 2 files changed, 122 insertions(+), 35 deletions(-) create mode 100644 library/Icinga/Web/Form/Element/Button.php diff --git a/library/Icinga/Web/Form/Element/Button.php b/library/Icinga/Web/Form/Element/Button.php new file mode 100644 index 000000000..00da28d10 --- /dev/null +++ b/library/Icinga/Web/Form/Element/Button.php @@ -0,0 +1,81 @@ + $options); + } + + if (!isset($options['ignore'])) { + $options['ignore'] = true; + } + + parent::__construct($spec, $options); + + if ($label = $this->getLabel()) { + // Necessary to get the label shown on the generated HTML + $this->content = $label; + } + } + + /** + * Validate element value (pseudo) + * + * There is no need to reset the value + * + * @param mixed $value Is always ignored + * @param mixed $context Is always ignored + * + * @return bool Returns always TRUE + */ + public function isValid($value, $context = null) + { + return true; + } + + /** + * Has this button been selected? + * + * @return bool + */ + public function isChecked() + { + return $this->getRequest()->getParam($this->getName()) === $this->getValue(); + } + + /** + * Return the current request + * + * @return Request + */ + protected function getRequest() + { + return Icinga::app()->getFrontController()->getRequest(); + } +} diff --git a/library/Icinga/Web/Wizard.php b/library/Icinga/Web/Wizard.php index faf950292..424b46b2c 100644 --- a/library/Icinga/Web/Wizard.php +++ b/library/Icinga/Web/Wizard.php @@ -8,6 +8,7 @@ use LogicException; use InvalidArgumentException; use Icinga\Web\Session\SessionNamespace; use Icinga\Web\Form\Decorator\ElementDoubler; +use Icinga\Web\Form\Element\Button; /** * Container and controller for form based wizards @@ -426,55 +427,60 @@ class Wizard $index = array_search($page, $pages, true); if ($index === 0) { $page->addElement( - 'button', - static::BTN_NEXT, - array( - 'type' => 'submit', - 'value' => $pages[1]->getName(), - 'label' => t('Next'), - 'decorators' => array('ViewHelper') + new Button( + static::BTN_NEXT, + array( + 'type' => 'submit', + 'value' => $pages[1]->getName(), + 'label' => t('Next'), + 'decorators' => array('ViewHelper') + ) ) ); } elseif ($index < count($pages) - 1) { $page->addElement( - 'button', - static::BTN_PREV, - array( - 'type' => 'submit', - 'value' => $pages[$index - 1]->getName(), - 'label' => t('Back'), - 'decorators' => array('ViewHelper') + new Button( + static::BTN_PREV, + array( + 'type' => 'submit', + 'value' => $pages[$index - 1]->getName(), + 'label' => t('Back'), + 'decorators' => array('ViewHelper') + ) ) ); $page->addElement( - 'button', - static::BTN_NEXT, - array( - 'type' => 'submit', - 'value' => $pages[$index + 1]->getName(), - 'label' => t('Next'), - 'decorators' => array('ViewHelper') + new Button( + static::BTN_NEXT, + array( + 'type' => 'submit', + 'value' => $pages[$index + 1]->getName(), + 'label' => t('Next'), + 'decorators' => array('ViewHelper') + ) ) ); } else { $page->addElement( - 'button', - static::BTN_PREV, - array( - 'type' => 'submit', - 'value' => $pages[$index - 1]->getName(), - 'label' => t('Back'), - 'decorators' => array('ViewHelper') + new Button( + static::BTN_PREV, + array( + 'type' => 'submit', + 'value' => $pages[$index - 1]->getName(), + 'label' => t('Back'), + 'decorators' => array('ViewHelper') + ) ) ); $page->addElement( - 'button', - static::BTN_NEXT, - array( - 'type' => 'submit', - 'value' => $page->getName(), - 'label' => t('Finish'), - 'decorators' => array('ViewHelper') + new Button( + static::BTN_NEXT, + array( + 'type' => 'submit', + 'value' => $page->getName(), + 'label' => t('Finish'), + 'decorators' => array('ViewHelper') + ) ) ); } From 4595b5131858809d830b3d014fa04a106b02947b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 13 Nov 2014 14:34:04 +0100 Subject: [PATCH 5/6] Remove Zend version check refs #7464 --- modules/setup/library/Setup/WebWizard.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index 9c5ec76e7..c33fceb92 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -5,7 +5,6 @@ namespace Icinga\Module\Setup; use PDOException; -use Zend_Version; use Icinga\Web\Form; use Icinga\Web\Wizard; use Icinga\Web\Request; @@ -384,20 +383,6 @@ class WebWizard extends Wizard implements SetupWizard sprintf(mt('setup', 'You are running PHP version %s.'), $phpVersion) ); - // The only reason for requiring 1.12.2 is a bug in Zend_Form_Decorator_ViewHelper in older versions causing a - // Zend_Form_Element_Button's value not being rendered. Feel free to adjust this in case we require an earlier - // version! - $zendVersion = Zend_Version::VERSION; - $requirements->addMandatory( - mt('setup', 'Zend Framework 1'), - mt( - 'setup', - 'Icinga Web 2 requires at least Zend Framework 1.12.2 to work properly.' - ), - Zend_Version::compareVersion('1.12.2') !== 1, - sprintf(mt('setup', 'You have got Zend Framwork %s installed.'), $zendVersion) - ); - $defaultTimezone = Platform::getPhpConfig('date.timezone'); $requirements->addMandatory( mt('setup', 'Default Timezone'), From 688c016f2d7fb36ad638000af5ad794467b1ea83 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 13 Nov 2014 14:34:31 +0100 Subject: [PATCH 6/6] Re-enable requirement checks for Zend_Db_Adapter_* refs #7464 --- modules/setup/library/Setup/WebWizard.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index c33fceb92..469f25e02 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -492,8 +492,7 @@ class WebWizard extends Wizard implements SetupWizard ) ); - // TODO(7464): Re-enable or remove this entirely once a decision has been made regarding shipping Zend with Iw2 - /*$mysqlAdapterFound = Platform::zendClassExists('Zend_Db_Adapter_Pdo_Mysql'); + $mysqlAdapterFound = Platform::zendClassExists('Zend_Db_Adapter_Pdo_Mysql'); $requirements->addOptional( mt('setup', 'Zend Database Adapter For MySQL'), mt('setup', 'The Zend database adapter for MySQL is required to access a MySQL database.'), @@ -511,7 +510,7 @@ class WebWizard extends Wizard implements SetupWizard $pgsqlAdapterFound ? mt('setup', 'The Zend database adapter for PostgreSQL is available.') : ( mt('setup', 'The Zend database adapter for PostgreSQL is missing.') ) - );*/ + ); $configDir = $this->getConfigDir(); $requirements->addMandatory(