Geomap: Add ability to select a data query filter for each layer (#49966)

* Fix random typo I found

* add 'useDataFrame' boolean to each layer type to determine whether the layer queues off of query data

* Add data frame picker to options layout depending on layer type

* change layer update logic to render features from a specific data frame. Lift data frame selection up a level in order to add some more complex error handling.

* add a todo to the MapLayerRegistryItem interface

* update optional arg in function signature for consistency

* move dataframe filtering to paneldata, revert layers to prior state

* commit refactor, need to clean up still

* pull copy-pasted code into its own function

* clean up comments

* Update layer.ts

* remove unused types

* fix spacing

* improve dropdown

* need to add dependency to this callback function, otherwise it will always use the context of the last layer

* add data query recovery logic to handle query renames

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Michael Mandrus
2022-06-09 11:54:57 -04:00
committed by GitHub
parent 9703c9211e
commit 1284c596fe
5 changed files with 103 additions and 12 deletions

View File

@@ -3,7 +3,7 @@ import BaseLayer from 'ol/layer/Base';
import { ReactNode } from 'react';
import { GrafanaTheme2 } from '../themes';
import { PanelData } from '../types';
import { MatcherConfig, PanelData } from '../types';
import { PanelOptionsEditorBuilder } from '../utils';
import { RegistryItemWithOptions } from '../utils/Registry';
@@ -58,6 +58,9 @@ export interface MapLayerOptions<TConfig = any> {
// Common method to define geometry fields
location?: FrameGeometrySource;
// Defines which data query refId is associated with the layer
filterData?: MatcherConfig;
// Common properties:
// https://openlayers.org/en/latest/apidoc/module-ol_layer_Base-BaseLayer.html
// Layer opacity (0-1)
@@ -72,6 +75,9 @@ export interface MapLayerOptions<TConfig = any> {
*/
export interface MapLayerHandler<TConfig = any> {
init: () => BaseLayer;
/**
* The update function should only be implemented if the layer type makes use of query data
*/
update?: (data: PanelData) => void;
legend?: ReactNode;