@kong-ui-public/dashboard-renderer 0.0.1
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/LICENSE +201 -0
- package/README.md +71 -0
- package/dist/dashboard-renderer.es.js +693 -0
- package/dist/dashboard-renderer.umd.js +1 -0
- package/dist/style.css +1 -0
- package/dist/types/components/AnalyticsChartRenderer.vue.d.ts +38 -0
- package/dist/types/components/AnalyticsChartRenderer.vue.d.ts.map +1 -0
- package/dist/types/components/DashboardRenderer.vue.d.ts +58 -0
- package/dist/types/components/DashboardRenderer.vue.d.ts.map +1 -0
- package/dist/types/components/DashboardTile.vue.d.ts +47 -0
- package/dist/types/components/DashboardTile.vue.d.ts.map +1 -0
- package/dist/types/components/QueryDataProvider.vue.d.ts +34 -0
- package/dist/types/components/QueryDataProvider.vue.d.ts.map +1 -0
- package/dist/types/components/SimpleChartRenderer.vue.d.ts +42 -0
- package/dist/types/components/SimpleChartRenderer.vue.d.ts.map +1 -0
- package/dist/types/composables/index.d.ts +6 -0
- package/dist/types/composables/index.d.ts.map +1 -0
- package/dist/types/composables/useI18n.d.ts +62 -0
- package/dist/types/composables/useI18n.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/mock-data.d.ts +25 -0
- package/dist/types/mock-data.d.ts.map +1 -0
- package/dist/types/types/dashboard-renderer-types.d.ts +182 -0
- package/dist/types/types/dashboard-renderer-types.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/query-provider.d.ts +5 -0
- package/dist/types/types/query-provider.d.ts.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,693 @@
|
|
|
1
|
+
import { getCurrentInstance as pe, ref as L, reactive as me, onMounted as _e, onUnmounted as ae, watch as ge, isReadonly as be, toRefs as Re, watchEffect as Ae, defineComponent as V, inject as ie, computed as w, resolveComponent as U, unref as I, openBlock as m, createBlock as E, withCtx as P, createTextVNode as oe, toDisplayString as $, renderSlot as Se, createVNode as ue, createElementBlock as x, createCommentVNode as X, resolveDynamicComponent as Ee, normalizeProps as Ce, mergeProps as Te, Fragment as De, renderList as we } from "vue";
|
|
2
|
+
import { ChartMetricDisplay as Ie, ChartTypesSimple as Oe, SimpleChart as qe, ChartTypes as ee, AnalyticsChart as Ve } from "@kong-ui-public/analytics-chart";
|
|
3
|
+
import { createI18n as ke, i18nTComponent as Le } from "@kong-ui-public/i18n";
|
|
4
|
+
var S = /* @__PURE__ */ ((e) => (e.HorizontalBar = "horizontal_bar", e.VerticalBar = "vertical_bar", e.Gauge = "gauge", e))(S || {});
|
|
5
|
+
const se = {
|
|
6
|
+
type: "string"
|
|
7
|
+
}, xe = {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
type: {
|
|
11
|
+
type: "string",
|
|
12
|
+
enum: [
|
|
13
|
+
"horizontal_bar",
|
|
14
|
+
"vertical_bar"
|
|
15
|
+
/* VerticalBar */
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
stacked: {
|
|
19
|
+
type: "boolean"
|
|
20
|
+
},
|
|
21
|
+
syntheticsDataKey: se
|
|
22
|
+
},
|
|
23
|
+
required: ["type"],
|
|
24
|
+
additionalProperties: !1
|
|
25
|
+
}, Ne = {
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {
|
|
28
|
+
type: {
|
|
29
|
+
type: "string",
|
|
30
|
+
enum: [
|
|
31
|
+
"gauge"
|
|
32
|
+
/* Gauge */
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
metricDisplay: {
|
|
36
|
+
type: "string",
|
|
37
|
+
enum: Object.values(Ie)
|
|
38
|
+
},
|
|
39
|
+
reverseDataset: {
|
|
40
|
+
type: "boolean"
|
|
41
|
+
},
|
|
42
|
+
numerator: {
|
|
43
|
+
type: "number"
|
|
44
|
+
},
|
|
45
|
+
syntheticsDataKey: se
|
|
46
|
+
},
|
|
47
|
+
required: ["type"],
|
|
48
|
+
additionalProperties: !1
|
|
49
|
+
}, Pe = {
|
|
50
|
+
type: "object",
|
|
51
|
+
properties: {
|
|
52
|
+
query: {
|
|
53
|
+
// TODO: JSON Schema for Explore v4.
|
|
54
|
+
type: "object"
|
|
55
|
+
},
|
|
56
|
+
chart: {
|
|
57
|
+
oneOf: [xe, Ne]
|
|
58
|
+
},
|
|
59
|
+
title: {
|
|
60
|
+
type: "string"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
required: ["chart", "query"],
|
|
64
|
+
additionalProperties: !1
|
|
65
|
+
}, dt = {
|
|
66
|
+
type: "object",
|
|
67
|
+
properties: {
|
|
68
|
+
tiles: {
|
|
69
|
+
type: "array",
|
|
70
|
+
items: Pe
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
required: ["tiles"],
|
|
74
|
+
additionalProperties: !1
|
|
75
|
+
};
|
|
76
|
+
var K = /* @__PURE__ */ new WeakMap(), te = 0;
|
|
77
|
+
function Be(e) {
|
|
78
|
+
if (!e.length)
|
|
79
|
+
return "";
|
|
80
|
+
for (var n = "arg", t = 0; t < e.length; ++t) {
|
|
81
|
+
var i = void 0;
|
|
82
|
+
e[t] === null || typeof e[t] != "object" && typeof e[t] != "function" ? typeof e[t] == "string" ? i = '"' + e[t] + '"' : i = String(e[t]) : K.has(e[t]) ? i = K.get(e[t]) : (i = te, K.set(e[t], te++)), n += "@" + i;
|
|
83
|
+
}
|
|
84
|
+
return n;
|
|
85
|
+
}
|
|
86
|
+
function Ge(e) {
|
|
87
|
+
if (typeof e == "function")
|
|
88
|
+
try {
|
|
89
|
+
e = e();
|
|
90
|
+
} catch {
|
|
91
|
+
e = "";
|
|
92
|
+
}
|
|
93
|
+
return Array.isArray(e) ? e = Be(e) : e = String(e || ""), e;
|
|
94
|
+
}
|
|
95
|
+
var M = (
|
|
96
|
+
/** @class */
|
|
97
|
+
function() {
|
|
98
|
+
function e(n) {
|
|
99
|
+
n === void 0 && (n = 0), this.items = /* @__PURE__ */ new Map(), this.ttl = n;
|
|
100
|
+
}
|
|
101
|
+
return e.prototype.serializeKey = function(n) {
|
|
102
|
+
return Ge(n);
|
|
103
|
+
}, e.prototype.get = function(n) {
|
|
104
|
+
var t = this.serializeKey(n);
|
|
105
|
+
return this.items.get(t);
|
|
106
|
+
}, e.prototype.set = function(n, t, i) {
|
|
107
|
+
var a = this.serializeKey(n), r = i || this.ttl, u = Date.now(), c = {
|
|
108
|
+
data: t,
|
|
109
|
+
createdAt: u,
|
|
110
|
+
expiresAt: r ? u + r : 1 / 0
|
|
111
|
+
};
|
|
112
|
+
this.dispatchExpire(r, c, a), this.items.set(a, c);
|
|
113
|
+
}, e.prototype.dispatchExpire = function(n, t, i) {
|
|
114
|
+
var a = this;
|
|
115
|
+
n && setTimeout(function() {
|
|
116
|
+
var r = Date.now(), u = r >= t.expiresAt;
|
|
117
|
+
u && a.delete(i);
|
|
118
|
+
}, n);
|
|
119
|
+
}, e.prototype.delete = function(n) {
|
|
120
|
+
this.items.delete(n);
|
|
121
|
+
}, e;
|
|
122
|
+
}()
|
|
123
|
+
);
|
|
124
|
+
function je() {
|
|
125
|
+
return typeof navigator.onLine < "u" ? navigator.onLine : !0;
|
|
126
|
+
}
|
|
127
|
+
function He() {
|
|
128
|
+
return typeof document < "u" && typeof document.visibilityState < "u" ? document.visibilityState !== "hidden" : !0;
|
|
129
|
+
}
|
|
130
|
+
var Ke = function(e) {
|
|
131
|
+
return fetch(e).then(function(n) {
|
|
132
|
+
return n.json();
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
const z = {
|
|
136
|
+
isOnline: je,
|
|
137
|
+
isDocumentVisible: He,
|
|
138
|
+
fetcher: Ke
|
|
139
|
+
};
|
|
140
|
+
var R = globalThis && globalThis.__assign || function() {
|
|
141
|
+
return R = Object.assign || function(e) {
|
|
142
|
+
for (var n, t = 1, i = arguments.length; t < i; t++) {
|
|
143
|
+
n = arguments[t];
|
|
144
|
+
for (var a in n)
|
|
145
|
+
Object.prototype.hasOwnProperty.call(n, a) && (e[a] = n[a]);
|
|
146
|
+
}
|
|
147
|
+
return e;
|
|
148
|
+
}, R.apply(this, arguments);
|
|
149
|
+
}, T = globalThis && globalThis.__awaiter || function(e, n, t, i) {
|
|
150
|
+
function a(r) {
|
|
151
|
+
return r instanceof t ? r : new t(function(u) {
|
|
152
|
+
u(r);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return new (t || (t = Promise))(function(r, u) {
|
|
156
|
+
function c(l) {
|
|
157
|
+
try {
|
|
158
|
+
o(i.next(l));
|
|
159
|
+
} catch (h) {
|
|
160
|
+
u(h);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function v(l) {
|
|
164
|
+
try {
|
|
165
|
+
o(i.throw(l));
|
|
166
|
+
} catch (h) {
|
|
167
|
+
u(h);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function o(l) {
|
|
171
|
+
l.done ? r(l.value) : a(l.value).then(c, v);
|
|
172
|
+
}
|
|
173
|
+
o((i = i.apply(e, n || [])).next());
|
|
174
|
+
});
|
|
175
|
+
}, D = globalThis && globalThis.__generator || function(e, n) {
|
|
176
|
+
var t = { label: 0, sent: function() {
|
|
177
|
+
if (r[0] & 1)
|
|
178
|
+
throw r[1];
|
|
179
|
+
return r[1];
|
|
180
|
+
}, trys: [], ops: [] }, i, a, r, u;
|
|
181
|
+
return u = { next: c(0), throw: c(1), return: c(2) }, typeof Symbol == "function" && (u[Symbol.iterator] = function() {
|
|
182
|
+
return this;
|
|
183
|
+
}), u;
|
|
184
|
+
function c(o) {
|
|
185
|
+
return function(l) {
|
|
186
|
+
return v([o, l]);
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function v(o) {
|
|
190
|
+
if (i)
|
|
191
|
+
throw new TypeError("Generator is already executing.");
|
|
192
|
+
for (; t; )
|
|
193
|
+
try {
|
|
194
|
+
if (i = 1, a && (r = o[0] & 2 ? a.return : o[0] ? a.throw || ((r = a.return) && r.call(a), 0) : a.next) && !(r = r.call(a, o[1])).done)
|
|
195
|
+
return r;
|
|
196
|
+
switch (a = 0, r && (o = [o[0] & 2, r.value]), o[0]) {
|
|
197
|
+
case 0:
|
|
198
|
+
case 1:
|
|
199
|
+
r = o;
|
|
200
|
+
break;
|
|
201
|
+
case 4:
|
|
202
|
+
return t.label++, { value: o[1], done: !1 };
|
|
203
|
+
case 5:
|
|
204
|
+
t.label++, a = o[1], o = [0];
|
|
205
|
+
continue;
|
|
206
|
+
case 7:
|
|
207
|
+
o = t.ops.pop(), t.trys.pop();
|
|
208
|
+
continue;
|
|
209
|
+
default:
|
|
210
|
+
if (r = t.trys, !(r = r.length > 0 && r[r.length - 1]) && (o[0] === 6 || o[0] === 2)) {
|
|
211
|
+
t = 0;
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
if (o[0] === 3 && (!r || o[1] > r[0] && o[1] < r[3])) {
|
|
215
|
+
t.label = o[1];
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
if (o[0] === 6 && t.label < r[1]) {
|
|
219
|
+
t.label = r[1], r = o;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
if (r && t.label < r[2]) {
|
|
223
|
+
t.label = r[2], t.ops.push(o);
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
r[2] && t.ops.pop(), t.trys.pop();
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
o = n.call(e, t);
|
|
230
|
+
} catch (l) {
|
|
231
|
+
o = [6, l], a = 0;
|
|
232
|
+
} finally {
|
|
233
|
+
i = r = 0;
|
|
234
|
+
}
|
|
235
|
+
if (o[0] & 5)
|
|
236
|
+
throw o[1];
|
|
237
|
+
return { value: o[0] ? o[1] : void 0, done: !0 };
|
|
238
|
+
}
|
|
239
|
+
}, ze = globalThis && globalThis.__read || function(e, n) {
|
|
240
|
+
var t = typeof Symbol == "function" && e[Symbol.iterator];
|
|
241
|
+
if (!t)
|
|
242
|
+
return e;
|
|
243
|
+
var i = t.call(e), a, r = [], u;
|
|
244
|
+
try {
|
|
245
|
+
for (; (n === void 0 || n-- > 0) && !(a = i.next()).done; )
|
|
246
|
+
r.push(a.value);
|
|
247
|
+
} catch (c) {
|
|
248
|
+
u = { error: c };
|
|
249
|
+
} finally {
|
|
250
|
+
try {
|
|
251
|
+
a && !a.done && (t = i.return) && t.call(i);
|
|
252
|
+
} finally {
|
|
253
|
+
if (u)
|
|
254
|
+
throw u.error;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return r;
|
|
258
|
+
}, Fe = globalThis && globalThis.__spreadArray || function(e, n, t) {
|
|
259
|
+
if (t || arguments.length === 2)
|
|
260
|
+
for (var i = 0, a = n.length, r; i < a; i++)
|
|
261
|
+
(r || !(i in n)) && (r || (r = Array.prototype.slice.call(n, 0, i)), r[i] = n[i]);
|
|
262
|
+
return e.concat(r || Array.prototype.slice.call(n));
|
|
263
|
+
}, le = new M(), N = new M(), F = new M(), ce = {
|
|
264
|
+
cache: le,
|
|
265
|
+
refreshInterval: 0,
|
|
266
|
+
ttl: 0,
|
|
267
|
+
serverTTL: 1e3,
|
|
268
|
+
dedupingInterval: 2e3,
|
|
269
|
+
revalidateOnFocus: !0,
|
|
270
|
+
revalidateDebounce: 0,
|
|
271
|
+
shouldRetryOnError: !0,
|
|
272
|
+
errorRetryInterval: 5e3,
|
|
273
|
+
errorRetryCount: 5,
|
|
274
|
+
fetcher: z.fetcher,
|
|
275
|
+
isOnline: z.isOnline,
|
|
276
|
+
isDocumentVisible: z.isDocumentVisible
|
|
277
|
+
};
|
|
278
|
+
function Ue(e, n, t) {
|
|
279
|
+
var i = N.get(e);
|
|
280
|
+
if (i)
|
|
281
|
+
i.data.push(n);
|
|
282
|
+
else {
|
|
283
|
+
var a = 5e3;
|
|
284
|
+
N.set(e, [n], t > 0 ? t + a : t);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function $e(e, n, t) {
|
|
288
|
+
if (t.isDocumentVisible() && !(t.errorRetryCount !== void 0 && n > t.errorRetryCount)) {
|
|
289
|
+
var i = Math.min(n || 0, t.errorRetryCount), a = i * t.errorRetryInterval;
|
|
290
|
+
setTimeout(function() {
|
|
291
|
+
e(null, { errorRetryCount: i + 1, shouldRetryOnError: !0 });
|
|
292
|
+
}, a);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
var re = function(e, n, t, i) {
|
|
296
|
+
return t === void 0 && (t = le), i === void 0 && (i = ce.ttl), T(void 0, void 0, void 0, function() {
|
|
297
|
+
var a, r, u, c, v, o, l;
|
|
298
|
+
return D(this, function(h) {
|
|
299
|
+
switch (h.label) {
|
|
300
|
+
case 0:
|
|
301
|
+
if (!Qe(n))
|
|
302
|
+
return [3, 5];
|
|
303
|
+
h.label = 1;
|
|
304
|
+
case 1:
|
|
305
|
+
return h.trys.push([1, 3, , 4]), [4, n];
|
|
306
|
+
case 2:
|
|
307
|
+
return a = h.sent(), [3, 4];
|
|
308
|
+
case 3:
|
|
309
|
+
return c = h.sent(), r = c, [3, 4];
|
|
310
|
+
case 4:
|
|
311
|
+
return [3, 6];
|
|
312
|
+
case 5:
|
|
313
|
+
a = n, h.label = 6;
|
|
314
|
+
case 6:
|
|
315
|
+
if (u = !1, v = { data: a, error: r, isValidating: u }, typeof a < "u")
|
|
316
|
+
try {
|
|
317
|
+
t.set(e, v, i);
|
|
318
|
+
} catch (y) {
|
|
319
|
+
console.error("swrv(mutate): failed to set cache", y);
|
|
320
|
+
}
|
|
321
|
+
return o = N.get(e), o && o.data.length && (l = o.data.filter(function(y) {
|
|
322
|
+
return y.key === e;
|
|
323
|
+
}), l.forEach(function(y, d) {
|
|
324
|
+
typeof v.data < "u" && (y.data = v.data), y.error = v.error, y.isValidating = v.isValidating;
|
|
325
|
+
var _ = d === l.length - 1;
|
|
326
|
+
_ || delete l[d];
|
|
327
|
+
}), l = l.filter(Boolean)), [2, v];
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
function Me() {
|
|
333
|
+
for (var e = this, n = [], t = 0; t < arguments.length; t++)
|
|
334
|
+
n[t] = arguments[t];
|
|
335
|
+
var i, a, r = R({}, ce), u = !1, c = !1, v = pe(), o = (v == null ? void 0 : v.proxy) || v;
|
|
336
|
+
if (!o)
|
|
337
|
+
return console.error("Could not get current instance, check to make sure that `useSwrv` is declared in the top level of the setup function."), null;
|
|
338
|
+
var l = (o == null ? void 0 : o.$isServer) || !1;
|
|
339
|
+
n.length >= 1 && (i = n[0]), n.length >= 2 && (a = n[1]), n.length > 2 && (r = R(R({}, r), n[2]));
|
|
340
|
+
var h = l ? r.serverTTL : r.ttl, y = typeof i == "function" ? i : L(i);
|
|
341
|
+
typeof a > "u" && (a = r.fetcher);
|
|
342
|
+
var d = null;
|
|
343
|
+
d || (d = me({
|
|
344
|
+
data: void 0,
|
|
345
|
+
error: void 0,
|
|
346
|
+
isValidating: !0,
|
|
347
|
+
key: null
|
|
348
|
+
}));
|
|
349
|
+
var _ = function(f, s) {
|
|
350
|
+
return T(e, void 0, void 0, function() {
|
|
351
|
+
var Q, p, O, q, B, W, G, J = this;
|
|
352
|
+
return D(this, function(j) {
|
|
353
|
+
switch (j.label) {
|
|
354
|
+
case 0:
|
|
355
|
+
return Q = d.data === void 0, p = y.value, p ? (O = r.cache.get(p), q = O && O.data, d.isValidating = !0, q && (d.data = q.data, d.error = q.error), B = f || a, !B || !r.isDocumentVisible() && !Q || (s == null ? void 0 : s.forceRevalidate) !== void 0 && !(s != null && s.forceRevalidate) ? (d.isValidating = !1, [
|
|
356
|
+
2
|
|
357
|
+
/*return*/
|
|
358
|
+
]) : O && (W = !!(Date.now() - O.createdAt >= r.dedupingInterval || s != null && s.forceRevalidate), !W) ? (d.isValidating = !1, [
|
|
359
|
+
2
|
|
360
|
+
/*return*/
|
|
361
|
+
]) : (G = function() {
|
|
362
|
+
return T(J, void 0, void 0, function() {
|
|
363
|
+
var A, Y, H, Z;
|
|
364
|
+
return D(this, function(k) {
|
|
365
|
+
switch (k.label) {
|
|
366
|
+
case 0:
|
|
367
|
+
return A = F.get(p), A ? [3, 2] : (Y = Array.isArray(p) ? p : [p], H = B.apply(void 0, Fe([], ze(Y), !1)), F.set(p, H, r.dedupingInterval), [4, re(p, H, r.cache, h)]);
|
|
368
|
+
case 1:
|
|
369
|
+
return k.sent(), [3, 4];
|
|
370
|
+
case 2:
|
|
371
|
+
return [4, re(p, A.data, r.cache, h)];
|
|
372
|
+
case 3:
|
|
373
|
+
k.sent(), k.label = 4;
|
|
374
|
+
case 4:
|
|
375
|
+
return d.isValidating = !1, F.delete(p), d.error !== void 0 && (Z = !u && r.shouldRetryOnError && (s ? s.shouldRetryOnError : !0), Z && $e(_, s ? s.errorRetryCount : 1, r)), [
|
|
376
|
+
2
|
|
377
|
+
/*return*/
|
|
378
|
+
];
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
}, q && r.revalidateDebounce ? (setTimeout(function() {
|
|
383
|
+
return T(J, void 0, void 0, function() {
|
|
384
|
+
return D(this, function(A) {
|
|
385
|
+
switch (A.label) {
|
|
386
|
+
case 0:
|
|
387
|
+
return u ? [3, 2] : [4, G()];
|
|
388
|
+
case 1:
|
|
389
|
+
A.sent(), A.label = 2;
|
|
390
|
+
case 2:
|
|
391
|
+
return [
|
|
392
|
+
2
|
|
393
|
+
/*return*/
|
|
394
|
+
];
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
}, r.revalidateDebounce), [3, 3]) : [3, 1])) : [
|
|
399
|
+
2
|
|
400
|
+
/*return*/
|
|
401
|
+
];
|
|
402
|
+
case 1:
|
|
403
|
+
return [4, G()];
|
|
404
|
+
case 2:
|
|
405
|
+
j.sent(), j.label = 3;
|
|
406
|
+
case 3:
|
|
407
|
+
return [
|
|
408
|
+
2
|
|
409
|
+
/*return*/
|
|
410
|
+
];
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
}, b = function() {
|
|
415
|
+
return T(e, void 0, void 0, function() {
|
|
416
|
+
return D(this, function(f) {
|
|
417
|
+
return [2, _(null, { shouldRetryOnError: !1 })];
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
}, g = null;
|
|
421
|
+
_e(function() {
|
|
422
|
+
var f = function() {
|
|
423
|
+
return T(e, void 0, void 0, function() {
|
|
424
|
+
return D(this, function(s) {
|
|
425
|
+
switch (s.label) {
|
|
426
|
+
case 0:
|
|
427
|
+
return !d.error && r.isOnline() ? [4, _()] : [3, 2];
|
|
428
|
+
case 1:
|
|
429
|
+
return s.sent(), [3, 3];
|
|
430
|
+
case 2:
|
|
431
|
+
g && clearTimeout(g), s.label = 3;
|
|
432
|
+
case 3:
|
|
433
|
+
return r.refreshInterval && !u && (g = setTimeout(f, r.refreshInterval)), [
|
|
434
|
+
2
|
|
435
|
+
/*return*/
|
|
436
|
+
];
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
};
|
|
441
|
+
r.refreshInterval && (g = setTimeout(f, r.refreshInterval)), r.revalidateOnFocus && (document.addEventListener("visibilitychange", b, !1), window.addEventListener("focus", b, !1));
|
|
442
|
+
}), ae(function() {
|
|
443
|
+
u = !0, g && clearTimeout(g), r.revalidateOnFocus && (document.removeEventListener("visibilitychange", b, !1), window.removeEventListener("focus", b, !1));
|
|
444
|
+
var f = N.get(y.value);
|
|
445
|
+
f && (f.data = f.data.filter(function(s) {
|
|
446
|
+
return s !== d;
|
|
447
|
+
}));
|
|
448
|
+
});
|
|
449
|
+
try {
|
|
450
|
+
ge(y, function(f) {
|
|
451
|
+
be(y) || (y.value = f), d.key = f, d.isValidating = !!f, Ue(y.value, d, h), !l && !c && y.value && _(), c = !1;
|
|
452
|
+
}, {
|
|
453
|
+
immediate: !0
|
|
454
|
+
});
|
|
455
|
+
} catch {
|
|
456
|
+
}
|
|
457
|
+
var C = R(R({}, Re(d)), { mutate: function(f, s) {
|
|
458
|
+
return _(f, R(R({}, s), { forceRevalidate: !0 }));
|
|
459
|
+
} });
|
|
460
|
+
return C;
|
|
461
|
+
}
|
|
462
|
+
function Qe(e) {
|
|
463
|
+
return e !== null && typeof e == "object" && typeof e.then == "function";
|
|
464
|
+
}
|
|
465
|
+
const de = "analytics-query-provider";
|
|
466
|
+
var fe = /* @__PURE__ */ ((e) => (e.VALIDATING = "VALIDATING", e.VALIDATING_HAS_DATA = "VALIDATING_HAS_DATA", e.PENDING = "PENDING", e.SUCCESS = "SUCCESS", e.SUCCESS_HAS_DATA = "SUCCESS_HAS_DATA", e.ERROR = "ERROR", e.STALE_IF_ERROR = "STALE_IF_ERROR", e))(fe || {});
|
|
467
|
+
const We = (e) => {
|
|
468
|
+
var n, t, i, a, r;
|
|
469
|
+
return e ? !!// TODO: revisit: currently only the first check ever matters?
|
|
470
|
+
((n = Object.keys(e)) != null && n.length || (t = e.data) != null && t.length || (a = (i = e.data) == null ? void 0 : i.data) != null && a.length || !((r = e.data) != null && r.data) && typeof e.data == "object" && Object.keys(e == null ? void 0 : e.data).length) : !1;
|
|
471
|
+
};
|
|
472
|
+
function Je(e = L({}), n, t, i = We) {
|
|
473
|
+
const a = L(
|
|
474
|
+
"PENDING"
|
|
475
|
+
/* PENDING */
|
|
476
|
+
);
|
|
477
|
+
return Ae(() => {
|
|
478
|
+
const r = i(e.value);
|
|
479
|
+
if (e.value && r && t.value) {
|
|
480
|
+
a.value = "VALIDATING_HAS_DATA";
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
if (e.value && t.value) {
|
|
484
|
+
a.value = "VALIDATING";
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
if (e.value && n.value) {
|
|
488
|
+
a.value = "STALE_IF_ERROR";
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (e.value === void 0 && !n.value) {
|
|
492
|
+
a.value = "PENDING";
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
if (e.value && !n.value && r) {
|
|
496
|
+
a.value = "SUCCESS_HAS_DATA";
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
if (e.value && !n.value) {
|
|
500
|
+
a.value = "SUCCESS";
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
e.value === void 0 && n && (a.value = "ERROR");
|
|
504
|
+
}), {
|
|
505
|
+
state: a,
|
|
506
|
+
swrvState: fe
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
const Ye = {
|
|
510
|
+
noQueryBridge: "No query bridge provided. Unable to render dashboard."
|
|
511
|
+
}, Ze = {
|
|
512
|
+
timeRangeExceeded: "The time range for this report is outside of your organization's data retention period"
|
|
513
|
+
}, Xe = {
|
|
514
|
+
renderer: Ye,
|
|
515
|
+
queryDataProvider: Ze
|
|
516
|
+
};
|
|
517
|
+
function et() {
|
|
518
|
+
const e = ke("en-us", Xe);
|
|
519
|
+
return {
|
|
520
|
+
i18n: e,
|
|
521
|
+
i18nT: Le(e)
|
|
522
|
+
// Translation component <i18n-t>
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
const ve = {
|
|
526
|
+
useI18n: et
|
|
527
|
+
}, ye = /* @__PURE__ */ V({
|
|
528
|
+
__name: "QueryDataProvider",
|
|
529
|
+
props: {
|
|
530
|
+
query: {},
|
|
531
|
+
queryReady: { type: Boolean }
|
|
532
|
+
},
|
|
533
|
+
emits: ["queryComplete"],
|
|
534
|
+
setup(e, { emit: n }) {
|
|
535
|
+
const t = e, { i18n: i } = ve.useI18n(), a = ie(de), r = () => t.queryReady && a ? JSON.stringify(t.query) : null, u = new AbortController();
|
|
536
|
+
ae(() => {
|
|
537
|
+
u.abort();
|
|
538
|
+
});
|
|
539
|
+
const { data: c, error: v, isValidating: o } = Me(r, async () => {
|
|
540
|
+
var b, g, C, f;
|
|
541
|
+
try {
|
|
542
|
+
return a == null ? void 0 : a.query(t.query, u);
|
|
543
|
+
} catch (s) {
|
|
544
|
+
y.value = ((g = (b = s == null ? void 0 : s.response) == null ? void 0 : b.data) == null ? void 0 : g.message) === "Range not allowed for this tier" ? i.t("queryDataProvider.timeRangeExceeded") : ((f = (C = s == null ? void 0 : s.response) == null ? void 0 : C.data) == null ? void 0 : f.message) || (s == null ? void 0 : s.message);
|
|
545
|
+
} finally {
|
|
546
|
+
n("queryComplete");
|
|
547
|
+
}
|
|
548
|
+
}), { state: l, swrvState: h } = Je(c, v, o), y = L(null), d = w(() => l.value === h.ERROR || !!y.value), _ = w(() => !t.queryReady || l.value === h.PENDING);
|
|
549
|
+
return (b, g) => {
|
|
550
|
+
const C = U("KSkeleton"), f = U("KEmptyState");
|
|
551
|
+
return _.value || !I(c) && !d.value ? (m(), E(C, {
|
|
552
|
+
key: 0,
|
|
553
|
+
class: "chart-skeleton",
|
|
554
|
+
type: "table"
|
|
555
|
+
})) : !_.value && d.value ? (m(), E(f, {
|
|
556
|
+
key: 1,
|
|
557
|
+
"cta-is-hidden": "",
|
|
558
|
+
"data-testid": "chart-empty-state",
|
|
559
|
+
"is-error": ""
|
|
560
|
+
}, {
|
|
561
|
+
message: P(() => [
|
|
562
|
+
oe($(y.value), 1)
|
|
563
|
+
]),
|
|
564
|
+
_: 1
|
|
565
|
+
})) : Se(b.$slots, "default", {
|
|
566
|
+
key: 2,
|
|
567
|
+
data: I(c)
|
|
568
|
+
});
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
}), tt = /* @__PURE__ */ V({
|
|
572
|
+
__name: "SimpleChartRenderer",
|
|
573
|
+
props: {
|
|
574
|
+
query: {},
|
|
575
|
+
queryReady: { type: Boolean },
|
|
576
|
+
chartOptions: {}
|
|
577
|
+
},
|
|
578
|
+
setup(e) {
|
|
579
|
+
const n = e, t = {
|
|
580
|
+
[S.Gauge]: Oe.GAUGE
|
|
581
|
+
}, i = w(() => ({
|
|
582
|
+
...n.chartOptions,
|
|
583
|
+
type: t[n.chartOptions.type]
|
|
584
|
+
}));
|
|
585
|
+
return (a, r) => (m(), E(ye, {
|
|
586
|
+
query: n.query,
|
|
587
|
+
"query-ready": n.queryReady
|
|
588
|
+
}, {
|
|
589
|
+
default: P(({ data: u }) => [
|
|
590
|
+
ue(I(qe), {
|
|
591
|
+
"chart-data": u,
|
|
592
|
+
"chart-options": i.value,
|
|
593
|
+
"synthetics-data-key": n.chartOptions.syntheticsDataKey
|
|
594
|
+
}, null, 8, ["chart-data", "chart-options", "synthetics-data-key"])
|
|
595
|
+
]),
|
|
596
|
+
_: 1
|
|
597
|
+
}, 8, ["query", "query-ready"]));
|
|
598
|
+
}
|
|
599
|
+
}), ne = /* @__PURE__ */ V({
|
|
600
|
+
__name: "AnalyticsChartRenderer",
|
|
601
|
+
props: {
|
|
602
|
+
query: {},
|
|
603
|
+
queryReady: { type: Boolean },
|
|
604
|
+
chartOptions: {}
|
|
605
|
+
},
|
|
606
|
+
setup(e) {
|
|
607
|
+
const n = e, t = {
|
|
608
|
+
[S.HorizontalBar]: ee.HORIZONTAL_BAR,
|
|
609
|
+
[S.VerticalBar]: ee.VERTICAL_BAR
|
|
610
|
+
}, i = w(() => ({
|
|
611
|
+
type: t[n.chartOptions.type]
|
|
612
|
+
}));
|
|
613
|
+
return (a, r) => (m(), E(ye, {
|
|
614
|
+
query: n.query,
|
|
615
|
+
"query-ready": n.queryReady
|
|
616
|
+
}, {
|
|
617
|
+
default: P(({ data: u }) => [
|
|
618
|
+
ue(I(Ve), {
|
|
619
|
+
"chart-data": u,
|
|
620
|
+
"chart-options": i.value,
|
|
621
|
+
"chart-title": "",
|
|
622
|
+
"tooltip-title": ""
|
|
623
|
+
}, null, 8, ["chart-data", "chart-options"])
|
|
624
|
+
]),
|
|
625
|
+
_: 1
|
|
626
|
+
}, 8, ["query", "query-ready"]));
|
|
627
|
+
}
|
|
628
|
+
}), rt = { class: "tile-boundary" }, nt = { key: 0 }, at = /* @__PURE__ */ V({
|
|
629
|
+
__name: "DashboardTile",
|
|
630
|
+
props: {
|
|
631
|
+
definition: {}
|
|
632
|
+
},
|
|
633
|
+
setup(e) {
|
|
634
|
+
const n = e, t = w(() => n.definition.title), i = {
|
|
635
|
+
[S.HorizontalBar]: ne,
|
|
636
|
+
[S.VerticalBar]: ne,
|
|
637
|
+
[S.Gauge]: tt
|
|
638
|
+
}, a = w(() => ({
|
|
639
|
+
component: i[n.definition.chart.type],
|
|
640
|
+
rendererProps: {
|
|
641
|
+
query: n.definition.query,
|
|
642
|
+
queryReady: !0,
|
|
643
|
+
// TODO: Pipelining
|
|
644
|
+
chartOptions: n.definition.chart
|
|
645
|
+
}
|
|
646
|
+
}));
|
|
647
|
+
return (r, u) => (m(), x("div", rt, [
|
|
648
|
+
t.value ? (m(), x("h2", nt, $(t.value), 1)) : X("", !0),
|
|
649
|
+
a.value ? (m(), E(Ee(a.value.component), Ce(Te({ key: 1 }, a.value.rendererProps)), null, 16)) : X("", !0)
|
|
650
|
+
]));
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
const he = (e, n) => {
|
|
654
|
+
const t = e.__vccOpts || e;
|
|
655
|
+
for (const [i, a] of n)
|
|
656
|
+
t[i] = a;
|
|
657
|
+
return t;
|
|
658
|
+
}, it = /* @__PURE__ */ he(at, [["__scopeId", "data-v-eb4fff82"]]), ot = { class: "kong-ui-public-dashboard-renderer" }, ut = /* @__PURE__ */ V({
|
|
659
|
+
__name: "DashboardRenderer",
|
|
660
|
+
props: {
|
|
661
|
+
context: {},
|
|
662
|
+
definition: {}
|
|
663
|
+
},
|
|
664
|
+
setup(e) {
|
|
665
|
+
const n = e, { i18n: t } = ve.useI18n(), i = ie(de);
|
|
666
|
+
return (a, r) => {
|
|
667
|
+
const u = U("KAlert");
|
|
668
|
+
return m(), x("div", ot, [
|
|
669
|
+
I(i) ? (m(!0), x(De, { key: 1 }, we(n.definition.tiles, (c, v) => (m(), E(it, {
|
|
670
|
+
key: v,
|
|
671
|
+
definition: c
|
|
672
|
+
}, null, 8, ["definition"]))), 128)) : (m(), E(u, {
|
|
673
|
+
key: 0,
|
|
674
|
+
appearance: "danger"
|
|
675
|
+
}, {
|
|
676
|
+
default: P(() => [
|
|
677
|
+
oe($(I(t).t("renderer.noQueryBridge")), 1)
|
|
678
|
+
]),
|
|
679
|
+
_: 1
|
|
680
|
+
}))
|
|
681
|
+
]);
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
});
|
|
685
|
+
const ft = /* @__PURE__ */ he(ut, [["__scopeId", "data-v-d6a56abf"]]);
|
|
686
|
+
export {
|
|
687
|
+
S as ChartTypes,
|
|
688
|
+
ft as DashboardRenderer,
|
|
689
|
+
xe as barChartSchema,
|
|
690
|
+
dt as dashboardDefinitionSchema,
|
|
691
|
+
Ne as gaugeChartSchema,
|
|
692
|
+
Pe as tileSchema
|
|
693
|
+
};
|