@sentinel-nvr/web 0.16.4 → 0.16.6

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/ui/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PlayerController,
3
3
  rlog
4
- } from "../chunk-JRYP7MG6.js";
4
+ } from "../chunk-QAYPO6TS.js";
5
5
  import {
6
6
  SENTINEL_DAY_MS,
7
7
  SENTINEL_EVENT_CLASSES,
@@ -27,7 +27,7 @@ import {
27
27
  sentinelWallMarks,
28
28
  sentinelWallSeconds,
29
29
  weekdayShorts
30
- } from "../chunk-Y4WFO6G3.js";
30
+ } from "../chunk-26BQB2OK.js";
31
31
 
32
32
  // src/ui/context.tsx
33
33
  import { createContext, useContext } from "react";
@@ -416,8 +416,8 @@ function fmtDays(d, t) {
416
416
  const n = Math.round(d);
417
417
  return t("nvr.time.days", { count: n });
418
418
  }
419
- function humanBytes(b) {
420
- const h = sentinelHumanBytes(b);
419
+ function humanBytes(b, locale) {
420
+ const h = sentinelHumanBytes(b, locale);
421
421
  return `${h.value} ${h.unit}`;
422
422
  }
423
423
 
@@ -791,11 +791,11 @@ function CardTitle({
791
791
  ] });
792
792
  }
793
793
  function Hero({ cameras, stats }) {
794
- const { t } = useSentinelUi();
794
+ const { t, locale } = useSentinelUi();
795
795
  const online = cameras.filter((c) => c.online).length;
796
796
  const offline = Math.max(0, stats.cameras - online);
797
797
  const fc = sentinelStorageForecast(stats);
798
- const bytes = sentinelHumanBytes(stats.bytes);
798
+ const bytes = sentinelHumanBytes(stats.bytes, locale);
799
799
  const span = fc.spanDays ? fmtDays(fc.spanDays, t).split(" ") : ["\u2013"];
800
800
  return /* @__PURE__ */ jsxs5("div", { className: "nvr-card nvr-hero", children: [
801
801
  /* @__PURE__ */ jsxs5("div", { className: "nvr-hero__head", children: [
@@ -894,7 +894,7 @@ function HistogramCard({ histogram }) {
894
894
  ] });
895
895
  }
896
896
  function StorageCard({ stats }) {
897
- const { t } = useSentinelUi();
897
+ const { t, locale } = useSentinelUi();
898
898
  const fc = sentinelStorageForecast(stats);
899
899
  const pct = (v) => stats.diskTotal ? `${(v / stats.diskTotal * 100).toFixed(2)}%` : "0%";
900
900
  const reserveShown = Math.min(fc.reserve, stats.diskFree);
@@ -935,36 +935,36 @@ function StorageCard({ stats }) {
935
935
  /* @__PURE__ */ jsx7("i", { className: "nvr-legend__sw nvr-legend__sw--rec" }),
936
936
  t("nvr.storage.recordings"),
937
937
  " ",
938
- humanBytes(stats.bytes)
938
+ humanBytes(stats.bytes, locale)
939
939
  ] }),
940
940
  /* @__PURE__ */ jsxs5("span", { children: [
941
941
  /* @__PURE__ */ jsx7("i", { className: "nvr-legend__sw nvr-legend__sw--other" }),
942
942
  t("nvr.storage.system"),
943
943
  " ",
944
- humanBytes(fc.other)
944
+ humanBytes(fc.other, locale)
945
945
  ] }),
946
946
  /* @__PURE__ */ jsxs5("span", { children: [
947
947
  /* @__PURE__ */ jsx7("i", { className: "nvr-legend__sw nvr-legend__sw--free" }),
948
948
  t("nvr.storage.free"),
949
949
  " ",
950
- humanBytes(stats.diskFree)
950
+ humanBytes(stats.diskFree, locale)
951
951
  ] }),
952
952
  /* @__PURE__ */ jsxs5("span", { children: [
953
953
  /* @__PURE__ */ jsx7("i", { className: "nvr-legend__sw nvr-legend__sw--reserve" }),
954
954
  t("nvr.storage.reserve"),
955
955
  " ",
956
- humanBytes(fc.reserve)
956
+ humanBytes(fc.reserve, locale)
957
957
  ] })
958
958
  ] }),
