@grafana/scenes 5.8.0--canary.854.10181837975.0 → 5.9.0--canary.334.10407518520.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +50 -0
- package/dist/esm/components/layout/grid/SceneGridLayoutRenderer.js +13 -8
- package/dist/esm/components/layout/grid/SceneGridLayoutRenderer.js.map +1 -1
- package/dist/esm/core/sceneGraph/sceneGraph.js +5 -0
- package/dist/esm/core/sceneGraph/sceneGraph.js.map +1 -1
- package/dist/esm/querying/SceneQueryRunner.js +30 -18
- 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/services/useUrlSync.js +2 -1
- package/dist/esm/services/useUrlSync.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFilterRenderer.js +2 -4
- package/dist/esm/variables/adhoc/AdHocFilterRenderer.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +2 -2
- 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/types.js.map +1 -1
- package/dist/esm/variables/variants/MultiValueVariable.js +5 -0
- package/dist/esm/variables/variants/MultiValueVariable.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 +8 -1
- package/dist/index.js +3820 -3823
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/utils/wrapInSafeSerializableSceneObject.js +0 -30
- package/dist/esm/utils/wrapInSafeSerializableSceneObject.js.map +0 -1
@@ -13,7 +13,7 @@ import { safeStringifyValue } from '../../utils.js';
|
|
13
13
|
import { SEARCH_FILTER_VARIABLE } from '../../constants.js';
|
14
14
|
import { debounce } from 'lodash';
|
15
15
|
import { registerQueryWithController } from '../../../querying/registerQueryWithController.js';
|
16
|
-
import {
|
16
|
+
import { SafeSerializableSceneObject } from '../../../utils/SafeSerializableSceneObject.js';
|
17
17
|
|
18
18
|
var __defProp = Object.defineProperty;
|
19
19
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
@@ -66,7 +66,7 @@ class QueryVariable extends MultiValueVariable {
|
|
66
66
|
this.setState({ loading: true, error: null });
|
67
67
|
return from(
|
68
68
|
getDataSource(this.state.datasource, {
|
69
|
-
__sceneObject:
|
69
|
+
__sceneObject: new SafeSerializableSceneObject(this)
|
70
70
|
})
|
71
71
|
).pipe(
|
72
72
|
mergeMap((ds) => {
|
@@ -107,7 +107,7 @@ class QueryVariable extends MultiValueVariable {
|
|
107
107
|
}
|
108
108
|
getRequest(target, searchFilter) {
|
109
109
|
const scopedVars = {
|
110
|
-
__sceneObject:
|
110
|
+
__sceneObject: new SafeSerializableSceneObject(this)
|
111
111
|
};
|
112
112
|
if (searchFilter) {
|
113
113
|
scopedVars.__searchFilter = { value: searchFilter, text: searchFilter };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"QueryVariable.js","sources":["../../../../../src/variables/variants/query/QueryVariable.tsx"],"sourcesContent":["import { Observable, of, filter, take, mergeMap, catchError, throwError, from, lastValueFrom } from 'rxjs';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport {\n CoreApp,\n DataQueryRequest,\n LoadingState,\n PanelData,\n ScopedVars,\n VariableRefresh,\n VariableSort,\n} from '@grafana/data';\n\nimport { sceneGraph } from '../../../core/sceneGraph';\nimport { SceneComponentProps, SceneDataQuery } from '../../../core/types';\nimport { VariableDependencyConfig } from '../../VariableDependencyConfig';\nimport { renderSelectForVariable } from '../../components/VariableValueSelect';\nimport { VariableValueOption } from '../../types';\nimport { MultiValueVariable, MultiValueVariableState, VariableGetOptionsArgs } from '../MultiValueVariable';\n\nimport { createQueryVariableRunner } from './createQueryVariableRunner';\nimport { metricNamesToVariableValues } from './utils';\nimport { toMetricFindValues } from './toMetricFindValues';\nimport { getDataSource } from '../../../utils/getDataSource';\nimport { safeStringifyValue } from '../../utils';\nimport { DataQuery, DataSourceRef } from '@grafana/schema';\nimport { SEARCH_FILTER_VARIABLE } from '../../constants';\nimport { debounce } from 'lodash';\nimport { registerQueryWithController } from '../../../querying/registerQueryWithController';\nimport {
|
1
|
+
{"version":3,"file":"QueryVariable.js","sources":["../../../../../src/variables/variants/query/QueryVariable.tsx"],"sourcesContent":["import { Observable, of, filter, take, mergeMap, catchError, throwError, from, lastValueFrom } from 'rxjs';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport {\n CoreApp,\n DataQueryRequest,\n LoadingState,\n PanelData,\n ScopedVars,\n VariableRefresh,\n VariableSort,\n} from '@grafana/data';\n\nimport { sceneGraph } from '../../../core/sceneGraph';\nimport { SceneComponentProps, SceneDataQuery } from '../../../core/types';\nimport { VariableDependencyConfig } from '../../VariableDependencyConfig';\nimport { renderSelectForVariable } from '../../components/VariableValueSelect';\nimport { VariableValueOption } from '../../types';\nimport { MultiValueVariable, MultiValueVariableState, VariableGetOptionsArgs } from '../MultiValueVariable';\n\nimport { createQueryVariableRunner } from './createQueryVariableRunner';\nimport { metricNamesToVariableValues } from './utils';\nimport { toMetricFindValues } from './toMetricFindValues';\nimport { getDataSource } from '../../../utils/getDataSource';\nimport { safeStringifyValue } from '../../utils';\nimport { DataQuery, DataSourceRef } from '@grafana/schema';\nimport { SEARCH_FILTER_VARIABLE } from '../../constants';\nimport { debounce } from 'lodash';\nimport { registerQueryWithController } from '../../../querying/registerQueryWithController';\nimport { SafeSerializableSceneObject } from '../../../utils/SafeSerializableSceneObject';\n\nexport interface QueryVariableState extends MultiValueVariableState {\n type: 'query';\n datasource: DataSourceRef | null;\n query: string | SceneDataQuery;\n regex: string;\n refresh: VariableRefresh;\n sort: VariableSort;\n /** @internal Only for use inside core dashboards */\n definition?: string;\n}\n\nexport class QueryVariable extends MultiValueVariable<QueryVariableState> {\n protected _variableDependency = new VariableDependencyConfig(this, {\n statePaths: ['regex', 'query', 'datasource'],\n });\n\n public constructor(initialState: Partial<QueryVariableState>) {\n super({\n type: 'query',\n name: '',\n value: '',\n text: '',\n options: [],\n datasource: null,\n regex: '',\n query: '',\n refresh: VariableRefresh.onDashboardLoad,\n sort: VariableSort.disabled,\n ...initialState,\n });\n }\n\n public getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]> {\n if (!this.state.query) {\n return of([]);\n }\n\n this.setState({ loading: true, error: null });\n\n return from(\n getDataSource(this.state.datasource, {\n __sceneObject: new SafeSerializableSceneObject(this),\n })\n ).pipe(\n mergeMap((ds) => {\n const runner = createQueryVariableRunner(ds);\n const target = runner.getTarget(this);\n const request = this.getRequest(target, args.searchFilter);\n\n return runner.runRequest({ variable: this, searchFilter: args.searchFilter }, request).pipe(\n registerQueryWithController({\n type: 'variable',\n request: request,\n origin: this,\n }),\n filter((data) => data.state === LoadingState.Done || data.state === LoadingState.Error), // we only care about done or error for now\n take(1), // take the first result, using first caused a bug where it in some situations throw an uncaught error because of no results had been received yet\n mergeMap((data: PanelData) => {\n if (data.state === LoadingState.Error) {\n return throwError(() => data.error);\n }\n return of(data);\n }),\n toMetricFindValues(),\n mergeMap((values) => {\n let regex = '';\n if (this.state.regex) {\n regex = sceneGraph.interpolate(this, this.state.regex, undefined, 'regex');\n }\n return of(metricNamesToVariableValues(regex, this.state.sort, values));\n }),\n catchError((error) => {\n if (error.cancelled) {\n return of([]);\n }\n return throwError(() => error);\n })\n );\n })\n );\n }\n\n private getRequest(target: DataQuery | string, searchFilter?: string) {\n const scopedVars: ScopedVars = {\n __sceneObject: new SafeSerializableSceneObject(this),\n };\n\n if (searchFilter) {\n scopedVars.__searchFilter = { value: searchFilter, text: searchFilter };\n }\n\n const range = sceneGraph.getTimeRange(this).state.value;\n\n const request: DataQueryRequest = {\n app: CoreApp.Dashboard,\n requestId: uuidv4(),\n timezone: '',\n range,\n interval: '',\n intervalMs: 0,\n // @ts-ignore\n targets: [target],\n scopedVars,\n startTime: Date.now(),\n };\n\n return request;\n }\n\n onSearchChange = (searchFilter: string) => {\n if (!containsSearchFilter(this.state.query)) {\n return;\n }\n\n this._updateOptionsBasedOnSearchFilter(searchFilter);\n };\n\n private _updateOptionsBasedOnSearchFilter = debounce(async (searchFilter: string) => {\n const result = await lastValueFrom(this.getValueOptions({ searchFilter }));\n this.setState({ options: result, loading: false });\n }, 400);\n\n public static Component = ({ model }: SceneComponentProps<MultiValueVariable>) => {\n return renderSelectForVariable(model);\n };\n}\n\nfunction containsSearchFilter(query: string | DataQuery) {\n const str = safeStringifyValue(query);\n return str.indexOf(SEARCH_FILTER_VARIABLE) > -1;\n}\n"],"names":["uuidv4"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CO,MAAM,sBAAsB,kBAAuC,CAAA;AAAA,EAKjE,YAAY,YAA2C,EAAA;AAC5D,IAAM,KAAA,CAAA,cAAA,CAAA;AAAA,MACJ,IAAM,EAAA,OAAA;AAAA,MACN,IAAM,EAAA,EAAA;AAAA,MACN,KAAO,EAAA,EAAA;AAAA,MACP,IAAM,EAAA,EAAA;AAAA,MACN,SAAS,EAAC;AAAA,MACV,UAAY,EAAA,IAAA;AAAA,MACZ,KAAO,EAAA,EAAA;AAAA,MACP,KAAO,EAAA,EAAA;AAAA,MACP,SAAS,eAAgB,CAAA,eAAA;AAAA,MACzB,MAAM,YAAa,CAAA,QAAA;AAAA,KAAA,EAChB,YACJ,CAAA,CAAA,CAAA;AAjBH,IAAU,IAAA,CAAA,mBAAA,GAAsB,IAAI,wBAAA,CAAyB,IAAM,EAAA;AAAA,MACjE,UAAY,EAAA,CAAC,OAAS,EAAA,OAAA,EAAS,YAAY,CAAA;AAAA,KAC5C,CAAA,CAAA;AA+FD,IAAA,IAAA,CAAA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|
57
57
|
*/
|
58
58
|
getValueText?(fieldPath?: string): string;
|
59
59
|
/**
|
60
|
-
*
|
60
|
+
* For special edge case senarios. For example local function that locally scoped variables can implement.
|
61
61
|
**/
|
62
62
|
isAncestorLoading?(): boolean;
|
63
63
|
/**
|
@@ -732,6 +732,7 @@ declare abstract class MultiValueVariable<TState extends MultiValueVariableState
|
|
732
732
|
*/
|
733
733
|
private setStateHelper;
|
734
734
|
getOptionsForSelect(): VariableValueOption[];
|
735
|
+
refreshOptions(): void;
|
735
736
|
/**
|
736
737
|
* Can be used by subclasses to do custom handling of option search based on search input
|
737
738
|
*/
|
@@ -1272,6 +1273,11 @@ interface QueryRunnerState extends SceneObjectState {
|
|
1272
1273
|
maxDataPointsFromWidth?: boolean;
|
1273
1274
|
cacheTimeout?: DataQueryRequest['cacheTimeout'];
|
1274
1275
|
queryCachingTTL?: DataQueryRequest['queryCachingTTL'];
|
1276
|
+
/**
|
1277
|
+
* When set to auto (the default) query runner will issue queries on activate (when variable dependencies are ready) or when time range change.
|
1278
|
+
* 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.
|
1279
|
+
*/
|
1280
|
+
runQueriesMode?: 'auto' | 'manual';
|
1275
1281
|
dataLayerFilter?: DataLayerFilter;
|
1276
1282
|
_hasFetchedData?: boolean;
|
1277
1283
|
}
|
@@ -1340,6 +1346,7 @@ declare class SceneQueryRunner extends SceneObjectBase<QueryRunnerState> impleme
|
|
1340
1346
|
*/
|
1341
1347
|
private findAndSubscribeToAdHocFilters;
|
1342
1348
|
private _updateExplicitVariableDependencies;
|
1349
|
+
private isQueryModeAuto;
|
1343
1350
|
}
|
1344
1351
|
|
1345
1352
|
type ExtraQueryDataProcessor = (primary: PanelData, secondary: PanelData) => Observable<PanelData>;
|