@kong-ui-public/dashboard-renderer 0.33.8 → 0.34.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.
@@ -1,25 +1,25 @@
1
- import { ref as x, watchEffect as oe, inject as K, defineComponent as I, onUnmounted as X, computed as v, watch as ie, resolveComponent as $, unref as l, openBlock as d, createBlock as g, withCtx as _, createTextVNode as M, toDisplayString as F, renderSlot as U, createCommentVNode as D, useCssVars as B, createElementVNode as L, createVNode as T, mergeProps as ee, createSlots as te, createElementBlock as E, normalizeProps as se, guardReactiveProps as ce, resolveDynamicComponent as le, onMounted as ue, Fragment as de, renderList as pe, normalizeClass as ye, normalizeStyle as j } from "vue";
2
- import { SimpleChart as he, AnalyticsChart as me, TopNTable as fe, CsvExportModal as ve } from "@kong-ui-public/analytics-chart";
3
- import ge from "swrv";
1
+ import { ref as O, watchEffect as le, inject as B, defineComponent as k, onUnmounted as te, computed as g, watch as ue, resolveComponent as N, unref as l, openBlock as d, createBlock as _, withCtx as b, createTextVNode as U, toDisplayString as L, renderSlot as V, createCommentVNode as S, useCssVars as G, createElementVNode as K, createVNode as F, mergeProps as re, createSlots as ae, createElementBlock as R, normalizeProps as de, guardReactiveProps as pe, resolveDynamicComponent as ye, onMounted as he, Fragment as me, renderList as fe, normalizeClass as ve, normalizeStyle as Q } from "vue";
2
+ import { stripUnknownFilters as ge, Timeframe as _e, TimePeriods as ne, TIMEFRAME_LOOKUP as qe, formatTime as J, msToGranularity as be } from "@kong-ui-public/analytics-utilities";
3
+ import { SimpleChart as Ee, AnalyticsChart as Ce, TopNTable as Ie, CsvExportModal as Te } from "@kong-ui-public/analytics-chart";
4
+ import Se from "swrv";
4
5
  import "axios";
