list/servicegrid: Add toggle to show problems only or everything

resolves #3793
This commit is contained in:
Johannes Meyer 2019-07-18 15:34:12 +02:00
parent 39fbd3e27e
commit b1705ca0e1
3 changed files with 28 additions and 0 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Monitoring\Controllers; namespace Icinga\Module\Monitoring\Controllers;
use Icinga\Web\Form;
use Zend_Form; use Zend_Form;
use Icinga\Data\Filter\Filter; use Icinga\Data\Filter\Filter;
use Icinga\Module\Monitoring\Backend; use Icinga\Module\Monitoring\Backend;
@ -669,6 +670,19 @@ class ListController extends Controller
$this->applyRestriction('monitoring/filter/objects', $query); $this->applyRestriction('monitoring/filter/objects', $query);
$this->filterQuery($query); $this->filterQuery($query);
$filter = (bool) $this->params->shift('problems', false) ? Filter::where('service_problem', 1) : null; $filter = (bool) $this->params->shift('problems', false) ? Filter::where('service_problem', 1) : null;
$this->view->problemToggle = $problemToggle = new Form(['method' => 'GET']);
$problemToggle->setUidDisabled();
$problemToggle->setTokenDisabled();
$problemToggle->setAttrib('class', 'filter-toggle inline icinga-controls');
$problemToggle->addElement('checkbox', 'problems', [
'disableHidden' => true,
'autosubmit' => true,
'value' => $filter !== null,
'label' => $this->translate('Problems Only'),
'decorators' => ['ViewHelper', ['Label', ['placement' => 'APPEND']]]
]);
if ($this->params->get('flipped', false)) { if ($this->params->get('flipped', false)) {
$pivot = $query $pivot = $query
->pivot( ->pivot(

View File

@ -6,6 +6,7 @@ use Icinga\Web\Url;
if (! $this->compact): ?> if (! $this->compact): ?>
<div class="controls"> <div class="controls">
<?= $this->tabs ?> <?= $this->tabs ?>
<?= $this->problemToggle ?>
<div class="sort-controls-container"> <div class="sort-controls-container">
<?= $this->sortBox ?> <?= $this->sortBox ?>
</div> </div>

View File

@ -60,3 +60,16 @@
vertical-align: middle; vertical-align: middle;
width: 1.5em; width: 1.5em;
} }
form.filter-toggle {
label:not(.toggle-switch) {
display: inline-block;
vertical-align: top;
margin-left: .5em;
color: @gray-light;
}
input[type="checkbox"]:checked ~ label {
color: inherit;
}
}