@grafana/scenes 5.23.3 → 5.23.4--canary.964.11745806385.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,6 +17,7 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ const GLOBAL_ANNOTATION_ID = 0;
20
21
  function filterAnnotations(data, filters) {
21
22
  var _a;
22
23
  if (!Array.isArray(data) || data.length === 0) {
@@ -34,11 +35,11 @@ function filterAnnotations(data, filters) {
34
35
  const sourceField = frame.fields.find((f) => f.name === "source");
35
36
  if (sourceField) {
36
37
  if (panelIdField && sourceField.values[index].type === "dashboard") {
37
- matching = panelIdField.values[index] === filters.panelId;
38
+ matching = [filters.panelId, GLOBAL_ANNOTATION_ID].includes(panelIdField.values[index]);
38
39
  }
39
40
  const sourceFilter = sourceField.values[index].filter;
40
41
  if (sourceFilter) {
41
- const includes = ((_a = sourceFilter.ids) != null ? _a : []).includes(filters.panelId);
42
+ const includes = [...(_a = sourceFilter.ids) != null ? _a : [], GLOBAL_ANNOTATION_ID].includes(filters.panelId);
42
43
  if (sourceFilter.exclude) {
43
44
  if (includes) {
44
45
  matching = false;
@@ -1 +1 @@
1
- {"version":3,"file":"filterAnnotations.js","sources":["../../../../../src/querying/layers/annotations/filterAnnotations.ts"],"sourcesContent":["import { DataFrame, Field } from '@grafana/data';\nimport { DataLayerFilter } from '../../../core/types';\n\n// Provided SceneDataLayerProviderResult is an array of DataFrames.\nexport function filterAnnotations(data: DataFrame[], filters: DataLayerFilter) {\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"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAIgB,SAAA,iBAAA,CAAkB,MAAmB,OAA0B,EAAA;AAJ/E,EAAA,IAAA,EAAA,CAAA;AAKE,EAAA,IAAI,CAAC,KAAM,CAAA,OAAA,CAAQ,IAAI,CAAK,IAAA,IAAA,CAAK,WAAW,CAAG,EAAA;AAC7C,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAM,MAAA,IAAA,GAAO,KAAM,CAAA,IAAA,CAAK,EAAE,MAAA,EAAQ,IAAK,CAAA,MAAA,EAAU,EAAA,sBAAU,IAAA,GAAA,EAAa,CAAA,CAAA;AAExE,EAAA,IAAI,QAAW,GAAA,CAAA,CAAA;AACf,EAAA,KAAA,MAAW,SAAS,IAAM,EAA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AA,QAAA,CAAA,CAAU,IAAI,KAAK,CAAA,CAAA;AAAA,OAC1B;AAAA,KACF;AACA,IAAA,QAAA,EAAA,CAAA;AAAA,GACF;AAEA,EAAA,MAAM,YAAyB,EAAC,CAAA;AAEhC,EAAW,QAAA,GAAA,CAAA,CAAA;AACX,EAAA,KAAA,MAAW,SAAS,IAAM,EAAA;AACxB,IAAM,MAAA,WAAA,GAAc,KAAK,QAAU,CAAA,CAAA,IAAA,CAAA;AACnC,IAAA,MAAM,SAAkB,EAAC,CAAA;AAEzB,IAAW,KAAA,MAAA,KAAA,IAAS,MAAM,MAAQ,EAAA;AAChC,MAAA,MAAM,SAAS,EAAC,CAAA;AAEhB,MAAA,KAAA,IAAS,KAAQ,GAAA,CAAA,EAAG,KAAQ,GAAA,KAAA,CAAM,QAAQ,KAAS,EAAA,EAAA;AACjD,QAAA,IAAI,IAAK,CAAA,QAAA,CAAA,CAAU,GAAI,CAAA,KAAK,CAAG,EAAA;AAC7B,UAAO,MAAA,CAAA,IAAA,CAAK,KAAM,CAAA,MAAA,CAAO,KAAM,CAAA,CAAA,CAAA;AAC/B,UAAA,SAAA;AAAA,SACF;AAAA,OACF;AAEA,MAAO,MAAA,CAAA,IAAA,CAAK,iCACP,KADO,CAAA,EAAA;AAAA,QAEV,MAAQ,EAAA,MAAA;AAAA,OACT,CAAA,CAAA,CAAA;AAAA,KACH;AAEA,IAAU,SAAA,CAAA,IAAA,CAAK,iCACV,KADU,CAAA,EAAA;AAAA,MAEb,MAAA;AAAA,MACA,MAAQ,EAAA,WAAA;AAAA,KACT,CAAA,CAAA,CAAA;AACD,IAAA,QAAA,EAAA,CAAA;AAAA,GACF;AACA,EAAO,OAAA,SAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"filterAnnotations.js","sources":["../../../../../src/querying/layers/annotations/filterAnnotations.ts"],"sourcesContent":["import { DataFrame, Field } from '@grafana/data';\nimport { DataLayerFilter } from '../../../core/types';\n\nconst GLOBAL_ANNOTATION_ID = 0;\n\n// Provided SceneDataLayerProviderResult is an array of DataFrames.\nexport function filterAnnotations(data: DataFrame[], filters: DataLayerFilter) {\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 = [filters.panelId, GLOBAL_ANNOTATION_ID].includes(panelIdField.values[index]);\n }\n\n const sourceFilter = sourceField.values[index].filter;\n\n // Here we are filtering based on annotation filter definition.\n // Those filters are: Show annotation in selected panels, Exclude annotation from selected panels.\n if (sourceFilter) {\n const includes = ([...(sourceFilter.ids ?? []), GLOBAL_ANNOTATION_ID]).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\n return processed;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAGA,MAAM,oBAAuB,GAAA,C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AAAA,SACF;AAAA,OACF;AAEA,MAAO,MAAA,CAAA,IAAA,CAAK,iCACP,KADO,CAAA,EAAA;AAAA,QAEV,MAAQ,EAAA,MAAA;AAAA,OACT,CAAA,CAAA,CAAA;AAAA,KACH;AAEA,IAAU,SAAA,CAAA,IAAA,CAAK,iCACV,KADU,CAAA,EAAA;AAAA,MAEb,MAAA;AAAA,MACA,MAAQ,EAAA,WAAA;AAAA,KACT,CAAA,CAAA,CAAA;AACD,IAAA,QAAA,EAAA,CAAA;AAAA,GACF;AAEA,EAAO,OAAA,SAAA,CAAA;AACT;;;;"}
package/dist/index.js CHANGED
@@ -2343,6 +2343,7 @@ var __spreadValues$G = (a, b) => {
2343
2343
  return a;
2344
2344
  };
2345
2345
  var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
2346
+ const GLOBAL_ANNOTATION_ID = 0;
2346
2347
  function filterAnnotations(data, filters) {
2347
2348
  var _a;
2348
2349
  if (!Array.isArray(data) || data.length === 0) {
@@ -2360,11 +2361,11 @@ function filterAnnotations(data, filters) {
2360
2361
  const sourceField = frame.fields.find((f) => f.name === "source");
2361
2362
  if (sourceField) {
2362
2363
  if (panelIdField && sourceField.values[index].type === "dashboard") {
2363
- matching = panelIdField.values[index] === filters.panelId;
2364
+ matching = [filters.panelId, GLOBAL_ANNOTATION_ID].includes(panelIdField.values[index]);
2364
2365
  }
2365
2366
  const sourceFilter = sourceField.values[index].filter;
2366
2367
  if (sourceFilter) {
2367
- const includes = ((_a = sourceFilter.ids) != null ? _a : []).includes(filters.panelId);
2368
+ const includes = [...(_a = sourceFilter.ids) != null ? _a : [], GLOBAL_ANNOTATION_ID].includes(filters.panelId);
2368
2369
  if (sourceFilter.exclude) {
2369
2370
  if (includes) {
2370
2371
  matching = false;