web-mojo 2.1.627 → 2.1.676
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/admin.cjs.js +1 -1
- package/dist/admin.cjs.js.map +1 -1
- package/dist/admin.es.js +105 -75
- package/dist/admin.es.js.map +1 -1
- package/dist/auth.cjs.js +1 -1
- package/dist/auth.cjs.js.map +1 -1
- package/dist/auth.es.js +3 -3
- package/dist/auth.es.js.map +1 -1
- package/dist/charts.cjs.js +1 -1
- package/dist/charts.cjs.js.map +1 -1
- package/dist/charts.es.js +8 -590
- package/dist/charts.es.js.map +1 -1
- package/dist/chunks/{ChatView-swFqHyZi.js → ChatView-B3p8qSTr.js} +6 -6
- package/dist/chunks/{ChatView-swFqHyZi.js.map → ChatView-B3p8qSTr.js.map} +1 -1
- package/dist/chunks/{ChatView-BjbXRdAB.js → ChatView-BGlI_MSK.js} +2 -2
- package/dist/chunks/{ChatView-BjbXRdAB.js.map → ChatView-BGlI_MSK.js.map} +1 -1
- package/dist/chunks/{ContextMenu-CyfbvpND.js → ContextMenu-Bx0cE5UR.js} +2 -2
- package/dist/chunks/{ContextMenu-CyfbvpND.js.map → ContextMenu-Bx0cE5UR.js.map} +1 -1
- package/dist/chunks/{ContextMenu-DeL1AJ2K.js → ContextMenu-C5T3u9pD.js} +2 -2
- package/dist/chunks/{ContextMenu-DeL1AJ2K.js.map → ContextMenu-C5T3u9pD.js.map} +1 -1
- package/dist/chunks/{DataView-gB9r-zaX.js → DataView-DnmzuwRI.js} +2 -2
- package/dist/chunks/{DataView-gB9r-zaX.js.map → DataView-DnmzuwRI.js.map} +1 -1
- package/dist/chunks/{DataView-jx8l28w_.js → DataView-Qn3t_qcS.js} +2 -2
- package/dist/chunks/{DataView-jx8l28w_.js.map → DataView-Qn3t_qcS.js.map} +1 -1
- package/dist/chunks/{Dialog-Cj0Qxc7O.js → Dialog-CDwoJqc9.js} +5 -5
- package/dist/chunks/{Dialog-Cj0Qxc7O.js.map → Dialog-CDwoJqc9.js.map} +1 -1
- package/dist/chunks/{Dialog-JhRBUdiM.js → Dialog-DMXaIubd.js} +2 -2
- package/dist/chunks/{Dialog-JhRBUdiM.js.map → Dialog-DMXaIubd.js.map} +1 -1
- package/dist/chunks/{FormView-bFKcq_xg.js → FormView-66LGmBqh.js} +2 -2
- package/dist/chunks/{FormView-bFKcq_xg.js.map → FormView-66LGmBqh.js.map} +1 -1
- package/dist/chunks/{FormView-CpChFpxv.js → FormView-DP6RZ-L7.js} +2 -2
- package/dist/chunks/{FormView-CpChFpxv.js.map → FormView-DP6RZ-L7.js.map} +1 -1
- package/dist/chunks/{MetricsChart-DS6rz7HC.js → MetricsMiniChartWidget-CzqKovoB.js} +777 -4
- package/dist/chunks/MetricsMiniChartWidget-CzqKovoB.js.map +1 -0
- package/dist/chunks/{MetricsChart-Dv49hXjf.js → MetricsMiniChartWidget-hthLm2UU.js} +2 -2
- package/dist/chunks/MetricsMiniChartWidget-hthLm2UU.js.map +1 -0
- package/dist/chunks/{PDFViewer-DnsHONcG.js → PDFViewer-B1mYS5sx.js} +2 -2
- package/dist/chunks/{PDFViewer-DnsHONcG.js.map → PDFViewer-B1mYS5sx.js.map} +1 -1
- package/dist/chunks/{PDFViewer-CcHiuM7c.js → PDFViewer-DcCMCAcj.js} +3 -3
- package/dist/chunks/{PDFViewer-CcHiuM7c.js.map → PDFViewer-DcCMCAcj.js.map} +1 -1
- package/dist/chunks/{Page-DmOy8qUF.js → Page-CTj8NKBW.js} +2 -2
- package/dist/chunks/{Page-DmOy8qUF.js.map → Page-CTj8NKBW.js.map} +1 -1
- package/dist/chunks/{Page-DdYMaASr.js → Page-CayRLia1.js} +2 -2
- package/dist/chunks/{Page-DdYMaASr.js.map → Page-CayRLia1.js.map} +1 -1
- package/dist/chunks/{TopNav-Bat8EzdF.js → TopNav-CKO0_lBo.js} +5 -5
- package/dist/chunks/{TopNav-Bat8EzdF.js.map → TopNav-CKO0_lBo.js.map} +1 -1
- package/dist/chunks/{TopNav-CN_2e_48.js → TopNav-DMkIwiOK.js} +2 -2
- package/dist/chunks/{TopNav-CN_2e_48.js.map → TopNav-DMkIwiOK.js.map} +1 -1
- package/dist/chunks/{WebApp-DpGABopL.js → WebApp-BEjXQJb8.js} +2 -2
- package/dist/chunks/{WebApp-DpGABopL.js.map → WebApp-BEjXQJb8.js.map} +1 -1
- package/dist/chunks/{WebApp-DeoEYrl6.js → WebApp-nRyeYQ0g.js} +14 -13
- package/dist/chunks/{WebApp-DeoEYrl6.js.map → WebApp-nRyeYQ0g.js.map} +1 -1
- package/dist/docit.cjs.js +1 -1
- package/dist/docit.es.js +5 -5
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +11 -11
- package/dist/lightbox.cjs.js +1 -1
- package/dist/lightbox.es.js +4 -4
- package/package.json +1 -1
- package/dist/chunks/MetricsChart-DS6rz7HC.js.map +0 -1
- package/dist/chunks/MetricsChart-Dv49hXjf.js.map +0 -1
package/dist/charts.es.js
CHANGED
|
@@ -1,599 +1,17 @@
|
|
|
1
|
-
import { B, M, P, S } from "./chunks/
|
|
2
|
-
import {
|
|
3
|
-
import { B as B2, b, a, c, e, f, W } from "./chunks/WebApp-DeoEYrl6.js";
|
|
4
|
-
class MiniChart extends View {
|
|
5
|
-
constructor(options = {}) {
|
|
6
|
-
super({
|
|
7
|
-
className: "mini-chart",
|
|
8
|
-
...options
|
|
9
|
-
});
|
|
10
|
-
this.chartType = options.chartType || "line";
|
|
11
|
-
this.data = options.data || [];
|
|
12
|
-
this.width = options.width || "100%";
|
|
13
|
-
this.height = options.height || 30;
|
|
14
|
-
this.maintainAspectRatio = options.maintainAspectRatio || false;
|
|
15
|
-
this.color = options.color || "rgba(54, 162, 235, 1)";
|
|
16
|
-
this.fillColor = options.fillColor || "rgba(54, 162, 235, 0.1)";
|
|
17
|
-
this.strokeWidth = options.strokeWidth || 2;
|
|
18
|
-
this.barGap = options.barGap || 2;
|
|
19
|
-
this.fill = options.fill !== false;
|
|
20
|
-
this.smoothing = options.smoothing || 0.3;
|
|
21
|
-
this.padding = options.padding || 2;
|
|
22
|
-
this.minValue = options.minValue;
|
|
23
|
-
this.maxValue = options.maxValue;
|
|
24
|
-
this.showDots = options.showDots || false;
|
|
25
|
-
this.dotRadius = options.dotRadius || 2;
|
|
26
|
-
this.animate = options.animate !== false;
|
|
27
|
-
this.animationDuration = options.animationDuration || 300;
|
|
28
|
-
this.showTooltip = options.showTooltip !== false;
|
|
29
|
-
this.tooltipFormatter = options.tooltipFormatter || null;
|
|
30
|
-
this.tooltipTemplate = options.tooltipTemplate || null;
|
|
31
|
-
this.valueFormat = options.valueFormat || null;
|
|
32
|
-
this.labelFormat = options.labelFormat || null;
|
|
33
|
-
this.showCrosshair = options.showCrosshair !== false;
|
|
34
|
-
this.crosshairColor = options.crosshairColor || "rgba(0, 0, 0, 0.2)";
|
|
35
|
-
this.crosshairWidth = options.crosshairWidth || 1;
|
|
36
|
-
this.showXAxis = options.showXAxis || false;
|
|
37
|
-
this.xAxisColor = options.xAxisColor || this.color;
|
|
38
|
-
this.xAxisWidth = options.xAxisWidth || 1;
|
|
39
|
-
this.xAxisDashed = options.xAxisDashed !== false;
|
|
40
|
-
this.tooltip = null;
|
|
41
|
-
this.crosshair = null;
|
|
42
|
-
this.hoveredIndex = -1;
|
|
43
|
-
this.dataFormatter = dataFormatter;
|
|
44
|
-
this.labels = options.labels || null;
|
|
45
|
-
}
|
|
46
|
-
getTemplate() {
|
|
47
|
-
const widthStyle = typeof this.width === "number" ? `${this.width}px` : this.width;
|
|
48
|
-
const heightStyle = typeof this.height === "number" ? `${this.height}px` : this.height;
|
|
49
|
-
const preserveAspectRatio = this.maintainAspectRatio ? "xMidYMid meet" : "none";
|
|
50
|
-
return `
|
|
51
|
-
<div class="mini-chart-wrapper" style="position: relative; display: block; width: ${widthStyle}; height: ${heightStyle};">
|
|
52
|
-
<svg
|
|
53
|
-
class="mini-chart-svg"
|
|
54
|
-
width="100%"
|
|
55
|
-
height="100%"
|
|
56
|
-
viewBox="0 0 100 ${this.height}"
|
|
57
|
-
preserveAspectRatio="${preserveAspectRatio}"
|
|
58
|
-
style="display: block;">
|
|
59
|
-
</svg>
|
|
60
|
-
${this.showTooltip ? '<div class="mini-chart-tooltip" style="display: none;"></div>' : ""}
|
|
61
|
-
</div>
|
|
62
|
-
`;
|
|
63
|
-
}
|
|
64
|
-
async onAfterRender() {
|
|
65
|
-
this.svg = this.element.querySelector(".mini-chart-svg");
|
|
66
|
-
this.tooltip = this.element.querySelector(".mini-chart-tooltip");
|
|
67
|
-
this.updateDimensions();
|
|
68
|
-
if (this.data && this.data.length > 0) {
|
|
69
|
-
this.renderChart();
|
|
70
|
-
}
|
|
71
|
-
if (this.showTooltip && this.svg) {
|
|
72
|
-
this.setupTooltip();
|
|
73
|
-
}
|
|
74
|
-
this.setupResizeObserver();
|
|
75
|
-
}
|
|
76
|
-
updateDimensions() {
|
|
77
|
-
if (!this.svg) return;
|
|
78
|
-
const rect = this.svg.getBoundingClientRect();
|
|
79
|
-
this.actualWidth = rect.width || 100;
|
|
80
|
-
this.actualHeight = rect.height || this.height;
|
|
81
|
-
this.svg.setAttribute("viewBox", `0 0 ${this.actualWidth} ${this.actualHeight}`);
|
|
82
|
-
}
|
|
83
|
-
setupResizeObserver() {
|
|
84
|
-
if (typeof ResizeObserver === "undefined") return;
|
|
85
|
-
this.resizeObserver = new ResizeObserver(() => {
|
|
86
|
-
this.updateDimensions();
|
|
87
|
-
if (this.data && this.data.length > 0) {
|
|
88
|
-
this.renderChart();
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
if (this.svg) {
|
|
92
|
-
this.resizeObserver.observe(this.svg);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
renderChart() {
|
|
96
|
-
if (!this.svg || !this.data || this.data.length === 0) return;
|
|
97
|
-
this.svg.innerHTML = "";
|
|
98
|
-
const { min, max } = this.calculateBounds();
|
|
99
|
-
if (this.showXAxis) {
|
|
100
|
-
this.renderXAxis(min, max);
|
|
101
|
-
}
|
|
102
|
-
if (this.chartType === "line") {
|
|
103
|
-
this.renderLine(min, max);
|
|
104
|
-
} else if (this.chartType === "bar") {
|
|
105
|
-
this.renderBar(min, max);
|
|
106
|
-
}
|
|
107
|
-
if (this.showCrosshair) {
|
|
108
|
-
const height = this.getActualHeight();
|
|
109
|
-
this.crosshair = this.createSVGElement("line", {
|
|
110
|
-
x1: 0,
|
|
111
|
-
y1: 0,
|
|
112
|
-
x2: 0,
|
|
113
|
-
y2: height,
|
|
114
|
-
stroke: this.crosshairColor,
|
|
115
|
-
"stroke-width": this.crosshairWidth,
|
|
116
|
-
"stroke-dasharray": "3,3",
|
|
117
|
-
style: "display: none; pointer-events: none;"
|
|
118
|
-
});
|
|
119
|
-
this.svg.appendChild(this.crosshair);
|
|
120
|
-
}
|
|
121
|
-
if (this.showTooltip && this.tooltip) {
|
|
122
|
-
this.setupTooltip();
|
|
123
|
-
}
|
|
124
|
-
if (this.animate) {
|
|
125
|
-
this.applyAnimation();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
renderXAxis(min, max) {
|
|
129
|
-
const width = this.getActualWidth();
|
|
130
|
-
const height = this.getActualHeight();
|
|
131
|
-
let yPos;
|
|
132
|
-
if (min <= 0 && max >= 0) {
|
|
133
|
-
const range = max - min;
|
|
134
|
-
const yScale = (height - this.padding * 2) / range;
|
|
135
|
-
yPos = height - this.padding - (0 - min) * yScale;
|
|
136
|
-
} else {
|
|
137
|
-
yPos = height - this.padding;
|
|
138
|
-
}
|
|
139
|
-
const xAxis = this.createSVGElement("line", {
|
|
140
|
-
x1: this.padding,
|
|
141
|
-
y1: yPos,
|
|
142
|
-
x2: width - this.padding,
|
|
143
|
-
y2: yPos,
|
|
144
|
-
stroke: this.xAxisColor,
|
|
145
|
-
"stroke-width": this.xAxisWidth,
|
|
146
|
-
"stroke-dasharray": this.xAxisDashed ? "2,2" : "none",
|
|
147
|
-
"stroke-opacity": "0.5"
|
|
148
|
-
});
|
|
149
|
-
this.svg.appendChild(xAxis);
|
|
150
|
-
}
|
|
151
|
-
calculateBounds() {
|
|
152
|
-
const values = this.data.map((d) => typeof d === "object" ? d.value : d);
|
|
153
|
-
let min = this.minValue !== void 0 ? this.minValue : Math.min(...values);
|
|
154
|
-
let max = this.maxValue !== void 0 ? this.maxValue : Math.max(...values);
|
|
155
|
-
const range = max - min;
|
|
156
|
-
if (range === 0) {
|
|
157
|
-
min = min - 1;
|
|
158
|
-
max = max + 1;
|
|
159
|
-
}
|
|
160
|
-
return { min, max };
|
|
161
|
-
}
|
|
162
|
-
getActualWidth() {
|
|
163
|
-
return this.actualWidth || this.width || 100;
|
|
164
|
-
}
|
|
165
|
-
getActualHeight() {
|
|
166
|
-
return this.actualHeight || this.height || 30;
|
|
167
|
-
}
|
|
168
|
-
renderLine(min, max) {
|
|
169
|
-
const values = this.data.map((d) => typeof d === "object" ? d.value : d);
|
|
170
|
-
const points = this.calculatePoints(values, min, max);
|
|
171
|
-
if (this.fill) {
|
|
172
|
-
const areaPath = this.createAreaPath(points);
|
|
173
|
-
const area = this.createSVGElement("path", {
|
|
174
|
-
d: areaPath,
|
|
175
|
-
fill: this.fillColor,
|
|
176
|
-
stroke: "none"
|
|
177
|
-
});
|
|
178
|
-
this.svg.appendChild(area);
|
|
179
|
-
}
|
|
180
|
-
const linePath = this.smoothing > 0 ? this.createSmoothPath(points) : this.createLinePath(points);
|
|
181
|
-
const line = this.createSVGElement("path", {
|
|
182
|
-
d: linePath,
|
|
183
|
-
fill: "none",
|
|
184
|
-
stroke: this.color,
|
|
185
|
-
"stroke-width": this.strokeWidth,
|
|
186
|
-
"stroke-linecap": "round",
|
|
187
|
-
"stroke-linejoin": "round"
|
|
188
|
-
});
|
|
189
|
-
this.svg.appendChild(line);
|
|
190
|
-
if (this.showDots) {
|
|
191
|
-
points.forEach((point) => {
|
|
192
|
-
const dot = this.createSVGElement("circle", {
|
|
193
|
-
cx: point.x,
|
|
194
|
-
cy: point.y,
|
|
195
|
-
r: this.dotRadius,
|
|
196
|
-
fill: this.color
|
|
197
|
-
});
|
|
198
|
-
this.svg.appendChild(dot);
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
renderBar(min, max) {
|
|
203
|
-
const values = this.data.map((d) => typeof d === "object" ? d.value : d);
|
|
204
|
-
const points = this.calculatePoints(values, min, max);
|
|
205
|
-
const width = this.getActualWidth();
|
|
206
|
-
const height = this.getActualHeight();
|
|
207
|
-
const barWidth = (width - this.padding * 2 - this.barGap * (values.length - 1)) / values.length;
|
|
208
|
-
points.forEach((point, index) => {
|
|
209
|
-
const barHeight = height - this.padding * 2 - point.y + this.padding;
|
|
210
|
-
const x = point.x - barWidth / 2;
|
|
211
|
-
const y = point.y;
|
|
212
|
-
const bar = this.createSVGElement("rect", {
|
|
213
|
-
x,
|
|
214
|
-
y,
|
|
215
|
-
width: barWidth,
|
|
216
|
-
height: barHeight,
|
|
217
|
-
fill: this.color,
|
|
218
|
-
rx: 1,
|
|
219
|
-
// Slight rounding
|
|
220
|
-
"data-bar-index": index,
|
|
221
|
-
class: "mini-chart-bar"
|
|
222
|
-
});
|
|
223
|
-
this.svg.appendChild(bar);
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
calculatePoints(values, min, max) {
|
|
227
|
-
const range = max - min;
|
|
228
|
-
const width = this.getActualWidth();
|
|
229
|
-
const height = this.getActualHeight();
|
|
230
|
-
const xStep = (width - this.padding * 2) / (values.length - 1 || 1);
|
|
231
|
-
const yScale = (height - this.padding * 2) / range;
|
|
232
|
-
return values.map((value, index) => ({
|
|
233
|
-
x: this.padding + index * xStep,
|
|
234
|
-
y: height - this.padding - (value - min) * yScale
|
|
235
|
-
}));
|
|
236
|
-
}
|
|
237
|
-
createLinePath(points) {
|
|
238
|
-
if (points.length === 0) return "";
|
|
239
|
-
let path = `M ${points[0].x},${points[0].y}`;
|
|
240
|
-
for (let i = 1; i < points.length; i++) {
|
|
241
|
-
path += ` L ${points[i].x},${points[i].y}`;
|
|
242
|
-
}
|
|
243
|
-
return path;
|
|
244
|
-
}
|
|
245
|
-
createSmoothPath(points) {
|
|
246
|
-
if (points.length < 2) return this.createLinePath(points);
|
|
247
|
-
let path = `M ${points[0].x},${points[0].y}`;
|
|
248
|
-
for (let i = 0; i < points.length - 1; i++) {
|
|
249
|
-
const current = points[i];
|
|
250
|
-
const next = points[i + 1];
|
|
251
|
-
const cp1x = current.x + (next.x - current.x) * this.smoothing;
|
|
252
|
-
const cp1y = current.y;
|
|
253
|
-
const cp2x = next.x - (next.x - current.x) * this.smoothing;
|
|
254
|
-
const cp2y = next.y;
|
|
255
|
-
path += ` C ${cp1x},${cp1y} ${cp2x},${cp2y} ${next.x},${next.y}`;
|
|
256
|
-
}
|
|
257
|
-
return path;
|
|
258
|
-
}
|
|
259
|
-
createAreaPath(points) {
|
|
260
|
-
if (points.length === 0) return "";
|
|
261
|
-
const linePath = this.smoothing > 0 ? this.createSmoothPath(points) : this.createLinePath(points);
|
|
262
|
-
const lastPoint = points[points.length - 1];
|
|
263
|
-
const firstPoint = points[0];
|
|
264
|
-
const height = this.getActualHeight();
|
|
265
|
-
return `${linePath} L ${lastPoint.x},${height - this.padding} L ${firstPoint.x},${height - this.padding} Z`;
|
|
266
|
-
}
|
|
267
|
-
createSVGElement(tag, attributes = {}) {
|
|
268
|
-
const element = document.createElementNS("http://www.w3.org/2000/svg", tag);
|
|
269
|
-
Object.entries(attributes).forEach(([key, value]) => {
|
|
270
|
-
element.setAttribute(key, value);
|
|
271
|
-
});
|
|
272
|
-
return element;
|
|
273
|
-
}
|
|
274
|
-
applyAnimation() {
|
|
275
|
-
const paths = this.svg.querySelectorAll("path");
|
|
276
|
-
paths.forEach((path) => {
|
|
277
|
-
const length = path.getTotalLength();
|
|
278
|
-
path.style.strokeDasharray = length;
|
|
279
|
-
path.style.strokeDashoffset = length;
|
|
280
|
-
path.style.animation = `mini-chart-draw ${this.animationDuration}ms ease-out forwards`;
|
|
281
|
-
});
|
|
282
|
-
const bars = this.svg.querySelectorAll("rect");
|
|
283
|
-
bars.forEach((bar, index) => {
|
|
284
|
-
bar.style.transformOrigin = "bottom";
|
|
285
|
-
bar.style.animation = `mini-chart-bar-grow ${this.animationDuration}ms ease-out ${index * 20}ms forwards`;
|
|
286
|
-
bar.style.transform = "scaleY(0)";
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
setupTooltip() {
|
|
290
|
-
if (!this.svg || !this.tooltip) return;
|
|
291
|
-
const values = this.data.map((d) => typeof d === "object" ? d.value : d);
|
|
292
|
-
const points = this.calculatePoints(values, ...Object.values(this.calculateBounds()));
|
|
293
|
-
const width = this.getActualWidth();
|
|
294
|
-
const height = this.getActualHeight();
|
|
295
|
-
const barWidth = width / values.length;
|
|
296
|
-
points.forEach((point, index) => {
|
|
297
|
-
const hitArea = this.createSVGElement("rect", {
|
|
298
|
-
x: index * barWidth,
|
|
299
|
-
y: 0,
|
|
300
|
-
width: barWidth,
|
|
301
|
-
height,
|
|
302
|
-
fill: "transparent",
|
|
303
|
-
style: "cursor: pointer;"
|
|
304
|
-
});
|
|
305
|
-
hitArea.addEventListener("mouseenter", (e2) => {
|
|
306
|
-
this.showTooltipAtIndex(index, e2);
|
|
307
|
-
});
|
|
308
|
-
hitArea.addEventListener("mousemove", (e2) => {
|
|
309
|
-
this.updateTooltipPosition(e2);
|
|
310
|
-
});
|
|
311
|
-
hitArea.addEventListener("mouseleave", () => {
|
|
312
|
-
this.hideTooltip();
|
|
313
|
-
});
|
|
314
|
-
this.svg.appendChild(hitArea);
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
showTooltipAtIndex(index, event) {
|
|
318
|
-
if (!this.tooltip) return;
|
|
319
|
-
this.hoveredIndex = index;
|
|
320
|
-
const value = typeof this.data[index] === "object" ? this.data[index].value : this.data[index];
|
|
321
|
-
const dataLabel = typeof this.data[index] === "object" ? this.data[index].label : null;
|
|
322
|
-
const label = this.labels ? this.labels[index] : dataLabel;
|
|
323
|
-
let content;
|
|
324
|
-
if (this.tooltipTemplate && typeof this.tooltipTemplate === "function") {
|
|
325
|
-
content = this.tooltipTemplate({ value, label, index, data: this.data[index] });
|
|
326
|
-
} else {
|
|
327
|
-
let displayValue = value;
|
|
328
|
-
if (this.valueFormat && this.dataFormatter) {
|
|
329
|
-
displayValue = this.dataFormatter.pipe(value, this.valueFormat);
|
|
330
|
-
} else if (this.tooltipFormatter && typeof this.tooltipFormatter === "function") {
|
|
331
|
-
displayValue = this.tooltipFormatter(value, index);
|
|
332
|
-
} else {
|
|
333
|
-
displayValue = typeof value === "number" ? value.toLocaleString() : value;
|
|
334
|
-
}
|
|
335
|
-
let displayLabel = label;
|
|
336
|
-
if (label && this.labelFormat && this.dataFormatter) {
|
|
337
|
-
displayLabel = this.dataFormatter.pipe(label, this.labelFormat);
|
|
338
|
-
}
|
|
339
|
-
content = `<strong>${displayValue}</strong>`;
|
|
340
|
-
if (displayLabel) {
|
|
341
|
-
content = `<div class="mini-chart-tooltip-label">${displayLabel}</div>${content}`;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
this.tooltip.innerHTML = content;
|
|
345
|
-
this.tooltip.style.display = "block";
|
|
346
|
-
this.updateTooltipPosition(event);
|
|
347
|
-
if (this.chartType === "bar") {
|
|
348
|
-
this.highlightBar(index);
|
|
349
|
-
}
|
|
350
|
-
if (this.crosshair && this.showCrosshair) {
|
|
351
|
-
const width = this.getActualWidth();
|
|
352
|
-
const barWidth = width / this.data.length;
|
|
353
|
-
const x = index * barWidth + barWidth / 2;
|
|
354
|
-
this.crosshair.setAttribute("x1", x);
|
|
355
|
-
this.crosshair.setAttribute("x2", x);
|
|
356
|
-
this.crosshair.style.display = "block";
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
updateTooltipPosition(event) {
|
|
360
|
-
if (!this.tooltip || this.tooltip.style.display === "none") return;
|
|
361
|
-
const rect = this.svg.getBoundingClientRect();
|
|
362
|
-
const x = event.clientX - rect.left;
|
|
363
|
-
const y = event.clientY - rect.top;
|
|
364
|
-
this.tooltip.style.left = `${x}px`;
|
|
365
|
-
this.tooltip.style.top = `${y - 10}px`;
|
|
366
|
-
this.tooltip.style.transform = "translate(-50%, -100%)";
|
|
367
|
-
}
|
|
368
|
-
hideTooltip() {
|
|
369
|
-
if (this.tooltip) {
|
|
370
|
-
this.tooltip.style.display = "none";
|
|
371
|
-
this.hoveredIndex = -1;
|
|
372
|
-
}
|
|
373
|
-
if (this.chartType === "bar") {
|
|
374
|
-
this.unhighlightBars();
|
|
375
|
-
}
|
|
376
|
-
if (this.crosshair) {
|
|
377
|
-
this.crosshair.style.display = "none";
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
highlightBar(index) {
|
|
381
|
-
if (!this.svg) return;
|
|
382
|
-
this.unhighlightBars();
|
|
383
|
-
const bar = this.svg.querySelector(`rect.mini-chart-bar[data-bar-index="${index}"]`);
|
|
384
|
-
if (bar) {
|
|
385
|
-
bar.style.opacity = "0.7";
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
unhighlightBars() {
|
|
389
|
-
if (!this.svg) return;
|
|
390
|
-
const bars = this.svg.querySelectorAll("rect.mini-chart-bar");
|
|
391
|
-
bars.forEach((bar) => {
|
|
392
|
-
bar.style.opacity = "1";
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
// Public API
|
|
396
|
-
setData(data) {
|
|
397
|
-
this.data = data;
|
|
398
|
-
if (this.svg) {
|
|
399
|
-
this.renderChart();
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
setColor(color) {
|
|
403
|
-
this.color = color;
|
|
404
|
-
if (this.svg) {
|
|
405
|
-
this.renderChart();
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
setType(type) {
|
|
409
|
-
if (["line", "bar"].includes(type)) {
|
|
410
|
-
this.chartType = type;
|
|
411
|
-
if (this.svg) {
|
|
412
|
-
this.renderChart();
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
resize(width, height) {
|
|
417
|
-
this.width = width;
|
|
418
|
-
this.height = height;
|
|
419
|
-
this.updateDimensions();
|
|
420
|
-
if (this.svg) {
|
|
421
|
-
this.renderChart();
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
async onBeforeDestroy() {
|
|
425
|
-
if (this.resizeObserver) {
|
|
426
|
-
this.resizeObserver.disconnect();
|
|
427
|
-
this.resizeObserver = null;
|
|
428
|
-
}
|
|
429
|
-
await super.onBeforeDestroy();
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
class MetricsMiniChart extends MiniChart {
|
|
433
|
-
constructor(options = {}) {
|
|
434
|
-
super(options);
|
|
435
|
-
this.endpoint = options.endpoint || "/api/metrics/fetch";
|
|
436
|
-
this.account = options.account || "global";
|
|
437
|
-
this.granularity = options.granularity || "hours";
|
|
438
|
-
this.slugs = options.slugs || null;
|
|
439
|
-
this.category = options.category || null;
|
|
440
|
-
this.dateStart = options.dateStart || null;
|
|
441
|
-
this.dateEnd = options.dateEnd || null;
|
|
442
|
-
this.defaultDateRange = options.defaultDateRange || "24h";
|
|
443
|
-
this.isLoading = false;
|
|
444
|
-
this.lastFetch = null;
|
|
445
|
-
this.refreshInterval = options.refreshInterval;
|
|
446
|
-
if (!this.dateStart || !this.dateEnd) {
|
|
447
|
-
this.setQuickRange(this.defaultDateRange);
|
|
448
|
-
}
|
|
449
|
-
if (this.slugs && !Array.isArray(this.slugs)) {
|
|
450
|
-
this.slugs = [this.slugs];
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
async onAfterRender() {
|
|
454
|
-
await super.onAfterRender();
|
|
455
|
-
if (this.endpoint && (!this.data || this.data.length === 0)) {
|
|
456
|
-
await this.fetchData();
|
|
457
|
-
}
|
|
458
|
-
if (this.refreshInterval && this.endpoint) {
|
|
459
|
-
this.startAutoRefresh();
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
buildApiParams() {
|
|
463
|
-
const params = {
|
|
464
|
-
granularity: this.granularity,
|
|
465
|
-
account: this.account,
|
|
466
|
-
with_labels: true
|
|
467
|
-
};
|
|
468
|
-
if (this.slugs && this.slugs.length > 0) {
|
|
469
|
-
this.slugs.forEach((slug) => {
|
|
470
|
-
if (!params["slugs[]"]) params["slugs[]"] = [];
|
|
471
|
-
params["slugs[]"].push(slug);
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
if (this.category) {
|
|
475
|
-
params.category = this.category;
|
|
476
|
-
}
|
|
477
|
-
if (this.dateStart) {
|
|
478
|
-
params.dr_start = Math.floor(this.dateStart.getTime() / 1e3);
|
|
479
|
-
}
|
|
480
|
-
if (this.dateEnd) {
|
|
481
|
-
params.dr_end = Math.floor(this.dateEnd.getTime() / 1e3);
|
|
482
|
-
}
|
|
483
|
-
params._ = Date.now();
|
|
484
|
-
return params;
|
|
485
|
-
}
|
|
486
|
-
async fetchData() {
|
|
487
|
-
if (!this.endpoint) return;
|
|
488
|
-
this.isLoading = true;
|
|
489
|
-
try {
|
|
490
|
-
const rest = this.getApp()?.rest;
|
|
491
|
-
if (!rest) {
|
|
492
|
-
throw new Error("No REST client available");
|
|
493
|
-
}
|
|
494
|
-
const params = this.buildApiParams();
|
|
495
|
-
const response = await rest.GET(this.endpoint, params);
|
|
496
|
-
if (!response.success) {
|
|
497
|
-
throw new Error(response.message || "Network error");
|
|
498
|
-
}
|
|
499
|
-
if (!response.data?.status) {
|
|
500
|
-
throw new Error(response.data?.error || "Server error");
|
|
501
|
-
}
|
|
502
|
-
const metricsData = response.data.data;
|
|
503
|
-
this.processMetricsData(metricsData);
|
|
504
|
-
this.lastFetch = /* @__PURE__ */ new Date();
|
|
505
|
-
await this.render();
|
|
506
|
-
this.emit("metrics:loaded", { chart: this, data: metricsData, params });
|
|
507
|
-
} catch (error) {
|
|
508
|
-
console.error("Failed to fetch metrics:", error);
|
|
509
|
-
this.emit("metrics:error", { chart: this, error });
|
|
510
|
-
} finally {
|
|
511
|
-
this.isLoading = false;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
processMetricsData(metricsData) {
|
|
515
|
-
const { data: metrics, labels } = metricsData;
|
|
516
|
-
if (!metrics) return;
|
|
517
|
-
const metricKeys = Object.keys(metrics);
|
|
518
|
-
if (metricKeys.length === 0) return;
|
|
519
|
-
const metricSlug = metricKeys[0];
|
|
520
|
-
const values = metrics[metricSlug];
|
|
521
|
-
const sanitizedValues = values.map((val) => {
|
|
522
|
-
if (val === null || val === void 0 || val === "") return 0;
|
|
523
|
-
return typeof val === "number" ? val : parseFloat(val) || 0;
|
|
524
|
-
});
|
|
525
|
-
this.labels = labels || null;
|
|
526
|
-
this.setData(sanitizedValues);
|
|
527
|
-
}
|
|
528
|
-
setQuickRange(range) {
|
|
529
|
-
const now = /* @__PURE__ */ new Date();
|
|
530
|
-
let startDate;
|
|
531
|
-
switch (range) {
|
|
532
|
-
case "1h":
|
|
533
|
-
startDate = new Date(now.getTime() - 60 * 60 * 1e3);
|
|
534
|
-
break;
|
|
535
|
-
case "24h":
|
|
536
|
-
startDate = new Date(now.getTime() - 24 * 60 * 60 * 1e3);
|
|
537
|
-
break;
|
|
538
|
-
case "7d":
|
|
539
|
-
startDate = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1e3);
|
|
540
|
-
break;
|
|
541
|
-
case "30d":
|
|
542
|
-
startDate = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1e3);
|
|
543
|
-
break;
|
|
544
|
-
default:
|
|
545
|
-
startDate = new Date(now.getTime() - 24 * 60 * 60 * 1e3);
|
|
546
|
-
}
|
|
547
|
-
this.dateStart = startDate;
|
|
548
|
-
this.dateEnd = now;
|
|
549
|
-
}
|
|
550
|
-
startAutoRefresh() {
|
|
551
|
-
if (this.refreshTimer) {
|
|
552
|
-
clearInterval(this.refreshTimer);
|
|
553
|
-
}
|
|
554
|
-
this.refreshTimer = setInterval(() => {
|
|
555
|
-
this.fetchData();
|
|
556
|
-
}, this.refreshInterval);
|
|
557
|
-
}
|
|
558
|
-
stopAutoRefresh() {
|
|
559
|
-
if (this.refreshTimer) {
|
|
560
|
-
clearInterval(this.refreshTimer);
|
|
561
|
-
this.refreshTimer = null;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
// Public API
|
|
565
|
-
setGranularity(granularity) {
|
|
566
|
-
this.granularity = granularity;
|
|
567
|
-
return this.fetchData();
|
|
568
|
-
}
|
|
569
|
-
setDateRange(startDate, endDate) {
|
|
570
|
-
this.dateStart = new Date(startDate);
|
|
571
|
-
this.dateEnd = new Date(endDate);
|
|
572
|
-
return this.fetchData();
|
|
573
|
-
}
|
|
574
|
-
setMetrics(slugs) {
|
|
575
|
-
this.slugs = Array.isArray(slugs) ? slugs : [slugs];
|
|
576
|
-
return this.fetchData();
|
|
577
|
-
}
|
|
578
|
-
refresh() {
|
|
579
|
-
return this.fetchData();
|
|
580
|
-
}
|
|
581
|
-
async onBeforeDestroy() {
|
|
582
|
-
this.stopAutoRefresh();
|
|
583
|
-
await super.onBeforeDestroy();
|
|
584
|
-
}
|
|
585
|
-
}
|
|
1
|
+
import { B, M, b, c, a, P, S } from "./chunks/MetricsMiniChartWidget-CzqKovoB.js";
|
|
2
|
+
import { B as B2, b as b2, a as a2, c as c2, e, f, W } from "./chunks/WebApp-nRyeYQ0g.js";
|
|
586
3
|
export {
|
|
587
4
|
B2 as BUILD_TIME,
|
|
588
5
|
B as BaseChart,
|
|
589
6
|
M as MetricsChart,
|
|
590
|
-
MetricsMiniChart,
|
|
591
|
-
|
|
7
|
+
b as MetricsMiniChart,
|
|
8
|
+
c as MetricsMiniChartWidget,
|
|
9
|
+
a as MiniChart,
|
|
592
10
|
P as PieChart,
|
|
593
11
|
S as SeriesChart,
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
12
|
+
b2 as VERSION,
|
|
13
|
+
a2 as VERSION_INFO,
|
|
14
|
+
c2 as VERSION_MAJOR,
|
|
597
15
|
e as VERSION_MINOR,
|
|
598
16
|
f as VERSION_REVISION,
|
|
599
17
|
W as WebApp
|