5
- import { createI18n as _e, i18nTComponent as qe } from "@kong-ui-public/i18n";
6
- import { stripUnknownFilters as be, Timeframe as Ce, TimePeriods as Ee, msToGranularity as Ie } from "@kong-ui-public/analytics-utilities";
7
- import { MetricsProvider as Se, MetricsConsumer as Te } from "@kong-ui-public/analytics-metric-provider";
8
- import { EntityLink as Re } from "@kong-ui-public/entities-shared";
9
- import { EditIcon as ke, MoreIcon as Ae } from "@kong/icons";
10
- import { useAnalyticsConfigStore as De } from "@kong-ui-public/analytics-config-store";
11
- var re = /* @__PURE__ */ ((a) => (a.VALIDATING = "VALIDATING", a.VALIDATING_HAS_DATA = "VALIDATING_HAS_DATA", a.PENDING = "PENDING", a.SUCCESS = "SUCCESS", a.SUCCESS_HAS_DATA = "SUCCESS_HAS_DATA", a.ERROR = "ERROR", a.STALE_IF_ERROR = "STALE_IF_ERROR", a))(re || {});
12
- const xe = (a) => {
6
+ import { createI18n as Re, i18nTComponent as ke } from "@kong-ui-public/i18n";
7
+ import { MetricsProvider as Ae, MetricsConsumer as De } from "@kong-ui-public/analytics-metric-provider";
8
+ import { EntityLink as xe } from "@kong-ui-public/entities-shared";
9
+ import { EditIcon as we, MoreIcon as Oe } from "@kong/icons";
10
+ import { useAnalyticsConfigStore as Fe } from "@kong-ui-public/analytics-config-store";
11
+ var oe = /* @__PURE__ */ ((a) => (a.VALIDATING = "VALIDATING", a.VALIDATING_HAS_DATA = "VALIDATING_HAS_DATA", a.PENDING = "PENDING", a.SUCCESS = "SUCCESS", a.SUCCESS_HAS_DATA = "SUCCESS_HAS_DATA", a.ERROR = "ERROR", a.STALE_IF_ERROR = "STALE_IF_ERROR", a))(oe || {});
12
+ const $e = (a) => {
13
13
  var t, e, r, s, o;
14
14
  return a ? !!// TODO: revisit: currently only the first check ever matters?
15
15
  ((t = Object.keys(a)) != null && t.length || (e = a.data) != null && e.length || (s = (r = a.data) == null ? void 0 : r.data) != null && s.length || !((o = a.data) != null && o.data) && typeof a.data == "object" && Object.keys(a == null ? void 0 : a.data).length) : !1;
16
16
  };
17
- function we(a = x({}), t, e, r = xe) {
18
- const s = x(
17
+ function Le(a = O({}), t, e, r = $e) {
18
+ const s = O(
19
19
  "PENDING"
20
20
  /* PENDING */
21
21
  );
22
- return oe(() => {
22
+ return le(() => {
23
23
  const o = r(a.value);
24
24
  if (a.value && o && e.value) {
25
25
  s.value = "VALIDATING_HAS_DATA";
@@ -48,10 +48,10 @@ function we(a = x({}), t, e, r = xe) {
48
48
  a.value === void 0 && t && (s.value = "ERROR");
49
49
  }), {
50
50
  state: s,
51
- swrvState: re
51
+ swrvState: oe
52
52
  };
53
53
  }
54
- const Oe = {
54
+ const Ne = {
55
55
  noQueryBridge: "No query bridge provided. Unable to render dashboard.",
56
56
  trendRange: {
57
57
  "24h": "Last 24-Hour Summary",
@@ -59,36 +59,36 @@ const Oe = {
59
59
  "30d": "Last 30-Day Summary"
60
60
  },
61
61
  edit: "Edit"
62
- }, Fe = {
62
+ }, ze = {
63
63
  timeRangeExceeded: "The time range for this report is outside of your organization's data retention period"
64
- }, $e = {
64
+ }, Ke = {
65
65
  defaultFilename: "Chart Export",
66
66
  exportAsCsv: "Export as CSV"
67
- }, Ne = "Explore", Le = {
68
- renderer: Oe,
69
- queryDataProvider: Fe,
70
- csvExport: $e,
71
- jumpToExplore: Ne
67
+ }, Be = "Explore", Pe = {
68
+ renderer: Ne,
69
+ queryDataProvider: ze,
70
+ csvExport: Ke,
71
+ jumpToExplore: Be
72
72
  };
73
- function Ke() {
74
- const a = _e("en-us", Le);
73
+ function Me() {
74
+ const a = Re("en-us", Pe);
75
75
  return {
76
76
  i18n: a,
77
- i18nT: qe(a)
77
+ i18nT: ke(a)
78
78
  // Translation component <i18n-t>
79
79
  };
80
80
  }
81
- const V = 170, z = "analytics-query-provider", Q = "{entity-id}", ze = "{cp-id}", Pe = "{timeframe}", Be = 30 * 1e3;
82
- function Ge() {
83
- const a = K(z);
81
+ const H = 170, P = "analytics-query-provider", Z = "{entity-id}", Ue = "{cp-id}", Ge = "{timeframe}", Ve = 30 * 1e3;
82
+ function He() {
83
+ const a = B(P);
84
84
  return {
85
85
  evaluateFeatureFlag: (e, r) => a ? a.evaluateFeatureFlagFn(e, r) : r
86
86
  };
87
87
  }
88
- const w = {
89
- useI18n: Ke,
90
- useEvaluateFeatureFlag: Ge
91
- }, H = /* @__PURE__ */ I({
88
+ const $ = {
89
+ useI18n: Me,
90
+ useEvaluateFeatureFlag: He
91
+ }, j = /* @__PURE__ */ k({
92
92
  __name: "QueryDataProvider",
93
93
  props: {
94
94
  context: {},
@@ -98,67 +98,73 @@ const w = {
98
98
  },
99
99
  emits: ["chart-data", "queryComplete"],
100
100
  setup(a, { emit: t }) {
101
- const e = a, r = t, { i18n: s } = w.useI18n(), o = K(z), c = () => e.queryReady && o ? JSON.stringify([e.query, e.context, e.refreshCounter]) : null, i = new AbortController();
102
- X(() => {
101
+ const e = a, r = t, { i18n: s } = $.useI18n(), o = B(P), c = () => e.queryReady && o ? JSON.stringify([e.query, e.context, e.refreshCounter]) : null, i = new AbortController();
102
+ te(() => {
103
103
  i.abort();
104
104
  });
105
- const u = (p, f, q) => {
106
- const b = [];
107
- return f && b.push(...f), b.push(...be(p, q)), b;
108
- }, { data: y, error: R, isValidating: k } = ge(c, async () => {
109
- var p, f, q, b;
105
+ const u = (p, v, T) => {
106
+ const C = [];
107
+ return v && C.push(...v), C.push(...ge(p, T)), C;
108
+ }, { data: y, error: D, isValidating: x } = Se(c, async () => {
109
+ var p, v, T, C;
110
110
  try {
111
111
  let {
112
- datasource: n,
113
- ...O
112
+ datasource: f,
113
+ ...n
114
114
  } = e.query;
115
- n || (n = "basic");
116
- const P = u(n, e.query.filters, e.context.filters), G = {
117
- datasource: n,
115
+ f || (f = "basic");
116
+ const A = u(f, e.query.filters, e.context.filters);
117
+ let q = e.query.time_range;
118
+ q ? q.tz || (q = {
119
+ ...q,
120
+ tz: e.context.tz
121
+ }) : q = {
122
+ ...e.context.timeSpec,
123
+ tz: e.context.tz
124
+ };
125
+ const M = {
126
+ datasource: f,
118
127
  query: {
119
- ...O,
120
- time_range: {
121
- ...e.context.timeSpec,
122
- tz: e.context.tz
123
- },
124
- filters: P
128
+ ...n,
129
+ time_range: q,
130
+ filters: A
125
131
  }
126
132
  };
127
- return o == null ? void 0 : o.queryFn(G, i);
128
- } catch (n) {
129
- A.value = ((f = (p = n == null ? void 0 : n.response) == null ? void 0 : p.data) == null ? void 0 : f.message) === "Range not allowed for this tier" ? s.t("queryDataProvider.timeRangeExceeded") : ((b = (q = n == null ? void 0 : n.response) == null ? void 0 : q.data) == null ? void 0 : b.message) || (n == null ? void 0 : n.message);
133
+ return o == null ? void 0 : o.queryFn(M, i);
134
+ } catch (f) {
135
+ w.value = ((v = (p = f == null ? void 0 : f.response) == null ? void 0 : p.data) == null ? void 0 : v.message) === "Range not allowed for this tier" ? s.t("queryDataProvider.timeRangeExceeded") : ((C = (T = f == null ? void 0 : f.response) == null ? void 0 : T.data) == null ? void 0 : C.message) || (f == null ? void 0 : f.message);
130
136
  } finally {
131
137
  r("queryComplete");
132
138
  }
133
139
  }, {
134
140
  refreshInterval: e.context.refreshInterval,
135
141
  revalidateOnFocus: !1
136
- }), { state: m, swrvState: S } = we(y, R, k), A = x(null), h = v(() => m.value === S.ERROR || !!A.value), C = v(() => !e.queryReady || m.value === S.PENDING);
137
- return ie(y, (p) => {
142
+ }), { state: m, swrvState: I } = Le(y, D, x), w = O(null), h = g(() => m.value === I.ERROR || !!w.value), E = g(() => !e.queryReady || m.value === I.PENDING);
143
+ return ue(y, (p) => {
138
144
  p && r("chart-data", p);
139
- }), (p, f) => {
140
- const q = $("KSkeleton"), b = $("KEmptyState");
141
- return C.value || !l(y) && !h.value ? (d(), g(q, {
145
+ }), (p, v) => {
146
+ const T = N("KSkeleton"), C = N("KEmptyState");
147
+ return E.value || !l(y) && !h.value ? (d(), _(T, {
142
148
  key: 0,
143
149
  class: "chart-skeleton",
144
150
  type: "table"
145
- })) : h.value ? (d(), g(b, {
151
+ })) : h.value ? (d(), _(C, {
146
152
  key: 1,
147
153
  "action-button-visible": !1,
148
154
  "data-testid": "chart-empty-state",
149
155
  "icon-variant": "error"
150
156
  }, {
151
- default: _(() => [
152
- M(F(A.value), 1)
157
+ default: b(() => [
158
+ U(L(w.value), 1)
153
159
  ]),
154
160
  _: 1
155
- })) : l(y) ? U(p.$slots, "default", {
161
+ })) : l(y) ? V(p.$slots, "default", {
156
162
  key: 2,
157
163
  data: l(y)
158
- }) : D("", !0);
164
+ }) : S("", !0);
159
165
  };
160
166
  }
161
- }), Me = { class: "analytics-chart" }, Ue = /* @__PURE__ */ I({
167
+ }), je = { class: "analytics-chart" }, Qe = /* @__PURE__ */ k({
162
168
  __name: "SimpleChartRenderer",
163
169
  props: {
164
170
  query: {},
@@ -169,19 +175,19 @@ const w = {
169
175
  refreshCounter: {}
170
176
  },
171
177
  setup(a) {
172
- B((e) => ({
178
+ G((e) => ({
173
179
  c40c0e86: `${e.height}px`
174
180
  }));
175
181
  const t = a;
176
- return (e, r) => (d(), g(H, {
182
+ return (e, r) => (d(), _(j, {
177
183
  context: e.context,
178
184
  query: e.query,
179
185
  "query-ready": e.queryReady,
180
186
  "refresh-counter": e.refreshCounter
181
187
  }, {
182
- default: _(({ data: s }) => [
183
- L("div", Me, [
184
- T(l(he), {
188
+ default: b(({ data: s }) => [
189
+ K("div", je, [
190
+ F(l(Ee), {
185
191
  "chart-data": s,
186
192
  "chart-options": t.chartOptions,
187
193
  "synthetics-data-key": e.chartOptions.syntheticsDataKey
@@ -191,12 +197,12 @@ const w = {
191
197
  _: 1
192
198
  }, 8, ["context", "query", "query-ready", "refresh-counter"]));
193
199
  }
194
- }), N = (a, t) => {
200
+ }), z = (a, t) => {
195
201
  const e = a.__vccOpts || a;
196
202
  for (const [r, s] of t)
197
203
  e[r] = s;
198
204
  return e;
199
- }, Ve = /* @__PURE__ */ N(Ue, [["__scopeId", "data-v-694cf637"]]), He = { class: "analytics-chart" }, je = /* @__PURE__ */ I({
205
+ }, Je = /* @__PURE__ */ z(Qe, [["__scopeId", "data-v-694cf637"]]), Ze = { class: "analytics-chart" }, We = /* @__PURE__ */ k({
200
206
  __name: "BaseAnalyticsChartRenderer",
201
207
  props: {
202
208
  query: {},
@@ -209,39 +215,39 @@ const w = {
209
215
  },
210
216
  emits: ["edit-tile", "chart-data"],
211
217
  setup(a, { emit: t }) {
212
- const e = a, r = t, s = K(z), { i18n: o } = w.useI18n(), { evaluateFeatureFlag: c } = w.useEvaluateFeatureFlag(), i = c("ma-3043-analytics-chart-kebab-menu", !1), u = v(() => ({
218
+ const e = a, r = t, s = B(P), { i18n: o } = $.useI18n(), { evaluateFeatureFlag: c } = $.useEvaluateFeatureFlag(), i = c("ma-3043-analytics-chart-kebab-menu", !1), u = g(() => ({
213
219
  type: e.chartOptions.type,
214
220
  stacked: e.chartOptions.stacked ?? !1,
215
221
  chartDatasetColors: e.chartOptions.chartDatasetColors,
216
222
  threshold: e.chartOptions.threshold
217
- })), y = v(() => {
223
+ })), y = g(() => {
218
224
  if (s && s.exploreBaseUrl) {
219
225
  const m = {
220
226
  filters: [...e.context.filters, ...e.query.filters ?? []],
221
227
  metrics: e.query.metrics ?? [],
222
228
  dimensions: e.query.dimensions ?? [],
223
229
  time_range: e.query.time_range || e.context.timeSpec
224
- }, S = ["advanced", "ai"].includes(e.query.datasource) ? e.query.datasource : "advanced";
225
- return `${s.exploreBaseUrl()}?q=${JSON.stringify(m)}&d=${S}&c=${e.chartOptions.type}`;
230
+ }, I = ["advanced", "ai"].includes(e.query.datasource) ? e.query.datasource : "advanced";
231
+ return `${s.exploreBaseUrl()}?q=${JSON.stringify(m)}&d=${I}&c=${e.chartOptions.type}`;
226
232
  }
227
233
  return "";
228
- }), R = () => {
234
+ }), D = () => {
229
235
  r("edit-tile");
230
- }, k = (m) => {
236
+ }, x = (m) => {
231
237
  r("chart-data", m);
232
238
  };
233
- return (m, S) => {
234
- const A = $("KDropdownItem");
235
- return d(), g(H, {
239
+ return (m, I) => {
240
+ const w = N("KDropdownItem");
241
+ return d(), _(j, {
236
242
  context: m.context,
237
243
  query: m.query,
238
244
  "query-ready": m.queryReady,
239
245
  "refresh-counter": m.refreshCounter,
240
- onChartData: k
246
+ onChartData: x
241
247
  }, {
242
- default: _(({ data: h }) => [
243
- L("div", He, [
244
- T(l(me), ee({
248
+ default: b(({ data: h }) => [
249
+ K("div", Ze, [
250
+ F(l(Ce), re({
245
251
  "allow-csv-export": m.chartOptions.allowCsvExport,
246
252
  "chart-data": h,
247
253
  "chart-options": u.value,
@@ -251,13 +257,13 @@ const w = {
251
257
  "show-menu": m.context.editable,
252
258
  "synthetics-data-key": m.chartOptions.syntheticsDataKey,
253
259
  "tooltip-title": ""
254
- }, m.extraProps), te({ _: 2 }, [
260
+ }, m.extraProps), ae({ _: 2 }, [
255
261
  m.context.editable ? {
256
262
  name: "menu-items",
257
- fn: _(() => [
258
- T(A, { onClick: R }, {
259
- default: _(() => [
260
- M(F(l(o).t("renderer.edit")), 1)
263
+ fn: b(() => [
264
+ F(w, { onClick: D }, {
265
+ default: b(() => [
266
+ U(L(l(o).t("renderer.edit")), 1)
261
267
  ]),
262
268
  _: 1
263
269
  })
@@ -271,7 +277,7 @@ const w = {
271
277
  }, 8, ["context", "query", "query-ready", "refresh-counter"]);
272
278
  };
273
279
  }
274
- }), ae = /* @__PURE__ */ N(je, [["__scopeId", "data-v-1bc587d3"]]), J = /* @__PURE__ */ I({
280
+ }), ie = /* @__PURE__ */ z(We, [["__scopeId", "data-v-1bc587d3"]]), W = /* @__PURE__ */ k({
275
281
  __name: "BarChartRenderer",
276
282
  props: {
277
283
  query: {},
@@ -282,7 +288,7 @@ const w = {
282
288
  refreshCounter: {}
283
289
  },
284
290
  setup(a) {
285
- return (t, e) => (d(), g(ae, {
291
+ return (t, e) => (d(), _(ie, {
286
292
  "chart-options": t.chartOptions,
287
293
  context: t.context,
288
294
  "extra-props": { showAnnotations: !1 },
@@ -292,7 +298,7 @@ const w = {
292
298
  "refresh-counter": t.refreshCounter
293
299
  }, null, 8, ["chart-options", "context", "height", "query", "query-ready", "refresh-counter"]));
294
300
  }
295
- }), Z = /* @__PURE__ */ I({
301
+ }), Y = /* @__PURE__ */ k({
296
302
  __name: "TimeseriesChartRenderer",
297
303
  props: {
298
304
  query: {},
@@ -303,7 +309,7 @@ const w = {
303
309
  refreshCounter: {}
304
310
  },
305
311
  setup(a) {
306
- return (t, e) => (d(), g(ae, {
312
+ return (t, e) => (d(), _(ie, {
307
313
  "chart-options": t.chartOptions,
308
314
  context: t.context,
309
315
  height: t.height,
@@ -312,7 +318,7 @@ const w = {
312
318
  "refresh-counter": t.refreshCounter
313
319
  }, null, 8, ["chart-options", "context", "height", "query", "query-ready", "refresh-counter"]));
314
320
  }
315
- }), Qe = { class: "metric-card-tile-wrapper" }, Je = /* @__PURE__ */ I({
321
+ }), Ye = { class: "metric-card-tile-wrapper" }, Xe = /* @__PURE__ */ k({
316
322
  __name: "GoldenSignalsRenderer",
317
323
  props: {
318
324
  query: {},
@@ -323,15 +329,15 @@ const w = {
323
329
  refreshCounter: {}
324
330
  },
325
331
  setup(a) {
326
- B((c) => ({
332
+ G((c) => ({
327
333
  "926e3b48": l(r) ? "90%" : "100%",
328
334
  "7be2893e": l(r) ? "auto" : "100%",
329
335
  "0d55c162": l(r) ? "100%" : "none"
330
336
  }));
331
- const t = a, { evaluateFeatureFlag: e } = w.useEvaluateFeatureFlag(), r = e("ma-3043-analytics-chart-kebab-menu", !1), s = v(() => {
337
+ const t = a, { evaluateFeatureFlag: e } = $.useEvaluateFeatureFlag(), r = e("ma-3043-analytics-chart-kebab-menu", !1), s = g(() => {
332
338
  const c = t.context.timeSpec;
333
339
  if (c.type === "absolute")
334
- return new Ce({
340
+ return new _e({
335
341
  key: "custom",
336
342
  timeframeText: "custom",
337
343
  display: "custom",
@@ -343,11 +349,11 @@ const w = {
343
349
  isRelative: !1,
344
350
  allowedTiers: ["free", "plus", "enterprise"]
345
351
  });
346
- const i = Ee.get(c.time_range);
352
+ const i = ne.get(c.time_range);
347
353
  if (!i)
348
354
  throw new Error("Unknown time range");
349
355
  return i;
350
- }), o = v(() => {
356
+ }), o = g(() => {
351
357
  var i, u;
352
358
  const c = (i = t.query) == null ? void 0 : i.datasource;
353
359
  if (c && c !== "advanced" && c !== "basic")
@@ -367,16 +373,16 @@ const w = {
367
373
  refreshCounter: t.refreshCounter
368
374
  };
369
375
  });
370
- return (c, i) => (d(), E("div", Qe, [
371
- T(l(Se), se(ce(o.value)), {
372
- default: _(() => [
373
- T(l(Te))
376
+ return (c, i) => (d(), R("div", Ye, [
377
+ F(l(Ae), de(pe(o.value)), {
378
+ default: b(() => [
379
+ F(l(De))
374
380
  ]),
375
381
  _: 1
376
382
  }, 16)
377
383
  ]));
378
384
  }
379
- }), Ze = /* @__PURE__ */ N(Je, [["__scopeId", "data-v-0f571079"]]), W = "#6c7489", Y = "20px", ne = "20px", We = /* @__PURE__ */ I({
385
+ }), et = /* @__PURE__ */ z(Xe, [["__scopeId", "data-v-0f571079"]]), X = "#6c7489", ee = "20px", se = "20px", tt = /* @__PURE__ */ k({
380
386
  __name: "TopNTableRenderer",
381
387
  props: {
382
388
  query: {},
@@ -387,33 +393,33 @@ const w = {
387
393
  refreshCounter: {}
388
394
  },
389
395
  setup(a) {
390
- const t = a, { evaluateFeatureFlag: e } = w.useEvaluateFeatureFlag(), r = e("ma-3043-analytics-chart-kebab-menu", !1), s = (o) => {
396
+ const t = a, { evaluateFeatureFlag: e } = $.useEvaluateFeatureFlag(), r = e("ma-3043-analytics-chart-kebab-menu", !1), s = (o) => {
391
397
  var c;
392
398
  if ((c = t.chartOptions) != null && c.entityLink)
393
399
  if (o.id.includes(":")) {
394
400
  const [i, u] = o.id.split(":");
395
- return t.chartOptions.entityLink.replace(ze, i).replace(Q, u);
401
+ return t.chartOptions.entityLink.replace(Ue, i).replace(Z, u);
396
402
  } else
397
- return t.chartOptions.entityLink.replace(Q, o.id);
403
+ return t.chartOptions.entityLink.replace(Z, o.id);
398
404
  return "";
399
405
  };
400
- return (o, c) => (d(), g(H, {
406
+ return (o, c) => (d(), _(j, {
401
407
  context: o.context,
402
408
  query: o.query,
403
409
  "query-ready": o.queryReady,
404
410
  "refresh-counter": o.refreshCounter
405
411
  }, {
406
- default: _(({ data: i }) => [
407
- T(l(fe), {
412
+ default: b(({ data: i }) => [
413
+ F(l(Ie), {
408
414
  data: i,
409
415
  description: !l(r) && o.chartOptions.description || "",
410
416
  "synthetics-data-key": o.chartOptions.syntheticsDataKey,
411
417
  title: !l(r) && o.chartOptions.chartTitle || ""
412
- }, te({ _: 2 }, [
418
+ }, ae({ _: 2 }, [
413
419
  t.chartOptions.entityLink ? {
414
420
  name: "name",
415
- fn: _(({ record: u }) => [
416
- T(l(Re), {
421
+ fn: b(({ record: u }) => [
422
+ F(l(xe), {
417
423
  "entity-link-data": {
418
424
  id: u.id,
419
425
  label: u.name,
@@ -429,47 +435,47 @@ const w = {
429
435
  _: 1
430
436
  }, 8, ["context", "query", "query-ready", "refresh-counter"]));
431
437
  }
432
- }), Ye = ["data-testid"], Xe = {
438
+ }), rt = ["data-testid"], at = {
433
439
  key: 0,
434
440
  class: "tile-header"
435
- }, et = ["data-testid"], tt = ["data-testid"], rt = ["data-testid"], at = ["data-testid"], nt = ["data-testid"], ot = /* @__PURE__ */ I({
441
+ }, nt = ["data-testid"], ot = ["data-testid"], it = ["data-testid"], st = ["data-testid"], ct = ["data-testid"], lt = /* @__PURE__ */ k({
436
442
  __name: "DashboardTile",
437
443
  props: {
438
444
  definition: {},
439
445
  context: {},
440
- height: { default: V },
446
+ height: { default: H },
441
447
  queryReady: { type: Boolean },
442
448
  refreshCounter: {},
443
449
  tileId: {}
444
450
  },
445
451
  emits: ["edit-tile"],
446
452
  setup(a, { emit: t }) {
447
- B((n) => ({
448
- bc8541b6: `${n.height}px`
453
+ G((n) => ({
454
+ "4fd5b2d2": `${n.height}px`
449
455
  }));
450
- const e = parseInt(ne, 10), r = a, s = t, o = K(z), { evaluateFeatureFlag: c } = w.useEvaluateFeatureFlag(), { i18n: i } = w.useI18n(), u = c("ma-3043-analytics-chart-kebab-menu", !1), y = x(), R = x(!1), k = v(() => {
456
+ const e = parseInt(se, 10), r = a, s = t, o = B(P), { evaluateFeatureFlag: c } = $.useEvaluateFeatureFlag(), { i18n: i } = $.useI18n(), u = c("ma-3043-analytics-chart-kebab-menu", !1), y = O(), D = O(!1), x = g(() => {
451
457
  if (o && o.exploreBaseUrl) {
452
458
  const n = {
453
459
  filters: [...r.context.filters, ...r.definition.query.filters ?? []],
454
460
  metrics: r.definition.query.metrics ?? [],
455
461
  dimensions: r.definition.query.dimensions ?? [],
456
462
  time_range: r.definition.query.time_range || r.context.timeSpec,
457
- granularity: r.definition.query.granularity || C.value
458
- }, O = ["advanced", "ai"].includes(r.definition.query.datasource) ? r.definition.query.datasource : "advanced";
459
- return `${o.exploreBaseUrl()}?q=${JSON.stringify(n)}&d=${O}&c=${r.definition.chart.type}`;
463
+ granularity: r.definition.query.granularity || p.value
464
+ }, A = ["advanced", "ai"].includes(r.definition.query.datasource) ? r.definition.query.datasource : "advanced";
465
+ return `${o.exploreBaseUrl()}?q=${JSON.stringify(n)}&d=${A}&c=${r.definition.chart.type}`;
460
466
  }
461
467
  return "";
462
- }), m = v(() => i.t("csvExport.defaultFilename")), S = v(() => u && !["golden_signals", "top_n", "gauge"].includes(r.definition.chart.type)), A = {
463
- timeseries_line: Z,
464
- timeseries_bar: Z,
465
- horizontal_bar: J,
466
- vertical_bar: J,
467
- gauge: Ve,
468
- golden_signals: Ze,
469
- top_n: We,
468
+ }), m = g(() => i.t("csvExport.defaultFilename")), I = g(() => u && !["golden_signals", "top_n", "gauge"].includes(r.definition.chart.type)), w = {
469
+ timeseries_line: Y,
470
+ timeseries_bar: Y,
471
+ horizontal_bar: W,
472
+ vertical_bar: W,
473
+ gauge: Je,
474
+ golden_signals: et,
475
+ top_n: tt,
470
476
  slottable: void 0
471
- }, h = v(() => {
472
- const n = A[r.definition.chart.type];
477
+ }, h = g(() => {
478
+ const n = w[r.definition.chart.type];
473
479
  return n && {
474
480
  component: n,
475
481
  rendererProps: {
@@ -481,98 +487,116 @@ const w = {
481
487
  refreshCounter: r.refreshCounter
482
488
  }
483
489
  };
484
- }), C = v(() => y.value ? Ie(y.value.meta.granularity_ms) : void 0), p = () => {
490
+ }), E = g(() => {
491
+ var A;
492
+ const n = (A = r.definition.query) == null ? void 0 : A.time_range;
493
+ if ((n == null ? void 0 : n.type) === "relative") {
494
+ const q = ne.get(qe[n.time_range]);
495
+ return q ? q.display : (console.warn("Did not recognize the given relative time range:", n.time_range), n.time_range);
496
+ } else if ((n == null ? void 0 : n.type) === "absolute") {
497
+ const q = n.tz || "Etc/UTC";
498
+ return `${J(n.start, { short: !0, tz: q })} - ${J(n.end, { short: !0, tz: q })}`;
499
+ }
500
+ return null;
501
+ }), p = g(() => y.value ? be(y.value.meta.granularity_ms) : void 0), v = () => {
485
502
  s("edit-tile", r.definition);
486
- }, f = (n) => {
503
+ }, T = (n) => {
487
504
  y.value = n;
488
- }, q = (n) => {
489
- R.value = n;
490
- }, b = () => {
491
- q(!0);
505
+ }, C = (n) => {
506
+ D.value = n;
507
+ }, f = () => {
508
+ C(!0);
492
509
  };
493
- return (n, O) => {
494
- const P = $("KDropdownItem"), G = $("KDropdown");
495
- return d(), E("div", {
510
+ return (n, A) => {
511
+ const q = N("KBadge"), M = N("KDropdownItem"), ce = N("KDropdown");
512
+ return d(), R("div", {
496
513
  class: "tile-boundary",
497
514
  "data-testid": `tile-${n.tileId}`
498
515
  }, [
499
- l(u) && n.definition.chart.type !== "slottable" ? (d(), E("div", Xe, [
500
- L("div", {
516
+ l(u) && n.definition.chart.type !== "slottable" ? (d(), R("div", at, [
517
+ K("div", {
501
518
  class: "title",
502
519
  "data-testid": `tile-title-${n.tileId}`
503
- }, F(n.definition.chart.chartTitle), 9, et),
504
- S.value ? (d(), E("div", {
520
+ }, L(n.definition.chart.chartTitle), 9, nt),
521
+ I.value || E.value ? (d(), R("div", {
505
522
  key: 0,
506
523
  class: "tile-actions",
507
524
  "data-testid": `tile-actions-${n.tileId}`
508
525
  }, [
509
- n.context.editable ? (d(), g(l(ke), {
510
- key: 0,
526
+ E.value ? (d(), _(q, { key: 0 }, {
527
+ default: b(() => [
528
+ U(L(E.value), 1)
529
+ ]),
530
+ _: 1
531
+ })) : S("", !0),
532
+ I.value && n.context.editable ? (d(), _(l(we), {
533
+ key: 1,
511
534
  class: "edit-icon",
512
- color: l(W),
535
+ color: l(X),
513
536
  "data-testid": `edit-tile-${n.tileId}`,
514
- size: l(Y),
515
- onClick: p
516
- }, null, 8, ["color", "data-testid", "size"])) : D("", !0),
517
- T(G, {
537
+ size: l(ee),
538
+ onClick: v
539
+ }, null, 8, ["color", "data-testid", "size"])) : S("", !0),
540
+ I.value ? (d(), _(ce, {
541
+ key: 2,
518
542
  class: "dropdown",
519
543
  "data-testid": `chart-action-menu-${n.tileId}`,
520
544
  "kpop-attributes": { placement: "bottom-end" }
521
545
  }, {
522
- items: _(() => [
523
- k.value ? (d(), g(P, {
546
+ items: b(() => [
547
+ x.value ? (d(), _(M, {
524
548
  key: 0,
525
549
  "data-testid": `chart-jump-to-explore-${n.tileId}`,
526
- item: { label: l(i).t("jumpToExplore"), to: k.value }
527
- }, null, 8, ["data-testid", "item"])) : D("", !0),
528
- "allowCsvExport" in n.definition.chart && n.definition.chart.allowCsvExport ? (d(), g(P, {
550
+ item: { label: l(i).t("jumpToExplore"), to: x.value }
551
+ }, null, 8, ["data-testid", "item"])) : S("", !0),
552
+ "allowCsvExport" in n.definition.chart && n.definition.chart.allowCsvExport ? (d(), _(M, {
529
553
  key: 1,
530
554
  class: "chart-export-button",
531
555
  "data-testid": `chart-csv-export-${n.tileId}`,
532
- onClick: O[0] || (O[0] = (yt) => b())
556
+ onClick: A[0] || (A[0] = (vt) => f())
533
557
  }, {
534
- default: _(() => [
535
- L("span", {
558
+ default: b(() => [
559
+ K("span", {
536
560
  class: "chart-export-trigger",
537
561
  "data-testid": `csv-export-button-${n.tileId}`
538
- }, F(l(i).t("csvExport.exportAsCsv")), 9, rt)
562
+ }, L(l(i).t("csvExport.exportAsCsv")), 9, it)
539
563
  ]),
540
564
  _: 1
541
- }, 8, ["data-testid"])) : D("", !0)
565
+ }, 8, ["data-testid"])) : S("", !0)
542
566
  ]),
543
- default: _(() => [
544
- T(l(Ae), {
567
+ default: b(() => [
568
+ F(l(Oe), {
545
569
  class: "kebab-action-menu",
546
- color: l(W),
570
+ color: l(X),
547
571
  "data-testid": `kebab-action-menu-${n.tileId}`,
548
- size: l(Y)
572
+ size: l(ee)
549
573
  }, null, 8, ["color", "data-testid", "size"])
550
574
  ]),
551
575
  _: 1
552
- }, 8, ["data-testid"])
553
- ], 8, tt)) : "description" in n.definition.chart ? (d(), E("div", {
576
+ }, 8, ["data-testid"])) : S("", !0)
577
+ ], 8, ot)) : "description" in n.definition.chart ? (d(), R("div", {
554
578
  key: 1,
555
579
  class: "header-description",
556
580
  "data-testid": `tile-description-${n.tileId}`
557
- }, F(n.definition.chart.description), 9, at)) : D("", !0),
558
- R.value ? (d(), g(l(ve), {
581
+ }, L(n.definition.chart.description), 9, st)) : S("", !0),
582
+ D.value ? (d(), _(l(Te), {
559
583
  key: 2,
560
584
  "chart-data": y.value,
561
585
  "data-testid": `csv-export-modal-${n.tileId}`,
562
586
  filename: m.value,
563
- onToggleModal: q
564
- }, null, 8, ["chart-data", "data-testid", "filename"])) : D("", !0)
565
- ])) : D("", !0),
566
- L("div", {
587
+ onToggleModal: C
588
+ }, null, 8, ["chart-data", "data-testid", "filename"])) : S("", !0)
589
+ ])) : S("", !0),
590
+ K("div", {
567
591
  class: "tile-content",
568
592
  "data-testid": `tile-content-${n.tileId}`
569
593
  }, [
570
- h.value ? (d(), g(le(h.value.component), ee({ key: 0 }, h.value.rendererProps, { onChartData: f }), null, 16)) : D("", !0)
571
- ], 8, nt)
572
- ], 8, Ye);
594
+ h.value ? (d(), _(ye(h.value.component), re({ key: 0 }, h.value.rendererProps, { onChartData: T }), null, 16)) : S("", !0)
595
+ ], 8, ct)
596
+ ], 8, rt);
573
597
  };
574
598
  }
575
- }), it = /* @__PURE__ */ N(ot, [["__scopeId", "data-v-e958ea7b"]]), st = (a, t, e) => {
599
+ }), ut = /* @__PURE__ */ z(lt, [["__scopeId", "data-v-3031ac6e"]]), dt = (a, t, e) => {
576
600
  const r = /* @__PURE__ */ new Map();
577
601
  e.forEach((o) => {
578
602
  const c = o.layout.position.row, i = r.get(c), u = o.layout.size.rows === 1 && !!o.layout.size.fitToContent;
@@ -582,7 +606,7 @@ const w = {
582
606
  for (let o = 0; o < a; o++)
583
607
  r.get(o) ? s.push("auto") : s.push(`${t}px`);
584
608
  return s;
585
- }, ct = /* @__PURE__ */ I({
609
+ }, pt = /* @__PURE__ */ k({
586
610
  __name: "GridLayout",
587
611
  props: {
588
612
  gridSize: {
@@ -592,7 +616,7 @@ const w = {
592
616
  tileHeight: {
593
617
  type: Number,
594
618
  required: !1,
595
- default: () => V
619
+ default: () => H
596
620
  },
597
621
  tiles: {
598
622
  type: Array,
@@ -600,24 +624,24 @@ const w = {
600
624
  }
601
625
  },
602
626
  setup(a) {
603
- B((i) => ({
627
+ G((i) => ({
604
628
  "3bc5e939": a.gridSize.cols,
605
629
  "77aa3028": o.value
606
630
  }));
607
- const t = a, e = x(null), r = x(0), s = new ResizeObserver((i) => {
631
+ const t = a, e = O(null), r = O(0), s = new ResizeObserver((i) => {
608
632
  window.requestAnimationFrame(() => {
609
633
  !Array.isArray(i) || !i.length || (r.value = i[0].contentRect.width);
610
634
  });
611
635
  });
612
- ue(() => {
636
+ he(() => {
613
637
  e.value && s.observe(e.value);
614
- }), X(() => {
638
+ }), te(() => {
615
639
  e.value && s.unobserve(e.value);
616
640
  });
617
- const o = v(() => {
641
+ const o = g(() => {
618
642
  var u;
619
- return st((u = t.gridSize) == null ? void 0 : u.rows, t.tileHeight, t.tiles).join(" ");
620
- }), c = v(() => t.tiles.map((i, u) => ({
643
+ return dt((u = t.gridSize) == null ? void 0 : u.rows, t.tileHeight, t.tiles).join(" ");
644
+ }), c = g(() => t.tiles.map((i, u) => ({
621
645
  key: `tile-${u}`,
622
646
  tile: i,
623
647
  style: {
@@ -627,29 +651,29 @@ const w = {
627
651
  "grid-row-end": i.layout.position.row + 1 + i.layout.size.rows
628
652
  }
629
653
  })));
630
- return (i, u) => (d(), E("div", {
654
+ return (i, u) => (d(), R("div", {
631
655
  ref_key: "gridContainer",
632
656
  ref: e,
633
657
  class: "kong-ui-public-grid-layout"
634
658
  }, [
635
- (d(!0), E(de, null, pe(c.value, (y) => (d(), E("div", {
659
+ (d(!0), R(me, null, fe(c.value, (y) => (d(), R("div", {
636
660
  key: y.key,
637
- class: ye(["grid-cell", {
661
+ class: ve(["grid-cell", {
638
662
  "empty-cell": !y.tile
639
663
  }]),
640
- style: j(y.style)
664
+ style: Q(y.style)
641
665
  }, [
642
- U(i.$slots, "tile", {
643
- style: j(y.style),
666
+ V(i.$slots, "tile", {
667
+ style: Q(y.style),
644
668
  tile: y.tile
645
669
  }, void 0, !0)
646
670
  ], 6))), 128))
647
671
  ], 512));
648
672
  }
649
- }), lt = /* @__PURE__ */ N(ct, [["__scopeId", "data-v-f43eb7b8"]]), ut = { class: "kong-ui-public-dashboard-renderer" }, dt = {
673
+ }), yt = /* @__PURE__ */ z(pt, [["__scopeId", "data-v-f43eb7b8"]]), ht = { class: "kong-ui-public-dashboard-renderer" }, mt = {
650
674
  key: 0,
651
675
  class: "tile-container"
652
- }, pt = /* @__PURE__ */ I({
676
+ }, ft = /* @__PURE__ */ k({
653
677
  __name: "DashboardRenderer",
654
678
  props: {
655
679
  context: {},
@@ -657,24 +681,24 @@ const w = {
657
681
  },
658
682
  emits: ["edit-tile"],
659
683
  setup(a, { expose: t, emit: e }) {
660
- const r = a, s = e, { i18n: o } = w.useI18n(), c = x(0), i = K(z);
684
+ const r = a, s = e, { i18n: o } = $.useI18n(), c = O(0), i = B(P);
661
685
  i || (console.warn("Analytics dashboards require a query bridge supplied via provide / inject."), console.warn("Please ensure your application has a query bridge provided under the key 'analytics-query-provider', as described in"), console.warn("https://github.com/Kong/public-ui-components/blob/main/packages/analytics/dashboard-renderer/README.md#requirements"));
662
- const u = De(), y = v(() => r.context.timeSpec ? r.context.timeSpec : {
686
+ const u = Fe(), y = g(() => r.context.timeSpec ? r.context.timeSpec : {
663
687
  type: "relative",
664
688
  time_range: u.defaultQueryTimeForOrg
665
- }), R = v(() => !!r.context.timeSpec || !u.loading), k = v(() => r.config.tiles.map((h, C) => {
666
- var f;
689
+ }), D = g(() => !!r.context.timeSpec || !u.loading), x = g(() => r.config.tiles.map((h, E) => {
690
+ var v;
667
691
  let p = h.definition;
668
692
  if ("description" in p.chart) {
669
- const q = (f = p.chart.description) == null ? void 0 : f.replace(Pe, () => {
670
- const n = `renderer.trendRange.${y.value.type === "absolute" ? "custom" : y.value.time_range}`;
671
- return o.te(n) ? o.t(n) : "";
693
+ const T = (v = p.chart.description) == null ? void 0 : v.replace(Ge, () => {
694
+ const f = `renderer.trendRange.${y.value.type === "absolute" ? "custom" : y.value.time_range}`;
695
+ return o.te(f) ? o.t(f) : "";
672
696
  });
673
697
  p = {
674
698
  ...p,
675
699
  chart: {
676
700
  ...p.chart,
677
- description: q
701
+ description: T
678
702
  }
679
703
  };
680
704
  }
@@ -682,67 +706,67 @@ const w = {
682
706
  layout: h.layout,
683
707
  meta: p,
684
708
  // Add a unique key to each tile internally.
685
- id: C
709
+ id: E
686
710
  };
687
- })), m = v(() => {
688
- let { tz: h, refreshInterval: C, editable: p } = r.context;
689
- return h || (h = new Intl.DateTimeFormat().resolvedOptions().timeZone), C === void 0 && (C = Be), p === void 0 && (p = !1), {
711
+ })), m = g(() => {
712
+ let { tz: h, refreshInterval: E, editable: p } = r.context;
713
+ return h || (h = new Intl.DateTimeFormat().resolvedOptions().timeZone), E === void 0 && (E = Ve), p === void 0 && (p = !1), {
690
714
  ...r.context,
691
715
  tz: h,
692
716
  timeSpec: y.value,
693
- refreshInterval: C,
717
+ refreshInterval: E,
694
718
  editable: p
695
719
  };
696
- }), S = (h) => {
720
+ }), I = (h) => {
697
721
  s("edit-tile", h);
698
722
  };
699
723
  return t({ refresh: () => {
700
724
  c.value++;
701
- } }), (h, C) => {
702
- const p = $("KAlert");
703
- return d(), E("div", ut, [
704
- l(i) ? (d(), g(lt, {
725
+ } }), (h, E) => {
726
+ const p = N("KAlert");
727
+ return d(), R("div", ht, [
728
+ l(i) ? (d(), _(yt, {
705
729
  key: 1,
706
730
  "grid-size": h.config.gridSize,
707
731
  "tile-height": h.config.tileHeight,
708
- tiles: k.value
732
+ tiles: x.value
709
733
  }, {
710
- tile: _(({ tile: f }) => [
711
- f.meta.chart.type === "slottable" ? (d(), E("div", dt, [
712
- U(h.$slots, f.meta.chart.id, {}, void 0, !0)
713
- ])) : (d(), g(it, {
734
+ tile: b(({ tile: v }) => [
735
+ v.meta.chart.type === "slottable" ? (d(), R("div", mt, [
736
+ V(h.$slots, v.meta.chart.id, {}, void 0, !0)
737
+ ])) : (d(), _(ut, {
714
738
  key: 1,
715
739
  class: "tile-container",
716
740
  context: m.value,
717
- definition: f.meta,
718
- height: f.layout.size.rows * (h.config.tileHeight || l(V)) + parseInt(l(ne), 10),
719
- "query-ready": R.value,
741
+ definition: v.meta,
742
+ height: v.layout.size.rows * (h.config.tileHeight || l(H)) + parseInt(l(se), 10),
743
+ "query-ready": D.value,
720
744
  "refresh-counter": c.value,
721
- "tile-id": f.id,
722
- onEditTile: (q) => S(f)
745
+ "tile-id": v.id,
746
+ onEditTile: (T) => I(v)
723
747
  }, null, 8, ["context", "definition", "height", "query-ready", "refresh-counter", "tile-id", "onEditTile"]))
724
748
  ]),
725
749
  _: 3
726
- }, 8, ["grid-size", "tile-height", "tiles"])) : (d(), g(p, {
750
+ }, 8, ["grid-size", "tile-height", "tiles"])) : (d(), _(p, {
727
751
  key: 0,
728
752
  appearance: "danger"
729
753
  }, {
730
- default: _(() => [
731
- M(F(l(o).t("renderer.noQueryBridge")), 1)
754
+ default: b(() => [
755
+ U(L(l(o).t("renderer.noQueryBridge")), 1)
732
756
  ]),
733
757
  _: 1
734
758
  }))
735
759
  ]);
736
760
  };
737
761
  }
738
- }), It = /* @__PURE__ */ N(pt, [["__scopeId", "data-v-6ee19c24"]]);
762
+ }), kt = /* @__PURE__ */ z(ft, [["__scopeId", "data-v-6ee19c24"]]);
739
763
  export {
740
- ze as CP_ID_TOKEN,
741
- V as DEFAULT_TILE_HEIGHT,
742
- Be as DEFAULT_TILE_REFRESH_INTERVAL_MS,
743
- It as DashboardRenderer,
744
- Q as ENTITY_ID_TOKEN,
745
- lt as GridLayout,
746
- z as INJECT_QUERY_PROVIDER,
747
- Pe as TIMEFRAME_TOKEN
764
+ Ue as CP_ID_TOKEN,
765
+ H as DEFAULT_TILE_HEIGHT,
766
+ Ve as DEFAULT_TILE_REFRESH_INTERVAL_MS,
767
+ kt as DashboardRenderer,
768
+ Z as ENTITY_ID_TOKEN,
769
+ yt as GridLayout,
770
+ P as INJECT_QUERY_PROVIDER,
771
+ Ge as TIMEFRAME_TOKEN
748
772
  };