@grafana/scenes 4.24.2--canary.757.9283024412.0 → 4.24.3--canary.734.9287358327.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +13 -0
- package/dist/esm/components/EmbeddedScene.js +2 -1
- package/dist/esm/components/EmbeddedScene.js.map +1 -1
- package/dist/esm/components/VizPanel/VizPanel.js +3 -0
- package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
- package/dist/esm/core/PanelBuilders/VizConfigBuilder.js +78 -0
- package/dist/esm/core/PanelBuilders/VizConfigBuilder.js.map +1 -0
- package/dist/esm/core/PanelBuilders/VizConfigBuilders.js +114 -0
- package/dist/esm/core/PanelBuilders/VizConfigBuilders.js.map +1 -0
- package/dist/esm/core/types.js.map +1 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
- package/dist/esm/services/UniqueUrlKeyMapper.js +1 -1
- package/dist/esm/services/UniqueUrlKeyMapper.js.map +1 -1
- package/dist/esm/services/UrlSyncManager.js +11 -3
- package/dist/esm/services/UrlSyncManager.js.map +1 -1
- package/dist/esm/utils/writeSceneLog.js +5 -1
- package/dist/esm/utils/writeSceneLog.js.map +1 -1
- package/dist/esm/variables/utils.js.map +1 -1
- package/dist/esm/variables/variants/query/QueryVariable.js.map +1 -1
- package/dist/index.d.ts +245 -142
- package/dist/index.js +194 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -6
package/dist/index.js
CHANGED
@@ -591,7 +591,7 @@ class UniqueUrlKeyMapper {
|
|
591
591
|
getUniqueKey(key, obj) {
|
592
592
|
const objectsWithKey = this.index.get(key);
|
593
593
|
if (!objectsWithKey) {
|
594
|
-
|
594
|
+
return key;
|
595
595
|
}
|
596
596
|
const address = objectsWithKey.findIndex((o) => o.sceneObject === obj);
|
597
597
|
if (address > 0) {
|
@@ -2042,7 +2042,11 @@ async function getDataSource(datasource, scopedVars) {
|
|
2042
2042
|
}
|
2043
2043
|
|
2044
2044
|
function writeSceneLog(logger, message, ...rest) {
|
2045
|
-
|
2045
|
+
let loggingEnabled = false;
|
2046
|
+
if (typeof window !== "undefined") {
|
2047
|
+
loggingEnabled = localStorage.getItem("grafana.debug.scenes") === "true";
|
2048
|
+
}
|
2049
|
+
if (loggingEnabled) {
|
2046
2050
|
console.log(`${logger}: `, message, ...rest);
|
2047
2051
|
}
|
2048
2052
|
}
|
@@ -5246,6 +5250,9 @@ class VizPanel extends SceneObjectBase {
|
|
5246
5250
|
(_a = this._panelContext) != null ? _a : this._panelContext = this.buildPanelContext();
|
5247
5251
|
return this._panelContext;
|
5248
5252
|
}
|
5253
|
+
clearFieldConfigCache() {
|
5254
|
+
this._dataWithFieldConfig = void 0;
|
5255
|
+
}
|
5249
5256
|
applyFieldConfig(rawData) {
|
5250
5257
|
var _a, _b, _c, _d;
|
5251
5258
|
const plugin = this._plugin;
|
@@ -7749,6 +7756,7 @@ class UrlSyncManager {
|
|
7749
7756
|
this._locationSub = null;
|
7750
7757
|
this._ignoreNextLocationUpdate = false;
|
7751
7758
|
this._onLocationUpdate = (location) => {
|
7759
|
+
this._urlParams = new URLSearchParams(location.search);
|
7752
7760
|
if (this._ignoreNextLocationUpdate) {
|
7753
7761
|
this._ignoreNextLocationUpdate = false;
|
7754
7762
|
return;
|
@@ -7756,9 +7764,8 @@ class UrlSyncManager {
|
|
7756
7764
|
if (this._lastPath !== location.pathname) {
|
7757
7765
|
return;
|
7758
7766
|
}
|
7759
|
-
const urlParams = new URLSearchParams(location.search);
|
7760
7767
|
this._urlKeyMapper.rebuildIndex(this._sceneRoot);
|
7761
|
-
syncStateFromUrl(this._sceneRoot,
|
7768
|
+
syncStateFromUrl(this._sceneRoot, this._urlParams, this._urlKeyMapper);
|
7762
7769
|
this._lastPath = location.pathname;
|
7763
7770
|
};
|
7764
7771
|
this._onStateChanged = ({ payload }) => {
|
@@ -7791,8 +7798,10 @@ class UrlSyncManager {
|
|
7791
7798
|
writeSceneLog("UrlSyncManager", "Unregister previous scene state subscription", this._sceneRoot.state.key);
|
7792
7799
|
this._stateSub.unsubscribe();
|
7793
7800
|
}
|
7801
|
+
const location = runtime.locationService.getLocation();
|
7794
7802
|
this._sceneRoot = root;
|
7795
|
-
this._lastPath =
|
7803
|
+
this._lastPath = location.pathname;
|
7804
|
+
this._urlParams = new URLSearchParams(location.search);
|
7796
7805
|
this._stateSub = root.subscribeToEvent(SceneObjectStateChangedEvent, this._onStateChanged);
|
7797
7806
|
this.syncFrom(this._sceneRoot);
|
7798
7807
|
}
|
@@ -7822,6 +7831,12 @@ class UrlSyncManager {
|
|
7822
7831
|
this._urlKeyMapper.rebuildIndex(this._sceneRoot);
|
7823
7832
|
syncStateFromUrl(sceneObj, urlParams, this._urlKeyMapper);
|
7824
7833
|
}
|
7834
|
+
syncNewObj(obj) {
|
7835
|
+
if (!this._urlParams) {
|
7836
|
+
throw new Error("UrlSyncManager not initialized");
|
7837
|
+
}
|
7838
|
+
syncStateFromUrl(obj, this._urlParams, this._urlKeyMapper);
|
7839
|
+
}
|
7825
7840
|
getUrlState(root) {
|
7826
7841
|
return getUrlState(root);
|
7827
7842
|
}
|
@@ -7865,7 +7880,7 @@ EmbeddedScene.Component = EmbeddedSceneRenderer;
|
|
7865
7880
|
function EmbeddedSceneRenderer({ model }) {
|
7866
7881
|
const { body, controls } = model.useState();
|
7867
7882
|
const styles = ui.useStyles2(getStyles$5);
|
7868
|
-
|
7883
|
+
const inner = /* @__PURE__ */ React__default["default"].createElement("div", {
|
7869
7884
|
className: styles.container
|
7870
7885
|
}, controls && /* @__PURE__ */ React__default["default"].createElement("div", {
|
7871
7886
|
className: styles.controls
|
@@ -7877,6 +7892,7 @@ function EmbeddedSceneRenderer({ model }) {
|
|
7877
7892
|
}, /* @__PURE__ */ React__default["default"].createElement(body.Component, {
|
7878
7893
|
model: body
|
7879
7894
|
})));
|
7895
|
+
return inner;
|
7880
7896
|
}
|
7881
7897
|
const getStyles$5 = (theme) => {
|
7882
7898
|
return {
|
@@ -10935,6 +10951,174 @@ const PanelBuilders = {
|
|
10935
10951
|
}
|
10936
10952
|
};
|
10937
10953
|
|
10954
|
+
class VizConfigBuilder {
|
10955
|
+
constructor(pluginId, pluginVersion, defaultOptions, defaultFieldConfig) {
|
10956
|
+
this._pluginId = pluginId;
|
10957
|
+
this._pluginVersion = pluginVersion;
|
10958
|
+
this._fieldConfigBuilder = new FieldConfigBuilder(defaultFieldConfig);
|
10959
|
+
this._panelOptionsBuilder = new PanelOptionsBuilder(defaultOptions);
|
10960
|
+
}
|
10961
|
+
setColor(color) {
|
10962
|
+
this._fieldConfigBuilder.setColor(color);
|
10963
|
+
return this;
|
10964
|
+
}
|
10965
|
+
setDecimals(decimals) {
|
10966
|
+
this._fieldConfigBuilder.setDecimals(decimals);
|
10967
|
+
return this;
|
10968
|
+
}
|
10969
|
+
setDisplayName(displayName) {
|
10970
|
+
this._fieldConfigBuilder.setDisplayName(displayName);
|
10971
|
+
return this;
|
10972
|
+
}
|
10973
|
+
setFilterable(filterable) {
|
10974
|
+
this._fieldConfigBuilder.setFilterable(filterable);
|
10975
|
+
return this;
|
10976
|
+
}
|
10977
|
+
setLinks(links) {
|
10978
|
+
this._fieldConfigBuilder.setLinks(links);
|
10979
|
+
return this;
|
10980
|
+
}
|
10981
|
+
setMappings(mappings) {
|
10982
|
+
this._fieldConfigBuilder.setMappings(mappings);
|
10983
|
+
return this;
|
10984
|
+
}
|
10985
|
+
setMax(max) {
|
10986
|
+
this._fieldConfigBuilder.setMax(max);
|
10987
|
+
return this;
|
10988
|
+
}
|
10989
|
+
setMin(min) {
|
10990
|
+
this._fieldConfigBuilder.setMin(min);
|
10991
|
+
return this;
|
10992
|
+
}
|
10993
|
+
setNoValue(noValue) {
|
10994
|
+
this._fieldConfigBuilder.setNoValue(noValue);
|
10995
|
+
return this;
|
10996
|
+
}
|
10997
|
+
setThresholds(thresholds) {
|
10998
|
+
this._fieldConfigBuilder.setThresholds(thresholds);
|
10999
|
+
return this;
|
11000
|
+
}
|
11001
|
+
setUnit(unit) {
|
11002
|
+
this._fieldConfigBuilder.setUnit(unit);
|
11003
|
+
return this;
|
11004
|
+
}
|
11005
|
+
setCustomFieldConfig(id, value) {
|
11006
|
+
this._fieldConfigBuilder.setCustomFieldConfig(id, value);
|
11007
|
+
return this;
|
11008
|
+
}
|
11009
|
+
setOverrides(builder) {
|
11010
|
+
this._fieldConfigBuilder.setOverrides(builder);
|
11011
|
+
return this;
|
11012
|
+
}
|
11013
|
+
setOption(id, value) {
|
11014
|
+
this._panelOptionsBuilder.setOption(id, value);
|
11015
|
+
return this;
|
11016
|
+
}
|
11017
|
+
build() {
|
11018
|
+
return {
|
11019
|
+
pluginId: this._pluginId,
|
11020
|
+
pluginVersion: this._pluginVersion,
|
11021
|
+
options: this._panelOptionsBuilder.build(),
|
11022
|
+
fieldConfig: this._fieldConfigBuilder.build()
|
11023
|
+
};
|
11024
|
+
}
|
11025
|
+
}
|
11026
|
+
|
11027
|
+
const VizConfigBuilders = {
|
11028
|
+
barchart() {
|
11029
|
+
return new VizConfigBuilder(
|
11030
|
+
"barchart",
|
11031
|
+
"10.0.0",
|
11032
|
+
() => BarChartPanelCfg_types_gen.defaultOptions,
|
11033
|
+
() => BarChartPanelCfg_types_gen.defaultFieldConfig
|
11034
|
+
);
|
11035
|
+
},
|
11036
|
+
bargauge() {
|
11037
|
+
return new VizConfigBuilder("bargauge", "10.0.0", () => BarGaugePanelCfg_types_gen.defaultOptions);
|
11038
|
+
},
|
11039
|
+
datagrid() {
|
11040
|
+
return new VizConfigBuilder("datagrid", "10.0.0", () => DatagridPanelCfg_types_gen.defaultOptions);
|
11041
|
+
},
|
11042
|
+
flamegraph() {
|
11043
|
+
return new VizConfigBuilder("flamegraph", "10.0.0");
|
11044
|
+
},
|
11045
|
+
gauge() {
|
11046
|
+
return new VizConfigBuilder("gauge", "10.0.0", () => GaugePanelCfg_types_gen.defaultOptions);
|
11047
|
+
},
|
11048
|
+
geomap() {
|
11049
|
+
return new VizConfigBuilder("geomap", "10.0.0", () => GeomapPanelCfg_types_gen.defaultOptions);
|
11050
|
+
},
|
11051
|
+
heatmap() {
|
11052
|
+
return new VizConfigBuilder("heatmap", "10.0.0", () => HeatmapPanelCfg_types_gen.defaultOptions);
|
11053
|
+
},
|
11054
|
+
histogram() {
|
11055
|
+
return new VizConfigBuilder(
|
11056
|
+
"histogram",
|
11057
|
+
"10.0.0",
|
11058
|
+
() => HistogramPanelCfg_types_gen.defaultOptions,
|
11059
|
+
() => HistogramPanelCfg_types_gen.defaultFieldConfig
|
11060
|
+
);
|
11061
|
+
},
|
11062
|
+
logs() {
|
11063
|
+
return new VizConfigBuilder("logs", "10.0.0");
|
11064
|
+
},
|
11065
|
+
news() {
|
11066
|
+
return new VizConfigBuilder("news", "10.0.0", () => NewsPanelCfg_types_gen.defaultOptions);
|
11067
|
+
},
|
11068
|
+
nodegraph() {
|
11069
|
+
return new VizConfigBuilder("nodeGraph", "10.0.0");
|
11070
|
+
},
|
11071
|
+
piechart() {
|
11072
|
+
return new VizConfigBuilder(
|
11073
|
+
"piechart",
|
11074
|
+
"10.0.0",
|
11075
|
+
() => PieChartPanelCfg_types_gen.defaultOptions
|
11076
|
+
);
|
11077
|
+
},
|
11078
|
+
stat() {
|
11079
|
+
return new VizConfigBuilder("stat", "10.0.0", () => StatPanelCfg_types_gen.defaultOptions);
|
11080
|
+
},
|
11081
|
+
statetimeline() {
|
11082
|
+
return new VizConfigBuilder(
|
11083
|
+
"state-timeline",
|
11084
|
+
"10.0.0",
|
11085
|
+
() => StateTimelinePanelCfg_types_gen.defaultOptions,
|
11086
|
+
() => StateTimelinePanelCfg_types_gen.defaultFieldConfig
|
11087
|
+
);
|
11088
|
+
},
|
11089
|
+
statushistory() {
|
11090
|
+
return new VizConfigBuilder(
|
11091
|
+
"status-history",
|
11092
|
+
"10.0.0",
|
11093
|
+
() => StatusHistoryPanelCfg_types_gen.defaultOptions,
|
11094
|
+
() => StatusHistoryPanelCfg_types_gen.defaultFieldConfig
|
11095
|
+
);
|
11096
|
+
},
|
11097
|
+
table() {
|
11098
|
+
return new VizConfigBuilder("table", "10.0.0", () => TablePanelCfg_types_gen.defaultOptions);
|
11099
|
+
},
|
11100
|
+
text() {
|
11101
|
+
return new VizConfigBuilder("text", "10.0.0", () => TextPanelCfg_types_gen.defaultOptions);
|
11102
|
+
},
|
11103
|
+
timeseries() {
|
11104
|
+
return new VizConfigBuilder("timeseries", "10.0.0");
|
11105
|
+
},
|
11106
|
+
trend() {
|
11107
|
+
return new VizConfigBuilder("trend", "10.0.0");
|
11108
|
+
},
|
11109
|
+
traces() {
|
11110
|
+
return new VizConfigBuilder("traces", "10.0.0");
|
11111
|
+
},
|
11112
|
+
xychart() {
|
11113
|
+
return new VizConfigBuilder(
|
11114
|
+
"xychart",
|
11115
|
+
"10.0.0",
|
11116
|
+
() => XYChartPanelCfg_types_gen.defaultOptions,
|
11117
|
+
() => XYChartPanelCfg_types_gen.defaultFieldConfig
|
11118
|
+
);
|
11119
|
+
}
|
11120
|
+
};
|
11121
|
+
|
10938
11122
|
const sceneUtils = {
|
10939
11123
|
getUrlWithAppState,
|
10940
11124
|
registerRuntimePanelPlugin,
|
@@ -10959,6 +11143,7 @@ exports.ConstantVariable = ConstantVariable;
|
|
10959
11143
|
exports.CustomVariable = CustomVariable;
|
10960
11144
|
exports.DataSourceVariable = DataSourceVariable;
|
10961
11145
|
exports.EmbeddedScene = EmbeddedScene;
|
11146
|
+
exports.FieldConfigBuilder = FieldConfigBuilder;
|
10962
11147
|
exports.FieldConfigBuilders = FieldConfigBuilders;
|
10963
11148
|
exports.FieldConfigOverridesBuilder = FieldConfigOverridesBuilder;
|
10964
11149
|
exports.GroupByVariable = GroupByVariable;
|
@@ -11013,7 +11198,10 @@ exports.UrlSyncManager = UrlSyncManager;
|
|
11013
11198
|
exports.UserActionEvent = UserActionEvent;
|
11014
11199
|
exports.VariableDependencyConfig = VariableDependencyConfig;
|
11015
11200
|
exports.VariableValueControl = VariableValueControl;
|
11201
|
+
exports.VariableValueSelectWrapper = VariableValueSelectWrapper;
|
11016
11202
|
exports.VariableValueSelectors = VariableValueSelectors;
|
11203
|
+
exports.VizConfigBuilder = VizConfigBuilder;
|
11204
|
+
exports.VizConfigBuilders = VizConfigBuilders;
|
11017
11205
|
exports.VizPanel = VizPanel;
|
11018
11206
|
exports.VizPanelBuilder = VizPanelBuilder;
|
11019
11207
|
exports.VizPanelMenu = VizPanelMenu;
|