Merge branch 'master' into feature/generate-webserver-config-6120

This commit is contained in:
Eric Lippmann 2014-11-13 15:09:34 +01:00
commit b52adcc2ab
12 changed files with 159 additions and 57 deletions
library/Icinga/Web
modules
monitoring
setup/library/Setup
public/js/icinga

View File

@ -0,0 +1,81 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Web\Form\Element;
use Zend_Form_Element;
use Icinga\Web\Request;
use Icinga\Application\Icinga;
/**
* A button
*/
class Button extends Zend_Form_Element
{
/**
* Use formButton view helper by default
*
* @var string
*/
public $helper = 'formButton';
/**
* Constructor
*
* @param string|array|Zend_Config $spec Element name or configuration
* @param string|array|Zend_Config $options Element value or configuration
*/
public function __construct($spec, $options = null)
{
if (is_string($spec) && ((null !== $options) && is_string($options))) {
$options = array('label' => $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();
}
}

View File

@ -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')
)
)
);
}

View File

@ -0,0 +1,6 @@
<?php
$helpMessage = $this->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');
?>
<div class="selection-info">
<span class="selection-info-count">0</span> <?= $this->translate('row(s) selected', 'multiselection') ?> <?= $this->icon('unhandled.png', $helpMessage) ?>
</div>

View File

@ -14,8 +14,8 @@
<div class="content">
<?= $this->filterEditor ?>
<?php if (empty($downtimes)): ?>
<?= $this->translate('No downtimes matching the filter'); ?>
<?php if (count($downtimes) === 0): ?>
<?= $this->translate('No active downtimes'); ?>
</div>
<?php return; endif ?>

View File

@ -16,6 +16,7 @@ if ($this->compact): ?>
<?= $this->widget('limiter')->setMaxLimit($this->hosts->count()) ?>
<?= $this->paginationControl($hosts, null, null, array('preserve' => $this->preserve)) ?>
<?= $this->selectionToolbar('multi', $this->href('monitoring/hosts/show?' . $this->filter->toQueryString())) ?>
<?= $this->render('list/components/selectioninfo.phtml') ?>
</div>
<div class="content">

View File

@ -20,6 +20,7 @@ if (!$this->compact): ?>
<?= $this->paginationControl($services, null, null, array('preserve' => $this->preserve)) ?>
<?php endif ?>
<?= $this->selectionToolbar('multi', $this->href('monitoring/services/show?' . $this->filter->toQueryString())) ?>
<?= $this->render('list/components/selectioninfo.phtml') ?>
</div>
<div class="content">

View File

@ -1,6 +1,6 @@
<div class="controls">
<?= $this->render('show/components/header.phtml') ?>
<h1><?= $this->translate("This service's current state") ?></h1>
<h1><?= $this->translate("Service detail information") ?></h1>
</div>
<div class="content" data-base-target="_next">
<?= $this->render('show/components/output.phtml') ?>

View File

@ -1,7 +1,7 @@
<?php if ($object->host_name !== false): ?>
<div class="controls">
<?= $this->render('show/components/header.phtml') ?>
<h1><?= $this->translate("This service's current state") ?></h1>
<h1><?= $this->translate("Service detail information") ?></h1>
</div>
<div class="content" data-base-target="_next">
<?= $this->render('show/components/output.phtml') ?>

View File

@ -141,3 +141,7 @@ table.avp .customvar ul {
padding: 0;
padding-left: 1.5em;
}
div.selection-info {
padding-top:1em;
}

View File

@ -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'),
@ -507,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.'),
@ -526,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(

View File

@ -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;

View File

@ -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.
*