Conversation
8453195 to
3c998e0
Compare
Add a new form that supports adding and removing dispalyed columns in tabular viewmode.
Add TabularViewModeSwitcher as a subclass of ViewModeSwitcher and remove tabular view as option of the ViewModeSwitcher.
Adjust HostsController and ServicesController to use the new ColumnChooser form and the TabularViewModeSwitcher. The Controller class is adjusted to work with the TabularViewModeSwitcher The HostGroupsController and ServiceGroupsController are adjusted, to ensure they use with the GridViewModeSwitcher.
Add a button to the StateItemTable to open the ColumnChooser form.
Exclude regular columns by using fixed columns and expand Objectsuggestions to exclude a given set of customvars.
3c998e0 to
2786e1d
Compare
…lass` Use the parameter to customize the type of ViewModeSwitcher used
Add a parameter for default columns to be used if no columns are set in the URL
Use `SearchSuggestions` in `HostsController` and `ServicesController`
Use the setter to set the url for the ColumnChooser
It was previously hard coded...
Ensure `GridViewModeSwitcher::class` is passed
nilmerg
left a comment
There was a problem hiding this comment.
I can see why you're not satisfied with the usage of SearchSuggestions. To get to a desirable result, a larger change is required. ObjectSuggestions were never designed to be more than a provider for the SearchBar. Now you're borrowing a part of its implementation either by making a protected method public or by copying parts of the code and reduce them to what you need.
I'd suggest to put the logic to retrieve custom variables and model columns for suggestions in a dedicated location that can be used by ObjectSuggestions and SearchSuggestions equally.
namespace Icinga\Module\Icingadb\Data;
/** Not necessarily complete, but I hope you get the idea */
class QueryColumnsProvider implements IteratorAggregate
{
public function __construct(Query $query, string $searchTerm);
public function setFixedColumns(array $columns);
public function setCustomVarSources(array $sources);
/** Basically a copy from `ObjectSuggestions` but without the need for a base implementation */
protected function matchSuggestion($path, $label, $searchTerm);
public function getIterator(): Generator;
/** public because `ObjectSuggestions::fetchValueSuggestions()` need it as well */
public static function collectFilterColumns(…): Generator;
}This should serve functionality currently only implemented in ObjectSuggestions to retrieve columns and custom variable names. It should be mostly a drop-in replacement for what ObjectSuggestions::fetchColumnSuggestions() currently does. Though, there is one thing it cannot provide:
addHtml – It's not a html element nor a container. The reason this is required comes from what the SearchSuggestions define as grouping. Though, in case of the column chooser this is required as well I think. QueryColumnsProvider should group by default. i.e. It yields in two levels, first a string key and a generator as value. SearchSuggestions should be able to handle this right now already, ObjectSuggestions need to be adjusted for this.
I hope this is sufficient to get you on track again.
From my understanding I added a group key to the values yielded by QueryColumnsProvider instead. |
nilmerg
left a comment
There was a problem hiding this comment.
Didn't look in detail at QueryColumnsProvider and ObjectSuggestions yet.
Use a `where` to filter out custom vars that should be excluded
| 'host' => t('Host %s', '..<customvar-name>'), | ||
| 'service' => t('Service %s', '..<customvar-name>') |
| 'host' => t('Host %s', '..<customvar-name>'), | ||
| 'service' => t('Service %s', '..<customvar-name>') |
| yield [ | ||
| 'search' => $relation . '.vars.' . $search, | ||
| 'label' => sprintf($label, $name), | ||
| 'group' => t('Best Suggestions') |
There was a problem hiding this comment.
Please use ipl-i18n's Translation trait instead of the global functions.
| if (isset($excludedByRelation[$name])) { | ||
| $flatname = $resolver->qualifyColumn('flatname', $resolver->getAlias($customVars->getModel())); | ||
| $select->where( | ||
| "$flatname Not In (?)", |
| ) { | ||
| yield [ | ||
| 'search' => $columnName, | ||
| 'label' => $columnMeta, |
There was a problem hiding this comment.
I noticed that a feature of ObjectSuggestions is missing here: Relation names. (Controlled by shouldShowRelationFor)
We have several duplicate column labels such as Endpoint Name that need further distinction in the suggestions. The search bar's Suggestions have this builtin, the SearchSuggestions on the other hand do not. But as said, they should be dumb, what I'd suggest is to teach them only about that labels might be ipl\Html\Contract\ValidHtml and in that case, they don't render an <input type="button"> but a <button type="button"></button> (That's what Suggestions already do but always.)
So please add support for this, I will create an issue for ip-web, and replicate here the markup the Suggestions use to show relations.
Add a new form to choose the displayed columns in hosts and services view.
resolves: #82
fixes #850
requires: Icinga/ipl-web#277 for the
TabularViewModeSwitchericonrequires: Icinga/ipl-web#357 to display error messages for invalid columns