@7365admin1/layer-common 4.161.3 → 4.161.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.161.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 1016919: CCTV Engine: plain help lines on Live, Events, Playback and Engines; Playback and Export say "No video saved for this time" instead of a generic error when the engine kept no recording.
8
+
9
+ ## 4.161.4
10
+
11
+ ### Patch Changes
12
+
13
+ - c5bae70: CCTV Engine: Zones & wrong-way and New smart detection now draw over the camera's live view instead of one still picture taken when the screen opened.
14
+
3
15
  ## 4.161.3
4
16
 
5
17
  ### Patch Changes
@@ -3674,11 +3686,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
3674
3686
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
3675
3687
  own rule from two endpoints the console already calls, unprojected:
3676
3688
 
3677
- GET /api/members/user/:user/app/admin the Seven365 staff membership
3678
- GET /api/roles/id/:role that membership's role document
3689
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
3690
+ GET /api/roles/id/:role that membership's role document
3679
3691
 
3680
- owner = member.type === "admin" && role.type === "admin" && role.default === true
3681
- staff = member.type === "admin" && role.type === "admin"
3692
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
3693
+ staff = member.type === "admin" && role.type === "admin"
3682
3694
 
3683
3695
  `role.default` is the marker because it is the only property of a platform
3684
3696
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -1,6 +1,6 @@
1
1
  <!--
2
2
  New smart detection, in two steps.
3
- Step 1: name it, pick a camera, drag a box over the area to watch on the camera's latest picture.
3
+ Step 1: name it, pick a camera, drag a box over the area to watch on the camera's live view.
4
4
  Step 2: list the results (what the area can look like) and which ones should raise an alert.
5
5
  The box is saved as fractions of the picture (0..1) so it stays right at any screen size.
6
6
  -->
@@ -42,26 +42,23 @@
42
42
  </v-row>
43
43
 
44
44
  <template v-if="camera">
45
- <v-progress-linear v-if="imgLoading" indeterminate class="mb-2" />
46
45
  <div
47
46
  ref="stage"
48
47
  class="cctv-dc__stage"
49
48
  role="img"
50
- :aria-label="`Latest picture from ${camera}. Drag to draw a box over the area.`"
49
+ :aria-label="`Live view of ${camera}. Drag to draw a box over the area.`"
51
50
  @pointerdown.prevent="down"
52
51
  @pointermove="move"
53
52
  @pointerup="up"
54
53
  @pointercancel="up"
55
54
  >
56
- <img v-if="image" :src="image" alt="" class="cctv-dc__img" draggable="false" />
57
- <div v-else-if="!imgLoading" class="cctv-dc__none">No picture available yet. The engine may be offline. You can still draw a box.</div>
55
+ <CctvEngineLiveTile :key="`${engine}/${camera}`" :engine-id="engine" :camera="camera" natural class="cctv-dc__live" />
58
56
  <div v-if="box" class="cctv-dc__box" :style="boxStyle" />
59
57
  </div>
60
58
  <div class="hero-muted mt-1">
61
59
  <template v-if="cropIsUsable(crop)">Area set. Drag again to change it.</template>
62
60
  <template v-else>Press and drag on the picture to draw a box around the area. Make it big enough to see clearly.</template>
63
61
  </div>
64
- <CctvEngineNotice v-if="imgError" class="mt-2" tone="info" :error="imgError" title="The latest picture could not be loaded" body="The engine may be offline. You can still draw a box on the grey area." />
65
62
  </template>
66
63
  </template>
67
64
 
@@ -115,7 +112,7 @@
115
112
  </template>
116
113
 
117
114
  <script setup lang="ts">
