Skip to content

Commit

Permalink
Assign: add "is not set" operator
Browse files Browse the repository at this point in the history
fixes #1436
  • Loading branch information
offsides authored and Thomas-Gelf committed May 4, 2018
1 parent 69d3675 commit 38a56f6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions application/views/helpers/FormDataFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected function element(FilterExpression $filter = null)
$filter->setExpression(json_decode($filter->getExpression()));
}

if ($filter->getExpression() === true) {
if (($filter->getExpression() === true) || ($filter->getExpression() === false)) {
return '';
}
$dummy = IcingaObject::createByType($type);
Expand Down Expand Up @@ -306,7 +306,8 @@ protected function selectSign(FilterExpression $filter = null)
'<=' => '<=',
'in' => 'in',
'contains' => 'contains',
'true' => 'is true (or set)',
'true' => 'is true (or set)',
'false' => 'is false (or not set)',
);

if ($filter === null) {
Expand All @@ -318,6 +319,8 @@ protected function selectSign(FilterExpression $filter = null)
$expression = json_decode($filter->getExpression());
if ($expression === true) {
$sign = 'true';
} elseif ($expression === false) {
$sign = 'false';
} elseif (is_array($expression)) {
$sign = 'in';
} else {
Expand Down
3 changes: 3 additions & 0 deletions doc/82-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ before switching to a new version.
* FEATURE: Grant access to Service Set in a controlled way
* FIX: do not allow a user to create hosts he wouldn't be allowed to see #1451

### Icinga Configuration
* FEATURE: Add 'is false (or not set)' condition for apply rules (#1436)

### User Interface
* FEATURE: Admins have now access to JSON download links in many places
* FEATURE: Users equipped with related permissions can toggle "Show SQL" in the GUI
Expand Down
6 changes: 6 additions & 0 deletions library/Director/IcingaConfig/AssignRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ protected function renderFilterExpression(FilterExpression $filter)
if ($rawExpression === true) {
return $column;
}
if ($rawExpression === false) {
return sprintf(
'! %s',
$column
);
}
if (strpos($expression, '*') === false) {
return $this->renderEquals($column, $expression);
} else {
Expand Down
6 changes: 6 additions & 0 deletions library/Director/Web/Form/Element/DataFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ protected function entryToFilterExpression($entry)
'=',
json_encode(true)
);
} elseif ($entry['sign'] === 'false') {
return Filter::expression(
$entry['column'],
'=',
json_encode(false)
);
} elseif ($entry['sign'] === 'in') {
if (array_key_exists('value', $entry)) {
if (is_array($entry['value'])) {
Expand Down

0 comments on commit 38a56f6

Please sign in to comment.