@grafana/scenes 4.24.4 → 4.24.5--canary.734.9304046092.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -2046,7 +2046,11 @@ async function getDataSource(datasource, scopedVars) {
2046
2046
  }
2047
2047
 
2048
2048
  function writeSceneLog(logger, message, ...rest) {
2049
- if (window.grafanaSceneLogging) {
2049
+ let loggingEnabled = false;
2050
+ if (typeof window !== "undefined") {
2051
+ loggingEnabled = localStorage.getItem("grafana.debug.scenes") === "true";
2052
+ }
2053
+ if (loggingEnabled) {
2050
2054
  console.log(`${logger}: `, message, ...rest);
2051
2055
  }
2052
2056
  }
@@ -5272,6 +5276,9 @@ class VizPanel extends SceneObjectBase {
5272
5276
  (_a = this._panelContext) != null ? _a : this._panelContext = this.buildPanelContext();
5273
5277
  return this._panelContext;
5274
5278
  }
5279
+ clearFieldConfigCache() {
5280
+ this._dataWithFieldConfig = void 0;
5281
+ }
5275
5282
  applyFieldConfig(rawData) {
5276
5283
  var _a, _b, _c, _d;
5277
5284
  const plugin = this._plugin;
@@ -7775,6 +7782,7 @@ class UrlSyncManager {
7775
7782
  this._locationSub = null;
7776
7783
  this._ignoreNextLocationUpdate = false;
7777
7784
  this._onLocationUpdate = (location) => {
7785
+ this._urlParams = new URLSearchParams(location.search);
7778
7786
  if (this._ignoreNextLocationUpdate) {
7779
7787
  this._ignoreNextLocationUpdate = false;
7780
7788
  return;
@@ -7782,9 +7790,8 @@ class UrlSyncManager {
7782
7790
  if (this._lastPath !== location.pathname) {
7783
7791
  return;
7784
7792
  }
7785
- const urlParams = new URLSearchParams(location.search);
7786
7793
  this._urlKeyMapper.rebuildIndex(this._sceneRoot);
7787
- syncStateFromUrl(this._sceneRoot, urlParams, this._urlKeyMapper);
7794
+ syncStateFromUrl(this._sceneRoot, this._urlParams, this._urlKeyMapper);
7788
7795
  this._lastPath = location.pathname;
7789
7796
  };
7790
7797
  this._onStateChanged = ({ payload }) => {
@@ -7817,8 +7824,10 @@ class UrlSyncManager {
7817
7824
  writeSceneLog("UrlSyncManager", "Unregister previous scene state subscription", this._sceneRoot.state.key);
7818
7825
  this._stateSub.unsubscribe();
7819
7826
  }
7827
+ const location = runtime.locationService.getLocation();
7820
7828
  this._sceneRoot = root;
7821
- this._lastPath = runtime.locationService.getLocation().pathname;
7829
+ this._lastPath = location.pathname;
7830
+ this._urlParams = new URLSearchParams(location.search);
7822
7831
  this._stateSub = root.subscribeToEvent(SceneObjectStateChangedEvent, this._onStateChanged);
7823
7832
  this.syncFrom(this._sceneRoot);
7824
7833
  }
@@ -7891,7 +7900,7 @@ EmbeddedScene.Component = EmbeddedSceneRenderer;
7891
7900
  function EmbeddedSceneRenderer({ model }) {
7892
7901
  const { body, controls } = model.useState();
7893
7902
  const styles = ui.useStyles2(getStyles$5);
7894
- return /* @__PURE__ */ React__default["default"].createElement("div", {
7903
+ const inner = /* @__PURE__ */ React__default["default"].createElement("div", {
7895
7904
  className: styles.container
7896
7905
  }, controls && /* @__PURE__ */ React__default["default"].createElement("div", {
7897
7906
  className: styles.controls
@@ -7903,6 +7912,7 @@ function EmbeddedSceneRenderer({ model }) {
7903
7912
  }, /* @__PURE__ */ React__default["default"].createElement(body.Component, {
7904
7913
  model: body
7905
7914
  })));
7915
+ return inner;
7906
7916
  }
7907
7917
  const getStyles$5 = (theme) => {
7908
7918
  return {
@@ -10961,6 +10971,174 @@ const PanelBuilders = {
10961
10971
  }
10962
10972
  };
10963
10973
 
10974
+ class VizConfigBuilder {
10975
+ constructor(pluginId, pluginVersion, defaultOptions, defaultFieldConfig) {
10976
+ this._pluginId = pluginId;
10977
+ this._pluginVersion = pluginVersion;
10978
+ this._fieldConfigBuilder = new FieldConfigBuilder(defaultFieldConfig);
10979
+ this._panelOptionsBuilder = new PanelOptionsBuilder(defaultOptions);
10980
+ }
10981
+ setColor(color) {
10982
+ this._fieldConfigBuilder.setColor(color);
10983
+ return this;
10984
+ }
10985
+ setDecimals(decimals) {
10986
+ this._fieldConfigBuilder.setDecimals(decimals);
10987
+ return this;
10988
+ }
10989
+ setDisplayName(displayName) {
10990
+ this._fieldConfigBuilder.setDisplayName(displayName);
10991
+ return this;
10992
+ }
10993
+ setFilterable(filterable) {
10994
+ this._fieldConfigBuilder.setFilterable(filterable);
10995
+ return this;
10996
+ }
10997
+ setLinks(links) {
10998
+ this._fieldConfigBuilder.setLinks(links);
10999
+ return this;
11000
+ }
11001
+ setMappings(mappings) {
11002
+ this._fieldConfigBuilder.setMappings(mappings);
11003
+ return this;
11004
+ }
11005
+ setMax(max) {
11006
+ this._fieldConfigBuilder.setMax(max);
11007
+ return this;
11008
+ }
11009
+ setMin(min) {
11010
+ this._fieldConfigBuilder.setMin(min);
11011
+ return this;
11012
+ }
11013
+ setNoValue(noValue) {
11014
+ this._fieldConfigBuilder.setNoValue(noValue);
11015
+ return this;
11016
+ }
11017
+ setThresholds(thresholds) {
11018
+ this._fieldConfigBuilder.setThresholds(thresholds);
11019
+ return this;
11020
+ }
11021
+ setUnit(unit) {
11022
+ this._fieldConfigBuilder.setUnit(unit);
11023
+ return this;
11024
+ }
11025
+ setCustomFieldConfig(id, value) {
11026
+ this._fieldConfigBuilder.setCustomFieldConfig(id, value);
11027
+ return this;
11028
+ }
11029
+ setOverrides(builder) {
11030
+ this._fieldConfigBuilder.setOverrides(builder);
11031
+ return this;
11032
+ }
11033
+ setOption(id, value) {
11034
+ this._panelOptionsBuilder.setOption(id, value);
11035
+ return this;
11036
+ }
11037
+ build() {
11038
+ return {
11039
+ pluginId: this._pluginId,
11040
+ pluginVersion: this._pluginVersion,
11041
+ options: this._panelOptionsBuilder.build(),
11042
+ fieldConfig: this._fieldConfigBuilder.build()
11043
+ };
11044
+ }
11045
+ }
11046
+
11047
+ const VizConfigBuilders = {
11048
+ barchart() {
11049
+ return new VizConfigBuilder(
11050
+ "barchart",
11051
+ "10.0.0",
11052
+ () => BarChartPanelCfg_types_gen.defaultOptions,
11053
+ () => BarChartPanelCfg_types_gen.defaultFieldConfig
11054
+ );
11055
+ },
11056
+ bargauge() {
11057
+ return new VizConfigBuilder("bargauge", "10.0.0", () => BarGaugePanelCfg_types_gen.defaultOptions);
11058
+ },
11059
+ datagrid() {
11060
+ return new VizConfigBuilder("datagrid", "10.0.0", () => DatagridPanelCfg_types_gen.defaultOptions);
11061
+ },
11062
+ flamegraph() {
11063
+ return new VizConfigBuilder("flamegraph", "10.0.0");
11064
+ },
11065
+ gauge() {
11066
+ return new VizConfigBuilder("gauge", "10.0.0", () => GaugePanelCfg_types_gen.defaultOptions);
11067
+ },
11068
+ geomap() {
11069
+ return new VizConfigBuilder("geomap", "10.0.0", () => GeomapPanelCfg_types_gen.defaultOptions);
11070
+ },
11071
+ heatmap() {
11072
+ return new VizConfigBuilder("heatmap", "10.0.0", () => HeatmapPanelCfg_types_gen.defaultOptions);
11073
+ },
11074
+ histogram() {
11075
+ return new VizConfigBuilder(
11076
+ "histogram",
11077
+ "10.0.0",
11078
+ () => HistogramPanelCfg_types_gen.defaultOptions,
11079
+ () => HistogramPanelCfg_types_gen.defaultFieldConfig
11080
+ );
11081
+ },
11082
+ logs() {
11083
+ return new VizConfigBuilder("logs", "10.0.0");
11084
+ },
11085
+ news() {
11086
+ return new VizConfigBuilder("news", "10.0.0", () => NewsPanelCfg_types_gen.defaultOptions);
11087
+ },
11088
+ nodegraph() {
11089
+ return new VizConfigBuilder("nodeGraph", "10.0.0");
11090
+ },
11091
+ piechart() {
11092
+ return new VizConfigBuilder(
11093
+ "piechart",
11094
+ "10.0.0",
11095
+ () => PieChartPanelCfg_types_gen.defaultOptions
11096
+ );
11097
+ },
11098
+ stat() {
11099
+ return new VizConfigBuilder("stat", "10.0.0", () => StatPanelCfg_types_gen.defaultOptions);
11100
+ },
11101
+ statetimeline() {
11102
+ return new VizConfigBuilder(
11103
+ "state-timeline",
11104
+ "10.0.0",
11105
+ () => StateTimelinePanelCfg_types_gen.defaultOptions,
11106
+ () => StateTimelinePanelCfg_types_gen.defaultFieldConfig
11107
+ );
11108
+ },
11109
+ statushistory() {
11110
+ return new VizConfigBuilder(
11111
+ "status-history",
11112
+ "10.0.0",
11113
+ () => StatusHistoryPanelCfg_types_gen.defaultOptions,
11114
+ () => StatusHistoryPanelCfg_types_gen.defaultFieldConfig
11115
+ );
11116
+ },
11117
+ table() {
11118
+ return new VizConfigBuilder("table", "10.0.0", () => TablePanelCfg_types_gen.defaultOptions);
11119
+ },
11120
+ text() {
11121
+ return new VizConfigBuilder("text", "10.0.0", () => TextPanelCfg_types_gen.defaultOptions);
11122
+ },
11123
+ timeseries() {
11124
+ return new VizConfigBuilder("timeseries", "10.0.0");
11125
+ },
11126
+ trend() {
11127
+ return new VizConfigBuilder("trend", "10.0.0");
11128
+ },
11129
+ traces() {
11130
+ return new VizConfigBuilder("traces", "10.0.0");
11131
+ },
11132
+ xychart() {
11133
+ return new VizConfigBuilder(
11134
+ "xychart",
11135
+ "10.0.0",
11136
+ () => XYChartPanelCfg_types_gen.defaultOptions,
11137
+ () => XYChartPanelCfg_types_gen.defaultFieldConfig
11138
+ );
11139
+ }
11140
+ };
11141
+
10964
11142
  const sceneUtils = {
10965
11143
  getUrlWithAppState,
10966
11144
  registerRuntimePanelPlugin,
@@ -10985,6 +11163,7 @@ exports.ConstantVariable = ConstantVariable;
10985
11163
  exports.CustomVariable = CustomVariable;
10986
11164
  exports.DataSourceVariable = DataSourceVariable;
10987
11165
  exports.EmbeddedScene = EmbeddedScene;
11166
+ exports.FieldConfigBuilder = FieldConfigBuilder;
10988
11167
  exports.FieldConfigBuilders = FieldConfigBuilders;
10989
11168
  exports.FieldConfigOverridesBuilder = FieldConfigOverridesBuilder;
10990
11169
  exports.GroupByVariable = GroupByVariable;
@@ -11039,7 +11218,10 @@ exports.UrlSyncManager = UrlSyncManager;
11039
11218
  exports.UserActionEvent = UserActionEvent;
11040
11219
  exports.VariableDependencyConfig = VariableDependencyConfig;
11041
11220
  exports.VariableValueControl = VariableValueControl;
11221
+ exports.VariableValueSelectWrapper = VariableValueSelectWrapper;
11042
11222
  exports.VariableValueSelectors = VariableValueSelectors;
11223
+ exports.VizConfigBuilder = VizConfigBuilder;
11224
+ exports.VizConfigBuilders = VizConfigBuilders;
11043
11225
  exports.VizPanel = VizPanel;
11044
11226
  exports.VizPanelBuilder = VizPanelBuilder;
11045
11227
  exports.VizPanelMenu = VizPanelMenu;