@grafana/scenes 5.5.0--canary.828.9973016839.0 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +26 -0
- package/dist/esm/components/VizPanel/VizPanel.js +35 -7
- package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/querying/SceneQueryRunner.js +1 -2
- package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
- package/dist/esm/querying/layers/annotations/AnnotationsDataLayer.js +1 -4
- package/dist/esm/querying/layers/annotations/AnnotationsDataLayer.js.map +1 -1
- package/dist/esm/querying/layers/annotations/standardAnnotationQuery.js +1 -2
- package/dist/esm/querying/layers/annotations/standardAnnotationQuery.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +2 -7
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
- package/dist/esm/variables/groupby/GroupByVariable.js +5 -8
- package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
- package/dist/esm/variables/variants/query/QueryVariable.js +3 -4
- package/dist/esm/variables/variants/query/QueryVariable.js.map +1 -1
- package/dist/index.d.ts +3 -11
- package/dist/index.js +67 -85
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/utils/SafeSerializableSceneObject.js +0 -39
- package/dist/esm/utils/SafeSerializableSceneObject.js.map +0 -1
package/dist/index.js
CHANGED
@@ -188,32 +188,32 @@ class UserActionEvent extends data.BusEventWithPayload {
|
|
188
188
|
}
|
189
189
|
UserActionEvent.type = "scene-object-user-action";
|
190
190
|
|
191
|
-
var __accessCheck$
|
191
|
+
var __accessCheck$2 = (obj, member, msg) => {
|
192
192
|
if (!member.has(obj))
|
193
193
|
throw TypeError("Cannot " + msg);
|
194
194
|
};
|
195
|
-
var __privateGet$
|
196
|
-
__accessCheck$
|
195
|
+
var __privateGet$2 = (obj, member, getter) => {
|
196
|
+
__accessCheck$2(obj, member, "read from private field");
|
197
197
|
return getter ? getter.call(obj) : member.get(obj);
|
198
198
|
};
|
199
|
-
var __privateAdd$
|
199
|
+
var __privateAdd$2 = (obj, member, value) => {
|
200
200
|
if (member.has(obj))
|
201
201
|
throw TypeError("Cannot add the same private member more than once");
|
202
202
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
203
203
|
};
|
204
|
-
var __privateSet$
|
205
|
-
__accessCheck$
|
204
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
205
|
+
__accessCheck$2(obj, member, "write to private field");
|
206
206
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
207
207
|
return value;
|
208
208
|
};
|
209
209
|
var _ref;
|
210
210
|
class SceneObjectRef {
|
211
211
|
constructor(ref) {
|
212
|
-
__privateAdd$
|
213
|
-
__privateSet$
|
212
|
+
__privateAdd$2(this, _ref, void 0);
|
213
|
+
__privateSet$1(this, _ref, ref);
|
214
214
|
}
|
215
215
|
resolve() {
|
216
|
-
return __privateGet$
|
216
|
+
return __privateGet$2(this, _ref);
|
217
217
|
}
|
218
218
|
}
|
219
219
|
_ref = new WeakMap();
|
@@ -1744,15 +1744,15 @@ function isDataLayer(obj) {
|
|
1744
1744
|
return "isDataLayer" in obj;
|
1745
1745
|
}
|
1746
1746
|
|
1747
|
-
var __accessCheck$
|
1747
|
+
var __accessCheck$1 = (obj, member, msg) => {
|
1748
1748
|
if (!member.has(obj))
|
1749
1749
|
throw TypeError("Cannot " + msg);
|
1750
1750
|
};
|
1751
|
-
var __privateGet$
|
1752
|
-
__accessCheck$
|
1751
|
+
var __privateGet$1 = (obj, member, getter) => {
|
1752
|
+
__accessCheck$1(obj, member, "read from private field");
|
1753
1753
|
return getter ? getter.call(obj) : member.get(obj);
|
1754
1754
|
};
|
1755
|
-
var __privateAdd$
|
1755
|
+
var __privateAdd$1 = (obj, member, value) => {
|
1756
1756
|
if (member.has(obj))
|
1757
1757
|
throw TypeError("Cannot add the same private member more than once");
|
1758
1758
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
@@ -1765,25 +1765,25 @@ class SceneQueryController extends SceneObjectBase {
|
|
1765
1765
|
constructor() {
|
1766
1766
|
super({ isRunning: false });
|
1767
1767
|
this.isQueryController = true;
|
1768
|
-
__privateAdd$
|
1768
|
+
__privateAdd$1(this, _running, /* @__PURE__ */ new Set());
|
1769
1769
|
this.addActivationHandler(() => {
|
1770
|
-
return () => __privateGet$
|
1770
|
+
return () => __privateGet$1(this, _running).clear();
|
1771
1771
|
});
|
1772
1772
|
}
|
1773
1773
|
queryStarted(entry) {
|
1774
|
-
__privateGet$
|
1774
|
+
__privateGet$1(this, _running).add(entry);
|
1775
1775
|
this.changeRunningQueryCount(1);
|
1776
1776
|
if (!this.state.isRunning) {
|
1777
1777
|
this.setState({ isRunning: true });
|
1778
1778
|
}
|
1779
1779
|
}
|
1780
1780
|
queryCompleted(entry) {
|
1781
|
-
if (!__privateGet$
|
1781
|
+
if (!__privateGet$1(this, _running).has(entry)) {
|
1782
1782
|
return;
|
1783
1783
|
}
|
1784
|
-
__privateGet$
|
1784
|
+
__privateGet$1(this, _running).delete(entry);
|
1785
1785
|
this.changeRunningQueryCount(-1);
|
1786
|
-
if (__privateGet$
|
1786
|
+
if (__privateGet$1(this, _running).size === 0) {
|
1787
1787
|
this.setState({ isRunning: false });
|
1788
1788
|
}
|
1789
1789
|
}
|
@@ -1793,7 +1793,7 @@ class SceneQueryController extends SceneObjectBase {
|
|
1793
1793
|
}
|
1794
1794
|
cancelAll() {
|
1795
1795
|
var _a;
|
1796
|
-
for (const entry of __privateGet$
|
1796
|
+
for (const entry of __privateGet$1(this, _running).values()) {
|
1797
1797
|
(_a = entry.cancel) == null ? void 0 : _a.call(entry);
|
1798
1798
|
}
|
1799
1799
|
}
|
@@ -3082,43 +3082,6 @@ function getEnrichedFiltersRequest(sourceRunner) {
|
|
3082
3082
|
return null;
|
3083
3083
|
}
|
3084
3084
|
|
3085
|
-
var __accessCheck$1 = (obj, member, msg) => {
|
3086
|
-
if (!member.has(obj))
|
3087
|
-
throw TypeError("Cannot " + msg);
|
3088
|
-
};
|
3089
|
-
var __privateGet$1 = (obj, member, getter) => {
|
3090
|
-
__accessCheck$1(obj, member, "read from private field");
|
3091
|
-
return getter ? getter.call(obj) : member.get(obj);
|
3092
|
-
};
|
3093
|
-
var __privateAdd$1 = (obj, member, value) => {
|
3094
|
-
if (member.has(obj))
|
3095
|
-
throw TypeError("Cannot add the same private member more than once");
|
3096
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
3097
|
-
};
|
3098
|
-
var __privateSet$1 = (obj, member, value, setter) => {
|
3099
|
-
__accessCheck$1(obj, member, "write to private field");
|
3100
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
3101
|
-
return value;
|
3102
|
-
};
|
3103
|
-
var _value;
|
3104
|
-
class SafeSerializableSceneObject {
|
3105
|
-
constructor(value) {
|
3106
|
-
__privateAdd$1(this, _value, void 0);
|
3107
|
-
this.text = "__sceneObject";
|
3108
|
-
__privateSet$1(this, _value, value);
|
3109
|
-
}
|
3110
|
-
toString() {
|
3111
|
-
return void 0;
|
3112
|
-
}
|
3113
|
-
valueOf() {
|
3114
|
-
return __privateGet$1(this, _value);
|
3115
|
-
}
|
3116
|
-
get value() {
|
3117
|
-
return this;
|
3118
|
-
}
|
3119
|
-
}
|
3120
|
-
_value = new WeakMap();
|
3121
|
-
|
3122
3085
|
var __defProp$z = Object.defineProperty;
|
3123
3086
|
var __defProps$n = Object.defineProperties;
|
3124
3087
|
var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
|
@@ -3163,7 +3126,9 @@ class GroupByVariable extends MultiValueVariable {
|
|
3163
3126
|
return override.values;
|
3164
3127
|
}
|
3165
3128
|
if (this.state.defaultOptions) {
|
3166
|
-
return this.state.defaultOptions.concat(
|
3129
|
+
return this.state.defaultOptions.concat(
|
3130
|
+
dataFromResponse((_c = override == null ? void 0 : override.values) != null ? _c : [])
|
3131
|
+
);
|
3167
3132
|
}
|
3168
3133
|
if (!ds.getTagKeys) {
|
3169
3134
|
return [];
|
@@ -3171,11 +3136,7 @@ class GroupByVariable extends MultiValueVariable {
|
|
3171
3136
|
const queries = getQueriesForVariables(this);
|
3172
3137
|
const otherFilters = this.state.baseFilters || [];
|
3173
3138
|
const timeRange = sceneGraph.getTimeRange(this).state.value;
|
3174
|
-
const response = await ds.getTagKeys(__spreadValues$z({
|
3175
|
-
filters: otherFilters,
|
3176
|
-
queries,
|
3177
|
-
timeRange
|
3178
|
-
}, getEnrichedFiltersRequest(this)));
|
3139
|
+
const response = await ds.getTagKeys(__spreadValues$z({ filters: otherFilters, queries, timeRange }, getEnrichedFiltersRequest(this)));
|
3179
3140
|
if (responseHasError(response)) {
|
3180
3141
|
this.setState({ error: response.error.message });
|
3181
3142
|
}
|
@@ -3225,7 +3186,7 @@ class GroupByVariable extends MultiValueVariable {
|
|
3225
3186
|
this.setState({ loading: true, error: null });
|
3226
3187
|
return rxjs.from(
|
3227
3188
|
getDataSource(this.state.datasource, {
|
3228
|
-
__sceneObject:
|
3189
|
+
__sceneObject: { text: "__sceneObject", value: this }
|
3229
3190
|
})
|
3230
3191
|
).pipe(
|
3231
3192
|
rxjs.mergeMap((ds) => {
|
@@ -3821,7 +3782,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
3821
3782
|
applyMode: "auto",
|
3822
3783
|
filterExpression: (_b = state.filterExpression) != null ? _b : renderExpression(state.expressionBuilder, state.filters)
|
3823
3784
|
}, state));
|
3824
|
-
this._scopedVars = { __sceneObject:
|
3785
|
+
this._scopedVars = { __sceneObject: { value: this } };
|
3825
3786
|
this._dataSourceSrv = runtime.getDataSourceSrv();
|
3826
3787
|
this._urlSync = new AdHocFiltersVariableUrlSyncHandler(this);
|
3827
3788
|
if (this.state.applyMode === "auto") {
|
@@ -3892,11 +3853,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
3892
3853
|
const otherFilters = this.state.filters.filter((f) => f.key !== currentKey).concat((_c = this.state.baseFilters) != null ? _c : []);
|
3893
3854
|
const timeRange = sceneGraph.getTimeRange(this).state.value;
|
3894
3855
|
const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : void 0;
|
3895
|
-
const response = await ds.getTagKeys(__spreadValues$y({
|
3896
|
-
filters: otherFilters,
|
3897
|
-
queries,
|
3898
|
-
timeRange
|
3899
|
-
}, getEnrichedFiltersRequest(this)));
|
3856
|
+
const response = await ds.getTagKeys(__spreadValues$y({ filters: otherFilters, queries, timeRange }, getEnrichedFiltersRequest(this)));
|
3900
3857
|
if (responseHasError(response)) {
|
3901
3858
|
this.setState({ error: response.error.message });
|
3902
3859
|
}
|
@@ -4069,7 +4026,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
4069
4026
|
this._dataLayersMerger = new DataLayersMerger();
|
4070
4027
|
this._variableValueRecorder = new VariableValueRecorder();
|
4071
4028
|
this._results = new rxjs.ReplaySubject(1);
|
4072
|
-
this._scopedVars = { __sceneObject:
|
4029
|
+
this._scopedVars = { __sceneObject: { value: this, text: "__sceneObject" } };
|
4073
4030
|
this._variableDependency = new VariableDependencyConfig(this, {
|
4074
4031
|
statePaths: ["queries", "datasource"],
|
4075
4032
|
onVariableUpdateCompleted: this.onVariableUpdatesCompleted.bind(this),
|
@@ -5347,15 +5304,15 @@ class VizPanel extends SceneObjectBase {
|
|
5347
5304
|
this._loadPlugin(this.state.pluginId);
|
5348
5305
|
}
|
5349
5306
|
}
|
5350
|
-
async _loadPlugin(pluginId) {
|
5307
|
+
async _loadPlugin(pluginId, overwriteOptions, overwriteFieldConfig, isAfterPluginChange) {
|
5351
5308
|
const plugin = loadPanelPluginSync(pluginId);
|
5352
5309
|
if (plugin) {
|
5353
|
-
this._pluginLoaded(plugin);
|
5310
|
+
this._pluginLoaded(plugin, overwriteOptions, overwriteFieldConfig, isAfterPluginChange);
|
5354
5311
|
} else {
|
5355
5312
|
const { importPanelPlugin } = runtime.getPluginImportUtils();
|
5356
5313
|
try {
|
5357
5314
|
const result = await importPanelPlugin(pluginId);
|
5358
|
-
this._pluginLoaded(result);
|
5315
|
+
this._pluginLoaded(result, overwriteOptions, overwriteFieldConfig, isAfterPluginChange);
|
5359
5316
|
} catch (err) {
|
5360
5317
|
this._pluginLoaded(getPanelPluginNotFound(pluginId));
|
5361
5318
|
if (err instanceof Error) {
|
@@ -5371,7 +5328,7 @@ class VizPanel extends SceneObjectBase {
|
|
5371
5328
|
}
|
5372
5329
|
return panelId;
|
5373
5330
|
}
|
5374
|
-
async _pluginLoaded(plugin) {
|
5331
|
+
async _pluginLoaded(plugin, overwriteOptions, overwriteFieldConfig, isAfterPluginChange) {
|
5375
5332
|
const { options, fieldConfig, title, pluginVersion, _UNSAFE_customMigrationHandler } = this.state;
|
5376
5333
|
const panel = {
|
5377
5334
|
title,
|
@@ -5381,6 +5338,12 @@ class VizPanel extends SceneObjectBase {
|
|
5381
5338
|
type: plugin.meta.id,
|
5382
5339
|
pluginVersion
|
5383
5340
|
};
|
5341
|
+
if (overwriteOptions) {
|
5342
|
+
panel.options = overwriteOptions;
|
5343
|
+
}
|
5344
|
+
if (overwriteFieldConfig) {
|
5345
|
+
panel.fieldConfig = overwriteFieldConfig;
|
5346
|
+
}
|
5384
5347
|
const currentVersion = this._getPluginVersion(plugin);
|
5385
5348
|
_UNSAFE_customMigrationHandler == null ? void 0 : _UNSAFE_customMigrationHandler(panel, plugin);
|
5386
5349
|
if (plugin.onPanelMigration && currentVersion !== this.state.pluginVersion) {
|
@@ -5390,13 +5353,14 @@ class VizPanel extends SceneObjectBase {
|
|
5390
5353
|
plugin,
|
5391
5354
|
currentOptions: panel.options,
|
5392
5355
|
currentFieldConfig: panel.fieldConfig,
|
5393
|
-
isAfterPluginChange: false
|
5356
|
+
isAfterPluginChange: isAfterPluginChange != null ? isAfterPluginChange : false
|
5394
5357
|
});
|
5395
5358
|
this._plugin = plugin;
|
5396
5359
|
this.setState({
|
5397
5360
|
options: withDefaults.options,
|
5398
5361
|
fieldConfig: withDefaults.fieldConfig,
|
5399
|
-
pluginVersion: currentVersion
|
5362
|
+
pluginVersion: currentVersion,
|
5363
|
+
pluginId: plugin.meta.id
|
5400
5364
|
});
|
5401
5365
|
if (plugin.meta.skipDataQuery) {
|
5402
5366
|
const sceneTimeRange = sceneGraph.getTimeRange(this);
|
@@ -5414,6 +5378,27 @@ class VizPanel extends SceneObjectBase {
|
|
5414
5378
|
(_a = this._panelContext) != null ? _a : this._panelContext = this.buildPanelContext();
|
5415
5379
|
return this._panelContext;
|
5416
5380
|
}
|
5381
|
+
async changePluginType(pluginId, newOptions, newFieldConfig) {
|
5382
|
+
var _a, _b;
|
5383
|
+
const {
|
5384
|
+
options: prevOptions,
|
5385
|
+
fieldConfig: prevFieldConfig,
|
5386
|
+
pluginId: prevPluginId
|
5387
|
+
} = this.state;
|
5388
|
+
this._dataWithFieldConfig = void 0;
|
5389
|
+
await this._loadPlugin(pluginId, newOptions != null ? newOptions : {}, newFieldConfig, true);
|
5390
|
+
const panel = {
|
5391
|
+
title: this.state.title,
|
5392
|
+
options: this.state.options,
|
5393
|
+
fieldConfig: this.state.fieldConfig,
|
5394
|
+
id: 1,
|
5395
|
+
type: pluginId
|
5396
|
+
};
|
5397
|
+
const updatedOptions = (_b = (_a = this._plugin) == null ? void 0 : _a.onPanelTypeChanged) == null ? void 0 : _b.call(_a, panel, prevPluginId, prevOptions, prevFieldConfig);
|
5398
|
+
if (updatedOptions && !lodash.isEmpty(updatedOptions)) {
|
5399
|
+
this.onOptionsChange(updatedOptions, true, true);
|
5400
|
+
}
|
5401
|
+
}
|
5417
5402
|
clearFieldConfigCache() {
|
5418
5403
|
this._dataWithFieldConfig = void 0;
|
5419
5404
|
}
|
@@ -5992,7 +5977,7 @@ function executeAnnotationQuery(datasource, timeRange, query, layer) {
|
|
5992
5977
|
__interval: { text: interval.interval, value: interval.interval },
|
5993
5978
|
__interval_ms: { text: interval.intervalMs.toString(), value: interval.intervalMs },
|
5994
5979
|
__annotation: { text: annotation.name, value: annotation },
|
5995
|
-
__sceneObject:
|
5980
|
+
__sceneObject: { text: "__sceneObject", value: layer }
|
5996
5981
|
};
|
5997
5982
|
const queryRequest = __spreadValues$q(__spreadProps$f(__spreadValues$q({
|
5998
5983
|
startTime: Date.now(),
|
@@ -6136,9 +6121,7 @@ class AnnotationsDataLayer extends SceneDataLayerBase {
|
|
6136
6121
|
}, initialState),
|
6137
6122
|
["query"]
|
6138
6123
|
);
|
6139
|
-
this._scopedVars = {
|
6140
|
-
__sceneObject: new SafeSerializableSceneObject(this)
|
6141
|
-
};
|
6124
|
+
this._scopedVars = { __sceneObject: { value: this, text: "__sceneObject" } };
|
6142
6125
|
}
|
6143
6126
|
onEnable() {
|
6144
6127
|
const timeRange = sceneGraph.getTimeRange(this);
|
@@ -7436,7 +7419,7 @@ class QueryVariable extends MultiValueVariable {
|
|
7436
7419
|
options: [],
|
7437
7420
|
datasource: null,
|
7438
7421
|
regex: "",
|
7439
|
-
query:
|
7422
|
+
query: "",
|
7440
7423
|
refresh: data.VariableRefresh.onDashboardLoad,
|
7441
7424
|
sort: data.VariableSort.disabled
|
7442
7425
|
}, initialState));
|
@@ -7461,7 +7444,7 @@ class QueryVariable extends MultiValueVariable {
|
|
7461
7444
|
this.setState({ loading: true, error: null });
|
7462
7445
|
return rxjs.from(
|
7463
7446
|
getDataSource(this.state.datasource, {
|
7464
|
-
__sceneObject:
|
7447
|
+
__sceneObject: { text: "__sceneObject", value: this }
|
7465
7448
|
})
|
7466
7449
|
).pipe(
|
7467
7450
|
rxjs.mergeMap((ds) => {
|
@@ -7502,7 +7485,7 @@ class QueryVariable extends MultiValueVariable {
|
|
7502
7485
|
}
|
7503
7486
|
getRequest(target, searchFilter) {
|
7504
7487
|
const scopedVars = {
|
7505
|
-
__sceneObject:
|
7488
|
+
__sceneObject: { text: "__sceneObject", value: this }
|
7506
7489
|
};
|
7507
7490
|
if (searchFilter) {
|
7508
7491
|
scopedVars.__searchFilter = { value: searchFilter, text: searchFilter };
|
@@ -11620,7 +11603,6 @@ exports.PanelBuilders = PanelBuilders;
|
|
11620
11603
|
exports.PanelOptionsBuilders = PanelOptionsBuilders;
|
11621
11604
|
exports.QueryVariable = QueryVariable;
|
11622
11605
|
exports.RuntimeDataSource = RuntimeDataSource;
|
11623
|
-
exports.SafeSerializableSceneObject = SafeSerializableSceneObject;
|
11624
11606
|
exports.SceneApp = SceneApp;
|
11625
11607
|
exports.SceneAppPage = SceneAppPage;
|
11626
11608
|
exports.SceneByFrameRepeater = SceneByFrameRepeater;
|