118
- import { computed, onBeforeUnmount, ref, watch } from "vue";
115
+ import { computed, ref, watch } from "vue";
119
116
  import {
120
117
  cropFromDrag, cropIsUsable, DEFAULT_RESULTS, detectionNameProblem, MIN_PHOTOS_PER_RESULT, resultsProblem, toWord,
121
118
  type TCrop,
@@ -123,7 +120,7 @@ import {
123
120
 
124
121
  const props = defineProps<{ modelValue: boolean; engine: string }>();
125
122
  const emit = defineEmits<{ (e: "update:modelValue", v: boolean): void; (e: "created", message: string): void }>();
126
- const { listCameras, latestImage, createClassifier } = useCctvEngine();
123
+ const { listCameras, createClassifier } = useCctvEngine();
127
124
 
128
125
  const step = ref(1);
129
126
  const name = ref("");
@@ -131,9 +128,6 @@ const camera = ref("");
131
128
  const cameras = ref<any[]>([]);
132
129
  const camLoading = ref(false);
133
130
  const camError = ref<unknown>(null);
134
- const image = ref("");
135
- const imgLoading = ref(false);
136
- const imgError = ref<unknown>(null);
137
131
  const crop = ref<TCrop | null>(null);
138
132
  const states = ref<string[]>([...DEFAULT_RESULTS]);
139
133
  const alertStates = ref<string[]>(["rubbish"]);
@@ -176,11 +170,6 @@ function setStates(v: string[]) {
176
170
  alertStates.value = alertStates.value.filter((a) => clean.includes(a));
177
171
  }
178
172
 
179
- function freeImage() {
180
- if (image.value) URL.revokeObjectURL(image.value);
181
- image.value = "";
182
- }
183
-
184
173
  async function loadCameras() {
185
174
  cameras.value = [];
186
175
  camError.value = null;
@@ -194,20 +183,6 @@ async function loadCameras() {
194
183
  camLoading.value = false;
195
184
  }
196
185
  }
197
- async function loadImage() {
198
- freeImage();
199
- crop.value = null;
200
- imgError.value = null;
201
- if (!camera.value) return;
202
- imgLoading.value = true;
203
- try {
204
- image.value = await latestImage(props.engine, camera.value);
205
- } catch (e) {
206
- imgError.value = e;
207
- } finally {
208
- imgLoading.value = false;
209
- }
210
- }
211
186
 
212
187
  async function create() {
213
188
  saving.value = true;
@@ -236,7 +211,6 @@ function reset() {
236
211
  states.value = [...DEFAULT_RESULTS];
237
212
  alertStates.value = ["rubbish"];
238
213
  error.value = null;
239
- freeImage();
240
214
  }
241
215
  function close(v: boolean) {
242
216
  emit("update:modelValue", v);
@@ -248,13 +222,11 @@ watch(() => props.modelValue, (open) => {
248
222
  loadCameras();
249
223
  }
250
224
  }, { immediate: true });
251
- watch(camera, loadImage);
252
- onBeforeUnmount(freeImage);
225
+ watch(camera, () => (crop.value = null));
253
226
  </script>
254
227
 
255
228
  <style scoped>
256
229
  .cctv-dc__stage { position: relative; background: #111; border-radius: 10px; overflow: hidden; min-height: 180px; user-select: none; cursor: crosshair; touch-action: none; }
257
- .cctv-dc__img { width: 100%; display: block; pointer-events: none; }
258
- .cctv-dc__none { color: #ddd; padding: 60px 16px; text-align: center; font-size: 13px; aspect-ratio: 16 / 9; }
230
+ .cctv-dc__live { pointer-events: none; }
259
231
  .cctv-dc__box { position: absolute; border: 2px solid #fff; background: rgba(30, 136, 229, 0.3); box-shadow: 0 0 0 1px #1e88e5; pointer-events: none; }
260
232
  </style>
@@ -9,6 +9,10 @@
9
9
  <v-btn variant="text" prepend-icon="mdi-refresh" :loading="loading" @click="load">Refresh</v-btn>
10
10
  <v-btn v-if="canEdit" color="primary" prepend-icon="mdi-plus" @click="openWizard">Add engine</v-btn>
11
11
  </div>
12
+ <p class="hero-muted mt-1 mb-2">
13
+ An engine is the small computer at the site that watches the cameras. "Online" means it is connected now. Open an
14
+ engine to see its cameras and health. If it shows Offline, check that the engine box has power and internet.
15
+ </p>
12
16
 
13
17
  <v-progress-linear v-if="loading && !engines.length" indeterminate />
14
18
  <CctvEngineNotice v-else-if="error" :error="error" retry @retry="load" />
@@ -1,6 +1,10 @@
1
1
  <!-- Events: what the engine saw. Filter, page through, open one for the picture, clip, zones and score. -->
2
2
  <template>
3
3
  <div>
4
+ <p class="hero-muted mt-0 mb-2">
5
+ Everything the engine noticed, newest first: people, vehicles, plates, faces and smart detections, each with a photo
6
+ and the time. Use the boxes to narrow the list, then press Search. Click a row to see the photo and details.
7
+ </p>
4
8
  <v-row dense>
5
9
  <v-col cols="6" sm="4" md="3"><v-text-field v-model="f.camera" label="Camera" density="comfortable" hide-details clearable /></v-col>
6
10
  <v-col cols="6" sm="4" md="3"><v-text-field v-model="f.label" label="Object (car, person...)" density="comfortable" hide-details clearable /></v-col>
@@ -2,6 +2,10 @@
2
2
  <template>
3
3
  <div>
4
4
  <CctvEngineCameraPicker v-model:engine="engine" no-camera :site="site" @engines="onEngines" />
5
+ <p class="hero-muted mt-2 mb-0">
6
+ Watch the cameras live. Choose how many to show at once (Single, 4, 9 or 16) and which ones. A green "Live" tag means
7
+ smooth video; "Low-bandwidth view" means a picture refreshed every 2 seconds, used when video cannot reach your network.
8
+ </p>
5
9
 
6
10
  <template v-if="engine">
7
11
  <div class="d-flex flex-wrap align-center ga-3 my-3">
@@ -4,7 +4,7 @@
4
4
  Offline engine / failures are shown on the tile in plain words with a Try again button.
5
5
  -->
6
6
  <template>
7
- <div class="cctv-tile" :class="{ 'cctv-tile--big': big }" data-test="cctv-tile">
7
+ <div class="cctv-tile" :class="{ 'cctv-tile--big': big, 'cctv-tile--natural': natural }" data-test="cctv-tile">
8
8
  <video v-show="mode === 'live'" ref="video" autoplay muted playsinline class="cctv-tile__media" />
9
9
  <img v-if="mode === 'still' && still" :src="still" :alt="`Latest picture from ${camera}`" class="cctv-tile__media" />
10
10
 
@@ -37,7 +37,8 @@
37
37
  import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
38
38
  import { cctvNotice, STILL_REFRESH_MS } from "../../utils/cctv-engine";
39
39
 
40
- const props = defineProps<{ engineId: string; camera: string; big?: boolean }>();
40
+ // natural: keep the camera's own shape (no 16:9 box) so drawings laid over the tile line up with the picture.
41
+ const props = defineProps<{ engineId: string; camera: string; big?: boolean; natural?: boolean }>();
41
42
 
42
43
  const { webrtcAnswer, latestImage } = useCctvEngine();
43
44
 
@@ -176,6 +177,8 @@ onBeforeUnmount(stop);
176
177
  <style scoped>
177
178
  .cctv-tile { position: relative; background: #000; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; color: #fff; }
178
179
  .cctv-tile__media { width: 100%; height: 100%; object-fit: contain; display: block; }
180
+ .cctv-tile--natural { aspect-ratio: auto; min-height: 180px; border-radius: 0; }
181
+ .cctv-tile--natural .cctv-tile__media { height: auto; }
179
182
  .cctv-tile__msg { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; text-align: center; padding: 12px; font-size: 12px; overflow: auto; }
180
183
  .cctv-tile__bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 6px; padding: 4px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.75)); }
181
184
  .cctv-tile__name { flex: 1; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@@ -7,6 +7,10 @@
7
7
  <CctvEngineCameraPicker v-model:engine="engine" no-camera :site="site" />
8
8
 
9
9
  <template v-if="engine">
10
+ <p class="hero-muted mt-2 mb-0">
11
+ Watch saved video from a time range. Video is only there if the site's engine is set to keep recordings;
12
+ a site set to "events only" keeps a photo of each event instead - see the Events tab.
13
+ </p>
10
14
  <v-row dense class="mt-2">
11
15
  <v-col cols="12" md="6">
12
16
  <v-select
@@ -34,6 +38,7 @@
34
38
  <span class="hero-muted">Up to 30 minutes. For longer, create an export below.</span>
35
39
  </div>
36
40
  <div v-if="problem" class="text-error mt-2" role="alert">{{ problem }}</div>
41
+ <CctvEngineNotice v-if="noVideo" class="mt-3" tone="info" title="No video saved for this time" :body="noVideo" />
37
42
  <CctvEngineNotice v-if="playError" class="mt-3" :error="playError" retry @retry="play" />
38
43
 
39
44
  <div v-if="clips.length" class="mt-4">
@@ -83,7 +88,7 @@ import { CCTV_PERMISSIONS, clipRangeProblem, seekSeconds, toIso } from "../../ut
83
88
 
84
89
  const props = defineProps<{ site: string; access?: { can: (p: any) => boolean } }>();
85
90
  const can = (p: string) => props.access?.can(p as any) ?? false;
86
- const { listCameras, cameraClip, createExport, listExports, downloadExport } = useCctvEngine();
91
+ const { listCameras, listRecordings, cameraClip, createExport, listExports, downloadExport } = useCctvEngine();
87
92
  const { smAndDown } = useDisplay();
88
93
 
89
94
  const engine = ref("");
@@ -121,6 +126,18 @@ watch(engine, async (id) => {
121
126
  const clips = ref<{ camera: string; url: string }[]>([]);
122
127
  const videos = new Map<string, HTMLVideoElement>();
123
128
  const problem = ref("");
129
+ const noVideo = ref("");
130
+
131
+ /** Picked cameras with no saved video in the range. A failed check counts as "has video" so the real error shows. */
132
+ async function camerasWithoutVideo(start: string, end: string) {
133
+ const checks = await Promise.allSettled(picked.value.map((c) => listRecordings(engine.value, c, start, end)));
134
+ return picked.value.filter((_, i) => {
135
+ const r = checks[i];
136
+ return r.status === "fulfilled" && Array.isArray(r.value) && r.value.length === 0;
137
+ });
138
+ }
139
+ const noVideoText = (cams: string[]) =>
140
+ `${cams.join(", ")} ${cams.length > 1 ? "have" : "has"} no saved video between these times. This engine may be set to keep only a photo of each event (see the Events tab), or the camera was offline. Try another time range.`;
124
141
  const playing = ref(false);
125
142
  const playError = ref<unknown>(null);
126
143
  const position = ref(0);
@@ -149,8 +166,16 @@ async function play() {
149
166
  playing.value = true;
150
167
  playError.value = null;
151
168
  freeClips();
169
+ noVideo.value = "";
152
170
  const iso = { from: toIso(from.value)!, to: toIso(to.value)! };
153
- const results = await Promise.allSettled(picked.value.map(async (camera) => ({ camera, url: await cameraClip(engine.value, camera, iso.from, iso.to) })));
171
+ const missing = await camerasWithoutVideo(iso.from, iso.to);
172
+ if (missing.length === picked.value.length) {
173
+ noVideo.value = noVideoText(missing);
174
+ playing.value = false;
175
+ return;
176
+ }
177
+ if (missing.length) noVideo.value = noVideoText(missing);
178
+ const results = await Promise.allSettled(picked.value.filter((c) => !missing.includes(c)).map(async (camera) => ({ camera, url: await cameraClip(engine.value, camera, iso.from, iso.to) })));
154
179
  const ok = results.filter((r): r is PromiseFulfilledResult<{ camera: string; url: string }> => r.status === "fulfilled").map((r) => r.value);
155
180
  const bad = results.find((r): r is PromiseRejectedResult => r.status === "rejected");
156
181
  clips.value = ok;
@@ -200,7 +225,9 @@ async function makeExport() {
200
225
  exporting.value = true;
201
226
  exportError.value = null;
202
227
  try {
203
- for (const camera of picked.value) {
228
+ const missing = await camerasWithoutVideo(toIso(from.value)!, toIso(to.value)!);
229
+ if (missing.length === picked.value.length) return void (exportMsg.value = noVideoText(missing));
230
+ for (const camera of picked.value.filter((c) => !missing.includes(c))) {
204
231
  await createExport(engine.value, { camera, from: toIso(from.value)!, to: toIso(to.value)!, name: exportName.value.trim() || `${camera} ${from.value}` });
205
232
  }
206
233
  exportMsg.value = "Export started. It is prepared at the site; press Refresh list until it says Ready.";
@@ -1,5 +1,5 @@
1
1
  <!--
2
- Zones & wrong-way. Draw areas on the camera's latest picture (click to add corners). Zones name an area
2
+ Zones & wrong-way. Draw areas on the camera's live view (click to add corners). Zones name an area
3
3
  (for alerts and wrong-way rules); masks tell the engine to ignore an area (motion / objects).
4
4
  Coordinates are saved as fractions of the picture (0..1), so they stay right at any screen size.
5
5
  -->
@@ -17,11 +17,10 @@
17
17
  class="cctv-zn__stage"
18
18
  :class="{ 'cctv-zn__stage--draw': canEdit }"
19
19
  role="img"
20
- :aria-label="`Latest picture from ${camera}. ${canEdit ? 'Click to add a corner.' : ''}`"
20
+ :aria-label="`Live view of ${camera}. ${canEdit ? 'Click to add a corner.' : ''}`"
21
21
  @click="addPoint"
22
22
  >
23
- <img v-if="image" :src="image" alt="" class="cctv-zn__img" draggable="false" />
24
- <div v-else class="cctv-zn__none">No picture available yet - you can still draw, but placing is easier with a picture.</div>
23
+ <CctvEngineLiveTile :key="`${engine}/${camera}`" :engine-id="engine" :camera="camera" natural />
25
24
  <svg viewBox="0 0 1 1" preserveAspectRatio="none" class="cctv-zn__svg" aria-hidden="true">
26
25
  <polygon v-for="(z, i) in zones" :key="`z${i}`" :points="svg(z.points)" :fill="color(i, 0.25)" :stroke="color(i, 1)" stroke-width="2" vector-effect="non-scaling-stroke" />
27
26
  <polygon v-for="(m, i) in masks" :key="`m${i}`" :points="svg(m.points)" fill="rgba(0,0,0,0.45)" stroke="#fff" stroke-dasharray="6 4" stroke-width="2" vector-effect="non-scaling-stroke" />
@@ -65,7 +64,6 @@
65
64
  </div>
66
65
  </v-col>
67
66
  </v-row>
68
- <CctvEngineNotice v-if="imageError && !error" class="mt-2" :error="imageError" title="The latest picture could not be loaded" body="The engine may be offline. You can still draw, then save when it is back." tone="info" />
69
67
  </template>
70
68
 
71
69
  <v-divider class="my-6" />
@@ -74,14 +72,14 @@
74
72
  </template>
75
73
 
76
74
  <script setup lang="ts">
77
- import { computed, onBeforeUnmount, ref, watch } from "vue";
75
+ import { computed, ref, watch } from "vue";
78
76
  import {
79
77
  buildZonesBody, CCTV_PERMISSIONS, isValidPolygon, pointFromClick, polygonToSvgPoints, readZonesReply,
80
78
  type TMask, type TPoint, type TZone,
81
79
  } from "../../utils/cctv-engine";
82
80
 
83
81
  const props = defineProps<{ site: string; access?: { can: (p: any) => boolean } }>();
84
- const { getZones, saveZones, latestImage } = useCctvEngine();
82
+ const { getZones, saveZones } = useCctvEngine();
85
83
 
86
84
  const engine = ref("");
87
85
  const camera = ref("");
@@ -98,8 +96,6 @@ const masks = ref<TMask[]>([]);
98
96
  const draft = ref<TPoint[]>([]);
99
97
  const kind = ref<"zone" | "motion" | "object">("zone");
100
98
  const zoneName = ref("");
101
- const image = ref("");
102
- const imageError = ref<unknown>(null);
103
99
  const loading = ref(false);
104
100
  const error = ref<unknown>(null);
105
101
  const saving = ref(false);
@@ -134,26 +130,19 @@ function readZones(res: any) {
134
130
  ({ zones: zones.value, masks: masks.value } = readZonesReply(res));
135
131
  }
136
132
 
137
- function freeImage() {
138
- if (image.value) URL.revokeObjectURL(image.value);
139
- image.value = "";
140
- }
141
-
142
133
  async function load() {
143
134
  zones.value = [];
144
135
  masks.value = [];
145
136
  draft.value = [];
146
137
  saveMsg.value = "";
147
138
  error.value = null;
148
- imageError.value = null;
149
- freeImage();
150
139
  if (!engine.value || !camera.value) return;
151
140
  loading.value = true;
152
- const [z, img] = await Promise.allSettled([getZones(engine.value, camera.value), latestImage(engine.value, camera.value)]);
153
- if (z.status === "fulfilled") readZones(z.value);
154
- else error.value = z.reason;
155
- if (img.status === "fulfilled") image.value = img.value;
156
- else imageError.value = img.reason;
141
+ try {
142
+ readZones(await getZones(engine.value, camera.value));
143
+ } catch (e) {
144
+ error.value = e;
145
+ }
157
146
  loading.value = false;
158
147
  }
159
148
 
@@ -176,14 +165,11 @@ async function save() {
176
165
  }
177
166
 
178
167
  watch([engine, camera], load);
179
- onBeforeUnmount(freeImage);
180
168
  </script>
181
169
 
182
170
  <style scoped>
183
171
  .cctv-zn__stage { position: relative; background: #111; border-radius: 10px; overflow: hidden; min-height: 180px; user-select: none; }
184
172
  .cctv-zn__stage--draw { cursor: crosshair; }
185
- .cctv-zn__img { width: 100%; display: block; }
186
- .cctv-zn__none { color: #ddd; padding: 60px 16px; text-align: center; font-size: 13px; aspect-ratio: 16 / 9; }
187
173
  .cctv-zn__svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
188
174
  .cctv-zn__dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: #fff; border: 2px solid #1e88e5; pointer-events: none; }
189
175
  </style>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "4.161.3",
5
+ "version": "4.161.5",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",