diff --git a/library/Icingadb/Model/Comment.php b/library/Icingadb/Model/Comment.php index dd5ee2a0d..80a74f940 100644 --- a/library/Icingadb/Model/Comment.php +++ b/library/Icingadb/Model/Comment.php @@ -8,6 +8,7 @@ use Icinga\Module\Icingadb\Model\Behavior\ReRoute; use Icinga\Module\Icingadb\Model\Behavior\Timestamp; use ipl\Orm\Behavior\Binary; +use ipl\Orm\Behavior\NonTextMatch; use ipl\Orm\Behaviors; use ipl\Orm\Model; use ipl\Orm\Relations; @@ -57,7 +58,14 @@ public function getColumnDefinitions() 'name' => t('Comment Name'), 'author' => t('Comment Author'), 'text' => t('Comment Text'), - 'entry_type' => t('Comment Type'), + 'entry_type' => [ + 'label' => t('Comment Type'), + 'type' => 'enum', + 'allowed_values' => [ + 'comment' => t('Comment'), + 'ack' => t('Acknowledgement') + ] + ], 'entry_time' => t('Comment Entry Time'), 'is_persistent' => t('Comment Is Persistent'), 'is_sticky' => t('Comment Is Sticky'), @@ -102,6 +110,8 @@ public function createBehaviors(Behaviors $behaviors) 'properties_checksum', 'zone_id' ])); + + $behaviors->add(new NonTextMatch()); } public function createRelations(Relations $relations) diff --git a/library/Icingadb/Model/ServiceState.php b/library/Icingadb/Model/ServiceState.php index 9de2a21e1..cb5cff438 100644 --- a/library/Icingadb/Model/ServiceState.php +++ b/library/Icingadb/Model/ServiceState.php @@ -23,12 +23,22 @@ public function getColumnDefinitions() { return [ 'environment_id' => t('Environment Id'), - 'state_type' => t('Service State Type'), + 'state_type' => [ + 'label' => t('Service State Type'), + 'type' => 'enum', + 'allowed_values' => [ + 'hard' => t('Hard'), + 'soft' => t('Soft') + ] + ], 'soft_state' => t('Service Soft State'), 'hard_state' => t('Service Hard State'), 'previous_soft_state' => t('Service Previous Soft State'), 'previous_hard_state' => t('Service Previous Hard State'), - 'check_attempt' => t('Service Check Attempt No.'), + 'check_attempt' => [ + 'label' => t('Service Check Attempt No.'), + 'type' => 'number' + ], 'severity' => t('Service State Severity'), 'output' => t('Service Output'), 'long_output' => t('Service Long Output'), diff --git a/library/Icingadb/Model/State.php b/library/Icingadb/Model/State.php index acd376931..b548c323c 100644 --- a/library/Icingadb/Model/State.php +++ b/library/Icingadb/Model/State.php @@ -7,6 +7,7 @@ use Icinga\Module\Icingadb\Model\Behavior\BoolCast; use Icinga\Module\Icingadb\Model\Behavior\Timestamp; use ipl\Orm\Behavior\Binary; +use ipl\Orm\Behavior\NonTextMatch; use ipl\Orm\Behaviors; use ipl\Orm\Model; @@ -79,5 +80,7 @@ public function createBehaviors(Behaviors $behaviors) 'acknowledgement_comment_id', 'last_comment_id' ])); + + $behaviors->add(new NonTextMatch()); } } diff --git a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php index b1a9491ae..62c81cb76 100644 --- a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php +++ b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php @@ -16,6 +16,7 @@ use ipl\Orm\Exception\InvalidColumnException; use ipl\Orm\Exception\InvalidRelationException; use ipl\Orm\Model; +use ipl\Orm\Query; use ipl\Orm\Relation; use ipl\Orm\Relation\BelongsToMany; use ipl\Orm\Relation\HasOne; @@ -37,6 +38,9 @@ class ObjectSuggestions extends Suggestions /** @var Model */ protected $model; + /** @var Query */ + protected $query; + /** @var array */ protected $customVarSources; @@ -91,6 +95,15 @@ public function getModel(): Model return $this->model; } + public function getQuery(): Query + { + if ($this->query === null) { + $this->query = ($this->getModel())::on($this->getDb()); + } + + return $this->query; + } + protected function shouldShowRelationFor(string $column): bool { if (strpos($column, '.vars.') !== false) { @@ -131,7 +144,7 @@ protected function createQuickSearchFilter($searchTerm) protected function fetchValueSuggestions($column, $searchTerm, Filter\Chain $searchFilter) { $model = $this->getModel(); - $query = $model::on($this->getDb()); + $query = $this->getQuery(); $query->limit(static::DEFAULT_LIMIT); if (strpos($column, ' ') !== false) { @@ -202,7 +215,7 @@ protected function fetchValueSuggestions($column, $searchTerm, Filter\Chain $sea protected function fetchColumnSuggestions($searchTerm) { $model = $this->getModel(); - $query = $model::on($this->getDb()); + $query = $this->getQuery(); // Ordinary columns first foreach (self::collectFilterColumns($model, $query->getResolver()) as $columnName => $columnMeta) {