@grafana/scenes 5.9.2--canary.830.10452071184.0 → 5.10.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +20 -0
- package/dist/esm/querying/SceneQueryRunner.js +2 -2
- package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
- package/dist/esm/querying/layers/annotations/AnnotationsDataLayer.js +2 -2
- package/dist/esm/querying/layers/annotations/AnnotationsDataLayer.js.map +1 -1
- package/dist/esm/querying/layers/annotations/standardAnnotationQuery.js +2 -2
- package/dist/esm/querying/layers/annotations/standardAnnotationQuery.js.map +1 -1
- package/dist/esm/utils/wrapInSafeSerializableSceneObject.js +30 -0
- package/dist/esm/utils/wrapInSafeSerializableSceneObject.js.map +1 -0
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +6 -14
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
- package/dist/esm/variables/groupby/GroupByVariable.js +2 -2
- package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
- package/dist/esm/variables/variants/query/QueryVariable.js +3 -3
- package/dist/esm/variables/variants/query/QueryVariable.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +234 -803
- package/dist/index.js.map +1 -1
- package/package.json +2 -4
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js +0 -387
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js.map +0 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersComboboxEditSwitch.js +0 -113
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersComboboxEditSwitch.js.map +0 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersComboboxRenderer.js +0 -63
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersComboboxRenderer.js.map +0 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/DropdownItem.js +0 -53
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/DropdownItem.js.map +0 -1
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
# v5.10.0 (Mon Aug 19 2024)
|
2
|
+
|
3
|
+
### Release Notes
|
4
|
+
|
5
|
+
#### SafeSerializableSceneObject: Wrap only for supported Grafana version ([#854](https://github.com/grafana/scenes/pull/854))
|
6
|
+
|
7
|
+
Brings a fix for [variables interpolation bug](https://github.com/grafana/scenes/issues/851) when apps using scenes 5.6.0+ were run in Grafana version lower than 11.2.0, 11.1.2, 11.0.4, 10.4.8.
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
#### 🚀 Enhancement
|
12
|
+
|
13
|
+
- SafeSerializableSceneObject: Wrap only for supported Grafana version [#854](https://github.com/grafana/scenes/pull/854) ([@dprokop](https://github.com/dprokop))
|
14
|
+
|
15
|
+
#### Authors: 1
|
16
|
+
|
17
|
+
- Dominik Prokop ([@dprokop](https://github.com/dprokop))
|
18
|
+
|
19
|
+
---
|
20
|
+
|
1
21
|
# v5.9.1 (Mon Aug 19 2024)
|
2
22
|
|
3
23
|
#### 🐛 Bug Fix
|
@@ -22,7 +22,7 @@ import { GroupByVariable } from '../variables/groupby/GroupByVariable.js';
|
|
22
22
|
import { AdHocFiltersVariable, isFilterComplete } from '../variables/adhoc/AdHocFiltersVariable.js';
|
23
23
|
import { DataLayersMerger } from './DataLayersMerger.js';
|
24
24
|
import { interpolate } from '../core/sceneGraph/sceneGraph.js';
|
25
|
-
import {
|
25
|
+
import { wrapInSafeSerializableSceneObject } from '../utils/wrapInSafeSerializableSceneObject.js';
|
26
26
|
|
27
27
|
var __defProp = Object.defineProperty;
|
28
28
|
var __defProps = Object.defineProperties;
|
@@ -53,7 +53,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
53
53
|
this._dataLayersMerger = new DataLayersMerger();
|
54
54
|
this._variableValueRecorder = new VariableValueRecorder();
|
55
55
|
this._results = new ReplaySubject(1);
|
56
|
-
this._scopedVars = { __sceneObject:
|
56
|
+
this._scopedVars = { __sceneObject: wrapInSafeSerializableSceneObject(this) };
|
57
57
|
this._variableDependency = new VariableDependencyConfig(this, {
|
58
58
|
statePaths: ["queries", "datasource"],
|
59
59
|
onVariableUpdateCompleted: this.onVariableUpdatesCompleted.bind(this),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SceneQueryRunner.js","sources":["../../../src/querying/SceneQueryRunner.ts"],"sourcesContent":["import { cloneDeep, isEqual } from 'lodash';\nimport { forkJoin, ReplaySubject, Unsubscribable } from 'rxjs';\n\nimport { DataQuery, DataSourceRef, LoadingState } from '@grafana/schema';\n\nimport {\n AlertStateInfo,\n DataFrame,\n DataFrameView,\n DataQueryRequest,\n DataSourceApi,\n DataTopic,\n PanelData,\n preProcessPanelData,\n rangeUtil,\n} from '@grafana/data';\n\n// TODO: Remove this ignore annotation when the grafana runtime dependency has been updated\n// @ts-ignore\nimport { getRunRequest, toDataQueryError, isExpressionReference } from '@grafana/runtime';\n\nimport { SceneObjectBase } from '../core/SceneObjectBase';\nimport { sceneGraph } from '../core/sceneGraph';\nimport {\n DataLayerFilter,\n SceneDataProvider,\n SceneDataProviderResult,\n SceneDataQuery,\n SceneObjectState,\n SceneTimeRangeLike,\n} from '../core/types';\nimport { getDataSource } from '../utils/getDataSource';\nimport { VariableDependencyConfig } from '../variables/VariableDependencyConfig';\nimport { writeSceneLog } from '../utils/writeSceneLog';\nimport { VariableValueRecorder } from '../variables/VariableValueRecorder';\nimport { emptyPanelData } from '../core/SceneDataNode';\nimport { getClosest } from '../core/sceneGraph/utils';\nimport { isExtraQueryProvider, ExtraQueryDataProcessor, ExtraQueryProvider } from './ExtraQueryProvider';\nimport { passthroughProcessor, extraQueryProcessingOperator } from './extraQueryProcessingOperator';\nimport { filterAnnotations } from './layers/annotations/filterAnnotations';\nimport { getEnrichedDataRequest } from './getEnrichedDataRequest';\nimport { findActiveAdHocFilterVariableByUid } from '../variables/adhoc/patchGetAdhocFilters';\nimport { registerQueryWithController } from './registerQueryWithController';\nimport { findActiveGroupByVariablesByUid } from '../variables/groupby/findActiveGroupByVariablesByUid';\nimport { GroupByVariable } from '../variables/groupby/GroupByVariable';\nimport { AdHocFiltersVariable, isFilterComplete } from '../variables/adhoc/AdHocFiltersVariable';\nimport { SceneVariable } from '../variables/types';\nimport { DataLayersMerger } from './DataLayersMerger';\nimport { interpolate } from '../core/sceneGraph/sceneGraph';\nimport { SafeSerializableSceneObject } from '../utils/SafeSerializableSceneObject';\n\nlet counter = 100;\n\nexport function getNextRequestId() {\n return 'SQR' + counter++;\n}\n\nexport interface QueryRunnerState extends SceneObjectState {\n data?: PanelData;\n queries: SceneDataQuery[];\n datasource?: DataSourceRef;\n minInterval?: string;\n maxDataPoints?: number;\n liveStreaming?: boolean;\n maxDataPointsFromWidth?: boolean;\n cacheTimeout?: DataQueryRequest['cacheTimeout'];\n queryCachingTTL?: DataQueryRequest['queryCachingTTL'];\n /**\n * When set to auto (the default) query runner will issue queries on activate (when variable dependencies are ready) or when time range change.\n * Set to manual to have full manual control over when queries are issued. Try not to set this. This is mainly useful for unit tests, or special edge case workflows.\n */\n runQueriesMode?: 'auto' | 'manual';\n // Filters to be applied to data layer results before combining them with SQR results\n dataLayerFilter?: DataLayerFilter;\n // Private runtime state\n _hasFetchedData?: boolean;\n}\n\nexport interface DataQueryExtended extends DataQuery {\n [key: string]: any;\n\n // Opt this query out of time window comparison\n timeRangeCompare?: boolean;\n}\n\n// The requests that will be run by the query runner.\n//\n// Generally the query runner will run a single primary request.\n// If the scene graph contains implementations of\n// `ExtraQueryProvider`, the requests created by these\n// implementations will be added to the list of secondary requests,\n// and these will be executed at the same time as the primary request.\n//\n// The results of each secondary request will be passed to an associated\n// processor function (along with the results of the primary request),\n// which can transform the results as desired.\ninterface PreparedRequests {\n // The primary request to run.\n primary: DataQueryRequest;\n // A possibly empty list of secondary requests to run alongside\n // the primary request.\n secondaries: DataQueryRequest[];\n // A map from `requestId` of secondary requests to processors\n // for those requests. Provided by the `ExtraQueryProvider`.\n processors: Map<string, ExtraQueryDataProcessor>;\n}\n\nexport class SceneQueryRunner extends SceneObjectBase<QueryRunnerState> implements SceneDataProvider {\n private _querySub?: Unsubscribable;\n private _dataLayersSub?: Unsubscribable;\n private _dataLayersMerger = new DataLayersMerger();\n private _timeSub?: Unsubscribable;\n private _timeSubRange?: SceneTimeRangeLike;\n private _containerWidth?: number;\n private _variableValueRecorder = new VariableValueRecorder();\n private _results = new ReplaySubject<SceneDataProviderResult>(1);\n private _scopedVars = { __sceneObject: new SafeSerializableSceneObject(this) };\n private _layerAnnotations?: DataFrame[];\n private _resultAnnotations?: DataFrame[];\n\n private _adhocFiltersVar?: AdHocFiltersVariable;\n private _groupByVar?: GroupByVariable;\n\n public getResultsStream() {\n return this._results;\n }\n\n protected _variableDependency: VariableDependencyConfig<QueryRunnerState> = new VariableDependencyConfig(this, {\n statePaths: ['queries', 'datasource'],\n onVariableUpdateCompleted: this.onVariableUpdatesCompleted.bind(this),\n onAnyVariableChanged: this.onAnyVariableChanged.bind(this),\n });\n\n public constructor(initialState: QueryRunnerState) {\n super(initialState);\n\n this.addActivationHandler(() => this._onActivate());\n }\n\n private _onActivate() {\n if (this.isQueryModeAuto()) {\n const timeRange = sceneGraph.getTimeRange(this);\n\n // Add subscriptions to any extra providers so that they rerun queries\n // when their state changes and they should rerun.\n const providers = this.getClosestExtraQueryProviders();\n for (const provider of providers) {\n this._subs.add(\n provider.subscribeToState((n, p) => {\n if (provider.shouldRerun(p, n, this.state.queries)) {\n this.runQueries();\n }\n }),\n );\n }\n\n this.subscribeToTimeRangeChanges(\n timeRange,\n );\n\n if (this.shouldRunQueriesOnActivate()) {\n this.runQueries();\n }\n }\n\n if (!this._dataLayersSub) {\n this._handleDataLayers();\n }\n\n return () => this._onDeactivate();\n }\n\n // This method subscribes to all SceneDataLayers up until the root, and combines the results into data provided from SceneQueryRunner\n private _handleDataLayers() {\n const dataLayers = sceneGraph.getDataLayers(this);\n\n if (dataLayers.length === 0) {\n return;\n }\n\n this._dataLayersSub = this._dataLayersMerger\n .getMergedStream(dataLayers)\n .subscribe(this._onLayersReceived.bind(this));\n }\n\n private _onLayersReceived(results: Iterable<SceneDataProviderResult>) {\n const timeRange = sceneGraph.getTimeRange(this);\n const { dataLayerFilter } = this.state;\n\n let annotations: DataFrame[] = [];\n let alertStates: DataFrame[] = [];\n let alertState: AlertStateInfo | undefined;\n\n for (const result of results) {\n for (let frame of result.data.series) {\n if (frame.meta?.dataTopic === DataTopic.Annotations) {\n annotations = annotations.concat(frame);\n }\n if (frame.meta?.dataTopic === DataTopic.AlertStates) {\n alertStates = alertStates.concat(frame);\n }\n }\n }\n\n if (dataLayerFilter?.panelId) {\n if (annotations.length > 0) {\n annotations = filterAnnotations(annotations, dataLayerFilter);\n }\n\n if (alertStates.length > 0) {\n for (const frame of alertStates) {\n const frameView = new DataFrameView<AlertStateInfo>(frame);\n\n for (const row of frameView) {\n if (row.panelId === dataLayerFilter.panelId) {\n alertState = row;\n break;\n }\n }\n }\n }\n }\n\n // Skip unnessary state updates\n if (\n allFramesEmpty(annotations) &&\n allFramesEmpty(this._layerAnnotations) &&\n isEqual(alertState, this.state.data?.alertState)\n ) {\n return;\n }\n\n this._layerAnnotations = annotations;\n\n const baseStateUpdate = this.state.data ? this.state.data : { ...emptyPanelData, timeRange: timeRange.state.value };\n\n this.setState({\n data: {\n ...baseStateUpdate,\n annotations: [...(this._resultAnnotations ?? []), ...annotations],\n alertState: alertState ?? this.state.data?.alertState,\n },\n });\n }\n\n /**\n * This tries to start a new query whenever a variable completes or is changed.\n *\n * We care about variable update completions even when the variable has not changed and even when it is not a direct dependency.\n * Example: Variables A and B (B depends on A). A update depends on time range. So when time change query runner will\n * find that variable A is loading which is a dependency on of variable B so will set _isWaitingForVariables to true and\n * not issue any query.\n *\n * When A completes it's loading (with no value change, so B never updates) it will cause a call of this function letting\n * the query runner know that A has completed, and in case _isWaitingForVariables we try to run the query. The query will\n * only run if all variables are in a non loading state so in other scenarios where a query depends on many variables this will\n * be called many times until all dependencies are in a non loading state. *\n */\n private onVariableUpdatesCompleted() {\n if(this.isQueryModeAuto()){\n this.runQueries();\n }\n }\n\n /**\n * Check if value changed is a adhoc filter o group by variable that did not exist when we issued the last query\n */\n private onAnyVariableChanged(variable: SceneVariable) {\n // If this variable has already been detected this variable as a dependency onVariableUpdatesCompleted above will handle value changes\n if (this._adhocFiltersVar === variable || this._groupByVar === variable || !this.isQueryModeAuto()) {\n return;\n }\n\n if (variable instanceof AdHocFiltersVariable && this._isRelevantAutoVariable(variable)) {\n this.runQueries();\n }\n\n if (variable instanceof GroupByVariable && this._isRelevantAutoVariable(variable)) {\n this.runQueries();\n }\n }\n\n private _isRelevantAutoVariable(variable: AdHocFiltersVariable | GroupByVariable) {\n const datasource = this.state.datasource ?? findFirstDatasource(this.state.queries);\n return variable.state.applyMode === 'auto' && datasource?.uid === variable.state.datasource?.uid;\n }\n\n private shouldRunQueriesOnActivate() {\n if (this._variableValueRecorder.hasDependenciesChanged(this)) {\n writeSceneLog(\n 'SceneQueryRunner',\n 'Variable dependency changed while inactive, shouldRunQueriesOnActivate returns true'\n );\n return true;\n }\n\n // If we don't have any data we should run queries\n if (!this.state.data) {\n return true;\n }\n\n // If time range is stale / different we should run queries\n if (this._isDataTimeRangeStale(this.state.data)) {\n return true;\n }\n\n return false;\n }\n\n private _isDataTimeRangeStale(data: PanelData) {\n const timeRange = sceneGraph.getTimeRange(this);\n\n const stateTimeRange = timeRange.state.value;\n const dataTimeRange = data.timeRange;\n\n if (\n stateTimeRange.from.unix() === dataTimeRange.from.unix() &&\n stateTimeRange.to.unix() === dataTimeRange.to.unix()\n ) {\n return false;\n }\n writeSceneLog('SceneQueryRunner', 'Data time range is stale');\n return true;\n }\n\n private _onDeactivate(): void {\n if (this._querySub) {\n this._querySub.unsubscribe();\n this._querySub = undefined;\n }\n\n if (this._dataLayersSub) {\n this._dataLayersSub.unsubscribe();\n this._dataLayersSub = undefined;\n }\n\n this._timeSub?.unsubscribe();\n this._timeSub = undefined;\n this._timeSubRange = undefined;\n this._adhocFiltersVar = undefined;\n this._groupByVar = undefined;\n this._variableValueRecorder.recordCurrentDependencyValuesForSceneObject(this);\n }\n\n public setContainerWidth(width: number) {\n // If we don't have a width we should run queries\n if (!this._containerWidth && width > 0) {\n this._containerWidth = width;\n\n // If we don't have maxDataPoints specifically set and maxDataPointsFromWidth is true\n if (this.state.maxDataPointsFromWidth && !this.state.maxDataPoints) {\n // As this is called from render path we need to wait for next tick before running queries\n setTimeout(() => {\n if (this.isActive && !this.state._hasFetchedData) {\n this.runQueries();\n }\n }, 0);\n }\n } else {\n // if the updated container width is bigger than 0 let's remember the width until next query issue\n if (width > 0) {\n this._containerWidth = width;\n }\n }\n }\n\n public isDataReadyToDisplay() {\n return Boolean(this.state._hasFetchedData);\n }\n\n private subscribeToTimeRangeChanges(timeRange: SceneTimeRangeLike) {\n if (this._timeSubRange === timeRange) {\n // Nothing to do, already subscribed\n return;\n }\n\n if (this._timeSub) {\n this._timeSub.unsubscribe();\n }\n\n this._timeSubRange = timeRange;\n this._timeSub = timeRange.subscribeToState(() => {\n this.runWithTimeRange(timeRange);\n });\n }\n\n public runQueries() {\n const timeRange = sceneGraph.getTimeRange(this);\n if(this.isQueryModeAuto()){\n this.subscribeToTimeRangeChanges(timeRange);\n }\n\n this.runWithTimeRange(timeRange);\n }\n\n private getMaxDataPoints() {\n if (this.state.maxDataPoints) {\n return this.state.maxDataPoints;\n }\n\n return this.state.maxDataPointsFromWidth ? this._containerWidth ?? 500 : 500;\n }\n\n public cancelQuery() {\n this._querySub?.unsubscribe();\n\n if (this._dataLayersSub) {\n this._dataLayersSub.unsubscribe();\n this._dataLayersSub = undefined;\n }\n\n this.setState({\n data: { ...this.state.data!, state: LoadingState.Done },\n });\n }\n\n private async runWithTimeRange(timeRange: SceneTimeRangeLike) {\n // If no maxDataPoints specified we might need to wait for container width to be set from the outside\n if (!this.state.maxDataPoints && this.state.maxDataPointsFromWidth && !this._containerWidth) {\n return;\n }\n\n // If data layers subscription doesn't exist, create one\n if (!this._dataLayersSub) {\n this._handleDataLayers();\n }\n\n // Cancel any running queries\n this._querySub?.unsubscribe();\n\n // Skip executing queries if variable dependency is in loading state\n if (this._variableDependency.hasDependencyInLoadingState()) {\n writeSceneLog('SceneQueryRunner', 'Variable dependency is in loading state, skipping query execution');\n this.setState({ data: { ...(this.state.data ?? emptyPanelData), state: LoadingState.Loading } });\n return;\n }\n\n const { queries } = this.state;\n\n // Simple path when no queries exist\n if (!queries?.length) {\n this._setNoDataState();\n return;\n }\n\n try {\n const datasource = this.state.datasource ?? findFirstDatasource(queries);\n const ds = await getDataSource(datasource, this._scopedVars);\n\n this.findAndSubscribeToAdHocFilters(datasource?.uid);\n\n const runRequest = getRunRequest();\n const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds);\n\n writeSceneLog('SceneQueryRunner', 'Starting runRequest', this.state.key);\n\n let stream = runRequest(ds, primary);\n\n if (secondaries.length > 0) {\n // Submit all secondary requests in parallel.\n const secondaryStreams = secondaries.map((r) => runRequest(ds, r));\n // Create the rxjs operator which will combine the primary and secondary responses\n // by calling the correct processor functions provided by the\n // extra request providers.\n const op = extraQueryProcessingOperator(processors);\n // Combine the primary and secondary streams into a single stream, and apply the operator.\n stream = forkJoin([stream, ...secondaryStreams]).pipe(op);\n }\n\n stream = stream.pipe(\n registerQueryWithController({\n type: 'data',\n request: primary,\n origin: this,\n cancel: () => this.cancelQuery(),\n })\n );\n\n this._querySub = stream.subscribe(this.onDataReceived);\n } catch (err) {\n console.error('PanelQueryRunner Error', err);\n\n this.onDataReceived({\n ...emptyPanelData,\n ...this.state.data,\n state: LoadingState.Error,\n errors: [toDataQueryError(err)],\n });\n }\n }\n\n public clone(withState?: Partial<QueryRunnerState>) {\n const clone = super.clone(withState);\n\n if (this._resultAnnotations) {\n clone['_resultAnnotations'] = this._resultAnnotations.map((frame) => ({ ...frame }));\n }\n\n if (this._layerAnnotations) {\n clone['_layerAnnotations'] = this._layerAnnotations.map((frame) => ({ ...frame }));\n }\n\n clone['_variableValueRecorder'] = this._variableValueRecorder.cloneAndRecordCurrentValuesForSceneObject(this);\n clone['_containerWidth'] = this._containerWidth;\n clone['_results'].next({ origin: this, data: this.state.data ?? emptyPanelData });\n\n return clone;\n }\n\n private prepareRequests(timeRange: SceneTimeRangeLike, ds: DataSourceApi): PreparedRequests {\n const { minInterval, queries } = this.state;\n\n let request: DataQueryRequest<DataQueryExtended> = {\n app: 'scenes',\n requestId: getNextRequestId(),\n timezone: timeRange.getTimeZone(),\n range: timeRange.state.value,\n interval: '1s',\n intervalMs: 1000,\n targets: cloneDeep(queries),\n maxDataPoints: this.getMaxDataPoints(),\n scopedVars: this._scopedVars,\n startTime: Date.now(),\n liveStreaming: this.state.liveStreaming,\n rangeRaw: {\n from: timeRange.state.from,\n to: timeRange.state.to,\n },\n cacheTimeout: this.state.cacheTimeout,\n queryCachingTTL: this.state.queryCachingTTL,\n // This asks the scene root to provide context properties like app, panel and dashboardUID\n ...getEnrichedDataRequest(this),\n };\n\n if (this._adhocFiltersVar) {\n // only pass filters that have both key and value\n // @ts-ignore (Temporary ignore until we update @grafana/data)\n request.filters = this._adhocFiltersVar.state.filters.filter(isFilterComplete);\n }\n\n if (this._groupByVar) {\n // @ts-ignore (Temporary ignore until we update @grafana/data)\n request.groupByKeys = this._groupByVar.state.value;\n }\n\n request.targets = request.targets.map((query) => {\n if (\n !query.datasource ||\n (query.datasource.uid !== ds.uid &&\n !ds.meta?.mixed &&\n isExpressionReference /* TODO: Remove this check when isExpressionReference is properly exported from grafan runtime */ &&\n !isExpressionReference(query.datasource))\n ) {\n query.datasource = ds.getRef();\n }\n return query;\n });\n\n const lowerIntervalLimit = minInterval ? interpolate(this, minInterval) : ds.interval;\n const norm = rangeUtil.calculateInterval(timeRange.state.value, request.maxDataPoints!, lowerIntervalLimit);\n\n // make shallow copy of scoped vars,\n // and add built in variables interval and interval_ms\n request.scopedVars = Object.assign({}, request.scopedVars, {\n __interval: { text: norm.interval, value: norm.interval },\n __interval_ms: { text: norm.intervalMs.toString(), value: norm.intervalMs },\n });\n\n request.interval = norm.interval;\n request.intervalMs = norm.intervalMs;\n\n // If there are any extra request providers, we need to add a new request for each\n // and map the request's ID to the processor function given by the provider, to ensure that\n // the processor is called with the correct response data.\n const primaryTimeRange = timeRange.state.value;\n let secondaryRequests: DataQueryRequest[] = [];\n let secondaryProcessors = new Map();\n for (const provider of this.getClosestExtraQueryProviders() ?? []) {\n for (const { req, processor } of provider.getExtraQueries(request)) {\n const requestId = getNextRequestId();\n secondaryRequests.push({ ...req, requestId });\n secondaryProcessors.set(requestId, processor ?? passthroughProcessor);\n }\n }\n request.range = primaryTimeRange;\n return { primary: request, secondaries: secondaryRequests, processors: secondaryProcessors };\n }\n\n private onDataReceived = (data: PanelData) => {\n // Will combine annotations from SQR queries (frames with meta.dataTopic === DataTopic.Annotations)\n const preProcessedData = preProcessPanelData(data, this.state.data);\n\n // Save query annotations\n this._resultAnnotations = data.annotations;\n\n // Will combine annotations & alert state from data layer providers\n const dataWithLayersApplied = this._combineDataLayers(preProcessedData);\n\n let hasFetchedData = this.state._hasFetchedData;\n\n if (!hasFetchedData && preProcessedData.state !== LoadingState.Loading) {\n hasFetchedData = true;\n }\n\n this.setState({ data: dataWithLayersApplied, _hasFetchedData: hasFetchedData });\n this._results.next({ origin: this, data: dataWithLayersApplied });\n };\n\n private _combineDataLayers(data: PanelData) {\n if (this._layerAnnotations && this._layerAnnotations.length > 0) {\n data.annotations = (data.annotations || []).concat(this._layerAnnotations);\n }\n\n if (this.state.data && this.state.data.alertState) {\n data.alertState = this.state.data.alertState;\n }\n\n return data;\n }\n\n private _setNoDataState() {\n if (this.state.data !== emptyPanelData) {\n this.setState({ data: emptyPanelData });\n }\n }\n\n /**\n * Walk up the scene graph and find any ExtraQueryProviders.\n *\n * This will return an array of the closest provider of each type.\n */\n private getClosestExtraQueryProviders(): Array<ExtraQueryProvider<any>> {\n // Maintain a map from provider constructor to provider object. The constructor\n // is used as a unique key for each class, to ensure we have no more than one\n // type of each type of provider.\n const found = new Map();\n if (!this.parent) {\n return [];\n }\n getClosest(this.parent, (s) => {\n if (isExtraQueryProvider(s) && !found.has(s.constructor)) {\n found.set(s.constructor, s);\n }\n s.forEachChild((child) => {\n if (isExtraQueryProvider(child) && !found.has(child.constructor)) {\n found.set(child.constructor, child);\n }\n });\n // Always return null so that the search continues to the top of\n // the scene graph.\n return null;\n });\n return Array.from(found.values());\n }\n\n /**\n * Walk up scene graph and find the closest filterset with matching data source\n */\n private findAndSubscribeToAdHocFilters(uid: string | undefined) {\n const filtersVar = findActiveAdHocFilterVariableByUid(uid);\n\n if (this._adhocFiltersVar !== filtersVar) {\n this._adhocFiltersVar = filtersVar;\n this._updateExplicitVariableDependencies();\n }\n\n const groupByVar = findActiveGroupByVariablesByUid(uid);\n if (this._groupByVar !== groupByVar) {\n this._groupByVar = groupByVar;\n this._updateExplicitVariableDependencies();\n }\n }\n\n private _updateExplicitVariableDependencies() {\n const explicitDependencies: string[] = [];\n\n if (this._adhocFiltersVar) {\n explicitDependencies.push(this._adhocFiltersVar.state.name);\n }\n\n if (this._groupByVar) {\n explicitDependencies.push(this._groupByVar.state.name);\n }\n\n this._variableDependency.setVariableNames(explicitDependencies);\n }\n\n private isQueryModeAuto(): boolean {\n return (this.state.runQueriesMode ?? 'auto') === 'auto'\n }\n}\n\nexport function findFirstDatasource(targets: DataQuery[]): DataSourceRef | undefined {\n return targets.find((t) => t.datasource !== null)?.datasource ?? undefined;\n}\n\nfunction allFramesEmpty(frames?: DataFrame[]) {\n if (!frames) {\n return true;\n }\n\n for (let i = 0; i < frames.length; i++) {\n if (frames[i].length > 0) {\n return false;\n }\n }\n\n return true;\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAI,OAAU,GAAA,GAAA,CAAA;AAEP,SAAS,gBAAmB,GAAA;AACjC,EAAA,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AA;AAEO,SAAS,oBAAoB,OAAiD,EAAA;AAprBrF,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AAqrBE,EAAO,OAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAA,CAAQ,IAAK,CAAA,CAAC,CAAM,KAAA,CAAA,CAAE,eAAe,IAAI,CAAA,KAAzC,IAA4C,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,UAAA,KAA5C,IAA0D,GAAA,EAAA,GAAA,KAAA,CAAA,CAAA;AACnE,CAAA;AAEA,SAAS,eAAe,MAAsB,EAAA;AAC5C,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,MAAA,CAAO,QAAQ,CAAK,EAAA,EAAA;AACtC,IAAI,IAAA,MAAA,CAAO,CAAG,CAAA,CAAA,MAAA,GAAS,CAAG,EAAA;AACxB,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAAA,GACF;AAEA,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}
|
1
|
+
{"version":3,"file":"SceneQueryRunner.js","sources":["../../../src/querying/SceneQueryRunner.ts"],"sourcesContent":["import { cloneDeep, isEqual } from 'lodash';\nimport { forkJoin, ReplaySubject, Unsubscribable } from 'rxjs';\n\nimport { DataQuery, DataSourceRef, LoadingState } from '@grafana/schema';\n\nimport {\n AlertStateInfo,\n DataFrame,\n DataFrameView,\n DataQueryRequest,\n DataSourceApi,\n DataTopic,\n PanelData,\n preProcessPanelData,\n rangeUtil,\n} from '@grafana/data';\n\n// TODO: Remove this ignore annotation when the grafana runtime dependency has been updated\n// @ts-ignore\nimport { getRunRequest, toDataQueryError, isExpressionReference, config } from '@grafana/runtime';\n\nimport { SceneObjectBase } from '../core/SceneObjectBase';\nimport { sceneGraph } from '../core/sceneGraph';\nimport {\n DataLayerFilter,\n SceneDataProvider,\n SceneDataProviderResult,\n SceneDataQuery,\n SceneObjectState,\n SceneTimeRangeLike,\n} from '../core/types';\nimport { getDataSource } from '../utils/getDataSource';\nimport { VariableDependencyConfig } from '../variables/VariableDependencyConfig';\nimport { writeSceneLog } from '../utils/writeSceneLog';\nimport { VariableValueRecorder } from '../variables/VariableValueRecorder';\nimport { emptyPanelData } from '../core/SceneDataNode';\nimport { getClosest } from '../core/sceneGraph/utils';\nimport { isExtraQueryProvider, ExtraQueryDataProcessor, ExtraQueryProvider } from './ExtraQueryProvider';\nimport { passthroughProcessor, extraQueryProcessingOperator } from './extraQueryProcessingOperator';\nimport { filterAnnotations } from './layers/annotations/filterAnnotations';\nimport { getEnrichedDataRequest } from './getEnrichedDataRequest';\nimport { findActiveAdHocFilterVariableByUid } from '../variables/adhoc/patchGetAdhocFilters';\nimport { registerQueryWithController } from './registerQueryWithController';\nimport { findActiveGroupByVariablesByUid } from '../variables/groupby/findActiveGroupByVariablesByUid';\nimport { GroupByVariable } from '../variables/groupby/GroupByVariable';\nimport { AdHocFiltersVariable, isFilterComplete } from '../variables/adhoc/AdHocFiltersVariable';\nimport { SceneVariable } from '../variables/types';\nimport { DataLayersMerger } from './DataLayersMerger';\nimport { interpolate } from '../core/sceneGraph/sceneGraph';\nimport { wrapInSafeSerializableSceneObject } from '../utils/wrapInSafeSerializableSceneObject';\n\nlet counter = 100;\n\nexport function getNextRequestId() {\n return 'SQR' + counter++;\n}\n\nexport interface QueryRunnerState extends SceneObjectState {\n data?: PanelData;\n queries: SceneDataQuery[];\n datasource?: DataSourceRef;\n minInterval?: string;\n maxDataPoints?: number;\n liveStreaming?: boolean;\n maxDataPointsFromWidth?: boolean;\n cacheTimeout?: DataQueryRequest['cacheTimeout'];\n queryCachingTTL?: DataQueryRequest['queryCachingTTL'];\n /**\n * When set to auto (the default) query runner will issue queries on activate (when variable dependencies are ready) or when time range change.\n * Set to manual to have full manual control over when queries are issued. Try not to set this. This is mainly useful for unit tests, or special edge case workflows.\n */\n runQueriesMode?: 'auto' | 'manual';\n // Filters to be applied to data layer results before combining them with SQR results\n dataLayerFilter?: DataLayerFilter;\n // Private runtime state\n _hasFetchedData?: boolean;\n}\n\nexport interface DataQueryExtended extends DataQuery {\n [key: string]: any;\n\n // Opt this query out of time window comparison\n timeRangeCompare?: boolean;\n}\n\n// The requests that will be run by the query runner.\n//\n// Generally the query runner will run a single primary request.\n// If the scene graph contains implementations of\n// `ExtraQueryProvider`, the requests created by these\n// implementations will be added to the list of secondary requests,\n// and these will be executed at the same time as the primary request.\n//\n// The results of each secondary request will be passed to an associated\n// processor function (along with the results of the primary request),\n// which can transform the results as desired.\ninterface PreparedRequests {\n // The primary request to run.\n primary: DataQueryRequest;\n // A possibly empty list of secondary requests to run alongside\n // the primary request.\n secondaries: DataQueryRequest[];\n // A map from `requestId` of secondary requests to processors\n // for those requests. Provided by the `ExtraQueryProvider`.\n processors: Map<string, ExtraQueryDataProcessor>;\n}\n\nexport class SceneQueryRunner extends SceneObjectBase<QueryRunnerState> implements SceneDataProvider {\n private _querySub?: Unsubscribable;\n private _dataLayersSub?: Unsubscribable;\n private _dataLayersMerger = new DataLayersMerger();\n private _timeSub?: Unsubscribable;\n private _timeSubRange?: SceneTimeRangeLike;\n private _containerWidth?: number;\n private _variableValueRecorder = new VariableValueRecorder();\n private _results = new ReplaySubject<SceneDataProviderResult>(1);\n private _scopedVars = { __sceneObject: wrapInSafeSerializableSceneObject(this) };\n private _layerAnnotations?: DataFrame[];\n private _resultAnnotations?: DataFrame[];\n\n private _adhocFiltersVar?: AdHocFiltersVariable;\n private _groupByVar?: GroupByVariable;\n\n public getResultsStream() {\n return this._results;\n }\n\n protected _variableDependency: VariableDependencyConfig<QueryRunnerState> = new VariableDependencyConfig(this, {\n statePaths: ['queries', 'datasource'],\n onVariableUpdateCompleted: this.onVariableUpdatesCompleted.bind(this),\n onAnyVariableChanged: this.onAnyVariableChanged.bind(this),\n });\n\n public constructor(initialState: QueryRunnerState) {\n super(initialState);\n\n this.addActivationHandler(() => this._onActivate());\n }\n\n private _onActivate() {\n if (this.isQueryModeAuto()) {\n const timeRange = sceneGraph.getTimeRange(this);\n\n // Add subscriptions to any extra providers so that they rerun queries\n // when their state changes and they should rerun.\n const providers = this.getClosestExtraQueryProviders();\n for (const provider of providers) {\n this._subs.add(\n provider.subscribeToState((n, p) => {\n if (provider.shouldRerun(p, n, this.state.queries)) {\n this.runQueries();\n }\n }),\n );\n }\n\n this.subscribeToTimeRangeChanges(\n timeRange,\n );\n\n if (this.shouldRunQueriesOnActivate()) {\n this.runQueries();\n }\n }\n\n if (!this._dataLayersSub) {\n this._handleDataLayers();\n }\n\n return () => this._onDeactivate();\n }\n\n // This method subscribes to all SceneDataLayers up until the root, and combines the results into data provided from SceneQueryRunner\n private _handleDataLayers() {\n const dataLayers = sceneGraph.getDataLayers(this);\n\n if (dataLayers.length === 0) {\n return;\n }\n\n this._dataLayersSub = this._dataLayersMerger\n .getMergedStream(dataLayers)\n .subscribe(this._onLayersReceived.bind(this));\n }\n\n private _onLayersReceived(results: Iterable<SceneDataProviderResult>) {\n const timeRange = sceneGraph.getTimeRange(this);\n const { dataLayerFilter } = this.state;\n\n let annotations: DataFrame[] = [];\n let alertStates: DataFrame[] = [];\n let alertState: AlertStateInfo | undefined;\n\n for (const result of results) {\n for (let frame of result.data.series) {\n if (frame.meta?.dataTopic === DataTopic.Annotations) {\n annotations = annotations.concat(frame);\n }\n if (frame.meta?.dataTopic === DataTopic.AlertStates) {\n alertStates = alertStates.concat(frame);\n }\n }\n }\n\n if (dataLayerFilter?.panelId) {\n if (annotations.length > 0) {\n annotations = filterAnnotations(annotations, dataLayerFilter);\n }\n\n if (alertStates.length > 0) {\n for (const frame of alertStates) {\n const frameView = new DataFrameView<AlertStateInfo>(frame);\n\n for (const row of frameView) {\n if (row.panelId === dataLayerFilter.panelId) {\n alertState = row;\n break;\n }\n }\n }\n }\n }\n\n // Skip unnessary state updates\n if (\n allFramesEmpty(annotations) &&\n allFramesEmpty(this._layerAnnotations) &&\n isEqual(alertState, this.state.data?.alertState)\n ) {\n return;\n }\n\n this._layerAnnotations = annotations;\n\n const baseStateUpdate = this.state.data ? this.state.data : { ...emptyPanelData, timeRange: timeRange.state.value };\n\n this.setState({\n data: {\n ...baseStateUpdate,\n annotations: [...(this._resultAnnotations ?? []), ...annotations],\n alertState: alertState ?? this.state.data?.alertState,\n },\n });\n }\n\n /**\n * This tries to start a new query whenever a variable completes or is changed.\n *\n * We care about variable update completions even when the variable has not changed and even when it is not a direct dependency.\n * Example: Variables A and B (B depends on A). A update depends on time range. So when time change query runner will\n * find that variable A is loading which is a dependency on of variable B so will set _isWaitingForVariables to true and\n * not issue any query.\n *\n * When A completes it's loading (with no value change, so B never updates) it will cause a call of this function letting\n * the query runner know that A has completed, and in case _isWaitingForVariables we try to run the query. The query will\n * only run if all variables are in a non loading state so in other scenarios where a query depends on many variables this will\n * be called many times until all dependencies are in a non loading state. *\n */\n private onVariableUpdatesCompleted() {\n if(this.isQueryModeAuto()){\n this.runQueries();\n }\n }\n\n /**\n * Check if value changed is a adhoc filter o group by variable that did not exist when we issued the last query\n */\n private onAnyVariableChanged(variable: SceneVariable) {\n // If this variable has already been detected this variable as a dependency onVariableUpdatesCompleted above will handle value changes\n if (this._adhocFiltersVar === variable || this._groupByVar === variable || !this.isQueryModeAuto()) {\n return;\n }\n\n if (variable instanceof AdHocFiltersVariable && this._isRelevantAutoVariable(variable)) {\n this.runQueries();\n }\n\n if (variable instanceof GroupByVariable && this._isRelevantAutoVariable(variable)) {\n this.runQueries();\n }\n }\n\n private _isRelevantAutoVariable(variable: AdHocFiltersVariable | GroupByVariable) {\n const datasource = this.state.datasource ?? findFirstDatasource(this.state.queries);\n return variable.state.applyMode === 'auto' && datasource?.uid === variable.state.datasource?.uid;\n }\n\n private shouldRunQueriesOnActivate() {\n if (this._variableValueRecorder.hasDependenciesChanged(this)) {\n writeSceneLog(\n 'SceneQueryRunner',\n 'Variable dependency changed while inactive, shouldRunQueriesOnActivate returns true'\n );\n return true;\n }\n\n // If we don't have any data we should run queries\n if (!this.state.data) {\n return true;\n }\n\n // If time range is stale / different we should run queries\n if (this._isDataTimeRangeStale(this.state.data)) {\n return true;\n }\n\n return false;\n }\n\n private _isDataTimeRangeStale(data: PanelData) {\n const timeRange = sceneGraph.getTimeRange(this);\n\n const stateTimeRange = timeRange.state.value;\n const dataTimeRange = data.timeRange;\n\n if (\n stateTimeRange.from.unix() === dataTimeRange.from.unix() &&\n stateTimeRange.to.unix() === dataTimeRange.to.unix()\n ) {\n return false;\n }\n writeSceneLog('SceneQueryRunner', 'Data time range is stale');\n return true;\n }\n\n private _onDeactivate(): void {\n if (this._querySub) {\n this._querySub.unsubscribe();\n this._querySub = undefined;\n }\n\n if (this._dataLayersSub) {\n this._dataLayersSub.unsubscribe();\n this._dataLayersSub = undefined;\n }\n\n this._timeSub?.unsubscribe();\n this._timeSub = undefined;\n this._timeSubRange = undefined;\n this._adhocFiltersVar = undefined;\n this._groupByVar = undefined;\n this._variableValueRecorder.recordCurrentDependencyValuesForSceneObject(this);\n }\n\n public setContainerWidth(width: number) {\n // If we don't have a width we should run queries\n if (!this._containerWidth && width > 0) {\n this._containerWidth = width;\n\n // If we don't have maxDataPoints specifically set and maxDataPointsFromWidth is true\n if (this.state.maxDataPointsFromWidth && !this.state.maxDataPoints) {\n // As this is called from render path we need to wait for next tick before running queries\n setTimeout(() => {\n if (this.isActive && !this.state._hasFetchedData) {\n this.runQueries();\n }\n }, 0);\n }\n } else {\n // if the updated container width is bigger than 0 let's remember the width until next query issue\n if (width > 0) {\n this._containerWidth = width;\n }\n }\n }\n\n public isDataReadyToDisplay() {\n return Boolean(this.state._hasFetchedData);\n }\n\n private subscribeToTimeRangeChanges(timeRange: SceneTimeRangeLike) {\n if (this._timeSubRange === timeRange) {\n // Nothing to do, already subscribed\n return;\n }\n\n if (this._timeSub) {\n this._timeSub.unsubscribe();\n }\n\n this._timeSubRange = timeRange;\n this._timeSub = timeRange.subscribeToState(() => {\n this.runWithTimeRange(timeRange);\n });\n }\n\n public runQueries() {\n const timeRange = sceneGraph.getTimeRange(this);\n if(this.isQueryModeAuto()){\n this.subscribeToTimeRangeChanges(timeRange);\n }\n\n this.runWithTimeRange(timeRange);\n }\n\n private getMaxDataPoints() {\n if (this.state.maxDataPoints) {\n return this.state.maxDataPoints;\n }\n\n return this.state.maxDataPointsFromWidth ? this._containerWidth ?? 500 : 500;\n }\n\n public cancelQuery() {\n this._querySub?.unsubscribe();\n\n if (this._dataLayersSub) {\n this._dataLayersSub.unsubscribe();\n this._dataLayersSub = undefined;\n }\n\n this.setState({\n data: { ...this.state.data!, state: LoadingState.Done },\n });\n }\n\n private async runWithTimeRange(timeRange: SceneTimeRangeLike) {\n // If no maxDataPoints specified we might need to wait for container width to be set from the outside\n if (!this.state.maxDataPoints && this.state.maxDataPointsFromWidth && !this._containerWidth) {\n return;\n }\n\n // If data layers subscription doesn't exist, create one\n if (!this._dataLayersSub) {\n this._handleDataLayers();\n }\n\n // Cancel any running queries\n this._querySub?.unsubscribe();\n\n // Skip executing queries if variable dependency is in loading state\n if (this._variableDependency.hasDependencyInLoadingState()) {\n writeSceneLog('SceneQueryRunner', 'Variable dependency is in loading state, skipping query execution');\n this.setState({ data: { ...(this.state.data ?? emptyPanelData), state: LoadingState.Loading } });\n return;\n }\n\n const { queries } = this.state;\n\n // Simple path when no queries exist\n if (!queries?.length) {\n this._setNoDataState();\n return;\n }\n\n try {\n const datasource = this.state.datasource ?? findFirstDatasource(queries);\n const ds = await getDataSource(datasource, this._scopedVars);\n\n this.findAndSubscribeToAdHocFilters(datasource?.uid);\n\n const runRequest = getRunRequest();\n const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds);\n\n writeSceneLog('SceneQueryRunner', 'Starting runRequest', this.state.key);\n\n let stream = runRequest(ds, primary);\n\n if (secondaries.length > 0) {\n // Submit all secondary requests in parallel.\n const secondaryStreams = secondaries.map((r) => runRequest(ds, r));\n // Create the rxjs operator which will combine the primary and secondary responses\n // by calling the correct processor functions provided by the\n // extra request providers.\n const op = extraQueryProcessingOperator(processors);\n // Combine the primary and secondary streams into a single stream, and apply the operator.\n stream = forkJoin([stream, ...secondaryStreams]).pipe(op);\n }\n\n stream = stream.pipe(\n registerQueryWithController({\n type: 'data',\n request: primary,\n origin: this,\n cancel: () => this.cancelQuery(),\n })\n );\n\n this._querySub = stream.subscribe(this.onDataReceived);\n } catch (err) {\n console.error('PanelQueryRunner Error', err);\n\n this.onDataReceived({\n ...emptyPanelData,\n ...this.state.data,\n state: LoadingState.Error,\n errors: [toDataQueryError(err)],\n });\n }\n }\n\n public clone(withState?: Partial<QueryRunnerState>) {\n const clone = super.clone(withState);\n\n if (this._resultAnnotations) {\n clone['_resultAnnotations'] = this._resultAnnotations.map((frame) => ({ ...frame }));\n }\n\n if (this._layerAnnotations) {\n clone['_layerAnnotations'] = this._layerAnnotations.map((frame) => ({ ...frame }));\n }\n\n clone['_variableValueRecorder'] = this._variableValueRecorder.cloneAndRecordCurrentValuesForSceneObject(this);\n clone['_containerWidth'] = this._containerWidth;\n clone['_results'].next({ origin: this, data: this.state.data ?? emptyPanelData });\n\n return clone;\n }\n\n private prepareRequests(timeRange: SceneTimeRangeLike, ds: DataSourceApi): PreparedRequests {\n const { minInterval, queries } = this.state;\n\n let request: DataQueryRequest<DataQueryExtended> = {\n app: 'scenes',\n requestId: getNextRequestId(),\n timezone: timeRange.getTimeZone(),\n range: timeRange.state.value,\n interval: '1s',\n intervalMs: 1000,\n targets: cloneDeep(queries),\n maxDataPoints: this.getMaxDataPoints(),\n scopedVars: this._scopedVars,\n startTime: Date.now(),\n liveStreaming: this.state.liveStreaming,\n rangeRaw: {\n from: timeRange.state.from,\n to: timeRange.state.to,\n },\n cacheTimeout: this.state.cacheTimeout,\n queryCachingTTL: this.state.queryCachingTTL,\n // This asks the scene root to provide context properties like app, panel and dashboardUID\n ...getEnrichedDataRequest(this),\n };\n\n if (this._adhocFiltersVar) {\n // only pass filters that have both key and value\n // @ts-ignore (Temporary ignore until we update @grafana/data)\n request.filters = this._adhocFiltersVar.state.filters.filter(isFilterComplete);\n }\n\n if (this._groupByVar) {\n // @ts-ignore (Temporary ignore until we update @grafana/data)\n request.groupByKeys = this._groupByVar.state.value;\n }\n\n request.targets = request.targets.map((query) => {\n if (\n !query.datasource ||\n (query.datasource.uid !== ds.uid &&\n !ds.meta?.mixed &&\n isExpressionReference /* TODO: Remove this check when isExpressionReference is properly exported from grafan runtime */ &&\n !isExpressionReference(query.datasource))\n ) {\n query.datasource = ds.getRef();\n }\n return query;\n });\n\n const lowerIntervalLimit = minInterval ? interpolate(this, minInterval) : ds.interval;\n const norm = rangeUtil.calculateInterval(timeRange.state.value, request.maxDataPoints!, lowerIntervalLimit);\n\n // make shallow copy of scoped vars,\n // and add built in variables interval and interval_ms\n request.scopedVars = Object.assign({}, request.scopedVars, {\n __interval: { text: norm.interval, value: norm.interval },\n __interval_ms: { text: norm.intervalMs.toString(), value: norm.intervalMs },\n });\n\n request.interval = norm.interval;\n request.intervalMs = norm.intervalMs;\n\n // If there are any extra request providers, we need to add a new request for each\n // and map the request's ID to the processor function given by the provider, to ensure that\n // the processor is called with the correct response data.\n const primaryTimeRange = timeRange.state.value;\n let secondaryRequests: DataQueryRequest[] = [];\n let secondaryProcessors = new Map();\n for (const provider of this.getClosestExtraQueryProviders() ?? []) {\n for (const { req, processor } of provider.getExtraQueries(request)) {\n const requestId = getNextRequestId();\n secondaryRequests.push({ ...req, requestId });\n secondaryProcessors.set(requestId, processor ?? passthroughProcessor);\n }\n }\n request.range = primaryTimeRange;\n return { primary: request, secondaries: secondaryRequests, processors: secondaryProcessors };\n }\n\n private onDataReceived = (data: PanelData) => {\n // Will combine annotations from SQR queries (frames with meta.dataTopic === DataTopic.Annotations)\n const preProcessedData = preProcessPanelData(data, this.state.data);\n\n // Save query annotations\n this._resultAnnotations = data.annotations;\n\n // Will combine annotations & alert state from data layer providers\n const dataWithLayersApplied = this._combineDataLayers(preProcessedData);\n\n let hasFetchedData = this.state._hasFetchedData;\n\n if (!hasFetchedData && preProcessedData.state !== LoadingState.Loading) {\n hasFetchedData = true;\n }\n\n this.setState({ data: dataWithLayersApplied, _hasFetchedData: hasFetchedData });\n this._results.next({ origin: this, data: dataWithLayersApplied });\n };\n\n private _combineDataLayers(data: PanelData) {\n if (this._layerAnnotations && this._layerAnnotations.length > 0) {\n data.annotations = (data.annotations || []).concat(this._layerAnnotations);\n }\n\n if (this.state.data && this.state.data.alertState) {\n data.alertState = this.state.data.alertState;\n }\n\n return data;\n }\n\n private _setNoDataState() {\n if (this.state.data !== emptyPanelData) {\n this.setState({ data: emptyPanelData });\n }\n }\n\n /**\n * Walk up the scene graph and find any ExtraQueryProviders.\n *\n * This will return an array of the closest provider of each type.\n */\n private getClosestExtraQueryProviders(): Array<ExtraQueryProvider<any>> {\n // Maintain a map from provider constructor to provider object. The constructor\n // is used as a unique key for each class, to ensure we have no more than one\n // type of each type of provider.\n const found = new Map();\n if (!this.parent) {\n return [];\n }\n getClosest(this.parent, (s) => {\n if (isExtraQueryProvider(s) && !found.has(s.constructor)) {\n found.set(s.constructor, s);\n }\n s.forEachChild((child) => {\n if (isExtraQueryProvider(child) && !found.has(child.constructor)) {\n found.set(child.constructor, child);\n }\n });\n // Always return null so that the search continues to the top of\n // the scene graph.\n return null;\n });\n return Array.from(found.values());\n }\n\n /**\n * Walk up scene graph and find the closest filterset with matching data source\n */\n private findAndSubscribeToAdHocFilters(uid: string | undefined) {\n const filtersVar = findActiveAdHocFilterVariableByUid(uid);\n\n if (this._adhocFiltersVar !== filtersVar) {\n this._adhocFiltersVar = filtersVar;\n this._updateExplicitVariableDependencies();\n }\n\n const groupByVar = findActiveGroupByVariablesByUid(uid);\n if (this._groupByVar !== groupByVar) {\n this._groupByVar = groupByVar;\n this._updateExplicitVariableDependencies();\n }\n }\n\n private _updateExplicitVariableDependencies() {\n const explicitDependencies: string[] = [];\n\n if (this._adhocFiltersVar) {\n explicitDependencies.push(this._adhocFiltersVar.state.name);\n }\n\n if (this._groupByVar) {\n explicitDependencies.push(this._groupByVar.state.name);\n }\n\n this._variableDependency.setVariableNames(explicitDependencies);\n }\n\n private isQueryModeAuto(): boolean {\n return (this.state.runQueriesMode ?? 'auto') === 'auto'\n }\n}\n\nexport function findFirstDatasource(targets: DataQuery[]): DataSourceRef | undefined {\n return targets.find((t) => t.datasource !== null)?.datasource ?? undefined;\n}\n\nfunction allFramesEmpty(frames?: DataFrame[]) {\n if (!frames) {\n return true;\n }\n\n for (let i = 0; i < frames.length; i++) {\n if (frames[i].length > 0) {\n return false;\n }\n }\n\n return true;\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAI,OAAU,GAAA,GAAA,CAAA;AAEP,SAAS,gBAAmB,GAAA;AACjC,EAAA,OAAO,KAAQ,GAAA,OAAA,EAAA,CAAA;AACjB,CAAA;AAoDO,MAAM,yBAAyB,eAA+D,CAAA;AAAA,EA0B5F,YAAY,YAAgC,EAAA;AACjD,IAAA,KAAA,CAAM,YAAY,CAAA,CAAA;AAxBpB,IAAQ,IAAA,CAAA,iBAAA,GAAoB,IAAI,gBAAiB,EAAA,CAAA;AAIjD,IAAQ,IAAA,CAAA,sBAAA,GAAyB,IAAI,qBAAsB,EAAA,CAAA;AAC3D,IAAQ,IAAA,CAAA,QAAA,GAAW,IAAI,aAAA,CAAuC,CAAC,CAAA,CAAA;AAC/D,IAAA,IAAA,CAAQ,WAAc,GAAA,EAAE,aAAe,EAAA,iCAAA,CAAkC,IAAI,CAAE,EAAA,CAAA;AAW/E,IAAU,IAAA,CAAA,mBAAA,GAAkE,IAAI,wBAAA,CAAyB,IAAM,EAAA;AAAA,MAC7G,UAAA,EAAY,CAAC,SAAA,EAAW,YAAY,CAAA;AAAA,MACpC,yBAA2B,EAAA,IAAA,CAAK,0BAA2B,CAAA,IAAA,CAAK,IAAI,CAAA;AAAA,MACpE,oBAAsB,EAAA,IAAA,C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
@@ -12,7 +12,7 @@ import { SceneDataLayerBase } from '../SceneDataLayerBase.js';
|
|
12
12
|
import { DataLayerControlSwitch } from '../SceneDataLayerControls.js';
|
13
13
|
import { executeAnnotationQuery } from './standardAnnotationQuery.js';
|
14
14
|
import { postProcessQueryResult, dedupAnnotations } from './utils.js';
|
15
|
-
import {
|
15
|
+
import { wrapInSafeSerializableSceneObject } from '../../../utils/wrapInSafeSerializableSceneObject.js';
|
16
16
|
|
17
17
|
var __defProp = Object.defineProperty;
|
18
18
|
var __defProps = Object.defineProperties;
|
@@ -42,7 +42,7 @@ class AnnotationsDataLayer extends SceneDataLayerBase {
|
|
42
42
|
["query"]
|
43
43
|
);
|
44
44
|
this._scopedVars = {
|
45
|
-
__sceneObject:
|
45
|
+
__sceneObject: wrapInSafeSerializableSceneObject(this)
|
46
46
|
};
|
47
47
|
}
|
48
48
|
onEnable() {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AnnotationsDataLayer.js","sources":["../../../../../src/querying/layers/annotations/AnnotationsDataLayer.tsx"],"sourcesContent":["import { arrayToDataFrame, DataTopic, AnnotationQuery, ScopedVars, PanelData } from '@grafana/data';\nimport { LoadingState } from '@grafana/schema';\nimport React from 'react';\nimport { map, Unsubscribable } from 'rxjs';\nimport { emptyPanelData } from '../../../core/SceneDataNode';\nimport { sceneGraph } from '../../../core/sceneGraph';\nimport {\n SceneComponentProps,\n SceneDataLayerProvider,\n SceneDataLayerProviderState,\n SceneTimeRangeLike,\n} from '../../../core/types';\nimport { getDataSource } from '../../../utils/getDataSource';\nimport { getMessageFromError } from '../../../utils/getMessageFromError';\nimport { writeSceneLog } from '../../../utils/writeSceneLog';\nimport { registerQueryWithController } from '../../registerQueryWithController';\nimport { SceneDataLayerBase } from '../SceneDataLayerBase';\nimport { DataLayerControlSwitch } from '../SceneDataLayerControls';\nimport { AnnotationQueryResults, executeAnnotationQuery } from './standardAnnotationQuery';\nimport { dedupAnnotations, postProcessQueryResult } from './utils';\nimport {
|
1
|
+
{"version":3,"file":"AnnotationsDataLayer.js","sources":["../../../../../src/querying/layers/annotations/AnnotationsDataLayer.tsx"],"sourcesContent":["import { arrayToDataFrame, DataTopic, AnnotationQuery, ScopedVars, PanelData } from '@grafana/data';\nimport { LoadingState } from '@grafana/schema';\nimport React from 'react';\nimport { map, Unsubscribable } from 'rxjs';\nimport { emptyPanelData } from '../../../core/SceneDataNode';\nimport { sceneGraph } from '../../../core/sceneGraph';\nimport {\n SceneComponentProps,\n SceneDataLayerProvider,\n SceneDataLayerProviderState,\n SceneTimeRangeLike,\n} from '../../../core/types';\nimport { getDataSource } from '../../../utils/getDataSource';\nimport { getMessageFromError } from '../../../utils/getMessageFromError';\nimport { writeSceneLog } from '../../../utils/writeSceneLog';\nimport { registerQueryWithController } from '../../registerQueryWithController';\nimport { SceneDataLayerBase } from '../SceneDataLayerBase';\nimport { DataLayerControlSwitch } from '../SceneDataLayerControls';\nimport { AnnotationQueryResults, executeAnnotationQuery } from './standardAnnotationQuery';\nimport { dedupAnnotations, postProcessQueryResult } from './utils';\nimport { wrapInSafeSerializableSceneObject } from '../../../utils/wrapInSafeSerializableSceneObject';\n\ninterface AnnotationsDataLayerState extends SceneDataLayerProviderState {\n query: AnnotationQuery;\n}\n\nexport class AnnotationsDataLayer\n extends SceneDataLayerBase<AnnotationsDataLayerState>\n implements SceneDataLayerProvider\n{\n static Component = AnnotationsDataLayerRenderer;\n\n private _scopedVars: ScopedVars = {\n __sceneObject: wrapInSafeSerializableSceneObject(this),\n };\n private _timeRangeSub: Unsubscribable | undefined;\n\n public constructor(initialState: AnnotationsDataLayerState) {\n super(\n {\n isEnabled: true,\n ...initialState,\n },\n ['query']\n );\n }\n\n public onEnable(): void {\n const timeRange = sceneGraph.getTimeRange(this);\n\n this._timeRangeSub = timeRange.subscribeToState(() => {\n this.runWithTimeRange(timeRange);\n });\n }\n\n public onDisable(): void {\n this._timeRangeSub?.unsubscribe();\n }\n\n public runLayer() {\n writeSceneLog('AnnotationsDataLayer', 'run layer');\n const timeRange = sceneGraph.getTimeRange(this);\n this.runWithTimeRange(timeRange);\n }\n\n private async runWithTimeRange(timeRange: SceneTimeRangeLike) {\n const { query } = this.state;\n\n if (this.querySub) {\n this.querySub.unsubscribe();\n }\n\n if (this._variableDependency.hasDependencyInLoadingState()) {\n writeSceneLog('AnnotationsDataLayer', 'Variable dependency is in loading state, skipping query execution');\n return;\n }\n\n try {\n const ds = await this.resolveDataSource(query);\n\n let stream = executeAnnotationQuery(ds, timeRange, query, this).pipe(\n registerQueryWithController({\n type: 'annotations',\n origin: this,\n cancel: () => this.cancelQuery(),\n }),\n map((events) => {\n const stateUpdate = this.processEvents(query, events);\n return stateUpdate;\n })\n );\n\n this.querySub = stream.subscribe((stateUpdate) => {\n this.publishResults(stateUpdate);\n });\n } catch (e) {\n this.publishResults({\n ...emptyPanelData,\n state: LoadingState.Error,\n errors: [\n {\n message: getMessageFromError(e),\n },\n ],\n });\n console.error('AnnotationsDataLayer error', e);\n }\n }\n\n protected async resolveDataSource(query: AnnotationQuery) {\n return await getDataSource(query.datasource || undefined, this._scopedVars);\n }\n\n protected processEvents(query: AnnotationQuery, events: AnnotationQueryResults): PanelData {\n let processedEvents = postProcessQueryResult(query, events.events || []);\n processedEvents = dedupAnnotations(processedEvents);\n\n const stateUpdate = { ...emptyPanelData, state: events.state };\n const df = arrayToDataFrame(processedEvents);\n\n df.meta = {\n ...df.meta,\n dataTopic: DataTopic.Annotations,\n };\n\n stateUpdate.series = [df];\n\n return stateUpdate;\n }\n}\n\nfunction AnnotationsDataLayerRenderer({ model }: SceneComponentProps<AnnotationsDataLayer>) {\n const { isHidden } = model.useState();\n\n if (isHidden) {\n return null;\n }\n\n return <DataLayerControlSwitch layer={model} />;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BO,MAAM,6BACH,kBAEV,CAAA;AAAA,EAQS,YAAY,YAAyC,EAAA;AAC1D,IAAA,KAAA;AAAA,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AA;AACzF,IAAA,IAAI,kBAAkB,sBAAuB,CAAA,KAAA,EAAO,MAAO,CAAA,MAAA,IAAU,EAAE,CAAA,CAAA;AACvE,IAAA,eAAA,GAAkB,iBAAiB,eAAe,CAAA,CAAA;AAElD,IAAA,MAAM,cAAc,aAAK,CAAA,cAAA,CAAA,EAAA,EAAA,cAAA,CAAA,EAAL,EAAqB,KAAA,EAAO,OAAO,KAAM,EAAA,CAAA,CAAA;AAC7D,IAAM,MAAA,EAAA,GAAK,iBAAiB,eAAe,CAAA,CAAA;AAE3C,IAAG,EAAA,CAAA,IAAA,GAAO,aACL,CAAA,cAAA,CAAA,EAAA,EAAA,EAAA,CAAG,IADE,CAAA,EAAA;AAAA,MAER,WAAW,SAAU,CAAA,WAAA;AAAA,KACvB,CAAA,CAAA;AAEA,IAAY,WAAA,CAAA,MAAA,GAAS,CAAC,EAAE,CAAA,CAAA;AAExB,IAAO,OAAA,WAAA,CAAA;AAAA,GACT;AACF,CAAA;AAvGa,oBAAA,CAIJ,SAAY,GAAA,4BAAA,CAAA;AAqGrB,SAAS,4BAAA,CAA6B,EAAE,KAAA,EAAoD,EAAA;AAC1F,EAAA,MAAM,EAAE,QAAA,EAAa,GAAA,KAAA,CAAM,QAAS,EAAA,CAAA;AAEpC,EAAA,IAAI,QAAU,EAAA;AACZ,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,sBAAA,EAAA;AAAA,IAAuB,KAAO,EAAA,KAAA;AAAA,GAAO,CAAA,CAAA;AAC/C;;;;"}
|
@@ -5,7 +5,7 @@ import { getRunRequest } from '@grafana/runtime';
|
|
5
5
|
import { shouldUseLegacyRunner, standardAnnotationSupport } from './standardAnnotationsSupport.js';
|
6
6
|
import { LoadingState } from '@grafana/schema';
|
7
7
|
import { getEnrichedDataRequest } from '../../getEnrichedDataRequest.js';
|
8
|
-
import {
|
8
|
+
import { wrapInSafeSerializableSceneObject } from '../../../utils/wrapInSafeSerializableSceneObject.js';
|
9
9
|
|
10
10
|
var __defProp = Object.defineProperty;
|
11
11
|
var __defProps = Object.defineProperties;
|
@@ -70,7 +70,7 @@ function executeAnnotationQuery(datasource, timeRange, query, layer) {
|
|
70
70
|
__interval: { text: interval.interval, value: interval.interval },
|
71
71
|
__interval_ms: { text: interval.intervalMs.toString(), value: interval.intervalMs },
|
72
72
|
__annotation: { text: annotation.name, value: annotation },
|
73
|
-
__sceneObject:
|
73
|
+
__sceneObject: wrapInSafeSerializableSceneObject(layer)
|
74
74
|
};
|
75
75
|
const queryRequest = __spreadValues(__spreadProps(__spreadValues({
|
76
76
|
startTime: Date.now(),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"standardAnnotationQuery.js","sources":["../../../../../src/querying/layers/annotations/standardAnnotationQuery.ts"],"sourcesContent":["import { from, Observable, of } from 'rxjs';\nimport { map, mergeMap } from 'rxjs/operators';\n\nimport {\n AnnotationEvent,\n AnnotationQuery,\n CoreApp,\n DataQueryRequest,\n DataSourceApi,\n DataTopic,\n PanelModel,\n rangeUtil,\n ScopedVars,\n} from '@grafana/data';\n\nimport { getRunRequest } from '@grafana/runtime';\nimport { shouldUseLegacyRunner, standardAnnotationSupport } from './standardAnnotationsSupport';\nimport { Dashboard, LoadingState } from '@grafana/schema';\nimport { SceneObject, SceneTimeRangeLike } from '../../../core/types';\nimport { getEnrichedDataRequest } from '../../getEnrichedDataRequest';\nimport {
|
1
|
+
{"version":3,"file":"standardAnnotationQuery.js","sources":["../../../../../src/querying/layers/annotations/standardAnnotationQuery.ts"],"sourcesContent":["import { from, Observable, of } from 'rxjs';\nimport { map, mergeMap } from 'rxjs/operators';\n\nimport {\n AnnotationEvent,\n AnnotationQuery,\n CoreApp,\n DataQueryRequest,\n DataSourceApi,\n DataTopic,\n PanelModel,\n rangeUtil,\n ScopedVars,\n} from '@grafana/data';\n\nimport { getRunRequest } from '@grafana/runtime';\nimport { shouldUseLegacyRunner, standardAnnotationSupport } from './standardAnnotationsSupport';\nimport { Dashboard, LoadingState } from '@grafana/schema';\nimport { SceneObject, SceneTimeRangeLike } from '../../../core/types';\nimport { getEnrichedDataRequest } from '../../getEnrichedDataRequest';\nimport { wrapInSafeSerializableSceneObject } from '../../../utils/wrapInSafeSerializableSceneObject';\n\nlet counter = 100;\nfunction getNextRequestId() {\n return 'AQ' + counter++;\n}\n\nexport interface AnnotationQueryOptions {\n dashboard: Dashboard;\n panel: PanelModel;\n}\n\nexport interface AnnotationQueryResults {\n state: LoadingState;\n events: AnnotationEvent[];\n}\n\nexport function executeAnnotationQuery(\n datasource: DataSourceApi,\n timeRange: SceneTimeRangeLike,\n query: AnnotationQuery,\n layer: SceneObject\n): Observable<AnnotationQueryResults> {\n // Check if we should use the old annotationQuery method\n if (datasource.annotationQuery && shouldUseLegacyRunner(datasource)) {\n console.warn('Using deprecated annotationQuery method, please upgrade your datasource');\n return from(\n datasource.annotationQuery({\n range: timeRange.state.value,\n rangeRaw: timeRange.state.value.raw,\n annotation: query,\n dashboard: {},\n })\n ).pipe(\n map((events) => ({\n state: LoadingState.Done,\n events,\n }))\n );\n }\n\n // Standard API for annotations support. Spread in datasource annotations support overrides\n const processor = {\n ...standardAnnotationSupport,\n ...datasource.annotations,\n };\n\n const annotationWithDefaults = {\n // Default query provided by a data source\n ...processor.getDefaultQuery?.(),\n ...query,\n };\n\n // Data source query migrations\n const annotation = processor.prepareAnnotation!(annotationWithDefaults);\n if (!annotation) {\n return of({\n state: LoadingState.Done,\n events: [],\n });\n }\n\n const processedQuery = processor.prepareQuery!(annotation);\n if (!processedQuery) {\n return of({\n state: LoadingState.Done,\n events: [],\n });\n }\n\n // No more points than pixels\n const maxDataPoints = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;\n\n // Add interval to annotation queries\n const interval = rangeUtil.calculateInterval(timeRange.state.value, maxDataPoints, datasource.interval);\n\n const scopedVars: ScopedVars = {\n __interval: { text: interval.interval, value: interval.interval },\n __interval_ms: { text: interval.intervalMs.toString(), value: interval.intervalMs },\n __annotation: { text: annotation.name, value: annotation },\n __sceneObject: wrapInSafeSerializableSceneObject(layer),\n };\n\n const queryRequest: DataQueryRequest = {\n startTime: Date.now(),\n requestId: getNextRequestId(),\n range: timeRange.state.value,\n maxDataPoints,\n scopedVars,\n ...interval,\n app: CoreApp.Dashboard,\n timezone: timeRange.getTimeZone(),\n targets: [\n {\n ...processedQuery,\n refId: 'Anno',\n },\n ],\n ...getEnrichedDataRequest(layer),\n };\n\n const runRequest = getRunRequest();\n\n return runRequest(datasource, queryRequest).pipe(\n mergeMap((panelData) => {\n // Some annotations set the topic already\n const data = panelData?.series.length ? panelData.series : panelData.annotations;\n\n if (!data?.length) {\n return of({\n state: panelData.state,\n events: [],\n });\n }\n\n // Add data topic to each frame\n data.forEach((frame) => {\n // If data topic has not been provided by the data source, make sure it's set correctly\n if (!frame.meta?.dataTopic) {\n frame.meta = { ...(frame.meta || {}), dataTopic: DataTopic.Annotations };\n }\n });\n\n return processor.processEvents!(annotation, data).pipe(\n map((events) => {\n return {\n state: panelData.state,\n events: events || [],\n };\n })\n );\n })\n );\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAI,OAAU,GAAA,GAAA,CAAA;AACd,SAAS,gBAAmB,GAAA;AAC1B,EAAA,OAAO,IAAO,GAAA,OAAA,EAAA,CAAA;AAChB,CAAA;AAYO,SAAS,sBACd,CAAA,UAAA,EACA,SACA,EAAA,KAAA,EACA,KACoC,EAAA;AA1CtC,EAAA,IAAA,EAAA,CAAA;AA4CE,EAAA,IAAI,UAAW,CAAA,eAAA,IAAmB,qBAAsB,CAAA,UAAU,CAAG,EAAA;AACnE,IAAA,OAAA,CAAQ,KAAK,yEAAyE,CAAA,CAAA;AACtF,IAAO,OAAA,IAAA;AAAA,MACL,WAAW,eAAgB,CAAA;AAAA,QACzB,KAAA,EAAO,UAAU,KAAM,CAAA,KAAA;AAAA,QACvB,QAAA,EAAU,SAA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U,CAAA,WAAA,CAAA;AAErE,MAAI,IAAA,EAAC,6BAAM,MAAQ,CAAA,EAAA;AACjB,QAAA,OAAO,EAAG,CAAA;AAAA,UACR,OAAO,SAAU,CAAA,KAAA;AAAA,UACjB,QAAQ,EAAC;AAAA,SACV,CAAA,CAAA;AAAA,OACH;AAGA,MAAK,IAAA,CAAA,OAAA,CAAQ,CAAC,KAAU,KAAA;AAxI9B,QAAAA,IAAAA,GAAAA,CAAAA;AA0IQ,QAAA,IAAI,GAACA,GAAA,GAAA,KAAA,CAAM,IAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAAA,IAAY,SAAW,CAAA,EAAA;AAC1B,UAAM,KAAA,CAAA,IAAA,GAAO,iCAAM,KAAM,CAAA,IAAA,IAAQ,EAApB,CAAA,EAAA,EAAyB,SAAW,EAAA,SAAA,CAAU,WAAY,EAAA,CAAA,CAAA;AAAA,SACzE;AAAA,OACD,CAAA,CAAA;AAED,MAAA,OAAO,SAAU,CAAA,aAAA,CAAe,UAAY,EAAA,IAAI,CAAE,CAAA,IAAA;AAAA,QAChD,GAAA,CAAI,CAAC,MAAW,KAAA;AACd,UAAO,OAAA;AAAA,YACL,OAAO,SAAU,CAAA,KAAA;AAAA,YACjB,MAAA,EAAQ,UAAU,EAAC;AAAA,WACrB,CAAA;AAAA,SACD,CAAA;AAAA,OACH,CAAA;AAAA,KACD,CAAA;AAAA,GACH,CAAA;AACF;;;;"}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { config } from '@grafana/runtime';
|
2
|
+
import { SafeSerializableSceneObject } from './SafeSerializableSceneObject.js';
|
3
|
+
|
4
|
+
function shouldWrapInSafeSerializableSceneObject(grafanaVersion) {
|
5
|
+
const pattern = /^(\d+)\.(\d+)\.(\d+)/;
|
6
|
+
const match = grafanaVersion.match(pattern);
|
7
|
+
if (!match) {
|
8
|
+
return false;
|
9
|
+
}
|
10
|
+
const major = parseInt(match[1], 10);
|
11
|
+
const minor = parseInt(match[2], 10);
|
12
|
+
const patch = parseInt(match[3], 10);
|
13
|
+
if (major === 11) {
|
14
|
+
return minor === 0 && patch >= 4 || minor === 1 && patch >= 2 || minor > 1;
|
15
|
+
}
|
16
|
+
if (major === 10) {
|
17
|
+
return minor === 4 && patch >= 8 || minor >= 5;
|
18
|
+
}
|
19
|
+
return major > 11;
|
20
|
+
}
|
21
|
+
function wrapInSafeSerializableSceneObject(sceneObject) {
|
22
|
+
const version = config.buildInfo.version;
|
23
|
+
if (shouldWrapInSafeSerializableSceneObject(version)) {
|
24
|
+
return new SafeSerializableSceneObject(sceneObject);
|
25
|
+
}
|
26
|
+
return { value: sceneObject, text: "__sceneObject" };
|
27
|
+
}
|
28
|
+
|
29
|
+
export { shouldWrapInSafeSerializableSceneObject, wrapInSafeSerializableSceneObject };
|
30
|
+
//# sourceMappingURL=wrapInSafeSerializableSceneObject.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"wrapInSafeSerializableSceneObject.js","sources":["../../../src/utils/wrapInSafeSerializableSceneObject.ts"],"sourcesContent":["import { config } from '@grafana/runtime';\nimport { SceneObject } from '../core/types';\nimport { SafeSerializableSceneObject } from './SafeSerializableSceneObject';\nimport { ScopedVar } from '@grafana/data';\n\nexport function shouldWrapInSafeSerializableSceneObject(grafanaVersion: string): boolean {\n const pattern = /^(\\d+)\\.(\\d+)\\.(\\d+)/;\n const match = grafanaVersion.match(pattern);\n\n if (!match) {\n return false;\n }\n\n const major = parseInt(match[1], 10);\n const minor = parseInt(match[2], 10);\n const patch = parseInt(match[3], 10);\n\n if (major === 11) {\n return (minor === 0 && patch >= 4) || (minor === 1 && patch >= 2) || minor > 1;\n }\n\n if (major === 10) {\n return (minor === 4 && patch >= 8) || minor >= 5;\n }\n\n return major > 11; // Assuming versions greater than 11 are also supported.\n}\n\nexport function wrapInSafeSerializableSceneObject(sceneObject: SceneObject): ScopedVar {\n const version = config.buildInfo.version;\n\n if (shouldWrapInSafeSerializableSceneObject(version)) {\n return new SafeSerializable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rD;;;;"}
|
@@ -11,8 +11,7 @@ import { getDataSourceSrv } from '@grafana/runtime';
|
|
11
11
|
import { AdHocFiltersVariableUrlSyncHandler } from './AdHocFiltersVariableUrlSyncHandler.js';
|
12
12
|
import { css } from '@emotion/css';
|
13
13
|
import { getEnrichedFiltersRequest } from '../getEnrichedFiltersRequest.js';
|
14
|
-
import {
|
15
|
-
import { SafeSerializableSceneObject } from '../../utils/SafeSerializableSceneObject.js';
|
14
|
+
import { wrapInSafeSerializableSceneObject } from '../../utils/wrapInSafeSerializableSceneObject.js';
|
16
15
|
|
17
16
|
var __defProp = Object.defineProperty;
|
18
17
|
var __defProps = Object.defineProperties;
|
@@ -44,7 +43,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
44
43
|
applyMode: "auto",
|
45
44
|
filterExpression: (_b = state.filterExpression) != null ? _b : renderExpression(state.expressionBuilder, state.filters)
|
46
45
|
}, state));
|
47
|
-
this._scopedVars = { __sceneObject:
|
46
|
+
this._scopedVars = { __sceneObject: wrapInSafeSerializableSceneObject(this) };
|
48
47
|
this._dataSourceSrv = getDataSourceSrv();
|
49
48
|
this._urlSync = new AdHocFiltersVariableUrlSyncHandler(this);
|
50
49
|
if (this.state.applyMode === "auto") {
|
@@ -99,12 +98,6 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
99
98
|
}
|
100
99
|
this.setState({ filters: this.state.filters.filter((f) => f !== filter) });
|
101
100
|
}
|
102
|
-
_removeLastFilter() {
|
103
|
-
const filterToRemove = this.state.filters.at(-1);
|
104
|
-
if (filterToRemove) {
|
105
|
-
this._removeFilter(filterToRemove);
|
106
|
-
}
|
107
|
-
}
|
108
101
|
async _getKeys(currentKey) {
|
109
102
|
var _a, _b, _c;
|
110
103
|
const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, currentKey));
|
@@ -186,11 +179,6 @@ function renderExpression(builder, filters) {
|
|
186
179
|
function AdHocFiltersVariableRenderer({ model }) {
|
187
180
|
const { filters, readOnly, addFilterButtonText } = model.useState();
|
188
181
|
const styles = useStyles2(getStyles);
|
189
|
-
if (model.state.layout === "combobox") {
|
190
|
-
return /* @__PURE__ */ React.createElement(AdHocFiltersComboboxRenderer, {
|
191
|
-
model
|
192
|
-
});
|
193
|
-
}
|
194
182
|
return /* @__PURE__ */ React.createElement("div", {
|
195
183
|
className: styles.wrapper
|
196
184
|
}, filters.map((filter, index) => /* @__PURE__ */ React.createElement(React.Fragment, {
|
@@ -211,6 +199,10 @@ const getStyles = (theme) => ({
|
|
211
199
|
alignItems: "flex-end",
|
212
200
|
columnGap: theme.spacing(2),
|
213
201
|
rowGap: theme.spacing(1)
|
202
|
+
}),
|
203
|
+
filterIcon: css({
|
204
|
+
color: theme.colors.text.secondary,
|
205
|
+
paddingRight: theme.spacing(0.5)
|
214
206
|
})
|
215
207
|
});
|
216
208
|
function toSelectableValue(input) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AdHocFiltersVariable.js","sources":["../../../../src/variables/adhoc/AdHocFiltersVariable.tsx"],"sourcesContent":["import React from 'react';\n// @ts-expect-error Remove when 11.1.x is released\nimport { AdHocVariableFilter, GetTagResponse, GrafanaTheme2, MetricFindValue, SelectableValue } from '@grafana/data';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneVariable, SceneVariableState, SceneVariableValueChangedEvent, VariableValue } from '../types';\nimport { ControlsLayout, SceneComponentProps } from '../../core/types';\nimport { DataSourceRef } from '@grafana/schema';\nimport { dataFromResponse, getQueriesForVariables, renderPrometheusLabelFilters, responseHasError } from '../utils';\nimport { patchGetAdhocFilters } from './patchGetAdhocFilters';\nimport { useStyles2 } from '@grafana/ui';\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { AdHocFilterBuilder } from './AdHocFilterBuilder';\nimport { AdHocFilterRenderer } from './AdHocFilterRenderer';\nimport { getDataSourceSrv } from '@grafana/runtime';\nimport { AdHocFiltersVariableUrlSyncHandler } from './AdHocFiltersVariableUrlSyncHandler';\nimport { css } from '@emotion/css';\nimport { getEnrichedFiltersRequest } from '../getEnrichedFiltersRequest';\nimport { AdHocFiltersComboboxRenderer } from './AdHocFiltersCombobox/AdHocFiltersComboboxRenderer';\nimport { SafeSerializableSceneObject } from '../../utils/SafeSerializableSceneObject';\n\nexport interface AdHocFilterWithLabels extends AdHocVariableFilter {\n keyLabel?: string;\n valueLabel?: string;\n}\n\nexport type AdHocControlsLayout = ControlsLayout | 'combobox';\n\nexport interface AdHocFiltersVariableState extends SceneVariableState {\n /** Optional text to display on the 'add filter' button */\n addFilterButtonText?: string;\n /** The visible filters */\n filters: AdHocFilterWithLabels[];\n /** Base filters to always apply when looking up keys*/\n baseFilters?: AdHocFilterWithLabels[];\n /** Datasource to use for getTagKeys and getTagValues and also controls which scene queries the filters should apply to */\n datasource: DataSourceRef | null;\n /** Controls if the filters can be changed */\n readOnly?: boolean;\n /**\n * @experimental\n * Controls the layout and design of the label.\n */\n layout?: AdHocControlsLayout;\n /**\n * Defaults to automatic which means filters will automatically be applied to all queries with the same data source as this AdHocFilterSet.\n * In manual mode you either have to use the filters programmatically or as a variable inside query expressions.\n */\n applyMode: 'auto' | 'manual';\n /**\n * Filter out the keys that do not match the regex.\n */\n tagKeyRegexFilter?: RegExp;\n /**\n * Extension hook for customizing the key lookup.\n * Return replace: true if you want to override the default lookup\n * Return replace: false if you want to combine the results with the default lookup\n */\n getTagKeysProvider?: getTagKeysProvider;\n /**\n * Extension hook for customizing the value lookup.\n * Return replace: true if you want to override the default lookup.\n * Return replace: false if you want to combine the results with the default lookup\n */\n getTagValuesProvider?: getTagValuesProvider;\n\n /**\n * Optionally provide an array of static keys that override getTagKeys\n */\n defaultKeys?: MetricFindValue[];\n\n /**\n * This is the expression that the filters resulted in. Defaults to\n * Prometheus / Loki compatible label filter expression\n */\n filterExpression?: string;\n\n /**\n * The default builder creates a Prometheus/Loki compatible filter expression,\n * this can be overridden to create a different expression based on the current filters.\n */\n expressionBuilder?: AdHocVariableExpressionBuilderFn;\n\n /**\n * When querying the datasource for label names and values to determine keys and values\n * for this ad hoc filter, consider the queries in the scene and use them as a filter.\n * This queries filter can be used to ensure that only ad hoc filter options that would\n * impact the current queries are presented to the user.\n */\n useQueriesAsFilterForOptions?: boolean;\n\n /**\n * @internal state of the new filter being added\n */\n _wip?: AdHocFilterWithLabels;\n}\n\nexport type AdHocVariableExpressionBuilderFn = (filters: AdHocFilterWithLabels[]) => string;\n\nexport type getTagKeysProvider = (\n variable: AdHocFiltersVariable,\n currentKey: string | null\n) => Promise<{ replace?: boolean; values: GetTagResponse | MetricFindValue[] }>;\n\nexport type getTagValuesProvider = (\n variable: AdHocFiltersVariable,\n filter: AdHocFilterWithLabels\n) => Promise<{ replace?: boolean; values: GetTagResponse | MetricFindValue[] }>;\n\nexport type AdHocFiltersVariableCreateHelperArgs = AdHocFiltersVariableState;\n\nexport class AdHocFiltersVariable\n extends SceneObjectBase<AdHocFiltersVariableState>\n implements SceneVariable<AdHocFiltersVariableState>\n{\n static Component = AdHocFiltersVariableRenderer;\n\n private _scopedVars = { __sceneObject: new SafeSerializableSceneObject(this) };\n private _dataSourceSrv = getDataSourceSrv();\n\n protected _urlSync = new AdHocFiltersVariableUrlSyncHandler(this);\n\n public constructor(state: Partial<AdHocFiltersVariableState>) {\n super({\n type: 'adhoc',\n name: state.name ?? 'Filters',\n filters: [],\n datasource: null,\n applyMode: 'auto',\n filterExpression: state.filterExpression ?? renderExpression(state.expressionBuilder, state.filters),\n ...state,\n });\n\n if (this.state.applyMode === 'auto') {\n patchGetAdhocFilters(this);\n }\n }\n\n public setState(update: Partial<AdHocFiltersVariableState>): void {\n let filterExpressionChanged = false;\n\n if (update.filters && update.filters !== this.state.filters && !update.filterExpression) {\n update.filterExpression = renderExpression(this.state.expressionBuilder, update.filters);\n filterExpressionChanged = update.filterExpression !== this.state.filterExpression;\n }\n\n super.setState(update);\n\n if (filterExpressionChanged) {\n this.publishEvent(new SceneVariableValueChangedEvent(this), true);\n }\n }\n\n public getValue(): VariableValue | undefined {\n return this.state.filterExpression;\n }\n\n public _updateFilter(\n filter: AdHocFilterWithLabels,\n prop: keyof AdHocFilterWithLabels,\n { value, label }: SelectableValue<string | undefined | null>\n ) {\n if (value == null) {\n return;\n }\n\n const { filters, _wip } = this.state;\n\n const propLabelKey = `${prop}Label`;\n\n if (filter === _wip) {\n // If we set value we are done with this \"work in progress\" filter and we can add it\n if (prop === 'value') {\n this.setState({ filters: [...filters, { ..._wip, [prop]: value, [propLabelKey]: label }], _wip: undefined });\n } else {\n this.setState({ _wip: { ...filter, [prop]: value, [propLabelKey]: label } });\n }\n return;\n }\n\n const updatedFilters = this.state.filters.map((f) => {\n if (f === filter) {\n const updatedFilter = { ...f, [prop]: value, [propLabelKey]: label };\n\n // clear value if key has changed\n if (prop === 'key' && filter[prop] !== value) {\n updatedFilter.value = '';\n updatedFilter.valueLabel = '';\n }\n return updatedFilter;\n }\n return f;\n });\n\n this.setState({ filters: updatedFilters });\n }\n\n public _removeFilter(filter: AdHocFilterWithLabels) {\n if (filter === this.state._wip) {\n this.setState({ _wip: undefined });\n return;\n }\n\n this.setState({ filters: this.state.filters.filter((f) => f !== filter) });\n }\n\n public _removeLastFilter() {\n const filterToRemove = this.state.filters.at(-1);\n\n if (filterToRemove) {\n this._removeFilter(filterToRemove);\n }\n }\n\n /**\n * Get possible keys given current filters. Do not call from plugins directly\n */\n public async _getKeys(currentKey: string | null): Promise<Array<SelectableValue<string>>> {\n const override = await this.state.getTagKeysProvider?.(this, currentKey);\n\n if (override && override.replace) {\n return dataFromResponse(override.values).map(toSelectableValue);\n }\n\n if (this.state.defaultKeys) {\n return this.state.defaultKeys.map(toSelectableValue);\n }\n\n const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);\n if (!ds || !ds.getTagKeys) {\n return [];\n }\n\n const otherFilters = this.state.filters.filter((f) => f.key !== currentKey).concat(this.state.baseFilters ?? []);\n const timeRange = sceneGraph.getTimeRange(this).state.value;\n const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : undefined;\n const response = await ds.getTagKeys({\n filters: otherFilters,\n queries,\n timeRange,\n ...getEnrichedFiltersRequest(this),\n });\n\n if (responseHasError(response)) {\n // @ts-expect-error Remove when 11.1.x is released\n this.setState({ error: response.error.message });\n }\n\n let keys = dataFromResponse(response);\n if (override) {\n keys = keys.concat(dataFromResponse(override.values));\n }\n\n const tagKeyRegexFilter = this.state.tagKeyRegexFilter;\n if (tagKeyRegexFilter) {\n // @ts-expect-error Remove when 11.1.x is released\n keys = keys.filter((f) => f.text.match(tagKeyRegexFilter));\n }\n\n return keys.map(toSelectableValue);\n }\n\n /**\n * Get possible key values for a specific key given current filters. Do not call from plugins directly\n */\n public async _getValuesFor(filter: AdHocFilterWithLabels): Promise<Array<SelectableValue<string>>> {\n const override = await this.state.getTagValuesProvider?.(this, filter);\n\n if (override && override.replace) {\n return dataFromResponse(override.values).map(toSelectableValue);\n }\n\n const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);\n\n if (!ds || !ds.getTagValues) {\n return [];\n }\n\n // Filter out the current filter key from the list of all filters\n const otherFilters = this.state.filters.filter((f) => f.key !== filter.key).concat(this.state.baseFilters ?? []);\n\n const timeRange = sceneGraph.getTimeRange(this).state.value;\n const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : undefined;\n\n const response = await ds.getTagValues({\n key: filter.key,\n filters: otherFilters,\n timeRange, // @ts-expect-error TODO: remove this once 11.1.x is released\n queries,\n ...getEnrichedFiltersRequest(this),\n });\n\n if (responseHasError(response)) {\n // @ts-expect-error Remove when 11.1.x is released\n this.setState({ error: response.error.message });\n }\n\n let values = dataFromResponse(response);\n if (override) {\n values = values.concat(dataFromResponse(override.values));\n }\n\n return values.map(toSelectableValue);\n }\n\n public _addWip() {\n this.setState({\n _wip: { key: '', keyLabel: '', value: '', valueLabel: '', operator: '=', condition: '' },\n });\n }\n\n public _getOperators() {\n return ['=', '!=', '<', '>', '=~', '!~'].map<SelectableValue<string>>((value) => ({\n label: value,\n value,\n }));\n }\n}\n\nfunction renderExpression(\n builder: AdHocVariableExpressionBuilderFn | undefined,\n filters: AdHocFilterWithLabels[] | undefined\n) {\n return (builder ?? renderPrometheusLabelFilters)(filters ?? []);\n}\n\nexport function AdHocFiltersVariableRenderer({ model }: SceneComponentProps<AdHocFiltersVariable>) {\n const { filters, readOnly, addFilterButtonText } = model.useState();\n const styles = useStyles2(getStyles);\n\n if (model.state.layout === 'combobox') {\n return <AdHocFiltersComboboxRenderer model={model} />;\n }\n\n return (\n <div className={styles.wrapper}>\n {filters.map((filter, index) => (\n <React.Fragment key={index}>\n <AdHocFilterRenderer filter={filter} model={model} />\n </React.Fragment>\n ))}\n\n {!readOnly && <AdHocFilterBuilder model={model} key=\"'builder\" addFilterButtonText={addFilterButtonText} />}\n </div>\n );\n}\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n wrapper: css({\n display: 'flex',\n flexWrap: 'wrap',\n alignItems: 'flex-end',\n columnGap: theme.spacing(2),\n rowGap: theme.spacing(1),\n }),\n});\n\nexport function toSelectableValue(input: MetricFindValue): SelectableValue<string> {\n const { text, value } = input;\n const result: SelectableValue<string> = {\n label: text,\n value: String(value ?? text),\n };\n\n if ('group' in input) {\n result.group = input.group;\n }\n\n return result;\n}\n\nexport function isFilterComplete(filter: AdHocFilterWithLabels): boolean {\n return filter.key !== '' && filter.operator !== '' && filter.value !== '';\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8GO,MAAM,6BACH,eAEV,CAAA;AAAA,EAQS,YAAY,KAA2C,EAAA;AAzHhE,IAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AA0HI,IAAM,KAAA,CAAA,cAAA,CAAA;AAAA,MACJ,IAAM,EAAA,OAAA;AAAA,MACN,IAAA,EAAA,CAAM,EAAM,GAAA,KAAA,CAAA,IAAA,KAAN,IAAc,GAAA,EAAA,GAAA,SAAA;AAAA,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,CAEA,EAAA,CAAC,4BAAa,KAAA,CAAA,aAAA,CAAA,kBAAA,EAAA;AAAA,IAAmB,KAAA;AAAA,IAAc,GAAI,EAAA,UAAA;AAAA,IAAW,mBAAA;AAAA,GAA0C,CAC3G,CAAA,CAAA;AAEJ,CAAA;AAEA,MAAM,SAAA,GAAY,CAAC,KAA0B,MAAA;AAAA,EAC3C,SAAS,GAAI,CAAA;AAAA,IACX,OAAS,EAAA,MAAA;AAAA,IACT,QAAU,EAAA,MAAA;AAAA,IACV,UAAY,EAAA,UAAA;AAAA,IACZ,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IAC1B,MAAA,EAAQ,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,GACxB,CAAA;AACH,CAAA,CAAA,CAAA;AAEO,SAAS,kBAAkB,KAAiD,EAAA;AACjF,EAAM,MAAA,EAAE,IAAM,EAAA,KAAA,EAAU,GAAA,KAAA,CAAA;AACxB,EAAA,MAAM,MAAkC,GAAA;AAAA,IACtC,KAAO,EAAA,IAAA;AAAA,IACP,KAAA,EAAO,MAAO,CAAA,KAAA,IAAA,IAAA,GAAA,KAAA,GAAS,IAAI,CAAA;AAAA,GAC7B,CAAA;AAEA,EAAA,IAAI,WAAW,KAAO,EAAA;AACpB,IAAA,MAAA,CAAO,QAAQ,KAAM,CAAA,KAAA,CAAA;AAAA,GACvB;AAEA,EAAO,OAAA,MAAA,CAAA;AACT,CAAA;AAEO,SAAS,iBAAiB,MAAwC,EAAA;AACvE,EAAA,OAAO,OAAO,GAAQ,KAAA,EAAA,IAAM,OAAO,QAAa,KAAA,EAAA,IAAM,OAAO,KAAU,KAAA,EAAA,CAAA;AACzE;;;;"}
|
1
|
+
{"version":3,"file":"AdHocFiltersVariable.js","sources":["../../../../src/variables/adhoc/AdHocFiltersVariable.tsx"],"sourcesContent":["import React from 'react';\n// @ts-expect-error Remove when 11.1.x is released\nimport { AdHocVariableFilter, GetTagResponse, GrafanaTheme2, MetricFindValue, SelectableValue } from '@grafana/data';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneVariable, SceneVariableState, SceneVariableValueChangedEvent, VariableValue } from '../types';\nimport { ControlsLayout, SceneComponentProps } from '../../core/types';\nimport { DataSourceRef } from '@grafana/schema';\nimport { dataFromResponse, getQueriesForVariables, renderPrometheusLabelFilters, responseHasError } from '../utils';\nimport { patchGetAdhocFilters } from './patchGetAdhocFilters';\nimport { useStyles2 } from '@grafana/ui';\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { AdHocFilterBuilder } from './AdHocFilterBuilder';\nimport { AdHocFilterRenderer } from './AdHocFilterRenderer';\nimport { getDataSourceSrv } from '@grafana/runtime';\nimport { AdHocFiltersVariableUrlSyncHandler } from './AdHocFiltersVariableUrlSyncHandler';\nimport { css } from '@emotion/css';\nimport { getEnrichedFiltersRequest } from '../getEnrichedFiltersRequest';\nimport { wrapInSafeSerializableSceneObject } from '../../utils/wrapInSafeSerializableSceneObject';\n\nexport interface AdHocFilterWithLabels extends AdHocVariableFilter {\n keyLabel?: string;\n valueLabel?: string;\n}\n\nexport interface AdHocFiltersVariableState extends SceneVariableState {\n /** Optional text to display on the 'add filter' button */\n addFilterButtonText?: string;\n /** The visible filters */\n filters: AdHocFilterWithLabels[];\n /** Base filters to always apply when looking up keys*/\n baseFilters?: AdHocFilterWithLabels[];\n /** Datasource to use for getTagKeys and getTagValues and also controls which scene queries the filters should apply to */\n datasource: DataSourceRef | null;\n /** Controls if the filters can be changed */\n readOnly?: boolean;\n /**\n * @experimental\n * Controls the layout and design of the label.\n */\n layout?: ControlsLayout;\n /**\n * Defaults to automatic which means filters will automatically be applied to all queries with the same data source as this AdHocFilterSet.\n * In manual mode you either have to use the filters programmatically or as a variable inside query expressions.\n */\n applyMode: 'auto' | 'manual';\n /**\n * Filter out the keys that do not match the regex.\n */\n tagKeyRegexFilter?: RegExp;\n /**\n * Extension hook for customizing the key lookup.\n * Return replace: true if you want to override the default lookup\n * Return replace: false if you want to combine the results with the default lookup\n */\n getTagKeysProvider?: getTagKeysProvider;\n /**\n * Extension hook for customizing the value lookup.\n * Return replace: true if you want to override the default lookup.\n * Return replace: false if you want to combine the results with the default lookup\n */\n getTagValuesProvider?: getTagValuesProvider;\n\n /**\n * Optionally provide an array of static keys that override getTagKeys\n */\n defaultKeys?: MetricFindValue[];\n\n /**\n * This is the expression that the filters resulted in. Defaults to\n * Prometheus / Loki compatible label filter expression\n */\n filterExpression?: string;\n\n /**\n * The default builder creates a Prometheus/Loki compatible filter expression,\n * this can be overridden to create a different expression based on the current filters.\n */\n expressionBuilder?: AdHocVariableExpressionBuilderFn;\n\n /**\n * When querying the datasource for label names and values to determine keys and values\n * for this ad hoc filter, consider the queries in the scene and use them as a filter.\n * This queries filter can be used to ensure that only ad hoc filter options that would\n * impact the current queries are presented to the user.\n */\n useQueriesAsFilterForOptions?: boolean;\n\n /**\n * @internal state of the new filter being added\n */\n _wip?: AdHocFilterWithLabels;\n}\n\nexport type AdHocVariableExpressionBuilderFn = (filters: AdHocFilterWithLabels[]) => string;\n\nexport type getTagKeysProvider = (\n variable: AdHocFiltersVariable,\n currentKey: string | null\n) => Promise<{ replace?: boolean; values: GetTagResponse | MetricFindValue[] }>;\n\nexport type getTagValuesProvider = (\n variable: AdHocFiltersVariable,\n filter: AdHocFilterWithLabels\n) => Promise<{ replace?: boolean; values: GetTagResponse | MetricFindValue[] }>;\n\nexport type AdHocFiltersVariableCreateHelperArgs = AdHocFiltersVariableState;\n\nexport class AdHocFiltersVariable\n extends SceneObjectBase<AdHocFiltersVariableState>\n implements SceneVariable<AdHocFiltersVariableState>\n{\n static Component = AdHocFiltersVariableRenderer;\n\n private _scopedVars = { __sceneObject: wrapInSafeSerializableSceneObject(this) };\n private _dataSourceSrv = getDataSourceSrv();\n\n protected _urlSync = new AdHocFiltersVariableUrlSyncHandler(this);\n\n public constructor(state: Partial<AdHocFiltersVariableState>) {\n super({\n type: 'adhoc',\n name: state.name ?? 'Filters',\n filters: [],\n datasource: null,\n applyMode: 'auto',\n filterExpression: state.filterExpression ?? renderExpression(state.expressionBuilder, state.filters),\n ...state,\n });\n\n if (this.state.applyMode === 'auto') {\n patchGetAdhocFilters(this);\n }\n }\n\n public setState(update: Partial<AdHocFiltersVariableState>): void {\n let filterExpressionChanged = false;\n\n if (update.filters && update.filters !== this.state.filters && !update.filterExpression) {\n update.filterExpression = renderExpression(this.state.expressionBuilder, update.filters);\n filterExpressionChanged = update.filterExpression !== this.state.filterExpression;\n }\n\n super.setState(update);\n\n if (filterExpressionChanged) {\n this.publishEvent(new SceneVariableValueChangedEvent(this), true);\n }\n }\n\n public getValue(): VariableValue | undefined {\n return this.state.filterExpression;\n }\n\n public _updateFilter(\n filter: AdHocFilterWithLabels,\n prop: keyof AdHocFilterWithLabels,\n { value, label }: SelectableValue<string | undefined | null>\n ) {\n if (value == null) {\n return;\n }\n\n const { filters, _wip } = this.state;\n\n const propLabelKey = `${prop}Label`;\n\n if (filter === _wip) {\n // If we set value we are done with this \"work in progress\" filter and we can add it\n if (prop === 'value') {\n this.setState({ filters: [...filters, { ..._wip, [prop]: value, [propLabelKey]: label }], _wip: undefined });\n } else {\n this.setState({ _wip: { ...filter, [prop]: value, [propLabelKey]: label } });\n }\n return;\n }\n\n const updatedFilters = this.state.filters.map((f) => {\n if (f === filter) {\n const updatedFilter = { ...f, [prop]: value, [propLabelKey]: label };\n\n // clear value if key has changed\n if (prop === 'key' && filter[prop] !== value) {\n updatedFilter.value = '';\n updatedFilter.valueLabel = '';\n }\n return updatedFilter;\n }\n return f;\n });\n\n this.setState({ filters: updatedFilters });\n }\n\n public _removeFilter(filter: AdHocFilterWithLabels) {\n if (filter === this.state._wip) {\n this.setState({ _wip: undefined });\n return;\n }\n\n this.setState({ filters: this.state.filters.filter((f) => f !== filter) });\n }\n\n /**\n * Get possible keys given current filters. Do not call from plugins directly\n */\n public async _getKeys(currentKey: string | null): Promise<Array<SelectableValue<string>>> {\n const override = await this.state.getTagKeysProvider?.(this, currentKey);\n\n if (override && override.replace) {\n return dataFromResponse(override.values).map(toSelectableValue);\n }\n\n if (this.state.defaultKeys) {\n return this.state.defaultKeys.map(toSelectableValue);\n }\n\n const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);\n if (!ds || !ds.getTagKeys) {\n return [];\n }\n\n const otherFilters = this.state.filters.filter((f) => f.key !== currentKey).concat(this.state.baseFilters ?? []);\n const timeRange = sceneGraph.getTimeRange(this).state.value;\n const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : undefined;\n const response = await ds.getTagKeys({\n filters: otherFilters,\n queries,\n timeRange,\n ...getEnrichedFiltersRequest(this),\n });\n\n if (responseHasError(response)) {\n // @ts-expect-error Remove when 11.1.x is released\n this.setState({ error: response.error.message });\n }\n\n let keys = dataFromResponse(response);\n if (override) {\n keys = keys.concat(dataFromResponse(override.values));\n }\n\n const tagKeyRegexFilter = this.state.tagKeyRegexFilter;\n if (tagKeyRegexFilter) {\n // @ts-expect-error Remove when 11.1.x is released\n keys = keys.filter((f) => f.text.match(tagKeyRegexFilter));\n }\n\n return keys.map(toSelectableValue);\n }\n\n /**\n * Get possible key values for a specific key given current filters. Do not call from plugins directly\n */\n public async _getValuesFor(filter: AdHocFilterWithLabels): Promise<Array<SelectableValue<string>>> {\n const override = await this.state.getTagValuesProvider?.(this, filter);\n\n if (override && override.replace) {\n return dataFromResponse(override.values).map(toSelectableValue);\n }\n\n const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);\n\n if (!ds || !ds.getTagValues) {\n return [];\n }\n\n // Filter out the current filter key from the list of all filters\n const otherFilters = this.state.filters.filter((f) => f.key !== filter.key).concat(this.state.baseFilters ?? []);\n\n const timeRange = sceneGraph.getTimeRange(this).state.value;\n const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : undefined;\n\n const response = await ds.getTagValues({\n key: filter.key,\n filters: otherFilters,\n timeRange, // @ts-expect-error TODO: remove this once 11.1.x is released\n queries,\n ...getEnrichedFiltersRequest(this),\n });\n\n if (responseHasError(response)) {\n // @ts-expect-error Remove when 11.1.x is released\n this.setState({ error: response.error.message });\n }\n\n let values = dataFromResponse(response);\n if (override) {\n values = values.concat(dataFromResponse(override.values));\n }\n\n return values.map(toSelectableValue);\n }\n\n public _addWip() {\n this.setState({\n _wip: { key: '', keyLabel: '', value: '', valueLabel: '', operator: '=', condition: '' },\n });\n }\n\n public _getOperators() {\n return ['=', '!=', '<', '>', '=~', '!~'].map<SelectableValue<string>>((value) => ({\n label: value,\n value,\n }));\n }\n}\n\nfunction renderExpression(\n builder: AdHocVariableExpressionBuilderFn | undefined,\n filters: AdHocFilterWithLabels[] | undefined\n) {\n return (builder ?? renderPrometheusLabelFilters)(filters ?? []);\n}\n\nexport function AdHocFiltersVariableRenderer({ model }: SceneComponentProps<AdHocFiltersVariable>) {\n const { filters, readOnly, addFilterButtonText } = model.useState();\n const styles = useStyles2(getStyles);\n\n return (\n <div className={styles.wrapper}>\n {filters.map((filter, index) => (\n <React.Fragment key={index}>\n <AdHocFilterRenderer filter={filter} model={model} />\n </React.Fragment>\n ))}\n\n {!readOnly && <AdHocFilterBuilder model={model} key=\"'builder\" addFilterButtonText={addFilterButtonText} />}\n </div>\n );\n}\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n wrapper: css({\n display: 'flex',\n flexWrap: 'wrap',\n alignItems: 'flex-end',\n columnGap: theme.spacing(2),\n rowGap: theme.spacing(1),\n }),\n filterIcon: css({\n color: theme.colors.text.secondary,\n paddingRight: theme.spacing(0.5),\n }),\n});\n\nexport function toSelectableValue(input: MetricFindValue): SelectableValue<string> {\n const { text, value } = input;\n const result: SelectableValue<string> = {\n label: text,\n value: String(value ?? text),\n };\n\n if ('group' in input) {\n result.group = input.group;\n }\n\n return result;\n}\n\nexport function isFilterComplete(filter: AdHocFilterWithLabels): boolean {\n return filter.key !== '' && filter.operator !== '' && filter.value !== '';\n}\n"],"names":[],"mappings":";;;;;;;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ler } from './GroupByVariableUrlSyncHandler.js';
|
12
12
|
import { getOptionSearcher } from '../components/getOptionSearcher.js';
|
13
13
|
import { getEnrichedFiltersRequest } from '../getEnrichedFiltersRequest.js';
|
14
|
-
import {
|
14
|
+
import { wrapInSafeSerializableSceneObject } from '../../utils/wrapInSafeSerializableSceneObject.js';
|
15
15
|
|
16
16
|
var __defProp = Object.defineProperty;
|
17
17
|
var __defProps = Object.defineProperties;
|
@@ -119,7 +119,7 @@ class GroupByVariable extends MultiValueVariable {
|
|
119
119
|
this.setState({ loading: true, error: null });
|
120
120
|
return from(
|
121
121
|
getDataSource(this.state.datasource, {
|
122
|
-
__sceneObject:
|
122
|
+
__sceneObject: wrapInSafeSerializableSceneObject(this)
|
123
123
|
})
|
124
124
|
).pipe(
|
125
125
|
mergeMap((ds) => {
|