diff --git a/application/forms/ConfirmRemovalForm.php b/application/forms/ConfirmRemovalForm.php
index 985413907..357928cd0 100644
--- a/application/forms/ConfirmRemovalForm.php
+++ b/application/forms/ConfirmRemovalForm.php
@@ -11,11 +11,11 @@ use Icinga\Web\Form;
class ConfirmRemovalForm extends Form
{
/**
- * Initalize this form
+ * Initialize this form
*/
public function init()
{
$this->setName('form_confirm_removal');
- $this->setSubmitLabel($this->translate('Confirm Removal'));
+ $this->getSubmitLabel() ?: $this->setSubmitLabel($this->translate('Confirm Removal'));
}
}
diff --git a/library/Icinga/Cli/Params.php b/library/Icinga/Cli/Params.php
index 507c50e3b..9e30cf19e 100644
--- a/library/Icinga/Cli/Params.php
+++ b/library/Icinga/Cli/Params.php
@@ -167,7 +167,7 @@ class Params
*
* @throws MissingParameterException If the parameter was not given
*/
- public function req($name, $strict = true)
+ public function getRequired($name, $strict = true)
{
if ($this->has($name)) {
$value = $this->get($name);
@@ -258,6 +258,30 @@ class Params
return $result;
}
+ /**
+ * Require and remove a parameter
+ *
+ * @param string $name Name of the parameter
+ * @param bool $strict Whether the parameter's value must not be the empty string
+ *
+ * @return mixed
+ *
+ * @throws MissingParameterException If the parameter was not given
+ */
+ public function shiftRequired($name, $strict = true)
+ {
+ if ($this->has($name)) {
+ $value = $this->get($name);
+ if (! $strict || strlen($value) > 0) {
+ $this->shift($name);
+ return $value;
+ }
+ }
+ $e = new MissingParameterException(t('Required parameter \'%s\' missing'), $name);
+ $e->setParameter($name);
+ throw $e;
+ }
+
/**
* Put the given value onto the argument stack
*
diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php
index 9acf17469..0975d4c13 100644
--- a/library/Icinga/Web/Controller.php
+++ b/library/Icinga/Web/Controller.php
@@ -3,6 +3,7 @@
namespace Icinga\Web;
+use Zend_Controller_Action_Exception;
use Icinga\Data\Sortable;
use Icinga\Data\QueryInterface;
use Icinga\Web\Controller\ModuleActionController;
@@ -49,6 +50,18 @@ class Controller extends ModuleActionController
}
}
+ /**
+ * Immediately respond w/ HTTP 404
+ *
+ * @param $message
+ *
+ * @throws Zend_Controller_Action_Exception
+ */
+ public function httpNotFound($message)
+ {
+ throw new Zend_Controller_Action_Exception($message, 404);
+ }
+
/**
* Create a SortBox widget and apply its sort rules on the given query
*
diff --git a/library/Icinga/Web/UrlParams.php b/library/Icinga/Web/UrlParams.php
index e25fa7e6c..d97f83b39 100644
--- a/library/Icinga/Web/UrlParams.php
+++ b/library/Icinga/Web/UrlParams.php
@@ -54,7 +54,7 @@ class UrlParams
*
* @throws MissingParameterException If the parameter was not given
*/
- public function req($name, $strict = true)
+ public function getRequired($name, $strict = true)
{
if ($this->has($name)) {
$value = $this->get($name);
@@ -138,6 +138,30 @@ class UrlParams
return $ret;
}
+ /**
+ * Require and remove a parameter
+ *
+ * @param string $name Name of the parameter
+ * @param bool $strict Whether the parameter's value must not be the empty string
+ *
+ * @return mixed
+ *
+ * @throws MissingParameterException If the parameter was not given
+ */
+ public function shiftRequired($name, $strict = true)
+ {
+ if ($this->has($name)) {
+ $value = $this->get($name);
+ if (! $strict || strlen($value) > 0) {
+ $this->shift($name);
+ return $value;
+ }
+ }
+ $e = new MissingParameterException(t('Required parameter \'%s\' missing'), $name);
+ $e->setParameter($name);
+ throw $e;
+ }
+
public function addEncoded($param, $value = true)
{
$this->params[] = array($param, $this->cleanupValue($value));
diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php
index a793f2a0a..92c42d4ad 100644
--- a/modules/monitoring/application/controllers/ListController.php
+++ b/modules/monitoring/application/controllers/ListController.php
@@ -12,7 +12,6 @@ use Icinga\Web\Widget\Tabs;
use Icinga\Data\Filter\Filter;
use Icinga\Web\Widget;
use Icinga\Module\Monitoring\Forms\StatehistoryForm;
-use Icinga\Data\Filterable;
class Monitoring_ListController extends Controller
{
@@ -96,7 +95,7 @@ class Monitoring_ListController extends Controller
'host_current_check_attempt',
'host_max_check_attempts'
), $this->addColumns()));
- $this->filterQuery($query, array('host', 'host_display_name'));
+ $this->filterQuery($query);
$this->applyRestriction('monitoring/hosts/filter', $query);
$this->view->hosts = $query;
@@ -180,7 +179,7 @@ class Monitoring_ListController extends Controller
'max_check_attempts' => 'service_max_check_attempts'
), $this->addColumns());
$query = $this->backend->select()->from('serviceStatus', $columns);
- $this->filterQuery($query, array('service', 'service_display_name'));
+ $this->filterQuery($query);
$this->applyRestriction('monitoring/services/filter', $query);
$this->view->services = $query;
@@ -498,7 +497,7 @@ class Monitoring_ListController extends Controller
))->order('services_severity')->order('servicegroup_alias');
// TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and
// service groups. We should separate them.
- $this->filterQuery($query, array('servicegroup', 'servicegroup_alias'));
+ $this->filterQuery($query);
$this->view->servicegroups = $query;
$this->setupLimitControl();
@@ -535,6 +534,7 @@ class Monitoring_ListController extends Controller
'hosts_unreachable_last_state_change_handled',
'hosts_down_last_state_change_unhandled',
'hosts_unreachable_last_state_change_unhandled',
+ 'hosts_total',
'services_ok',
'services_unknown_handled',
'services_unknown_unhandled',
@@ -555,7 +555,7 @@ class Monitoring_ListController extends Controller
))->order('services_severity')->order('hostgroup_alias');
// TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and
// service groups. We should separate them.
- $this->filterQuery($query, array('hostgroup', 'hostgroup_alias'));
+ $this->filterQuery($query);
$this->view->hostgroups = $query;
$this->setupLimitControl();
@@ -626,15 +626,7 @@ class Monitoring_ListController extends Controller
$this->view->verticalPaginator = $pivot->paginateYAxis();
}
- /**
- * Apply filters on a query
- *
- * @param Filterable $query The query to apply filters on
- * @param array $searchColumns Columns to search in
- *
- * @return Filterable $query
- */
- protected function filterQuery(Filterable $query, array $searchColumns = null)
+ protected function filterQuery($query)
{
$editor = Widget::create('filterEditor')
->setQuery($query)
@@ -642,11 +634,8 @@ class Monitoring_ListController extends Controller
'limit', 'sort', 'dir', 'format', 'view', 'backend',
'stateType', 'addColumns', '_dev'
)
- ->ignoreParams('page');
- if ($searchColumns !== null) {
- $editor->setSearchColumns($searchColumns);
- }
- $editor->handleRequest($this->getRequest());
+ ->ignoreParams('page')
+ ->handleRequest($this->getRequest());
$query->applyFilter($editor->getFilter());
$this->setupFilterControl($editor);
diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml
index 90e96e660..23d031b3f 100644
--- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml
+++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml
@@ -22,6 +22,8 @@ if (count($hostgroups) === 0) {
= $this->translate('Last Problem'); ?>
= $this->translate('Host Group'); ?>
+ = $this->translate('Total Hosts'); ?>
+ = $this->translate('Host States'); ?>
= $this->translate('Total Services'); ?>
= $this->translate('Service States'); ?>
@@ -68,6 +70,173 @@ if (count($hostgroups) === 0) {
array('title' => sprintf($this->translate('List all hosts in the group "%s"'), $h->hostgroup_alias))
); ?>
+