@7365admin1/layer-common 4.161.4 → 4.162.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/CHANGELOG.md +16 -4
- package/components/CctvEngine/Engines.vue +4 -0
- package/components/CctvEngine/Events.vue +4 -0
- package/components/CctvEngine/Live.vue +4 -0
- package/components/CctvEngine/Playback.vue +30 -3
- package/components/CctvEngine/Search.vue +21 -3
- package/package.json +1 -1
- package/utils/cctv-engine.ts +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.162.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c198838: CCTV Engine smart search: From / To dates with quick choices (Today, Last 7 days, Last 30 days, Any time).
|
|
8
|
+
|
|
9
|
+
## 4.161.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 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.
|
|
14
|
+
|
|
3
15
|
## 4.161.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -3680,11 +3692,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
|
|
|
3680
3692
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
3681
3693
|
own rule from two endpoints the console already calls, unprojected:
|
|
3682
3694
|
|
|
3683
|
-
|
|
3684
|
-
|
|
3695
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
3696
|
+
GET /api/roles/id/:role that membership's role document
|
|
3685
3697
|
|
|
3686
|
-
|
|
3687
|
-
|
|
3698
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
3699
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
3688
3700
|
|
|
3689
3701
|
`role.default` is the marker because it is the only property of a platform
|
|
3690
3702
|
staff role no API caller can set - `role.controller.ts` validates create and
|
|
@@ -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">
|
|
@@ -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
|
|
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
|
-
|
|
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.";
|
|
@@ -38,9 +38,18 @@
|
|
|
38
38
|
<v-col cols="4" md="2" class="d-flex align-center">
|
|
39
39
|
<v-btn type="submit" color="primary" block :loading="loading" :disabled="loading">Search</v-btn>
|
|
40
40
|
</v-col>
|
|
41
|
+
<v-col cols="6" md="3">
|
|
42
|
+
<v-text-field v-model="fromDay" type="date" label="From (optional)" density="comfortable" hide-details clearable />
|
|
43
|
+
</v-col>
|
|
44
|
+
<v-col cols="6" md="3">
|
|
45
|
+
<v-text-field v-model="toDay" type="date" label="To (optional)" density="comfortable" hide-details clearable />
|
|
46
|
+
</v-col>
|
|
47
|
+
<v-col cols="12" md="6" class="d-flex flex-wrap align-center ga-2">
|
|
48
|
+
<v-chip v-for="c in QUICK" :key="c.key" size="small" variant="tonal" @click="pick(c.key)">{{ c.label }}</v-chip>
|
|
49
|
+
</v-col>
|
|
41
50
|
</v-row>
|
|
42
51
|
</v-form>
|
|
43
|
-
<div class="hero-muted mt-1">Free to use. The search runs on the engine at your site, so pictures stay there.</div>
|
|
52
|
+
<div class="hero-muted mt-1">Leave the dates empty to search everything saved. Free to use. The search runs on the engine at your site, so pictures stay there.</div>
|
|
44
53
|
|
|
45
54
|
<CctvEngineNotice v-if="problem" class="mt-3" tone="info" title="Check what you typed" :body="problem" />
|
|
46
55
|
<v-progress-linear v-if="loading" indeterminate class="mt-3" />
|
|
@@ -88,7 +97,7 @@
|
|
|
88
97
|
|
|
89
98
|
<script setup lang="ts">
|
|
90
99
|
import { onBeforeUnmount, ref, watch } from "vue";
|
|
91
|
-
import { buildSearchQuery, classificationTitle } from "../../utils/cctv-engine";
|
|
100
|
+
import { buildSearchQuery, classificationTitle, quickDays } from "../../utils/cctv-engine";
|
|
92
101
|
|
|
93
102
|
defineProps<{ site: string; access?: unknown }>();
|
|
94
103
|
const { listCameras, searchEvents, eventSnapshot } = useCctvEngine();
|
|
@@ -97,6 +106,15 @@ const engine = ref("");
|
|
|
97
106
|
const camera = ref<string | null>(null);
|
|
98
107
|
const cameras = ref<any[]>([]);
|
|
99
108
|
const text = ref("");
|
|
109
|
+
const fromDay = ref("");
|
|
110
|
+
const toDay = ref("");
|
|
111
|
+
const QUICK = [
|
|
112
|
+
{ key: "today", label: "Today" },
|
|
113
|
+
{ key: "7d", label: "Last 7 days" },
|
|
114
|
+
{ key: "30d", label: "Last 30 days" },
|
|
115
|
+
{ key: "any", label: "Any time" },
|
|
116
|
+
] as const;
|
|
117
|
+
const pick = (k: (typeof QUICK)[number]["key"]) => ([fromDay.value, toDay.value] = quickDays(k));
|
|
100
118
|
const items = ref<any[]>([]);
|
|
101
119
|
const thumbs = ref<Record<string, string>>({});
|
|
102
120
|
const loading = ref(false);
|
|
@@ -116,7 +134,7 @@ function freeThumbs() {
|
|
|
116
134
|
async function run() {
|
|
117
135
|
problem.value = searchOff.value = "";
|
|
118
136
|
error.value = null;
|
|
119
|
-
const q = buildSearchQuery(text.value, camera.value);
|
|
137
|
+
const q = buildSearchQuery(text.value, camera.value, 24, { from: fromDay.value, to: toDay.value });
|
|
120
138
|
if (!q.ok) {
|
|
121
139
|
problem.value = q.problem;
|
|
122
140
|
return;
|
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.
|
|
5
|
+
"version": "4.162.0",
|
|
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.",
|
package/utils/cctv-engine.ts
CHANGED
|
@@ -344,15 +344,31 @@ export function buildSearchQuery(
|
|
|
344
344
|
text: string,
|
|
345
345
|
camera?: string | null,
|
|
346
346
|
limit = 24,
|
|
347
|
+
days: { from?: string | null; to?: string | null } = {},
|
|
347
348
|
): { ok: true; query: Record<string, string | number> } | { ok: false; problem: string } {
|
|
348
349
|
const q = (text ?? "").trim().replace(/\s+/g, " ");
|
|
349
350
|
if (q.length < SEARCH_MIN) return { ok: false, problem: `Type at least ${SEARCH_MIN} letters describing what you are looking for.` };
|
|
350
351
|
if (q.length > SEARCH_MAX) return { ok: false, problem: `Keep it under ${SEARCH_MAX} characters.` };
|
|
351
352
|
const query: Record<string, string | number> = { q, limit: Math.min(50, Math.max(1, Math.floor(limit) || 24)) };
|
|
352
353
|
if (camera) query.camera = camera;
|
|
354
|
+
// Whole days in the viewer's time: From = start of that day, To = end of that day.
|
|
355
|
+
const from = days.from ? new Date(`${days.from}T00:00:00`) : null;
|
|
356
|
+
const to = days.to ? new Date(`${days.to}T23:59:59`) : null;
|
|
357
|
+
if ((from && isNaN(+from)) || (to && isNaN(+to))) return { ok: false, problem: "Pick the dates from the calendar." };
|
|
358
|
+
if (from && to && to < from) return { ok: false, problem: "The 'To' date must be on or after the 'From' date." };
|
|
359
|
+
if (from) query.from = from.toISOString();
|
|
360
|
+
if (to) query.to = to.toISOString();
|
|
353
361
|
return { ok: true, query };
|
|
354
362
|
}
|
|
355
363
|
|
|
364
|
+
/** Quick date choices for searches: [from, to] as YYYY-MM-DD in the viewer's time ("" = no limit). */
|
|
365
|
+
export function quickDays(choice: "today" | "7d" | "30d" | "any", now = new Date()): [string, string] {
|
|
366
|
+
if (choice === "any") return ["", ""];
|
|
367
|
+
const day = (d: Date) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
368
|
+
const back = { today: 0, "7d": 6, "30d": 29 }[choice];
|
|
369
|
+
return [day(new Date(now.getFullYear(), now.getMonth(), now.getDate() - back)), day(now)];
|
|
370
|
+
}
|
|
371
|
+
|
|
356
372
|
/** Event heading: smart detections read "rubbish (bin_area)", everything else is the object name. */
|
|
357
373
|
export function classificationTitle(e: { kind?: string; label?: string; subLabel?: string }) {
|
|
358
374
|
return e.kind === "classification" && e.subLabel ? `${e.label} (${e.subLabel})` : String(e.label ?? "");
|