@sentinel-nvr/web 0.2.2 → 0.3.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/controller-BPkrGlSF.d.ts +205 -0
- package/dist/player/index.d.ts +3 -204
- package/dist/ui/index.d.ts +47 -1
- package/dist/ui/index.js +339 -0
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/ui.css +90 -2
- package/package.json +1 -1
- /package/dist/ui/locales/{de.json → locales/de.json} +0 -0
- /package/dist/ui/locales/{en.json → locales/en.json} +0 -0
- /package/dist/ui/locales/{es.json → locales/es.json} +0 -0
- /package/dist/ui/locales/{fr.json → locales/fr.json} +0 -0
- /package/dist/ui/locales/{it.json → locales/it.json} +0 -0
- /package/dist/ui/locales/{pt.json → locales/pt.json} +0 -0
- /package/dist/ui/locales/{sv.json → locales/sv.json} +0 -0
package/dist/ui/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SENTINEL_DAY_MS,
|
|
3
|
+
SENTINEL_EVENT_CLASSES,
|
|
3
4
|
fmtDay,
|
|
4
5
|
fmtMonthYear,
|
|
5
6
|
fmtTime,
|
|
@@ -8,12 +9,15 @@ import {
|
|
|
8
9
|
sentinelClassOf,
|
|
9
10
|
sentinelClassesOf,
|
|
10
11
|
sentinelClipRuns,
|
|
12
|
+
sentinelDayOf,
|
|
11
13
|
sentinelEventPlayTs,
|
|
12
14
|
sentinelHumanBytes,
|
|
15
|
+
sentinelMergeDays,
|
|
13
16
|
sentinelStorageForecast,
|
|
14
17
|
weekdayShorts
|
|
15
18
|
} from "../chunk-VUKE4DDM.js";
|
|
16
19
|
import {
|
|
20
|
+
PlayerController,
|
|
17
21
|
rlog
|
|
18
22
|
} from "../chunk-VHZTAIPQ.js";
|
|
19
23
|
|
|
@@ -1069,9 +1073,342 @@ function VerticalTimeline(p) {
|
|
|
1069
1073
|
] })
|
|
1070
1074
|
] });
|
|
1071
1075
|
}
|
|
1076
|
+
|
|
1077
|
+
// src/ui/components/CameraPage.tsx
|
|
1078
|
+
import { useCallback, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef2, useState as useState4 } from "react";
|
|
1079
|
+
import { Calendar, Camera as Camera2, ChevronLeft as ChevronLeft2, ChevronRight as ChevronRight2, FastForward, Maximize2, Pause, PictureInPicture2, Play, Rewind, Volume2, VolumeX } from "lucide-react";
|
|
1080
|
+
|
|
1081
|
+
// src/ui/camera-logic.ts
|
|
1082
|
+
function dateChipNav(centerDay, oldestAllowed, today = sentinelDayOf(Date.now())) {
|
|
1083
|
+
return { prevDisabled: centerDay - SENTINEL_DAY_MS < oldestAllowed, nextDisabled: centerDay >= today };
|
|
1084
|
+
}
|
|
1085
|
+
function stageStatus(ps, t, locale, loadError = false, now = Date.now()) {
|
|
1086
|
+
const label = loadError ? t("nvr.error.loadFailed") : ps.label ? t(`nvr.player.${ps.label}`) : "";
|
|
1087
|
+
if (ps.live || ps.playhead == null) return label;
|
|
1088
|
+
const day = sentinelDayOf(ps.playhead) === sentinelDayOf(now) ? "" : fmtDay(ps.playhead, locale) + " ";
|
|
1089
|
+
return `${label} \xB7 ${day}${fmtTimeSec(ps.playhead, locale)}`;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
// src/ui/components/CameraPage.tsx
|
|
1093
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1094
|
+
var IDLE = { live: true, label: "live", playhead: null, rate: 1, sound: false, paused: false, transport: "none", muted: true };
|
|
1095
|
+
var todayStart = () => sentinelDayOf(Date.now());
|
|
1096
|
+
function CameraTitle({ name, onBack, children }) {
|
|
1097
|
+
const { t } = useSentinelUi();
|
|
1098
|
+
return /* @__PURE__ */ jsxs7("div", { className: "nvr-cam__head", children: [
|
|
1099
|
+
/* @__PURE__ */ jsxs7("div", { className: "nvr-cam__title", children: [
|
|
1100
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-iconbtn", "aria-label": t("nvr.back"), onClick: onBack, children: /* @__PURE__ */ jsx9(ChevronLeft2, { size: 20 }) }),
|
|
1101
|
+
/* @__PURE__ */ jsx9("h1", { className: "nvr-cam__h1", children: name })
|
|
1102
|
+
] }),
|
|
1103
|
+
children ? /* @__PURE__ */ jsx9("div", { className: "nvr-cam__actions", children }) : null
|
|
1104
|
+
] });
|
|
1105
|
+
}
|
|
1106
|
+
function CameraPage(p) {
|
|
1107
|
+
const { client, t, locale } = useSentinelUi();
|
|
1108
|
+
const { camId, name, earliest, startAt = 0, posterTs = 0 } = p;
|
|
1109
|
+
const [days, setDays] = useState4({});
|
|
1110
|
+
const [nowTick, setNowTick] = useState4(Date.now());
|
|
1111
|
+
useEffect3(() => {
|
|
1112
|
+
const i = setInterval(() => setNowTick(Date.now()), 3e4);
|
|
1113
|
+
return () => clearInterval(i);
|
|
1114
|
+
}, []);
|
|
1115
|
+
const [centerDay, setCenterDay] = useState4(todayStart());
|
|
1116
|
+
const [jump, setJump] = useState4(null);
|
|
1117
|
+
const [tab, setTab] = useState4("tl");
|
|
1118
|
+
const [filterOff, setFilterOff] = useState4({});
|
|
1119
|
+
const [ps, setPs] = useState4(IDLE);
|
|
1120
|
+
const [loadError, setLoadError] = useState4(false);
|
|
1121
|
+
const [dt, setDt] = useState4(false);
|
|
1122
|
+
const stage = useRef2(null);
|
|
1123
|
+
const video = useRef2(null);
|
|
1124
|
+
const freeze = useRef2(null);
|
|
1125
|
+
const img = useRef2(null);
|
|
1126
|
+
const ctl = useRef2(null);
|
|
1127
|
+
const psRef = useRef2(ps);
|
|
1128
|
+
psRef.current = ps;
|
|
1129
|
+
const loading = useRef2(/* @__PURE__ */ new Set());
|
|
1130
|
+
const daysRef = useRef2(days);
|
|
1131
|
+
daysRef.current = days;
|
|
1132
|
+
const camRef = useRef2(camId);
|
|
1133
|
+
camRef.current = camId;
|
|
1134
|
+
const merged = useMemo2(() => {
|
|
1135
|
+
const m = sentinelMergeDays(days);
|
|
1136
|
+
const rangeStart = m.oldestDay ?? todayStart();
|
|
1137
|
+
const rangeEnd = Math.min(todayStart() + SENTINEL_DAY_MS, nowTick + 20 * 6e4);
|
|
1138
|
+
return { ...m, rangeStart, rangeEnd };
|
|
1139
|
+
}, [days, nowTick]);
|
|
1140
|
+
const mergedRef = useRef2(merged);
|
|
1141
|
+
mergedRef.current = merged;
|
|
1142
|
+
useEffect3(() => {
|
|
1143
|
+
ctl.current?.setClips(merged.clips, merged.codecs, merged.rangeStart, merged.rangeEnd);
|
|
1144
|
+
}, [merged]);
|
|
1145
|
+
const fetchDay = useCallback(async (ds) => {
|
|
1146
|
+
const d = await client.getJson(`api/clips?camera=${encodeURIComponent(camId)}&start=${ds}&end=${ds + SENTINEL_DAY_MS}`);
|
|
1147
|
+
d.clips = (d.clips || []).sort((a, b) => a.startTime - b.startTime);
|
|
1148
|
+
d.events = d.events || [];
|
|
1149
|
+
d.motion = d.motion || [];
|
|
1150
|
+
return d;
|
|
1151
|
+
}, [client, camId]);
|
|
1152
|
+
const ensureDay = useCallback(async (ds, force = false) => {
|
|
1153
|
+
if (ds > todayStart()) return;
|
|
1154
|
+
if (earliest && ds + SENTINEL_DAY_MS < sentinelDayOf(earliest)) return;
|
|
1155
|
+
if (!force && (daysRef.current[ds] || loading.current.has(ds))) return;
|
|
1156
|
+
loading.current.add(ds);
|
|
1157
|
+
try {
|
|
1158
|
+
const d = await fetchDay(ds);
|
|
1159
|
+
if (camRef.current !== camId) return;
|
|
1160
|
+
setDays((prev) => ({ ...prev, [ds]: d }));
|
|
1161
|
+
} finally {
|
|
1162
|
+
loading.current.delete(ds);
|
|
1163
|
+
}
|
|
1164
|
+
}, [fetchDay, earliest, camId]);
|
|
1165
|
+
const onCenter = useCallback((ts) => {
|
|
1166
|
+
const d = sentinelDayOf(ts);
|
|
1167
|
+
setCenterDay(d);
|
|
1168
|
+
void ensureDay(d);
|
|
1169
|
+
void ensureDay(d - SENTINEL_DAY_MS);
|
|
1170
|
+
void ensureDay(d + SENTINEL_DAY_MS);
|
|
1171
|
+
}, [ensureDay]);
|
|
1172
|
+
useEffect3(() => {
|
|
1173
|
+
const c = new PlayerController(client, {
|
|
1174
|
+
onState: (s) => setPs(s),
|
|
1175
|
+
onClipsRefresh: async () => {
|
|
1176
|
+
await ensureDay(todayStart(), true);
|
|
1177
|
+
return mergedRef.current.clips;
|
|
1178
|
+
},
|
|
1179
|
+
storagePrefix: p.storagePrefix,
|
|
1180
|
+
brand: p.brand
|
|
1181
|
+
});
|
|
1182
|
+
c.attach({ video: video.current, freeze: freeze.current, img: img.current, stage: stage.current });
|
|
1183
|
+
ctl.current = c;
|
|
1184
|
+
window.__snvr = { ctl: c, state: () => psRef.current };
|
|
1185
|
+
return () => {
|
|
1186
|
+
c.destroy();
|
|
1187
|
+
ctl.current = null;
|
|
1188
|
+
delete window.__snvr;
|
|
1189
|
+
};
|
|
1190
|
+
}, [client]);
|
|
1191
|
+
useEffect3(() => {
|
|
1192
|
+
const c = ctl.current;
|
|
1193
|
+
if (!c || !camId) return;
|
|
1194
|
+
c.setCamera(camId, name);
|
|
1195
|
+
setDays({});
|
|
1196
|
+
daysRef.current = {};
|
|
1197
|
+
setFilterOff({});
|
|
1198
|
+
setTab("tl");
|
|
1199
|
+
setLoadError(false);
|
|
1200
|
+
loading.current.clear();
|
|
1201
|
+
if (startAt) c.posterEvent(posterTs || startAt);
|
|
1202
|
+
else c.posterFromSnapshot();
|
|
1203
|
+
const t0 = todayStart();
|
|
1204
|
+
const target = startAt ? sentinelDayOf(startAt) : t0;
|
|
1205
|
+
Promise.all([ensureDay(target), ensureDay(target - SENTINEL_DAY_MS), target !== t0 ? ensureDay(t0) : Promise.resolve(), target === t0 ? Promise.resolve() : ensureDay(target + SENTINEL_DAY_MS)]).then(() => {
|
|
1206
|
+
if (c.camId !== camId || ctl.current !== c) return;
|
|
1207
|
+
setLoadError(false);
|
|
1208
|
+
const m = mergedRef.current;
|
|
1209
|
+
c.setClips(m.clips, m.codecs, m.rangeStart, m.rangeEnd);
|
|
1210
|
+
if (startAt) {
|
|
1211
|
+
c.playAt(startAt, {});
|
|
1212
|
+
setJump({ ts: startAt, n: Date.now() });
|
|
1213
|
+
} else c.goLive();
|
|
1214
|
+
}).catch(() => setLoadError(true));
|
|
1215
|
+
}, [camId, client]);
|
|
1216
|
+
useEffect3(() => {
|
|
1217
|
+
if (ctl.current && name) ctl.current.camName = name;
|
|
1218
|
+
}, [name]);
|
|
1219
|
+
useEffect3(() => {
|
|
1220
|
+
const i = setInterval(() => {
|
|
1221
|
+
if (psRef.current.live) ensureDay(todayStart(), true).catch(() => {
|
|
1222
|
+
});
|
|
1223
|
+
}, 15e3);
|
|
1224
|
+
return () => clearInterval(i);
|
|
1225
|
+
}, [ensureDay]);
|
|
1226
|
+
const present = useMemo2(() => {
|
|
1227
|
+
const m = {};
|
|
1228
|
+
for (const e of merged.events) {
|
|
1229
|
+
const k = sentinelClassOf(e);
|
|
1230
|
+
m[k] = (m[k] ?? 0) + 1;
|
|
1231
|
+
}
|
|
1232
|
+
return m;
|
|
1233
|
+
}, [merged.events]);
|
|
1234
|
+
const visEvents = useMemo2(() => merged.events.filter((e) => !filterOff[sentinelClassOf(e)]), [merged.events, filterOff]);
|
|
1235
|
+
const goLive = useCallback(() => {
|
|
1236
|
+
ctl.current?.goLive();
|
|
1237
|
+
setJump({ ts: Date.now(), n: Date.now() });
|
|
1238
|
+
}, []);
|
|
1239
|
+
const playEvent = useCallback((ev) => {
|
|
1240
|
+
const c = ctl.current;
|
|
1241
|
+
if (!c) return;
|
|
1242
|
+
setTab("tl");
|
|
1243
|
+
c.posterEvent(ev.timestamp);
|
|
1244
|
+
c.playAt(sentinelEventPlayTs(ev), {});
|
|
1245
|
+
}, []);
|
|
1246
|
+
const jumpEvent = useCallback((dir) => {
|
|
1247
|
+
const c = ctl.current;
|
|
1248
|
+
if (!c) return;
|
|
1249
|
+
const ts = c.currentTs() ?? Date.now();
|
|
1250
|
+
let best;
|
|
1251
|
+
if (dir > 0) best = visEvents.find((e) => e.timestamp > ts + 500);
|
|
1252
|
+
else {
|
|
1253
|
+
for (let i = visEvents.length - 1; i >= 0; i--) {
|
|
1254
|
+
const e = visEvents[i];
|
|
1255
|
+
if (e.timestamp < ts - 500) {
|
|
1256
|
+
best = e;
|
|
1257
|
+
break;
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
if (best) playEvent(best);
|
|
1262
|
+
}, [visEvents, playEvent]);
|
|
1263
|
+
const goToDay = useCallback(async (ds, at) => {
|
|
1264
|
+
const c = ctl.current;
|
|
1265
|
+
if (!c) return;
|
|
1266
|
+
await Promise.all([ensureDay(ds), ensureDay(ds - SENTINEL_DAY_MS), ensureDay(ds + SENTINEL_DAY_MS)]);
|
|
1267
|
+
if (camRef.current !== camId) return;
|
|
1268
|
+
if (ds === todayStart() && at == null) {
|
|
1269
|
+
goLive();
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
const want = at ?? ds + SENTINEL_DAY_MS / 2;
|
|
1273
|
+
if (want > Date.now()) {
|
|
1274
|
+
goLive();
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
const m = mergedRef.current;
|
|
1278
|
+
c.setClips(m.clips, m.codecs, m.rangeStart, m.rangeEnd);
|
|
1279
|
+
const inDay = m.clips.filter((x) => x.startTime >= ds && x.startTime < ds + SENTINEL_DAY_MS);
|
|
1280
|
+
const exact = c.clipIndexFor(want) >= 0;
|
|
1281
|
+
const pick = exact ? want : (inDay.find((x) => x.startTime >= want) || inDay[inDay.length - 1])?.startTime;
|
|
1282
|
+
setJump({ ts: pick ?? want, n: Date.now() });
|
|
1283
|
+
if (pick != null) c.playAt(pick, {});
|
|
1284
|
+
else setPs((s) => ({ ...s, live: false, label: "noRecording", playhead: null }));
|
|
1285
|
+
}, [ensureDay, camId, goLive]);
|
|
1286
|
+
const scrub = useMemo2(() => ({
|
|
1287
|
+
begin: () => ctl.current?.scrubBegin(),
|
|
1288
|
+
move: (c, v, s) => ctl.current?.scrubMove(c, v, s),
|
|
1289
|
+
seek: (ts) => ctl.current?.scrubSeek(ts),
|
|
1290
|
+
idle: () => ctl.current?.scrubIdle()
|
|
1291
|
+
}), []);
|
|
1292
|
+
useEffect3(() => {
|
|
1293
|
+
const k = (e) => {
|
|
1294
|
+
if (dt) return;
|
|
1295
|
+
const tag = (e.target?.tagName || "").toLowerCase();
|
|
1296
|
+
if (tag === "input" || tag === "select" || tag === "textarea") return;
|
|
1297
|
+
const c = ctl.current;
|
|
1298
|
+
if (!c) return;
|
|
1299
|
+
if (e.key === " ") {
|
|
1300
|
+
e.preventDefault();
|
|
1301
|
+
c.togglePlayPause();
|
|
1302
|
+
} else if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
|
1303
|
+
e.preventDefault();
|
|
1304
|
+
const ts = c.currentTs();
|
|
1305
|
+
if (ts == null) return;
|
|
1306
|
+
c.playAt(ts + (e.key === "ArrowRight" ? 1 : -1) * (e.shiftKey ? 60 : 10) * 1e3, {});
|
|
1307
|
+
} else if (e.key === "n") jumpEvent(1);
|
|
1308
|
+
else if (e.key === "p") jumpEvent(-1);
|
|
1309
|
+
else if (e.key === "l" || e.key === "L") goLive();
|
|
1310
|
+
};
|
|
1311
|
+
document.addEventListener("keydown", k);
|
|
1312
|
+
return () => document.removeEventListener("keydown", k);
|
|
1313
|
+
}, [dt, jumpEvent, goLive]);
|
|
1314
|
+
const mjpeg = ps.transport === "mjpeg";
|
|
1315
|
+
const oldestAllowed = earliest ? sentinelDayOf(earliest) : -Infinity;
|
|
1316
|
+
const statusText = stageStatus(ps, t, locale, loadError);
|
|
1317
|
+
const nav = dateChipNav(centerDay, oldestAllowed);
|
|
1318
|
+
const cors = p.crossOrigin ? "anonymous" : void 0;
|
|
1319
|
+
return /* @__PURE__ */ jsxs7("div", { className: "nvr-cam", children: [
|
|
1320
|
+
p.header,
|
|
1321
|
+
/* @__PURE__ */ jsxs7("div", { className: "nvr-cam__body", children: [
|
|
1322
|
+
/* @__PURE__ */ jsx9("div", { className: "nvr-cam__left", children: /* @__PURE__ */ jsxs7("div", { className: "nvr-card nvr-stage-card", children: [
|
|
1323
|
+
/* @__PURE__ */ jsx9("div", { className: "nvr-stage-wrap", children: /* @__PURE__ */ jsxs7("div", { className: "nvr-stage", ref: stage, children: [
|
|
1324
|
+
/* @__PURE__ */ jsx9("video", { ref: video, playsInline: true, autoPlay: true, muted: true, crossOrigin: cors, className: "nvr-stage__video" }),
|
|
1325
|
+
/* @__PURE__ */ jsx9("img", { ref: img, crossOrigin: cors, className: "nvr-stage__video nvr-stage__img hidden", alt: "" }),
|
|
1326
|
+
/* @__PURE__ */ jsx9("canvas", { ref: freeze, className: "nvr-stage__video nvr-stage__freeze hidden" }),
|
|
1327
|
+
!mjpeg && /* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-mute", "aria-label": t("nvr.player.sound"), "aria-pressed": ps.sound, onClick: () => ctl.current?.setSound(!ps.sound), children: ps.sound && !ps.muted ? /* @__PURE__ */ jsx9(Volume2, { size: 18 }) : /* @__PURE__ */ jsx9(VolumeX, { size: 18 }) }),
|
|
1328
|
+
/* @__PURE__ */ jsxs7("div", { className: "nvr-pill-ctl" + (ps.live ? " nvr-pill-ctl--live" : ""), children: [
|
|
1329
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-pb", "aria-label": t("nvr.player.back15"), onClick: () => ctl.current?.skip(-15e3), children: /* @__PURE__ */ jsx9(Rewind, { size: 18 }) }),
|
|
1330
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-pb", "aria-label": ps.paused ? t("nvr.player.play") : t("nvr.player.pause"), disabled: ps.live, onClick: () => ctl.current?.togglePlayPause(), children: ps.paused ? /* @__PURE__ */ jsx9(Play, { size: 18 }) : /* @__PURE__ */ jsx9(Pause, { size: 18 }) }),
|
|
1331
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-pb", "aria-label": t("nvr.player.fwd15"), disabled: ps.live, onClick: () => ctl.current?.skip(15e3), children: /* @__PURE__ */ jsx9(FastForward, { size: 18 }) }),
|
|
1332
|
+
/* @__PURE__ */ jsxs7("button", { type: "button", className: "nvr-pb nvr-pb--speed nvr-data", "aria-label": t("nvr.player.speed"), disabled: ps.live, onClick: () => ctl.current?.cycleSpeed(), children: [
|
|
1333
|
+
ps.rate,
|
|
1334
|
+
"\xD7"
|
|
1335
|
+
] })
|
|
1336
|
+
] })
|
|
1337
|
+
] }) }),
|
|
1338
|
+
/* @__PURE__ */ jsxs7("div", { className: "nvr-stage-bar", children: [
|
|
1339
|
+
/* @__PURE__ */ jsx9("span", { className: "nvr-statusdot" + (ps.live ? " nvr-statusdot--live" : ""), "aria-hidden": "true" }),
|
|
1340
|
+
/* @__PURE__ */ jsxs7("span", { className: "nvr-stage-title", children: [
|
|
1341
|
+
/* @__PURE__ */ jsx9("b", { children: name }),
|
|
1342
|
+
/* @__PURE__ */ jsx9("small", { children: statusText })
|
|
1343
|
+
] }),
|
|
1344
|
+
/* @__PURE__ */ jsxs7("span", { className: "nvr-stage-actions", children: [
|
|
1345
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-iconbtn", "aria-label": t("nvr.player.snapshot"), onClick: () => ctl.current?.snapshot(), children: /* @__PURE__ */ jsx9(Camera2, { size: 16 }) }),
|
|
1346
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-iconbtn", "aria-label": t("nvr.player.pip"), onClick: () => ctl.current?.pip(), children: /* @__PURE__ */ jsx9(PictureInPicture2, { size: 16 }) }),
|
|
1347
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-iconbtn", "aria-label": t("nvr.player.fullscreen"), onClick: () => ctl.current?.fullscreen(), children: /* @__PURE__ */ jsx9(Maximize2, { size: 16 }) })
|
|
1348
|
+
] })
|
|
1349
|
+
] })
|
|
1350
|
+
] }) }),
|
|
1351
|
+
/* @__PURE__ */ jsxs7("aside", { className: "nvr-card nvr-cam__right", children: [
|
|
1352
|
+
/* @__PURE__ */ jsxs7("div", { className: "nvr-tabs", role: "tablist", children: [
|
|
1353
|
+
/* @__PURE__ */ jsx9("button", { type: "button", role: "tab", "aria-selected": tab === "tl", className: tab === "tl" ? "nvr-tabs__tab--active" : "", onClick: () => setTab("tl"), children: t("nvr.tab.timeline") }),
|
|
1354
|
+
/* @__PURE__ */ jsxs7("button", { type: "button", role: "tab", "aria-selected": tab === "ev", className: tab === "ev" ? "nvr-tabs__tab--active" : "", onClick: () => setTab("ev"), children: [
|
|
1355
|
+
t("nvr.tab.events"),
|
|
1356
|
+
visEvents.length ? ` (${visEvents.length})` : ""
|
|
1357
|
+
] })
|
|
1358
|
+
] }),
|
|
1359
|
+
/* @__PURE__ */ jsx9("div", { className: "nvr-filters", children: SENTINEL_EVENT_CLASSES.filter((k) => present[k]).map((k) => /* @__PURE__ */ jsxs7("button", { type: "button", className: "nvr-fchip" + (filterOff[k] ? " nvr-fchip--off" : ""), onClick: () => setFilterOff((f) => ({ ...f, [k]: !f[k] })), title: classLabel(t, k), "aria-pressed": !filterOff[k], children: [
|
|
1360
|
+
/* @__PURE__ */ jsx9(ClassBadge, { cls: k, size: 18 }),
|
|
1361
|
+
present[k]
|
|
1362
|
+
] }, k)) }),
|
|
1363
|
+
tab === "tl" ? /* @__PURE__ */ jsx9(
|
|
1364
|
+
VerticalTimeline,
|
|
1365
|
+
{
|
|
1366
|
+
camId,
|
|
1367
|
+
rangeStart: merged.rangeStart,
|
|
1368
|
+
rangeEnd: merged.rangeEnd,
|
|
1369
|
+
clips: merged.clips,
|
|
1370
|
+
events: merged.events,
|
|
1371
|
+
motion: merged.motion,
|
|
1372
|
+
live: ps.live,
|
|
1373
|
+
playhead: () => ctl.current?.currentTs() ?? null,
|
|
1374
|
+
following: () => !psRef.current.paused,
|
|
1375
|
+
filterOff,
|
|
1376
|
+
onEvent: playEvent,
|
|
1377
|
+
onGoLive: goLive,
|
|
1378
|
+
scrub,
|
|
1379
|
+
onCenter,
|
|
1380
|
+
jump
|
|
1381
|
+
}
|
|
1382
|
+
) : /* @__PURE__ */ jsx9(EventList, { camId, events: merged.events, filterOff, onPick: playEvent }),
|
|
1383
|
+
/* @__PURE__ */ jsxs7("div", { className: "nvr-datechip" + (ps.live ? "" : " nvr-datechip--rec"), children: [
|
|
1384
|
+
/* @__PURE__ */ jsx9("button", { type: "button", onClick: () => void goToDay(centerDay - SENTINEL_DAY_MS), disabled: nav.prevDisabled, "aria-label": t("nvr.date.prevDay"), children: /* @__PURE__ */ jsx9(ChevronLeft2, { size: 14 }) }),
|
|
1385
|
+
/* @__PURE__ */ jsxs7("button", { type: "button", className: "nvr-datechip__lbl nvr-data", onClick: () => setDt(true), "aria-label": t("nvr.date.title"), children: [
|
|
1386
|
+
/* @__PURE__ */ jsx9(Calendar, { size: 13 }),
|
|
1387
|
+
fmtDay(centerDay, locale)
|
|
1388
|
+
] }),
|
|
1389
|
+
/* @__PURE__ */ jsx9("button", { type: "button", onClick: () => void goToDay(centerDay + SENTINEL_DAY_MS), disabled: nav.nextDisabled, "aria-label": t("nvr.date.nextDay"), children: /* @__PURE__ */ jsx9(ChevronRight2, { size: 14 }) })
|
|
1390
|
+
] })
|
|
1391
|
+
] })
|
|
1392
|
+
] }),
|
|
1393
|
+
dt && p.renderDatePicker({
|
|
1394
|
+
dayStart: centerDay,
|
|
1395
|
+
timeTs: ps.live ? Date.now() : ctl.current?.currentTs() ?? Date.now(),
|
|
1396
|
+
oldestAllowed,
|
|
1397
|
+
onClose: () => setDt(false),
|
|
1398
|
+
onGo: (ds, time) => {
|
|
1399
|
+
setDt(false);
|
|
1400
|
+
const at = time ? ds + (Number(time.split(":")[0]) * 3600 + Number(time.split(":")[1]) * 60) * 1e3 : void 0;
|
|
1401
|
+
goToDay(ds, at).catch(() => {
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
})
|
|
1405
|
+
] });
|
|
1406
|
+
}
|
|
1072
1407
|
export {
|
|
1073
1408
|
CameraGrid,
|
|
1409
|
+
CameraPage,
|
|
1074
1410
|
CameraTiles,
|
|
1411
|
+
CameraTitle,
|
|
1075
1412
|
CardTitle,
|
|
1076
1413
|
ClassBadge,
|
|
1077
1414
|
DatePickerPanel,
|
|
@@ -1093,6 +1430,7 @@ export {
|
|
|
1093
1430
|
applyTheme,
|
|
1094
1431
|
classLabel,
|
|
1095
1432
|
createT,
|
|
1433
|
+
dateChipNav,
|
|
1096
1434
|
eventLabel,
|
|
1097
1435
|
fmtDays,
|
|
1098
1436
|
fmtRelative,
|
|
@@ -1102,6 +1440,7 @@ export {
|
|
|
1102
1440
|
pickLocale,
|
|
1103
1441
|
resolveMode,
|
|
1104
1442
|
resolveThemeMode,
|
|
1443
|
+
stageStatus,
|
|
1105
1444
|
translate,
|
|
1106
1445
|
useDatePicker,
|
|
1107
1446
|
useSentinelUi,
|