@grafana/scenes 6.47.0--canary.1236.19342243048.0 → 6.47.0--canary.1302.19359467581.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/VizPanel/VizPanelRenderer.js +1 -1
- package/dist/esm/components/VizPanel/VizPanelRenderer.js.map +1 -1
- package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
- package/dist/esm/variables/types.js.map +1 -1
- package/dist/esm/variables/variants/CustomVariable.js +1 -19
- package/dist/esm/variables/variants/CustomVariable.js.map +1 -1
- package/dist/esm/variables/variants/LocalValueVariable.js +3 -16
- package/dist/esm/variables/variants/LocalValueVariable.js.map +1 -1
- package/dist/esm/variables/variants/MultiValueVariable.js +18 -39
- package/dist/esm/variables/variants/MultiValueVariable.js.map +1 -1
- package/dist/esm/variables/variants/query/toMetricFindValues.js +42 -65
- package/dist/esm/variables/variants/query/toMetricFindValues.js.map +1 -1
- package/dist/esm/variables/variants/query/utils.js +1 -1
- package/dist/esm/variables/variants/query/utils.js.map +1 -1
- package/dist/index.d.ts +8 -19
- package/dist/index.js +64 -137
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1774,7 +1774,7 @@ function isRepeatCloneOrChildOf(scene) {
|
|
|
1774
1774
|
return false;
|
|
1775
1775
|
}
|
|
1776
1776
|
|
|
1777
|
-
|
|
1777
|
+
class MultiValueVariable extends SceneObjectBase {
|
|
1778
1778
|
constructor() {
|
|
1779
1779
|
super(...arguments);
|
|
1780
1780
|
this._urlSync = new MultiValueUrlSyncHandler(this);
|
|
@@ -1865,7 +1865,7 @@ const _MultiValueVariable = class _MultiValueVariable extends SceneObjectBase {
|
|
|
1865
1865
|
} else {
|
|
1866
1866
|
const defaultState = this.getDefaultSingleState(options);
|
|
1867
1867
|
stateUpdate.value = defaultState.value;
|
|
1868
|
-
stateUpdate.text = defaultState.
|
|
1868
|
+
stateUpdate.text = defaultState.text;
|
|
1869
1869
|
}
|
|
1870
1870
|
return stateUpdate;
|
|
1871
1871
|
}
|
|
@@ -1887,35 +1887,16 @@ const _MultiValueVariable = class _MultiValueVariable extends SceneObjectBase {
|
|
|
1887
1887
|
if (this.state.allValue) {
|
|
1888
1888
|
return new CustomAllValue(this.state.allValue, this);
|
|
1889
1889
|
}
|
|
1890
|
-
value = this.state.options.map((
|
|
1890
|
+
value = this.state.options.map((x) => x.value);
|
|
1891
1891
|
}
|
|
1892
|
-
if (fieldPath != null) {
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
return value[index];
|
|
1897
|
-
}
|
|
1898
|
-
const accesor2 = this.getFieldAccessor(fieldPath);
|
|
1899
|
-
return value.map((v) => {
|
|
1900
|
-
const o2 = this.state.options.find((o3) => o3.value === v);
|
|
1901
|
-
return o2 ? accesor2(o2.properties) : v;
|
|
1902
|
-
});
|
|
1903
|
-
}
|
|
1904
|
-
const accesor = this.getFieldAccessor(fieldPath);
|
|
1905
|
-
const o = this.state.options.find((o2) => o2.value === value);
|
|
1906
|
-
if (o) {
|
|
1907
|
-
return accesor(o.properties);
|
|
1892
|
+
if (fieldPath != null && Array.isArray(value)) {
|
|
1893
|
+
const index = parseInt(fieldPath, 10);
|
|
1894
|
+
if (!isNaN(index) && index >= 0 && index < value.length) {
|
|
1895
|
+
return value[index];
|
|
1908
1896
|
}
|
|
1909
1897
|
}
|
|
1910
1898
|
return value;
|
|
1911
1899
|
}
|
|
1912
|
-
getFieldAccessor(fieldPath) {
|
|
1913
|
-
const accessor = _MultiValueVariable.fieldAccessorCache[fieldPath];
|
|
1914
|
-
if (accessor) {
|
|
1915
|
-
return accessor;
|
|
1916
|
-
}
|
|
1917
|
-
return _MultiValueVariable.fieldAccessorCache[fieldPath] = lodash.property(fieldPath);
|
|
1918
|
-
}
|
|
1919
1900
|
getValueText() {
|
|
1920
1901
|
if (this.hasAllValue()) {
|
|
1921
1902
|
return ALL_VARIABLE_TEXT;
|
|
@@ -1933,18 +1914,18 @@ const _MultiValueVariable = class _MultiValueVariable extends SceneObjectBase {
|
|
|
1933
1914
|
if (this.state.defaultToAll) {
|
|
1934
1915
|
return { value: [ALL_VARIABLE_VALUE], text: [ALL_VARIABLE_TEXT] };
|
|
1935
1916
|
} else if (options.length > 0) {
|
|
1936
|
-
return { value: [options[0].value], text: [options[0].label]
|
|
1917
|
+
return { value: [options[0].value], text: [options[0].label] };
|
|
1937
1918
|
} else {
|
|
1938
1919
|
return { value: [], text: [] };
|
|
1939
1920
|
}
|
|
1940
1921
|
}
|
|
1941
1922
|
getDefaultSingleState(options) {
|
|
1942
1923
|
if (this.state.defaultToAll) {
|
|
1943
|
-
return { value: ALL_VARIABLE_VALUE,
|
|
1924
|
+
return { value: ALL_VARIABLE_VALUE, text: ALL_VARIABLE_TEXT };
|
|
1944
1925
|
} else if (options.length > 0) {
|
|
1945
|
-
return { value: options[0].value,
|
|
1926
|
+
return { value: options[0].value, text: options[0].label };
|
|
1946
1927
|
} else {
|
|
1947
|
-
return { value: "",
|
|
1928
|
+
return { value: "", text: "" };
|
|
1948
1929
|
}
|
|
1949
1930
|
}
|
|
1950
1931
|
/**
|
|
@@ -2029,17 +2010,15 @@ const _MultiValueVariable = class _MultiValueVariable extends SceneObjectBase {
|
|
|
2029
2010
|
this.updateValueGivenNewOptions(options);
|
|
2030
2011
|
});
|
|
2031
2012
|
}
|
|
2032
|
-
}
|
|
2033
|
-
_MultiValueVariable.fieldAccessorCache = {};
|
|
2034
|
-
let MultiValueVariable = _MultiValueVariable;
|
|
2013
|
+
}
|
|
2035
2014
|
function findOptionMatchingCurrent(currentValue, currentText, options) {
|
|
2036
2015
|
let textMatch;
|
|
2037
|
-
for (const
|
|
2038
|
-
if (
|
|
2039
|
-
return
|
|
2016
|
+
for (const item of options) {
|
|
2017
|
+
if (item.value === currentValue) {
|
|
2018
|
+
return item;
|
|
2040
2019
|
}
|
|
2041
|
-
if (
|
|
2042
|
-
textMatch =
|
|
2020
|
+
if (item.label === currentText) {
|
|
2021
|
+
textMatch = item;
|
|
2043
2022
|
}
|
|
2044
2023
|
}
|
|
2045
2024
|
return textMatch;
|
|
@@ -4143,7 +4122,7 @@ function VizPanelRenderer({ model }) {
|
|
|
4143
4122
|
height,
|
|
4144
4123
|
selectionId: model.state.key,
|
|
4145
4124
|
displayMode,
|
|
4146
|
-
titleItems: titleItemsElement,
|
|
4125
|
+
titleItems: titleItemsElement.length > 0 ? titleItemsElement : void 0,
|
|
4147
4126
|
dragClass,
|
|
4148
4127
|
actions: actionsElement,
|
|
4149
4128
|
dragClassCancel,
|
|
@@ -9455,7 +9434,7 @@ function metricNamesToVariableValues(variableRegEx, sort, metricNames) {
|
|
|
9455
9434
|
value = firstMatch[1];
|
|
9456
9435
|
}
|
|
9457
9436
|
}
|
|
9458
|
-
options.push({ label: text, value
|
|
9437
|
+
options.push({ label: text, value });
|
|
9459
9438
|
}
|
|
9460
9439
|
options = lodash.uniqBy(options, "value");
|
|
9461
9440
|
return sortVariableValues(options, sort);
|
|
@@ -9529,7 +9508,7 @@ function sortByNaturalSort(options) {
|
|
|
9529
9508
|
});
|
|
9530
9509
|
}
|
|
9531
9510
|
|
|
9532
|
-
function toMetricFindValues(
|
|
9511
|
+
function toMetricFindValues() {
|
|
9533
9512
|
return (source) => source.pipe(
|
|
9534
9513
|
rxjs.map((panelData) => {
|
|
9535
9514
|
const frames = panelData.series;
|
|
@@ -9542,81 +9521,58 @@ function toMetricFindValues(valueProp, textProp) {
|
|
|
9542
9521
|
if (frames[0].fields.length === 0) {
|
|
9543
9522
|
return [];
|
|
9544
9523
|
}
|
|
9545
|
-
const
|
|
9546
|
-
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9524
|
+
const processedDataFrames = data.getProcessedDataFrames(frames);
|
|
9525
|
+
const metrics = [];
|
|
9526
|
+
let valueIndex = -1;
|
|
9527
|
+
let textIndex = -1;
|
|
9528
|
+
let stringIndex = -1;
|
|
9529
|
+
let expandableIndex = -1;
|
|
9530
|
+
for (const frame of processedDataFrames) {
|
|
9531
|
+
for (let index = 0; index < frame.fields.length; index++) {
|
|
9532
|
+
const field = frame.fields[index];
|
|
9533
|
+
const fieldName = data.getFieldDisplayName(field, frame, frames).toLowerCase();
|
|
9534
|
+
if (field.type === data.FieldType.string && stringIndex === -1) {
|
|
9535
|
+
stringIndex = index;
|
|
9536
|
+
}
|
|
9537
|
+
if (fieldName === "text" && field.type === data.FieldType.string && textIndex === -1) {
|
|
9538
|
+
textIndex = index;
|
|
9539
|
+
}
|
|
9540
|
+
if (fieldName === "value" && field.type === data.FieldType.string && valueIndex === -1) {
|
|
9541
|
+
valueIndex = index;
|
|
9542
|
+
}
|
|
9543
|
+
if (fieldName === "expandable" && (field.type === data.FieldType.boolean || field.type === data.FieldType.number) && expandableIndex === -1) {
|
|
9544
|
+
expandableIndex = index;
|
|
9545
|
+
}
|
|
9546
|
+
}
|
|
9552
9547
|
}
|
|
9553
|
-
if (
|
|
9554
|
-
throw new Error("
|
|
9548
|
+
if (stringIndex === -1) {
|
|
9549
|
+
throw new Error("Couldn't find any field of type string in the results.");
|
|
9555
9550
|
}
|
|
9556
|
-
const metrics = [];
|
|
9557
9551
|
for (const frame of frames) {
|
|
9558
9552
|
for (let index = 0; index < frame.length; index++) {
|
|
9559
|
-
const
|
|
9560
|
-
const
|
|
9561
|
-
const
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
text: text || value,
|
|
9566
|
-
expandable
|
|
9567
|
-
});
|
|
9553
|
+
const expandable = expandableIndex !== -1 ? frame.fields[expandableIndex].values.get(index) : void 0;
|
|
9554
|
+
const string = frame.fields[stringIndex].values.get(index);
|
|
9555
|
+
const text = textIndex !== -1 ? frame.fields[textIndex].values.get(index) : "";
|
|
9556
|
+
const value = valueIndex !== -1 ? frame.fields[valueIndex].values.get(index) : "";
|
|
9557
|
+
if (valueIndex === -1 && textIndex === -1) {
|
|
9558
|
+
metrics.push({ text: string, value: string, expandable });
|
|
9568
9559
|
continue;
|
|
9569
9560
|
}
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
}
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
});
|
|
9561
|
+
if (valueIndex === -1 && textIndex !== -1) {
|
|
9562
|
+
metrics.push({ text, value: text, expandable });
|
|
9563
|
+
continue;
|
|
9564
|
+
}
|
|
9565
|
+
if (valueIndex !== -1 && textIndex === -1) {
|
|
9566
|
+
metrics.push({ text: value, value, expandable });
|
|
9567
|
+
continue;
|
|
9568
|
+
}
|
|
9569
|
+
metrics.push({ text, value, expandable });
|
|
9580
9570
|
}
|
|
9581
9571
|
}
|
|
9582
9572
|
return metrics;
|
|
9583
9573
|
})
|
|
9584
9574
|
);
|
|
9585
9575
|
}
|
|
9586
|
-
function findFieldsIndices(frames) {
|
|
9587
|
-
const indices = {
|
|
9588
|
-
value: -1,
|
|
9589
|
-
text: -1,
|
|
9590
|
-
properties: [],
|
|
9591
|
-
expandable: -1
|
|
9592
|
-
};
|
|
9593
|
-
for (const frame of data.getProcessedDataFrames(frames)) {
|
|
9594
|
-
for (let index = 0; index < frame.fields.length; index++) {
|
|
9595
|
-
const field = frame.fields[index];
|
|
9596
|
-
const fieldName = data.getFieldDisplayName(field, frame, frames).toLowerCase();
|
|
9597
|
-
if (field.type === data.FieldType.string) {
|
|
9598
|
-
if (fieldName === "value") {
|
|
9599
|
-
if (indices.value === -1) {
|
|
9600
|
-
indices.value = index;
|
|
9601
|
-
}
|
|
9602
|
-
continue;
|
|
9603
|
-
}
|
|
9604
|
-
if (fieldName === "text") {
|
|
9605
|
-
if (indices.text === -1) {
|
|
9606
|
-
indices.text = index;
|
|
9607
|
-
}
|
|
9608
|
-
continue;
|
|
9609
|
-
}
|
|
9610
|
-
indices.properties.push({ name: fieldName, index });
|
|
9611
|
-
continue;
|
|
9612
|
-
}
|
|
9613
|
-
if (fieldName === "expandable" && (field.type === data.FieldType.boolean || field.type === data.FieldType.number) && indices.expandable === -1) {
|
|
9614
|
-
indices.expandable = index;
|
|
9615
|
-
}
|
|
9616
|
-
}
|
|
9617
|
-
}
|
|
9618
|
-
return indices;
|
|
9619
|
-
}
|
|
9620
9576
|
function areMetricFindValues(data$1) {
|
|
9621
9577
|
if (!data$1) {
|
|
9622
9578
|
return false;
|
|
@@ -10020,7 +9976,7 @@ const sceneGraph = {
|
|
|
10020
9976
|
getScopes
|
|
10021
9977
|
};
|
|
10022
9978
|
|
|
10023
|
-
|
|
9979
|
+
class LocalValueVariable extends SceneObjectBase {
|
|
10024
9980
|
constructor(initialState) {
|
|
10025
9981
|
super({
|
|
10026
9982
|
type: "system",
|
|
@@ -10031,19 +9987,9 @@ const _LocalValueVariable = class _LocalValueVariable extends SceneObjectBase {
|
|
|
10031
9987
|
skipUrlSync: true
|
|
10032
9988
|
});
|
|
10033
9989
|
}
|
|
10034
|
-
getValue(
|
|
10035
|
-
if (fieldPath != null && this.state.properties) {
|
|
10036
|
-
return this.getFieldAccessor(fieldPath)(this.state.properties);
|
|
10037
|
-
}
|
|
9990
|
+
getValue() {
|
|
10038
9991
|
return this.state.value;
|
|
10039
9992
|
}
|
|
10040
|
-
getFieldAccessor(fieldPath) {
|
|
10041
|
-
const accessor = _LocalValueVariable.fieldAccessorCache[fieldPath];
|
|
10042
|
-
if (accessor) {
|
|
10043
|
-
return accessor;
|
|
10044
|
-
}
|
|
10045
|
-
return _LocalValueVariable.fieldAccessorCache[fieldPath] = lodash.property(fieldPath);
|
|
10046
|
-
}
|
|
10047
9993
|
getValueText() {
|
|
10048
9994
|
return this.state.text.toString();
|
|
10049
9995
|
}
|
|
@@ -10064,9 +10010,7 @@ const _LocalValueVariable = class _LocalValueVariable extends SceneObjectBase {
|
|
|
10064
10010
|
}
|
|
10065
10011
|
return false;
|
|
10066
10012
|
}
|
|
10067
|
-
}
|
|
10068
|
-
_LocalValueVariable.fieldAccessorCache = {};
|
|
10069
|
-
let LocalValueVariable = _LocalValueVariable;
|
|
10013
|
+
}
|
|
10070
10014
|
|
|
10071
10015
|
const PATH_ID_SEPARATOR = "$";
|
|
10072
10016
|
function buildPathIdFor(panel) {
|
|
@@ -11863,7 +11807,6 @@ class CustomVariable extends MultiValueVariable {
|
|
|
11863
11807
|
super({
|
|
11864
11808
|
type: "custom",
|
|
11865
11809
|
query: "",
|
|
11866
|
-
valuesFormat: "csv",
|
|
11867
11810
|
value: "",
|
|
11868
11811
|
text: "",
|
|
11869
11812
|
options: [],
|
|
@@ -11892,24 +11835,8 @@ class CustomVariable extends MultiValueVariable {
|
|
|
11892
11835
|
}
|
|
11893
11836
|
});
|
|
11894
11837
|
}
|
|
11895
|
-
transformJsonToOptions(json) {
|
|
11896
|
-
const parsedOptions = JSON.parse(json);
|
|
11897
|
-
if (!Array.isArray(parsedOptions) || parsedOptions.some((o) => typeof o !== "object" || o === null)) {
|
|
11898
|
-
throw new Error("Query must be a JSON array of objects");
|
|
11899
|
-
}
|
|
11900
|
-
const textProp = "text";
|
|
11901
|
-
const valueProp = "value";
|
|
11902
|
-
return parsedOptions.map((o) => {
|
|
11903
|
-
var _a;
|
|
11904
|
-
return {
|
|
11905
|
-
label: (_a = String(o[textProp] || o[valueProp])) == null ? void 0 : _a.trim(),
|
|
11906
|
-
value: String(o[valueProp]).trim(),
|
|
11907
|
-
properties: lodash.omit(o, [textProp, valueProp])
|
|
11908
|
-
};
|
|
11909
|
-
});
|
|
11910
|
-
}
|
|
11911
11838
|
getValueOptions(args) {
|
|
11912
|
-
const options = this.
|
|
11839
|
+
const options = this.transformCsvStringToOptions(this.state.query);
|
|
11913
11840
|
if (!options.length) {
|
|
11914
11841
|
this.skipNextValidation = true;
|
|
11915
11842
|
}
|