Merge pull request #3871 from Icinga/feature/add-servicegrid-problem-toggle-3793

Servicegrid: Add toggle to show problems only or everything
This commit is contained in:
Johannes Meyer 2019-07-30 08:26:46 +02:00 committed by GitHub
commit d13cade0f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 0 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Monitoring\Controllers;
use Icinga\Web\Form;
use Zend_Form;
use Icinga\Data\Filter\Filter;
use Icinga\Module\Monitoring\Backend;
@ -671,6 +672,19 @@ class ListController extends Controller
$this->applyRestriction('monitoring/filter/objects', $query);
$this->filterQuery($query);
$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)) {
$pivot = $query
->pivot(

View File

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

View File

@ -60,3 +60,16 @@
vertical-align: middle;
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;
}
}