959
959
  /* @__PURE__ */ jsxs5("ul", { className: "nvr-kv", children: [
960
960
  /* @__PURE__ */ jsxs5("li", { children: [
961
961
  /* @__PURE__ */ jsx7("span", { children: t("nvr.storage.rate") }),
962
- /* @__PURE__ */ jsx7("b", { className: "nvr-data", children: fc.ratePerDay ? t("nvr.storage.perDay", { value: humanBytes(fc.ratePerDay) }) : "\u2013" })
962
+ /* @__PURE__ */ jsx7("b", { className: "nvr-data", children: fc.ratePerDay ? t("nvr.storage.perDay", { value: humanBytes(fc.ratePerDay, locale) }) : "\u2013" })
963
963
  ] }),
964
964
  /* @__PURE__ */ jsxs5("li", { children: [
965
965
  /* @__PURE__ */ jsx7("span", { children: t("nvr.storage.capacity") }),
966
966
  /* @__PURE__ */ jsxs5("b", { className: "nvr-data", children: [
967
- humanBytes(fc.capacity),
967
+ humanBytes(fc.capacity, locale),
968
968
  fc.ratePerDay ? /* @__PURE__ */ jsxs5("em", { children: [
969
969
  " \u2248 ",
970
970
  fmtDays(fc.fitsDays, t)
@@ -1424,6 +1424,11 @@ function shouldHandleKey(e) {
1424
1424
  return false;
1425
1425
  return true;
1426
1426
  }
1427
+ var GESTURE_STALE_MS = 1e4;
1428
+ function todayRefreshAllowed(s) {
1429
+ if (s.hidden || s.settling) return false;
1430
+ return !(s.gestureAt > 0 && s.now - s.gestureAt < GESTURE_STALE_MS);
1431
+ }
1427
1432
 
1428
1433
  // src/ui/components/CameraPage.tsx
1429
1434
  import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
@@ -1492,6 +1497,7 @@ function CameraPage(p) {
1492
1497
  const camRef = useRef2(camId);
1493
1498
  camRef.current = camId;
1494
1499
  const deepRef = useRef2("");
1500
+ const gestureAt = useRef2(0);
1495
1501
  const merged = useMemo2(() => {
1496
1502
  const m = sentinelMergeDays(days);
1497
1503
  const rangeStart = m.oldestDay ?? todayStart();
@@ -1631,7 +1637,13 @@ function CameraPage(p) {
1631
1637
  }, [name]);
1632
1638
  useEffect3(() => {
1633
1639
  const i = setInterval(() => {
1634
- if (psRef.current.live)
1640
+ const ok = todayRefreshAllowed({
1641
+ hidden: document.visibilityState === "hidden",
1642
+ gestureAt: gestureAt.current,
1643
+ settling: !!ctl.current?.scrubSettling(),
1644
+ now: Date.now()
1645
+ });
1646
+ if (ok)
1635
1647
  ensureDay(todayStart(), true).catch(() => {
1636
1648
  });
1637
1649
  }, 15e3);
@@ -1706,11 +1718,26 @@ function CameraPage(p) {
1706
1718
  );
1707
1719
  const scrub = useMemo2(
1708
1720
  () => ({
1709
- begin: () => ctl.current?.scrubBegin(),
1710
- move: (c, v, s) => ctl.current?.scrubMove(c, v, s),
1711
- seek: (ts) => ctl.current?.scrubSeek(ts),
1712
- hold: (ts) => ctl.current?.scrubHold(ts),
1713
- idle: (ts) => ctl.current?.scrubIdle(ts)
1721
+ begin: () => {
1722
+ gestureAt.current = Date.now();
1723
+ ctl.current?.scrubBegin();
1724
+ },
1725
+ move: (c, v, s) => {
1726
+ gestureAt.current = Date.now();
1727
+ ctl.current?.scrubMove(c, v, s);
1728
+ },
1729
+ seek: (ts) => {
1730
+ gestureAt.current = Date.now();
1731
+ ctl.current?.scrubSeek(ts);
1732
+ },
1733
+ hold: (ts) => {
1734
+ gestureAt.current = Date.now();
1735
+ ctl.current?.scrubHold(ts);
1736
+ },
1737
+ idle: (ts) => {
1738
+ gestureAt.current = 0;
1739
+ ctl.current?.scrubIdle(ts);
1740
+ }
1714
1741
  }),
1715
1742
  []
1716
1743
  );