mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
Adjust customVarSources and minor improvements
This commit is contained in:
parent
47f4c4c562
commit
0e6d03f3da
4 changed files with 18 additions and 36 deletions
|
|
@ -213,17 +213,8 @@ class HostsController extends Controller
|
|||
public function suggestColumnsAction()
|
||||
{
|
||||
$this->suggestColumns(Host::class, [
|
||||
'checkcommand' => t('Checkcommand %s', '..<customvar-name>'),
|
||||
'eventcommand' => t('Eventcommand %s', '..<customvar-name>'),
|
||||
'host' => t('Host %s', '..<customvar-name>'),
|
||||
'hostgroup' => t('Hostgroup %s', '..<customvar-name>'),
|
||||
'notification' => t('Notification %s', '..<customvar-name>'),
|
||||
'notificationcommand' => t('Notificationcommand %s', '..<customvar-name>'),
|
||||
'service' => t('Service %s', '..<customvar-name>'),
|
||||
'servicegroup' => t('Servicegroup %s', '..<customvar-name>'),
|
||||
'timeperiod' => t('Timeperiod %s', '..<customvar-name>'),
|
||||
'user' => t('Contact %s', '..<customvar-name>'),
|
||||
'usergroup' => t('Contactgroup %s', '..<customvar-name>')
|
||||
'service' => t('Service %s', '..<customvar-name>')
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -230,17 +230,8 @@ class ServicesController extends Controller
|
|||
public function suggestColumnsAction()
|
||||
{
|
||||
$this->suggestColumns(Service::class, [
|
||||
'checkcommand' => t('Checkcommand %s', '..<customvar-name>'),
|
||||
'eventcommand' => t('Eventcommand %s', '..<customvar-name>'),
|
||||
'host' => t('Host %s', '..<customvar-name>'),
|
||||
'hostgroup' => t('Hostgroup %s', '..<customvar-name>'),
|
||||
'notification' => t('Notification %s', '..<customvar-name>'),
|
||||
'notificationcommand' => t('Notificationcommand %s', '..<customvar-name>'),
|
||||
'service' => t('Service %s', '..<customvar-name>'),
|
||||
'servicegroup' => t('Servicegroup %s', '..<customvar-name>'),
|
||||
'timeperiod' => t('Timeperiod %s', '..<customvar-name>'),
|
||||
'user' => t('Contact %s', '..<customvar-name>'),
|
||||
'usergroup' => t('Contactgroup %s', '..<customvar-name>')
|
||||
'service' => t('Service %s', '..<customvar-name>')
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,6 +105,20 @@ class QueryColumnsProvider implements IteratorAggregate
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set columns to exclude from the suggestions
|
||||
*
|
||||
* @param array $columns
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setExcludedColumns(array $columns): static
|
||||
{
|
||||
$this->excludedColumns = $columns;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIterator(): Generator
|
||||
{
|
||||
$exactVarSearches = [];
|
||||
|
|
@ -175,7 +189,7 @@ class QueryColumnsProvider implements IteratorAggregate
|
|||
);
|
||||
foreach ($columns as $columnName => $columnMeta) {
|
||||
if (
|
||||
! in_array($columnName, $this->excludedColumns)
|
||||
! in_array($columnName, $this->excludedColumns, true)
|
||||
&& $this->matchSuggestion($columnName, $columnMeta, $this->searchTerm)
|
||||
) {
|
||||
yield [
|
||||
|
|
@ -429,20 +443,6 @@ class QueryColumnsProvider implements IteratorAggregate
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set columns to exclude from the suggestions
|
||||
*
|
||||
* @param array $columns
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setExcludedColumns(array $columns): static
|
||||
{
|
||||
$this->excludedColumns = $columns;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given column path and label match the search term
|
||||
*
|
||||
|
|
|
|||
|
|
@ -514,7 +514,7 @@ class Controller extends CompatController
|
|||
$query = $model::on($this->getDb());
|
||||
$provider = (new QueryColumnsProvider($query))->setCustomVarSources($customVarSources);
|
||||
$suggestions = new SearchSuggestions($provider);
|
||||
$suggestions->forRequest(ServerRequest::fromGlobals());
|
||||
$suggestions->forRequest($this->getServerRequest());
|
||||
$provider->forSuggestions($suggestions);
|
||||
$this->getDocument()->addHtml($suggestions);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue