@grafana/scenes 1.3.1 → 1.3.2
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# v1.3.2 (Mon Sep 18 2023)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- Annotations filtering operator: Correctly populate filtered frames [#343](https://github.com/grafana/scenes/pull/343) ([@dprokop](https://github.com/dprokop))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Dominik Prokop ([@dprokop](https://github.com/dprokop))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
1
13
|
# v1.3.1 (Mon Sep 18 2023)
|
|
2
14
|
|
|
3
15
|
#### 🐛 Bug Fix
|
|
@@ -26,10 +26,11 @@ const filterAnnotationsOperator = (filters) => (ctx) => (source) => {
|
|
|
26
26
|
if (!Array.isArray(data) || data.length === 0) {
|
|
27
27
|
return data;
|
|
28
28
|
}
|
|
29
|
-
const rows = /* @__PURE__ */ new Set();
|
|
29
|
+
const rows = Array.from({ length: data.length }, () => /* @__PURE__ */ new Set());
|
|
30
|
+
let frameIdx = 0;
|
|
30
31
|
for (const frame of data) {
|
|
31
32
|
for (let index = 0; index < frame.length; index++) {
|
|
32
|
-
if (rows.has(index)) {
|
|
33
|
+
if (rows[frameIdx].has(index)) {
|
|
33
34
|
continue;
|
|
34
35
|
}
|
|
35
36
|
let matching = true;
|
|
@@ -52,18 +53,20 @@ const filterAnnotationsOperator = (filters) => (ctx) => (source) => {
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
if (matching) {
|
|
55
|
-
rows.add(index);
|
|
56
|
+
rows[frameIdx].add(index);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
59
|
+
frameIdx++;
|
|
58
60
|
}
|
|
59
61
|
const processed = [];
|
|
60
|
-
|
|
62
|
+
frameIdx = 0;
|
|
61
63
|
for (const frame of data) {
|
|
64
|
+
const frameLength = rows[frameIdx].size;
|
|
62
65
|
const fields = [];
|
|
63
66
|
for (const field of frame.fields) {
|
|
64
67
|
const buffer = [];
|
|
65
68
|
for (let index = 0; index < frame.length; index++) {
|
|
66
|
-
if (rows.has(index)) {
|
|
69
|
+
if (rows[frameIdx].has(index)) {
|
|
67
70
|
buffer.push(field.values[index]);
|
|
68
71
|
continue;
|
|
69
72
|
}
|
|
@@ -76,6 +79,7 @@ const filterAnnotationsOperator = (filters) => (ctx) => (source) => {
|
|
|
76
79
|
fields,
|
|
77
80
|
length: frameLength
|
|
78
81
|
}));
|
|
82
|
+
frameIdx++;
|
|
79
83
|
}
|
|
80
84
|
return processed;
|
|
81
85
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterAnnotationsOperator.js","sources":["../../../../../src/querying/layers/annotations/filterAnnotationsOperator.ts"],"sourcesContent":["import { CustomTransformOperator, DataFrame, Field } from '@grafana/data';\nimport { map } from 'rxjs';\nimport { DataLayerFilter } from '../../../core/types';\n\n// Provided SceneDataLayerProviderResult is an array of DataFrames.\nexport const filterAnnotationsOperator: (filters: DataLayerFilter) => CustomTransformOperator =\n (filters) => (ctx) => (source) => {\n return source.pipe(\n map((data) => {\n if (!Array.isArray(data) || data.length === 0) {\n return data;\n }\n\n const rows = new Set<number>();\n\n for (const frame of data) {\n for (let index = 0; index < frame.length; index++) {\n if (rows.has(index)) {\n continue;\n }\n let matching = true;\n\n // Let's call those standard fields that annotations data frame has.\n // panelId is a standard field, but it's not always present. It's added to annotations that were added to a particular panel.\n const panelIdField = frame.fields.find((f) => f.name === 'panelId');\n // Source field contains annotation definition, with type and filters included.\n const sourceField = frame.fields.find((f) => f.name === 'source');\n\n if (sourceField) {\n // Here we are filtering Grafana annotations that were added to a particular panel.\n if (panelIdField && sourceField.values[index].type === 'dashboard') {\n matching = panelIdField.values[index] === filters.panelId;\n }\n\n const sourceFilter = sourceField.values[index].filter;\n\n // Here we are filtering based on annotation filter definition.\n // Those fitlers are: Show annotation in selected panels, Exclude annotation from selected panels.\n if (sourceFilter) {\n const includes = (sourceFilter.ids ?? []).includes(filters.panelId);\n if (sourceFilter.exclude) {\n if (includes) {\n matching = false;\n }\n } else if (!includes) {\n matching = false;\n }\n }\n }\n\n if (matching) {\n rows.add(index);\n }\n }\n }\n\n const processed: DataFrame[] = [];\n
|
|
1
|
+
{"version":3,"file":"filterAnnotationsOperator.js","sources":["../../../../../src/querying/layers/annotations/filterAnnotationsOperator.ts"],"sourcesContent":["import { CustomTransformOperator, DataFrame, Field } from '@grafana/data';\nimport { map } from 'rxjs';\nimport { DataLayerFilter } from '../../../core/types';\n\n// Provided SceneDataLayerProviderResult is an array of DataFrames.\nexport const filterAnnotationsOperator: (filters: DataLayerFilter) => CustomTransformOperator =\n (filters) => (ctx) => (source) => {\n return source.pipe(\n map((data) => {\n if (!Array.isArray(data) || data.length === 0) {\n return data;\n }\n\n const rows = Array.from({ length: data.length }, () => new Set<number>());\n\n let frameIdx = 0;\n for (const frame of data) {\n for (let index = 0; index < frame.length; index++) {\n if (rows[frameIdx].has(index)) {\n continue;\n }\n let matching = true;\n\n // Let's call those standard fields that annotations data frame has.\n // panelId is a standard field, but it's not always present. It's added to annotations that were added to a particular panel.\n const panelIdField = frame.fields.find((f) => f.name === 'panelId');\n // Source field contains annotation definition, with type and filters included.\n const sourceField = frame.fields.find((f) => f.name === 'source');\n\n if (sourceField) {\n // Here we are filtering Grafana annotations that were added to a particular panel.\n if (panelIdField && sourceField.values[index].type === 'dashboard') {\n matching = panelIdField.values[index] === filters.panelId;\n }\n\n const sourceFilter = sourceField.values[index].filter;\n\n // Here we are filtering based on annotation filter definition.\n // Those fitlers are: Show annotation in selected panels, Exclude annotation from selected panels.\n if (sourceFilter) {\n const includes = (sourceFilter.ids ?? []).includes(filters.panelId);\n if (sourceFilter.exclude) {\n if (includes) {\n matching = false;\n }\n } else if (!includes) {\n matching = false;\n }\n }\n }\n\n if (matching) {\n rows[frameIdx].add(index);\n }\n }\n frameIdx++;\n }\n\n const processed: DataFrame[] = [];\n\n frameIdx = 0;\n for (const frame of data) {\n const frameLength = rows[frameIdx].size;\n const fields: Field[] = [];\n\n for (const field of frame.fields) {\n const buffer = [];\n\n for (let index = 0; index < frame.length; index++) {\n if (rows[frameIdx].has(index)) {\n buffer.push(field.values[index]);\n continue;\n }\n }\n\n fields.push({\n ...field,\n values: buffer,\n });\n }\n\n processed.push({\n ...frame,\n fields: fields,\n length: frameLength,\n });\n frameIdx++;\n }\n return processed;\n })\n );\n };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAKO,MAAM,4BACX,CAAC,OAAA,KAAY,CAAC,GAAA,KAAQ,CAAC,MAAW,KAAA;AAChC,EAAA,OAAO,MAAO,CAAA,IAAA;AAAA,IACZ,GAAA,CAAI,CAAC,IAAS,KAAA;AARpB,MAAA,IAAA,EAAA,CAAA;AASQ,MAAA,IAAI,CAAC,KAAM,CAAA,OAAA,CAAQ,IAAI,CAAK,IAAA,IAAA,CAAK,WAAW,CAAG,EAAA;AAC7C,QAAO,OAAA,IAAA,CAAA;AAAA,OACT;AAEA,MAAM,MAAA,IAAA,GAAO,KAAM,CAAA,IAAA,CAAK,EAAE,MAAA,EAAQ,IAAK,CAAA,MAAA,EAAU,EAAA,sBAAU,IAAA,GAAA,EAAa,CAAA,CAAA;AAExE,MAAA,IAAI,QAAW,GAAA,CAAA,CAAA;AACf,MAAA,KAAA,MAAW,SAAS,IAAM,EAAA;AACxB,QAAA,KAAA,IAAS,KAAQ,GAAA,CAAA,EAAG,KAAQ,GAAA,KAAA,CAAM,QAAQ,KAAS,EAAA,EAAA;AACjD,UAAA,IAAI,IAAK,CAAA,QAAA,CAAA,CAAU,GAAI,CAAA,KAAK,CAAG,EAAA;AAC7B,YAAA,SAAA;AAAA,WACF;AACA,UAAA,IAAI,QAAW,GAAA,IAAA,CAAA;AAIf,UAA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AAK,QAAU,CAAA,CAAA,IAAA,CAAA;AACnC,QAAA,MAAM,SAAkB,EAAC,CAAA;AAEzB,QAAW,KAAA,MAAA,KAAA,IAAS,MAAM,MAAQ,EAAA;AAChC,UAAA,MAAM,SAAS,EAAC,CAAA;AAEhB,UAAA,KAAA,IAAS,KAAQ,GAAA,CAAA,EAAG,KAAQ,GAAA,KAAA,CAAM,QAAQ,KAAS,EAAA,EAAA;AACjD,YAAA,IAAI,IAAK,CAAA,QAAA,CAAA,CAAU,GAAI,CAAA,KAAK,CAAG,EAAA;AAC7B,cAAO,MAAA,CAAA,IAAA,CAAK,KAAM,CAAA,MAAA,CAAO,KAAM,CAAA,CAAA,CAAA;AAC/B,cAAA,SAAA;AAAA,aACF;AAAA,WACF;AAEA,UAAO,MAAA,CAAA,IAAA,CAAK,iCACP,KADO,CAAA,EAAA;AAAA,YAEV,MAAQ,EAAA,MAAA;AAAA,WACT,CAAA,CAAA,CAAA;AAAA,SACH;AAEA,QAAU,SAAA,CAAA,IAAA,CAAK,iCACV,KADU,CAAA,EAAA;AAAA,UAEb,MAAA;AAAA,UACA,MAAQ,EAAA,WAAA;AAAA,SACT,CAAA,CAAA,CAAA;AACD,QAAA,QAAA,EAAA,CAAA;AAAA,OACF;AACA,MAAO,OAAA,SAAA,CAAA;AAAA,KACR,CAAA;AAAA,GACH,CAAA;AACF;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -2768,10 +2768,11 @@ const filterAnnotationsOperator = (filters) => (ctx) => (source) => {
|
|
|
2768
2768
|
if (!Array.isArray(data) || data.length === 0) {
|
|
2769
2769
|
return data;
|
|
2770
2770
|
}
|
|
2771
|
-
const rows = /* @__PURE__ */ new Set();
|
|
2771
|
+
const rows = Array.from({ length: data.length }, () => /* @__PURE__ */ new Set());
|
|
2772
|
+
let frameIdx = 0;
|
|
2772
2773
|
for (const frame of data) {
|
|
2773
2774
|
for (let index = 0; index < frame.length; index++) {
|
|
2774
|
-
if (rows.has(index)) {
|
|
2775
|
+
if (rows[frameIdx].has(index)) {
|
|
2775
2776
|
continue;
|
|
2776
2777
|
}
|
|
2777
2778
|
let matching = true;
|
|
@@ -2794,18 +2795,20 @@ const filterAnnotationsOperator = (filters) => (ctx) => (source) => {
|
|
|
2794
2795
|
}
|
|
2795
2796
|
}
|
|
2796
2797
|
if (matching) {
|
|
2797
|
-
rows.add(index);
|
|
2798
|
+
rows[frameIdx].add(index);
|
|
2798
2799
|
}
|
|
2799
2800
|
}
|
|
2801
|
+
frameIdx++;
|
|
2800
2802
|
}
|
|
2801
2803
|
const processed = [];
|
|
2802
|
-
|
|
2804
|
+
frameIdx = 0;
|
|
2803
2805
|
for (const frame of data) {
|
|
2806
|
+
const frameLength = rows[frameIdx].size;
|
|
2804
2807
|
const fields = [];
|
|
2805
2808
|
for (const field of frame.fields) {
|
|
2806
2809
|
const buffer = [];
|
|
2807
2810
|
for (let index = 0; index < frame.length; index++) {
|
|
2808
|
-
if (rows.has(index)) {
|
|
2811
|
+
if (rows[frameIdx].has(index)) {
|
|
2809
2812
|
buffer.push(field.values[index]);
|
|
2810
2813
|
continue;
|
|
2811
2814
|
}
|
|
@@ -2818,6 +2821,7 @@ const filterAnnotationsOperator = (filters) => (ctx) => (source) => {
|
|
|
2818
2821
|
fields,
|
|
2819
2822
|
length: frameLength
|
|
2820
2823
|
}));
|
|
2824
|
+
frameIdx++;
|
|
2821
2825
|
}
|
|
2822
2826
|
return processed;
|
|
2823
2827
|
})
|