@pennsieve-viz/tsviewer 1.0.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.
- package/dist/BFLibraryButton-BiLkvU6m.cjs +1 -0
- package/dist/BFLibraryButton-C6aAhW1T.js +72 -0
- package/dist/IconSelection-Bud2XLOy.js +37 -0
- package/dist/IconSelection-DGTELjPb.cjs +1 -0
- package/dist/TSAnnotationCanvas-C3-VI46n.cjs +1 -0
- package/dist/TSAnnotationCanvas-CMZHn8mY.js +729 -0
- package/dist/TSAnnotationModal-BcqWVXP_.js +199 -0
- package/dist/TSAnnotationModal-DskdoFo4.cjs +1 -0
- package/dist/TSFilterModal-BtLOK_nq.js +233 -0
- package/dist/TSFilterModal-DEOWfIi6.cjs +1 -0
- package/dist/TSScrubber-CTjzX-Xq.js +377 -0
- package/dist/TSScrubber-DAnIUBuC.cjs +1 -0
- package/dist/TSViewerCanvas-DkKV70m8.js +5731 -0
- package/dist/TSViewerCanvas-Jbu-Kh9F.cjs +11 -0
- package/dist/TSViewerLayerWindow-wHkjTl6e.cjs +1 -0
- package/dist/TSViewerLayerWindow-zI_48DIx.js +257 -0
- package/dist/TSViewerToolbar-BMZIlD4q.js +551 -0
- package/dist/TSViewerToolbar-C6yy7GJr.cjs +1 -0
- package/dist/TsAnnotationDeleteDialog-Be3AJIyo.cjs +1 -0
- package/dist/TsAnnotationDeleteDialog-Iwpo79Pe.js +245 -0
- package/dist/index-CGSfhm_E.cjs +1 -0
- package/dist/index-Cexzl5Xu.js +1317 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +6 -0
- package/dist/pathOr-D0158Gk1.cjs +1 -0
- package/dist/pathOr-Do2dduwx.js +18 -0
- package/dist/style.css +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { ref as v, computed as N, watch as U, nextTick as E, onMounted as Ne, createElementBlock as Ie, openBlock as $e, createElementVNode as x, toDisplayString as K, normalizeStyle as Q } from "vue";
|
|
2
|
+
import { _ as ve, a as Se, b as Y, c as Ue, d as ge, e as Ve, f as Oe, k as Le, g as Xe, u as je, h as de, i as fe, j as he } from "./index-Cexzl5Xu.js";
|
|
3
|
+
function me(g, c, l) {
|
|
4
|
+
return function() {
|
|
5
|
+
for (var t = [], p = 0, u = g, k = 0; k < c.length || p < arguments.length; ) {
|
|
6
|
+
var W;
|
|
7
|
+
k < c.length && (!ve(c[k]) || p >= arguments.length) ? W = c[k] : (W = arguments[p], p += 1), t[k] = W, ve(W) || (u -= 1), k += 1;
|
|
8
|
+
}
|
|
9
|
+
return u <= 0 ? l.apply(this, t) : Se(u, me(g, t, l));
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
var ze = /* @__PURE__ */ Y(function(c, l) {
|
|
13
|
+
return c === 1 ? Ue(l) : Se(c, me(c, [], l));
|
|
14
|
+
});
|
|
15
|
+
function Be(g, c) {
|
|
16
|
+
for (var l = 0, t = c.length, p = Array(t); l < t; )
|
|
17
|
+
p[l] = g(c[l]), l += 1;
|
|
18
|
+
return p;
|
|
19
|
+
}
|
|
20
|
+
var He = /* @__PURE__ */ (function() {
|
|
21
|
+
function g(c, l) {
|
|
22
|
+
this.xf = l, this.f = c;
|
|
23
|
+
}
|
|
24
|
+
return g.prototype["@@transducer/init"] = ge.init, g.prototype["@@transducer/result"] = ge.result, g.prototype["@@transducer/step"] = function(c, l) {
|
|
25
|
+
return this.xf["@@transducer/step"](c, this.f(l));
|
|
26
|
+
}, g;
|
|
27
|
+
})(), qe = /* @__PURE__ */ Y(function(c, l) {
|
|
28
|
+
return new He(c, l);
|
|
29
|
+
}), Fe = /* @__PURE__ */ Y(
|
|
30
|
+
/* @__PURE__ */ Ve(["fantasy-land/map", "map"], qe, function(c, l) {
|
|
31
|
+
switch (Object.prototype.toString.call(l)) {
|
|
32
|
+
case "[object Function]":
|
|
33
|
+
return ze(l.length, function() {
|
|
34
|
+
return c.call(this, l.apply(this, arguments));
|
|
35
|
+
});
|
|
36
|
+
case "[object Object]":
|
|
37
|
+
return Oe(function(t, p) {
|
|
38
|
+
return t[p] = c(l[p]), t;
|
|
39
|
+
}, {}, Le(l));
|
|
40
|
+
default:
|
|
41
|
+
return Be(c, l);
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
const Ge = { class: "timeseries-scrubber" }, Je = { class: "dateWrap" }, Ke = { class: "noselect" }, Qe = {
|
|
46
|
+
id: "scrubber",
|
|
47
|
+
noselect: ""
|
|
48
|
+
}, Ye = ["width", "height"], Ze = ["width", "height"], et = ["width", "height"], tt = {
|
|
49
|
+
__name: "TSScrubber",
|
|
50
|
+
props: {
|
|
51
|
+
ts_start: Number,
|
|
52
|
+
ts_end: Number,
|
|
53
|
+
cWidth: Number,
|
|
54
|
+
constants: Object,
|
|
55
|
+
start: Number,
|
|
56
|
+
duration: Number,
|
|
57
|
+
cursorLoc: Number,
|
|
58
|
+
labelWidth: Number,
|
|
59
|
+
activeViewer: Object
|
|
60
|
+
},
|
|
61
|
+
emits: ["setStart"],
|
|
62
|
+
setup(g, { expose: c, emit: l }) {
|
|
63
|
+
const t = g, p = l, u = je(), k = v(null), W = v(null), H = v(null), w = v(null), d = v(1), Z = v(28), T = v(30), V = v(!1), I = v(""), O = v("point"), ee = v(null), D = v([]), _ = v([]), C = v([]), L = v(!1), te = v(0), ne = v(0), R = v(0), X = v(0), pe = N(() => oe(t.ts_start)), be = N(() => oe(t.ts_end)), _e = N(() => {
|
|
64
|
+
if (I.value !== "")
|
|
65
|
+
return I.value;
|
|
66
|
+
if (t.start > 0) {
|
|
67
|
+
const n = new Date(t.start / 1e3).toUTCString();
|
|
68
|
+
return n.substring(0, n.length - 3);
|
|
69
|
+
}
|
|
70
|
+
return "";
|
|
71
|
+
}), ae = N(() => ({
|
|
72
|
+
width: t.labelWidth + t.cWidth - 8 + 5 + "px",
|
|
73
|
+
height: "28px"
|
|
74
|
+
})), we = N(() => ({
|
|
75
|
+
width: t.labelWidth + t.cWidth - 8 + 5 + "px",
|
|
76
|
+
height: "30px"
|
|
77
|
+
})), Te = N(() => t.cWidth + t.labelWidth - 8 + 5), Ce = N(() => Math.floor((t.ts_end - t.ts_start) / t.cWidth));
|
|
78
|
+
U(() => t.start, () => {
|
|
79
|
+
A();
|
|
80
|
+
}), U(() => t.duration, () => {
|
|
81
|
+
A();
|
|
82
|
+
}), U(() => t.cWidth, () => {
|
|
83
|
+
A();
|
|
84
|
+
}), U(() => t.activeViewer, (n, e) => {
|
|
85
|
+
var a;
|
|
86
|
+
n && n !== e && (console.log("TSScrubber: ActiveViewer changed, resetting component state"), L.value = !0, se(), (a = n.content) != null && a.id ? E(() => {
|
|
87
|
+
B(), L.value = !1;
|
|
88
|
+
}) : L.value = !1);
|
|
89
|
+
}, { deep: !0 }), U(() => u.viewerChannels, (n, e) => {
|
|
90
|
+
var a, r;
|
|
91
|
+
n && n.length > 0 && !L.value && (!e || n.length !== e.length || ((a = n[0]) == null ? void 0 : a.id) !== ((r = e[0]) == null ? void 0 : r.id)) && (console.log("TSScrubber: Viewer channels changed, re-initializing segments"), z(), E(() => {
|
|
92
|
+
ie();
|
|
93
|
+
}));
|
|
94
|
+
}, { deep: !0 }), U(() => u.viewerAnnotations, (n, e) => {
|
|
95
|
+
var a;
|
|
96
|
+
n && n !== e && !L.value ? (console.log("TSScrubber: Viewer annotations changed independently, re-fetching annotations"), E(() => {
|
|
97
|
+
B();
|
|
98
|
+
})) : n && n.length > 0 && !e && ((a = t.activeViewer) != null && a.content.id) && (console.log("TSScrubber: Annotation layers now available, fetching annotations"), E(() => {
|
|
99
|
+
B();
|
|
100
|
+
}));
|
|
101
|
+
}, { deep: !0 });
|
|
102
|
+
const se = () => {
|
|
103
|
+
console.log("TSScrubber: Resetting component state"), D.value = [], z(), V.value = !1, I.value = "", O.value = "point", re();
|
|
104
|
+
}, z = () => {
|
|
105
|
+
console.log("TSScrubber: Resetting segment state"), C.value = new Array(5e3), C.value = C.value.fill(0, 0, 4999), _.value = [];
|
|
106
|
+
}, re = () => {
|
|
107
|
+
E(() => {
|
|
108
|
+
[W.value, H.value, w.value].forEach((e) => {
|
|
109
|
+
if (e) {
|
|
110
|
+
const a = e.getContext("2d");
|
|
111
|
+
a && a.clearRect(0, 0, e.width, e.height);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}, $ = (n, e, a) => e * (n + a), ye = () => {
|
|
116
|
+
const n = w.value.getContext("2d"), e = window.devicePixelRatio || 1, a = n.webkitBackingStorePixelRatio || n.mozBackingStorePixelRatio || n.msBackingStorePixelRatio || n.oBackingStorePixelRatio || n.backingStorePixelRatio || 1;
|
|
117
|
+
return e / a;
|
|
118
|
+
}, oe = (n) => {
|
|
119
|
+
if (n > 0)
|
|
120
|
+
return n = n / 1e3, n = new Date(n), ("0" + n.getUTCHours()).slice(-2) + ":" + ("0" + n.getUTCMinutes()).slice(-2) + ":" + ("0" + n.getUTCSeconds()).slice(-2);
|
|
121
|
+
}, xe = (n) => {
|
|
122
|
+
if (V.value) {
|
|
123
|
+
const a = (n.clientX - te.value) / t.cWidth * (t.ts_end - t.ts_start), r = ne.value + a;
|
|
124
|
+
p("setStart", r);
|
|
125
|
+
const s = new Date((a + t.ts_start) / 1e3);
|
|
126
|
+
I.value = s.toUTCString();
|
|
127
|
+
} else {
|
|
128
|
+
const e = w.value.getBoundingClientRect(), a = n.clientX - e.left, r = R.value + X.value, s = O.value;
|
|
129
|
+
a > R.value - 10 && a < r + 10 ? (O.value = "drag", w.value.setAttribute("dragme", !0), w.value.removeAttribute("resizeme")) : (O.value = "point", w.value.removeAttribute("dragme"), w.value.removeAttribute("resizeme"));
|
|
130
|
+
const o = a / t.cWidth * (t.ts_end - t.ts_start) + t.ts_start, b = new Date(o / 1e3).toUTCString();
|
|
131
|
+
I.value = b.substring(0, b.length - 3), s !== O.value && A();
|
|
132
|
+
}
|
|
133
|
+
}, ke = () => {
|
|
134
|
+
V.value = !1;
|
|
135
|
+
}, We = (n) => {
|
|
136
|
+
V.value = !0;
|
|
137
|
+
const e = w.value.getBoundingClientRect(), a = n.clientX - e.left;
|
|
138
|
+
te.value = n.clientX;
|
|
139
|
+
const r = a / Te.value * (t.ts_end - t.ts_start);
|
|
140
|
+
p("setStart", r + t.ts_start), ne.value = r + t.ts_start;
|
|
141
|
+
}, Re = () => {
|
|
142
|
+
V.value = !1;
|
|
143
|
+
}, Ae = () => {
|
|
144
|
+
I.value = "";
|
|
145
|
+
}, ie = () => {
|
|
146
|
+
var a;
|
|
147
|
+
if (!u.viewerChannels || u.viewerChannels.length === 0) {
|
|
148
|
+
console.warn("TSScrubber: Cannot init segment spans - no viewer channels available");
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (!t.ts_start || !t.ts_end) {
|
|
152
|
+
console.warn("TSScrubber: Cannot init segment spans - invalid time range");
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (!((a = u.config) != null && a.timeSeriesApi)) {
|
|
156
|
+
console.warn("TSScrubber: Cannot init segment spans - no timeSeriesApi configured");
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
console.log(`TSScrubber: Initializing segment spans for ${u.viewerChannels.length} channels`), z();
|
|
160
|
+
const n = Math.min(t.constants.SEGMENTSPAN, t.ts_end - t.ts_start), e = u.viewerChannels;
|
|
161
|
+
for (let r = 0; r < e.length; r++)
|
|
162
|
+
le(e[r].id, r, t.ts_start, t.ts_start + n, 0);
|
|
163
|
+
}, le = async (n, e, a, r, s) => {
|
|
164
|
+
var o;
|
|
165
|
+
const i = t.constants.MAXRECURSION;
|
|
166
|
+
if (!((o = u.config) != null && o.timeSeriesApi)) {
|
|
167
|
+
console.warn("TSScrubber: Cannot request segment span - no timeSeriesApi configured");
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (!n) {
|
|
171
|
+
console.warn("TSScrubber: Cannot request segment span - no channel ID provided");
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
const b = await de(), f = `${u.config.timeSeriesApi}/ts/retrieve/segments?session=${b}&channel=${n}&start=${a}&end=${r}`;
|
|
176
|
+
console.log(`TSScrubber: Fetching segments for channel ${n} (${e})`);
|
|
177
|
+
const S = await fe(f);
|
|
178
|
+
if (!u.viewerChannels[e] || u.viewerChannels[e].id !== n) {
|
|
179
|
+
console.warn("TSScrubber: Channel mismatch detected, ignoring segment response (likely package switched)");
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
let h = new Array(S.length * 2), m = 0;
|
|
183
|
+
for (let M = 0; M < S.length; M++) {
|
|
184
|
+
h[m] = S[M][0], h[m + 1] = S[M][1], m = m + 2;
|
|
185
|
+
const J = Math.floor((S[M][0] - t.ts_start) / (t.ts_end - t.ts_start) * 5e3), De = Math.ceil((S[M][1] - t.ts_start) / (t.ts_end - t.ts_start) * 5e3);
|
|
186
|
+
C.value.fill(1, J, De);
|
|
187
|
+
}
|
|
188
|
+
let y = 0, j = !1, G = 0;
|
|
189
|
+
for (_.value = []; y < C.value.length - 1; ) {
|
|
190
|
+
if (!C.value[y] && !j) {
|
|
191
|
+
y++;
|
|
192
|
+
continue;
|
|
193
|
+
} else C.value[y] ? j || (G = y, j = !0) : (_.value = _.value.concat([G, y]), j = !1);
|
|
194
|
+
y++;
|
|
195
|
+
}
|
|
196
|
+
j && (_.value = _.value.concat([G, y])), _.value = _.value.concat([5e3]);
|
|
197
|
+
let Ee = h[0], P = u.viewerChannels[e];
|
|
198
|
+
if (!P || P.id !== n) {
|
|
199
|
+
console.warn("TSScrubber: Channel configuration mismatch, skipping update");
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
Ee < P.dataSegments[P.dataSegments.length - 1] && (h.shift(), h.shift()), P.dataSegments = P.dataSegments.concat(h.sort((M, J) => M - J)), u.updateChannelProperty(P.id, "dataSegments", P.dataSegments);
|
|
203
|
+
let ue = r - a;
|
|
204
|
+
a + ue < t.ts_end && s < i ? le(n, e, r, r + ue, s + 1) : F();
|
|
205
|
+
} catch (b) {
|
|
206
|
+
console.error(`TSScrubber: Error fetching segments for channel ${n}:`, b), he(b);
|
|
207
|
+
}
|
|
208
|
+
}, B = async () => {
|
|
209
|
+
var e, a, r;
|
|
210
|
+
const n = (e = t.activeViewer) == null ? void 0 : e.content.id;
|
|
211
|
+
if (!n) {
|
|
212
|
+
console.warn("TSScrubber: Cannot get annotations - no active viewer ID"), D.value = [];
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (!((a = u.config) != null && a.apiUrl)) {
|
|
216
|
+
console.warn("TSScrubber: Cannot get annotations - no API URL configured"), D.value = [];
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (!u.viewerAnnotations || u.viewerAnnotations.length === 0) {
|
|
220
|
+
console.log("TSScrubber: No annotation layers available, skipping annotation fetch"), D.value = [], A();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
const s = await de(), i = Fe((h) => h.id, u.viewerAnnotations), o = t.ts_end;
|
|
225
|
+
let f = `${u.config.apiUrl}/timeseries/${n}/annotations/window` + `?api_key=${s}&aggregation=count&start=${t.ts_start}&end=${t.ts_end}&period=${Ce.value}&mergePeriods=true`;
|
|
226
|
+
for (let h in i)
|
|
227
|
+
f = f + `&layerIds=${i[h]}`;
|
|
228
|
+
console.log(`TSScrubber: Fetching annotations for viewer ${n}`);
|
|
229
|
+
const S = await fe(f);
|
|
230
|
+
((r = t.activeViewer) == null ? void 0 : r.content.id) === n ? (D.value = S, A()) : console.log("TSScrubber: Ignoring annotation response - viewer changed during fetch");
|
|
231
|
+
} catch (s) {
|
|
232
|
+
console.error("TSScrubber: Error fetching annotations:", s), D.value = [], he(s), A();
|
|
233
|
+
}
|
|
234
|
+
}, A = () => {
|
|
235
|
+
q(), ce(), F();
|
|
236
|
+
}, q = () => {
|
|
237
|
+
E(() => {
|
|
238
|
+
const n = w.value;
|
|
239
|
+
if (!n) {
|
|
240
|
+
console.warn("iCanvas ref is missing, skipping render");
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const e = n.getContext("2d");
|
|
244
|
+
if (!e) {
|
|
245
|
+
console.warn("2D context is not available");
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
e.setTransform(d.value, 0, 0, d.value, 0, 0), e.clearRect(0, 0, t.cWidth, T.value), R.value = (t.start - t.ts_start) / (t.ts_end - t.ts_start) * t.cWidth + 0.5 | 0, X.value = t.duration / (t.ts_end - t.ts_start) * t.cWidth + 0.5 | 0, e.fillStyle = "rgb(80,80,80)", e.strokeStyle = "rgb(80,80,80)", e.strokeRect(R.value + 0.5, 0.5, X.value, T.value - 1), e.fillRect(R.value - 2, T.value / 2 - 5 | 0, 2, 10), e.fillRect(R.value + X.value + 1, T.value / 2 - 5 | 0, 2, 10);
|
|
249
|
+
const a = R.value + t.cursorLoc * X.value;
|
|
250
|
+
a > R.value + 0.5 && (e.strokeStyle = "red", e.beginPath(), e.moveTo(a, 0), e.lineTo(a, T.value - 1), e.stroke());
|
|
251
|
+
});
|
|
252
|
+
}, F = () => {
|
|
253
|
+
E(() => {
|
|
254
|
+
const n = W.value;
|
|
255
|
+
if (!n) {
|
|
256
|
+
console.warn("segmentsCanvas ref is missing, skipping renderSegments");
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const e = n.getContext("2d");
|
|
260
|
+
if (!e) {
|
|
261
|
+
console.warn("Unable to get 2D context for segmentsCanvas, skipping renderSegments");
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
e.setTransform(d.value, 0, 0, d.value, 0, 0), e.fillStyle = e.createPattern(ee.value, "repeat"), e.clearRect(0, 0, t.cWidth, T.value);
|
|
265
|
+
for (let a = 1; a < _.value.length; a += 2) {
|
|
266
|
+
const r = t.cWidth * _.value[a] / 5e3, s = t.cWidth * _.value[a + 1] / 5e3;
|
|
267
|
+
e.fillRect(r, 2, s - r, T.value - 6);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}, ce = () => {
|
|
271
|
+
const n = H.value;
|
|
272
|
+
if (!n) {
|
|
273
|
+
console.warn("annotationCanvas ref is missing, skipping renderTimelimeLine");
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const e = n.getContext("2d");
|
|
277
|
+
if (!e) {
|
|
278
|
+
console.warn("Unable to get 2D context for annotationCanvas, skipping renderTimelimeLine");
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
e.setTransform(d.value, 0, 0, d.value, 0, 0), e.clearRect(0, 0, t.cWidth, Z.value);
|
|
282
|
+
const a = t.ts_start, r = t.ts_end, s = D.value;
|
|
283
|
+
let i = 0;
|
|
284
|
+
const o = 0, b = Math.floor((Z.value - 2) / Object.keys(s).length - o), f = u.viewerAnnotations;
|
|
285
|
+
let S = "rgb(0,0,0)";
|
|
286
|
+
for (const h in s)
|
|
287
|
+
if (s.hasOwnProperty(h)) {
|
|
288
|
+
for (let m = 0; m < f.length; m++)
|
|
289
|
+
if (f[m].id === parseInt(h)) {
|
|
290
|
+
i = m, S = f[m].color;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
Pe(e, a, r, o, b, s[h], i, S);
|
|
294
|
+
}
|
|
295
|
+
}, Pe = (n, e, a, r, s, i, o, b) => {
|
|
296
|
+
E(() => {
|
|
297
|
+
n.setTransform(d.value, 0, 0, d.value, 0, 0), n.fillStyle = b;
|
|
298
|
+
for (let f = 0; f < i.length; f++)
|
|
299
|
+
if (i[f].value > 0) {
|
|
300
|
+
const S = (i[f].start - e) / (a - e) * t.cWidth;
|
|
301
|
+
let m = (i[f].end - e) / (a - e) * t.cWidth - S;
|
|
302
|
+
m < 1 && (m = 1);
|
|
303
|
+
const y = 1 + o * (s - 1 + r) + o;
|
|
304
|
+
n.fillRect(S, y, m, s);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
}, Me = () => {
|
|
308
|
+
const n = document.createElement("canvas"), e = n.getContext("2d", { antialias: !0 }), a = "rgb(220,220,220)", r = 5, s = r, i = r, o = 10;
|
|
309
|
+
return n.width = s, n.height = i, e.fillStyle = a, e.beginPath(), e.moveTo(0, i * (1 / o)), e.lineTo(s * (1 / o), 0), e.lineTo(0, 0), e.lineTo(0, i * (1 / o)), e.fill(), e.beginPath(), e.moveTo(s, i * (1 / o)), e.lineTo(s * (1 / o), i), e.lineTo(0, i), e.lineTo(0, i * ((o - 1) / o)), e.lineTo(s * ((o - 1) / o), 0), e.lineTo(s, 0), e.lineTo(s, i * (1 / o)), e.fill(), e.beginPath(), e.moveTo(s, i * ((o - 1) / o)), e.lineTo(s * ((o - 1) / o), i), e.lineTo(s, i), e.lineTo(s, i * ((o - 1) / o)), e.fill(), n;
|
|
310
|
+
};
|
|
311
|
+
return Ne(() => {
|
|
312
|
+
C.value = new Array(5e3), C.value = C.value.fill(0, 0, 4999), d.value = ye(), ee.value = Me(), q();
|
|
313
|
+
}), c({
|
|
314
|
+
getAnnotations: B,
|
|
315
|
+
initSegmentSpans: ie,
|
|
316
|
+
render: A,
|
|
317
|
+
renderViewPort: q,
|
|
318
|
+
renderSegments: F,
|
|
319
|
+
renderTimelimeLine: ce,
|
|
320
|
+
resetComponentState: se,
|
|
321
|
+
resetSegmentState: z,
|
|
322
|
+
clearCanvases: re
|
|
323
|
+
}), (n, e) => ($e(), Ie("div", Ge, [
|
|
324
|
+
x("div", Je, [
|
|
325
|
+
x("div", null, K(pe.value), 1),
|
|
326
|
+
x("div", null, K(_e.value), 1),
|
|
327
|
+
x("div", null, K(be.value), 1)
|
|
328
|
+
]),
|
|
329
|
+
x("div", Ke, [
|
|
330
|
+
x("div", Qe, [
|
|
331
|
+
x("div", {
|
|
332
|
+
id: "canvasWrap",
|
|
333
|
+
ref_key: "canvasWrap",
|
|
334
|
+
ref: k
|
|
335
|
+
}, [
|
|
336
|
+
x("canvas", {
|
|
337
|
+
id: "segmentsCanvas",
|
|
338
|
+
class: "canvas",
|
|
339
|
+
ref_key: "segmentsCanvas",
|
|
340
|
+
ref: W,
|
|
341
|
+
width: $(g.cWidth, d.value, 0),
|
|
342
|
+
height: $(T.value - 2, d.value, 0),
|
|
343
|
+
style: Q(ae.value)
|
|
344
|
+
}, null, 12, Ye),
|
|
345
|
+
x("canvas", {
|
|
346
|
+
id: "annotationCanvas",
|
|
347
|
+
class: "canvas",
|
|
348
|
+
ref_key: "annotationCanvas",
|
|
349
|
+
ref: H,
|
|
350
|
+
width: $(g.cWidth, d.value, 0),
|
|
351
|
+
height: $(T.value - 2, d.value, 0),
|
|
352
|
+
style: Q(ae.value)
|
|
353
|
+
}, null, 12, Ze),
|
|
354
|
+
x("canvas", {
|
|
355
|
+
id: "iCanvas",
|
|
356
|
+
class: "canvas",
|
|
357
|
+
ref_key: "iCanvas",
|
|
358
|
+
ref: w,
|
|
359
|
+
width: $(g.cWidth, d.value, 0),
|
|
360
|
+
height: $(T.value, d.value, 0),
|
|
361
|
+
onClick: e[0] || (e[0] = (...a) => n._onTap && n._onTap(...a)),
|
|
362
|
+
onMousemove: xe,
|
|
363
|
+
onMousedown: We,
|
|
364
|
+
onMouseup: ke,
|
|
365
|
+
onMouseenter: Re,
|
|
366
|
+
onMouseout: Ae,
|
|
367
|
+
style: Q(we.value)
|
|
368
|
+
}, null, 44, et)
|
|
369
|
+
], 512)
|
|
370
|
+
])
|
|
371
|
+
])
|
|
372
|
+
]));
|
|
373
|
+
}
|
|
374
|
+
}, st = /* @__PURE__ */ Xe(tt, [["__scopeId", "data-v-8618a902"]]);
|
|
375
|
+
export {
|
|
376
|
+
st as default
|
|
377
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue"),d=require("./index-CGSfhm_E.cjs");function se(g,u,c){return function(){for(var t=[],b=0,v=g,k=0;k<u.length||b<arguments.length;){var W;k<u.length&&(!d._isPlaceholder(u[k])||b>=arguments.length)?W=u[k]:(W=arguments[b],b+=1),t[k]=W,d._isPlaceholder(W)||(v-=1),k+=1}return v<=0?c.apply(this,t):d._arity(v,se(g,t,c))}}var Te=d._curry2(function(u,c){return u===1?d._curry1(c):d._arity(u,se(u,[],c))});function ye(g,u){for(var c=0,t=u.length,b=Array(t);c<t;)b[c]=g(u[c]),c+=1;return b}var Ce=(function(){function g(u,c){this.xf=c,this.f=u}return g.prototype["@@transducer/init"]=d._xfBase.init,g.prototype["@@transducer/result"]=d._xfBase.result,g.prototype["@@transducer/step"]=function(u,c){return this.xf["@@transducer/step"](u,this.f(c))},g})(),xe=d._curry2(function(u,c){return new Ce(u,c)}),ke=d._curry2(d._dispatchable(["fantasy-land/map","map"],xe,function(u,c){switch(Object.prototype.toString.call(c)){case"[object Function]":return Te(c.length,function(){return u.call(this,c.apply(this,arguments))});case"[object Object]":return d._reduce(function(t,b){return t[b]=u(c[b]),t},{},d.keys(c));default:return ye(u,c)}}));const We={class:"timeseries-scrubber"},Ee={class:"dateWrap"},Ne={class:"noselect"},Pe={id:"scrubber",noselect:""},Re=["width","height"],Ae=["width","height"],Me=["width","height"],Ve={__name:"TSScrubber",props:{ts_start:Number,ts_end:Number,cWidth:Number,constants:Object,start:Number,duration:Number,cursorLoc:Number,labelWidth:Number,activeViewer:Object},emits:["setStart"],setup(g,{expose:u,emit:c}){const t=g,b=c,v=d.useViewerStore(),k=a.ref(null),W=a.ref(null),B=a.ref(null),T=a.ref(null),f=a.ref(1),F=a.ref(28),y=a.ref(30),D=a.ref(!1),M=a.ref(""),I=a.ref("point"),G=a.ref(null),A=a.ref([]),w=a.ref([]),C=a.ref([]),$=a.ref(!1),J=a.ref(0),K=a.ref(0),E=a.ref(0),U=a.ref(0),oe=a.computed(()=>ee(t.ts_start)),ie=a.computed(()=>ee(t.ts_end)),le=a.computed(()=>{if(M.value!=="")return M.value;if(t.start>0){const n=new Date(t.start/1e3).toUTCString();return n.substring(0,n.length-3)}return""}),Q=a.computed(()=>({width:t.labelWidth+t.cWidth-8+5+"px",height:"28px"})),ce=a.computed(()=>({width:t.labelWidth+t.cWidth-8+5+"px",height:"30px"})),ue=a.computed(()=>t.cWidth+t.labelWidth-8+5),ve=a.computed(()=>Math.floor((t.ts_end-t.ts_start)/t.cWidth));a.watch(()=>t.start,()=>{N()}),a.watch(()=>t.duration,()=>{N()}),a.watch(()=>t.cWidth,()=>{N()}),a.watch(()=>t.activeViewer,(n,e)=>{var r;n&&n!==e&&(console.log("TSScrubber: ActiveViewer changed, resetting component state"),$.value=!0,Y(),(r=n.content)!=null&&r.id?a.nextTick(()=>{z(),$.value=!1}):$.value=!1)},{deep:!0}),a.watch(()=>v.viewerChannels,(n,e)=>{var r,o;n&&n.length>0&&!$.value&&(!e||n.length!==e.length||((r=n[0])==null?void 0:r.id)!==((o=e[0])==null?void 0:o.id))&&(console.log("TSScrubber: Viewer channels changed, re-initializing segments"),X(),a.nextTick(()=>{te()}))},{deep:!0}),a.watch(()=>v.viewerAnnotations,(n,e)=>{var r;n&&n!==e&&!$.value?(console.log("TSScrubber: Viewer annotations changed independently, re-fetching annotations"),a.nextTick(()=>{z()})):n&&n.length>0&&!e&&((r=t.activeViewer)!=null&&r.content.id)&&(console.log("TSScrubber: Annotation layers now available, fetching annotations"),a.nextTick(()=>{z()}))},{deep:!0});const Y=()=>{console.log("TSScrubber: Resetting component state"),A.value=[],X(),D.value=!1,M.value="",I.value="point",Z()},X=()=>{console.log("TSScrubber: Resetting segment state"),C.value=new Array(5e3),C.value=C.value.fill(0,0,4999),w.value=[]},Z=()=>{a.nextTick(()=>{[W.value,B.value,T.value].forEach(e=>{if(e){const r=e.getContext("2d");r&&r.clearRect(0,0,e.width,e.height)}})})},V=(n,e,r)=>e*(n+r),de=()=>{const n=T.value.getContext("2d"),e=window.devicePixelRatio||1,r=n.webkitBackingStorePixelRatio||n.mozBackingStorePixelRatio||n.msBackingStorePixelRatio||n.oBackingStorePixelRatio||n.backingStorePixelRatio||1;return e/r},ee=n=>{if(n>0)return n=n/1e3,n=new Date(n),("0"+n.getUTCHours()).slice(-2)+":"+("0"+n.getUTCMinutes()).slice(-2)+":"+("0"+n.getUTCSeconds()).slice(-2)},ge=n=>{if(D.value){const r=(n.clientX-J.value)/t.cWidth*(t.ts_end-t.ts_start),o=K.value+r;b("setStart",o);const s=new Date((r+t.ts_start)/1e3);M.value=s.toUTCString()}else{const e=T.value.getBoundingClientRect(),r=n.clientX-e.left,o=E.value+U.value,s=I.value;r>E.value-10&&r<o+10?(I.value="drag",T.value.setAttribute("dragme",!0),T.value.removeAttribute("resizeme")):(I.value="point",T.value.removeAttribute("dragme"),T.value.removeAttribute("resizeme"));const i=r/t.cWidth*(t.ts_end-t.ts_start)+t.ts_start,_=new Date(i/1e3).toUTCString();M.value=_.substring(0,_.length-3),s!==I.value&&N()}},fe=()=>{D.value=!1},he=n=>{D.value=!0;const e=T.value.getBoundingClientRect(),r=n.clientX-e.left;J.value=n.clientX;const o=r/ue.value*(t.ts_end-t.ts_start);b("setStart",o+t.ts_start),K.value=o+t.ts_start},me=()=>{D.value=!1},Se=()=>{M.value=""},te=()=>{var r;if(!v.viewerChannels||v.viewerChannels.length===0){console.warn("TSScrubber: Cannot init segment spans - no viewer channels available");return}if(!t.ts_start||!t.ts_end){console.warn("TSScrubber: Cannot init segment spans - invalid time range");return}if(!((r=v.config)!=null&&r.timeSeriesApi)){console.warn("TSScrubber: Cannot init segment spans - no timeSeriesApi configured");return}console.log(`TSScrubber: Initializing segment spans for ${v.viewerChannels.length} channels`),X();const n=Math.min(t.constants.SEGMENTSPAN,t.ts_end-t.ts_start),e=v.viewerChannels;for(let o=0;o<e.length;o++)ne(e[o].id,o,t.ts_start,t.ts_start+n,0)},ne=async(n,e,r,o,s)=>{var i;const l=t.constants.MAXRECURSION;if(!((i=v.config)!=null&&i.timeSeriesApi)){console.warn("TSScrubber: Cannot request segment span - no timeSeriesApi configured");return}if(!n){console.warn("TSScrubber: Cannot request segment span - no channel ID provided");return}try{const _=await d.useToken(),h=`${v.config.timeSeriesApi}/ts/retrieve/segments?session=${_}&channel=${n}&start=${r}&end=${o}`;console.log(`TSScrubber: Fetching segments for channel ${n} (${e})`);const S=await d.useSendXhr(h);if(!v.viewerChannels[e]||v.viewerChannels[e].id!==n){console.warn("TSScrubber: Channel mismatch detected, ignoring segment response (likely package switched)");return}let m=new Array(S.length*2),p=0;for(let R=0;R<S.length;R++){m[p]=S[R][0],m[p+1]=S[R][1],p=p+2;const q=Math.floor((S[R][0]-t.ts_start)/(t.ts_end-t.ts_start)*5e3),we=Math.ceil((S[R][1]-t.ts_start)/(t.ts_end-t.ts_start)*5e3);C.value.fill(1,q,we)}let x=0,O=!1,j=0;for(w.value=[];x<C.value.length-1;){if(!C.value[x]&&!O){x++;continue}else C.value[x]?O||(j=x,O=!0):(w.value=w.value.concat([j,x]),O=!1);x++}O&&(w.value=w.value.concat([j,x])),w.value=w.value.concat([5e3]);let _e=m[0],P=v.viewerChannels[e];if(!P||P.id!==n){console.warn("TSScrubber: Channel configuration mismatch, skipping update");return}_e<P.dataSegments[P.dataSegments.length-1]&&(m.shift(),m.shift()),P.dataSegments=P.dataSegments.concat(m.sort((R,q)=>R-q)),v.updateChannelProperty(P.id,"dataSegments",P.dataSegments);let re=o-r;r+re<t.ts_end&&s<l?ne(n,e,o,o+re,s+1):L()}catch(_){console.error(`TSScrubber: Error fetching segments for channel ${n}:`,_),d.useHandleXhrError(_)}},z=async()=>{var e,r,o;const n=(e=t.activeViewer)==null?void 0:e.content.id;if(!n){console.warn("TSScrubber: Cannot get annotations - no active viewer ID"),A.value=[];return}if(!((r=v.config)!=null&&r.apiUrl)){console.warn("TSScrubber: Cannot get annotations - no API URL configured"),A.value=[];return}if(!v.viewerAnnotations||v.viewerAnnotations.length===0){console.log("TSScrubber: No annotation layers available, skipping annotation fetch"),A.value=[],N();return}try{const s=await d.useToken(),l=ke(m=>m.id,v.viewerAnnotations),i=t.ts_end;let h=`${v.config.apiUrl}/timeseries/${n}/annotations/window`+`?api_key=${s}&aggregation=count&start=${t.ts_start}&end=${t.ts_end}&period=${ve.value}&mergePeriods=true`;for(let m in l)h=h+`&layerIds=${l[m]}`;console.log(`TSScrubber: Fetching annotations for viewer ${n}`);const S=await d.useSendXhr(h);((o=t.activeViewer)==null?void 0:o.content.id)===n?(A.value=S,N()):console.log("TSScrubber: Ignoring annotation response - viewer changed during fetch")}catch(s){console.error("TSScrubber: Error fetching annotations:",s),A.value=[],d.useHandleXhrError(s),N()}},N=()=>{H(),ae(),L()},H=()=>{a.nextTick(()=>{const n=T.value;if(!n){console.warn("iCanvas ref is missing, skipping render");return}const e=n.getContext("2d");if(!e){console.warn("2D context is not available");return}e.setTransform(f.value,0,0,f.value,0,0),e.clearRect(0,0,t.cWidth,y.value),E.value=(t.start-t.ts_start)/(t.ts_end-t.ts_start)*t.cWidth+.5|0,U.value=t.duration/(t.ts_end-t.ts_start)*t.cWidth+.5|0,e.fillStyle="rgb(80,80,80)",e.strokeStyle="rgb(80,80,80)",e.strokeRect(E.value+.5,.5,U.value,y.value-1),e.fillRect(E.value-2,y.value/2-5|0,2,10),e.fillRect(E.value+U.value+1,y.value/2-5|0,2,10);const r=E.value+t.cursorLoc*U.value;r>E.value+.5&&(e.strokeStyle="red",e.beginPath(),e.moveTo(r,0),e.lineTo(r,y.value-1),e.stroke())})},L=()=>{a.nextTick(()=>{const n=W.value;if(!n){console.warn("segmentsCanvas ref is missing, skipping renderSegments");return}const e=n.getContext("2d");if(!e){console.warn("Unable to get 2D context for segmentsCanvas, skipping renderSegments");return}e.setTransform(f.value,0,0,f.value,0,0),e.fillStyle=e.createPattern(G.value,"repeat"),e.clearRect(0,0,t.cWidth,y.value);for(let r=1;r<w.value.length;r+=2){const o=t.cWidth*w.value[r]/5e3,s=t.cWidth*w.value[r+1]/5e3;e.fillRect(o,2,s-o,y.value-6)}})},ae=()=>{const n=B.value;if(!n){console.warn("annotationCanvas ref is missing, skipping renderTimelimeLine");return}const e=n.getContext("2d");if(!e){console.warn("Unable to get 2D context for annotationCanvas, skipping renderTimelimeLine");return}e.setTransform(f.value,0,0,f.value,0,0),e.clearRect(0,0,t.cWidth,F.value);const r=t.ts_start,o=t.ts_end,s=A.value;let l=0;const i=0,_=Math.floor((F.value-2)/Object.keys(s).length-i),h=v.viewerAnnotations;let S="rgb(0,0,0)";for(const m in s)if(s.hasOwnProperty(m)){for(let p=0;p<h.length;p++)if(h[p].id===parseInt(m)){l=p,S=h[p].color;break}pe(e,r,o,i,_,s[m],l,S)}},pe=(n,e,r,o,s,l,i,_)=>{a.nextTick(()=>{n.setTransform(f.value,0,0,f.value,0,0),n.fillStyle=_;for(let h=0;h<l.length;h++)if(l[h].value>0){const S=(l[h].start-e)/(r-e)*t.cWidth;let p=(l[h].end-e)/(r-e)*t.cWidth-S;p<1&&(p=1);const x=1+i*(s-1+o)+i;n.fillRect(S,x,p,s)}})},be=()=>{const n=document.createElement("canvas"),e=n.getContext("2d",{antialias:!0}),r="rgb(220,220,220)",o=5,s=o,l=o,i=10;return n.width=s,n.height=l,e.fillStyle=r,e.beginPath(),e.moveTo(0,l*(1/i)),e.lineTo(s*(1/i),0),e.lineTo(0,0),e.lineTo(0,l*(1/i)),e.fill(),e.beginPath(),e.moveTo(s,l*(1/i)),e.lineTo(s*(1/i),l),e.lineTo(0,l),e.lineTo(0,l*((i-1)/i)),e.lineTo(s*((i-1)/i),0),e.lineTo(s,0),e.lineTo(s,l*(1/i)),e.fill(),e.beginPath(),e.moveTo(s,l*((i-1)/i)),e.lineTo(s*((i-1)/i),l),e.lineTo(s,l),e.lineTo(s,l*((i-1)/i)),e.fill(),n};return a.onMounted(()=>{C.value=new Array(5e3),C.value=C.value.fill(0,0,4999),f.value=de(),G.value=be(),H()}),u({getAnnotations:z,initSegmentSpans:te,render:N,renderViewPort:H,renderSegments:L,renderTimelimeLine:ae,resetComponentState:Y,resetSegmentState:X,clearCanvases:Z}),(n,e)=>(a.openBlock(),a.createElementBlock("div",We,[a.createElementVNode("div",Ee,[a.createElementVNode("div",null,a.toDisplayString(oe.value),1),a.createElementVNode("div",null,a.toDisplayString(le.value),1),a.createElementVNode("div",null,a.toDisplayString(ie.value),1)]),a.createElementVNode("div",Ne,[a.createElementVNode("div",Pe,[a.createElementVNode("div",{id:"canvasWrap",ref_key:"canvasWrap",ref:k},[a.createElementVNode("canvas",{id:"segmentsCanvas",class:"canvas",ref_key:"segmentsCanvas",ref:W,width:V(g.cWidth,f.value,0),height:V(y.value-2,f.value,0),style:a.normalizeStyle(Q.value)},null,12,Re),a.createElementVNode("canvas",{id:"annotationCanvas",class:"canvas",ref_key:"annotationCanvas",ref:B,width:V(g.cWidth,f.value,0),height:V(y.value-2,f.value,0),style:a.normalizeStyle(Q.value)},null,12,Ae),a.createElementVNode("canvas",{id:"iCanvas",class:"canvas",ref_key:"iCanvas",ref:T,width:V(g.cWidth,f.value,0),height:V(y.value,f.value,0),onClick:e[0]||(e[0]=(...r)=>n._onTap&&n._onTap(...r)),onMousemove:ge,onMousedown:he,onMouseup:fe,onMouseenter:me,onMouseout:Se,style:a.normalizeStyle(ce.value)},null,44,Me)],512)])])]))}},De=d._export_sfc(Ve,[["__scopeId","data-v-8618a902"]]);exports.default=De;
|