@7365admin1/layer-common 4.160.0 → 4.161.1

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.
@@ -0,0 +1,135 @@
1
+ <!--
2
+ Smart detection: teach the engine to recognise what an area looks like (clean or rubbish, door open or shut...).
3
+ Lists the detections for an engine with where each one is up to; open one to sort its photos and teach it.
4
+ Needs the "Manage zones and smart detection" permission (cctv-engine:manage-zones).
5
+ -->
6
+ <template>
7
+ <div>
8
+ <CctvEngineCameraPicker v-model:engine="engine" :site="site" no-camera />
9
+
10
+ <template v-if="engine">
11
+ <template v-if="selected">
12
+ <CctvEngineDetectionDetail
13
+ :key="engine + selected"
14
+ :engine="engine"
15
+ :name="selected"
16
+ :teaching="teachingNames.has(selected)"
17
+ @back="selected = ''"
18
+ @changed="load(true)"
19
+ @taught="startTeaching(selected)"
20
+ @deleted="onDeleted"
21
+ />
22
+ </template>
23
+ <template v-else>
24
+ <div class="d-flex align-center flex-wrap ga-2 mt-3">
25
+ <p class="hero-muted flex-grow-1 mb-0">
26
+ Teach the engine to tell what an area looks like, for example a bin area that is clean or full of rubbish.
27
+ It can raise an alert for the results you choose.
28
+ </p>
29
+ <v-btn color="primary" prepend-icon="mdi-plus" @click="creating = true">New smart detection</v-btn>
30
+ </div>
31
+
32
+ <v-progress-linear v-if="loading" indeterminate class="mt-3" />
33
+ <CctvEngineNotice v-else-if="error" class="mt-3" :error="error" retry @retry="load()" />
34
+ <CctvEngineNotice
35
+ v-else-if="!items.length"
36
+ class="mt-3"
37
+ title="No smart detections yet"
38
+ body="Press New smart detection, draw a box over an area on a camera, and name the results you want to tell apart."
39
+ />
40
+ <v-row v-else class="mt-1">
41
+ <v-col v-for="c in items" :key="c.name" cols="12" sm="6" md="4">
42
+ <v-card variant="outlined" class="h-100" @click="selected = c.name">
43
+ <v-card-title class="text-subtitle-1">{{ c.name }}</v-card-title>
44
+ <v-card-text>
45
+ <v-chip size="small" label :color="statusOf(c).color" class="mb-2">{{ statusOf(c).title }}</v-chip>
46
+ <div class="hero-muted">Camera: {{ c.camera }}</div>
47
+ <div class="hero-muted">Results: {{ (c.states ?? []).join(", ") }}</div>
48
+ <div class="hero-muted">Alerts on: {{ (c.alertStates ?? []).join(", ") || "none" }}</div>
49
+ <div v-if="c.engineUnreachable" class="text-warning mt-1">The engine could not be reached, so this may be out of date.</div>
50
+ </v-card-text>
51
+ </v-card>
52
+ </v-col>
53
+ </v-row>
54
+ </template>
55
+
56
+ <CctvEngineDetectionCreate v-model="creating" :engine="engine" @created="onCreated" />
57
+ </template>
58
+
59
+ <v-snackbar v-model="snack.open" timeout="6000" multi-line>{{ snack.text }}</v-snackbar>
60
+ </div>
61
+ </template>
62
+
63
+ <script setup lang="ts">
64
+ import { onBeforeUnmount, reactive, ref, watch } from "vue";
65
+ import { classifierStatus, type TClassifier } from "../../utils/cctv-engine";
66
+
67
+ defineProps<{ site: string; access?: unknown }>();
68
+ const { listClassifiers } = useCctvEngine();
69
+
70
+ const engine = ref("");
71
+ const items = ref<TClassifier[]>([]);
72
+ const loading = ref(false);
73
+ const error = ref<unknown>(null);
74
+ const selected = ref("");
75
+ const creating = ref(false);
76
+ const snack = reactive({ open: false, text: "" });
77
+
78
+ // Teach runs on the engine in the background. Remember which were started here and check every 10 s until each
79
+ // one's last-trained time moves on (ponytail: only trainings started on this screen are tracked).
80
+ const teachingNames = ref<Set<string>>(new Set());
81
+ const taughtBefore = new Map<string, string | null>();
82
+ let timer: ReturnType<typeof setInterval> | undefined;
83
+
84
+ const statusOf = (c: TClassifier) => classifierStatus(c, { teaching: teachingNames.value.has(c.name) });
85
+
86
+ async function load(quiet = false) {
87
+ if (!quiet) loading.value = true;
88
+ error.value = null;
89
+ try {
90
+ const res: any = await listClassifiers(engine.value);
91
+ items.value = res?.items ?? [];
92
+ checkTeaching();
93
+ } catch (e) {
94
+ error.value = e;
95
+ if (!quiet) items.value = [];
96
+ } finally {
97
+ loading.value = false;
98
+ }
99
+ }
100
+
101
+ function startTeaching(name: string) {
102
+ taughtBefore.set(name, items.value.find((c) => c.name === name)?.training?.lastTrainedAt ?? null);
103
+ teachingNames.value = new Set(teachingNames.value).add(name);
104
+ clearInterval(timer);
105
+ timer = setInterval(() => load(true), 10000);
106
+ }
107
+ function checkTeaching() {
108
+ const still = new Set<string>();
109
+ for (const name of teachingNames.value) {
110
+ const c = items.value.find((x) => x.name === name);
111
+ if (c && (c.training?.lastTrainedAt ?? null) === taughtBefore.get(name)) still.add(name);
112
+ }
113
+ teachingNames.value = still;
114
+ if (!still.size) clearInterval(timer);
115
+ }
116
+
117
+ function onCreated(message: string) {
118
+ Object.assign(snack, { open: true, text: message });
119
+ load(true);
120
+ }
121
+ function onDeleted() {
122
+ Object.assign(snack, { open: true, text: "Smart detection deleted." });
123
+ selected.value = "";
124
+ load(true);
125
+ }
126
+
127
+ watch(engine, () => {
128
+ selected.value = "";
129
+ items.value = [];
130
+ teachingNames.value = new Set();
131
+ clearInterval(timer);
132
+ if (engine.value) load();
133
+ });
134
+ onBeforeUnmount(() => clearInterval(timer));
135
+ </script>
@@ -0,0 +1,108 @@
1
+ <!--
2
+ One event in a dialog: picture, clip (when there is one), and the facts. Used by Events and Smart search.
3
+ Pass the event row to open it; it emits `close` when dismissed. Smart detection results have a photo and no clip.
4
+ -->
5
+ <template>
6
+ <v-dialog :model-value="!!event" max-width="900" scrollable @update:model-value="(v: boolean) => !v && $emit('close')">
7
+ <v-card v-if="event">
8
+ <v-card-title class="d-flex align-center">
9
+ <span class="flex-grow-1">{{ title }}</span>
10
+ <v-btn icon="mdi-close" variant="text" aria-label="Close" @click="$emit('close')" />
11
+ </v-card-title>
12
+ <v-card-text>
13
+ <v-progress-linear v-if="mediaLoading" indeterminate />
14
+ <img v-if="snapshot" :src="snapshot" :alt="`Snapshot of ${title}`" class="cctv-ev__img" />
15
+ <CctvEngineNotice v-else-if="!mediaLoading && event.hasSnapshot === false" title="No picture saved" body="The engine did not keep a snapshot for this event." />
16
+ <CctvEngineNotice v-if="mediaError" :error="mediaError" />
17
+
18
+ <template v-if="!isClassification">
19
+ <video v-if="clip" :src="clip" controls autoplay class="cctv-ev__img mt-3" />
20
+ <v-btn v-else-if="event.hasClip" class="mt-3" prepend-icon="mdi-play" :loading="clipLoading" @click="loadClip">Play clip</v-btn>
21
+ <div v-else class="hero-muted mt-3">No video clip was saved for this event.</div>
22
+ </template>
23
+
24
+ <v-table density="compact" class="mt-4">
25
+ <tbody>
26
+ <tr><th>Camera</th><td>{{ event.camera }}</td></tr>
27
+ <tr><th>When</th><td>{{ when(event.startTime) }}<template v-if="event.endTime"> to {{ when(event.endTime) }}</template></td></tr>
28
+ <template v-if="isClassification">
29
+ <tr><th>Result</th><td>{{ event.label }}</td></tr>
30
+ <tr><th>Smart detection</th><td>{{ event.subLabel }}</td></tr>
31
+ </template>
32
+ <tr v-else><th>Object</th><td>{{ event.label }}<template v-if="event.subLabel"> ({{ event.subLabel }})</template></td></tr>
33
+ <tr v-if="event.faceName"><th>Face</th><td>{{ event.faceName }}</td></tr>
34
+ <tr v-if="event.plate"><th>Plate</th><td>{{ event.plate }}</td></tr>
35
+ <tr v-if="!isClassification"><th>Zones</th><td>{{ (event.zones ?? []).join(", ") || "None" }}<template v-if="(event.enteredZones ?? []).length"> (entered: {{ event.enteredZones.join(" then ") }})</template></td></tr>
36
+ <tr><th>Confidence</th><td>{{ scoreText(event.score) }}</td></tr>
37
+ <tr v-if="event.incident"><th>Incident</th><td>An incident report was created for this alert.</td></tr>
38
+ </tbody>
39
+ </v-table>
40
+ </v-card-text>
41
+ </v-card>
42
+ </v-dialog>
43
+ </template>
44
+
45
+ <script setup lang="ts">
46
+ import { computed, onBeforeUnmount, ref, watch } from "vue";
47
+ import { classificationTitle } from "../../utils/cctv-engine";
48
+
49
+ const props = defineProps<{ event: any | null }>();
50
+ defineEmits<{ (e: "close"): void }>();
51
+ const { eventSnapshot, eventClip } = useCctvEngine();
52
+
53
+ const snapshot = ref("");
54
+ const clip = ref("");
55
+ const mediaLoading = ref(false);
56
+ const clipLoading = ref(false);
57
+ const mediaError = ref<unknown>(null);
58
+
59
+ const isClassification = computed(() => props.event?.kind === "classification");
60
+ const title = computed(() => {
61
+ const e = props.event;
62
+ if (!e) return "";
63
+ if (e.kind === "classification") return classificationTitle(e);
64
+ return [e.label, e.faceName && `- ${e.faceName}`, e.plate && `- ${e.plate}`].filter(Boolean).join(" ") || "Event";
65
+ });
66
+ const when = (v?: string) => (v ? new Date(v).toLocaleString() : "");
67
+ const scoreText = (s?: number) => (typeof s === "number" ? `${Math.round(s <= 1 ? s * 100 : s)}%` : "Not given");
68
+
69
+ function freeMedia() {
70
+ if (snapshot.value) URL.revokeObjectURL(snapshot.value);
71
+ if (clip.value) URL.revokeObjectURL(clip.value);
72
+ snapshot.value = clip.value = "";
73
+ mediaError.value = null;
74
+ }
75
+ async function show(e: any | null) {
76
+ freeMedia();
77
+ if (!e || e.hasSnapshot === false) return;
78
+ mediaLoading.value = true;
79
+ try {
80
+ const url = await eventSnapshot(e._id);
81
+ // The person may have closed it or opened another one while this loaded.
82
+ if (props.event?._id === e._id) snapshot.value = url;
83
+ else URL.revokeObjectURL(url);
84
+ } catch (err) {
85
+ mediaError.value = err;
86
+ } finally {
87
+ mediaLoading.value = false;
88
+ }
89
+ }
90
+ async function loadClip() {
91
+ clipLoading.value = true;
92
+ mediaError.value = null;
93
+ try {
94
+ clip.value = await eventClip(props.event._id);
95
+ } catch (err) {
96
+ mediaError.value = err;
97
+ } finally {
98
+ clipLoading.value = false;
99
+ }
100
+ }
101
+
102
+ watch(() => props.event, show, { immediate: true });
103
+ onBeforeUnmount(freeMedia);
104
+ </script>
105
+
106
+ <style scoped>
107
+ .cctv-ev__img { width: 100%; max-height: 60vh; object-fit: contain; background: #000; border-radius: 8px; }
108
+ </style>
@@ -39,47 +39,17 @@
39
39
  <v-pagination v-if="pages > 1" v-model="page" :length="pages" :total-visible="smAndDown ? 3 : 7" class="mt-2" @update:model-value="load" />
40
40
  <div v-if="pageRange" class="hero-muted text-center">{{ pageRange }}</div>
41
41
 
42
- <v-dialog v-model="detailOpen" max-width="900" scrollable>
43
- <v-card v-if="current">
44
- <v-card-title class="d-flex align-center">
45
- <span class="flex-grow-1">{{ titleOf(current) }}</span>
46
- <v-btn icon="mdi-close" variant="text" aria-label="Close" @click="closeDetail" />
47
- </v-card-title>
48
- <v-card-text>
49
- <v-progress-linear v-if="mediaLoading" indeterminate />
50
- <img v-if="snapshot" :src="snapshot" :alt="`Snapshot of ${titleOf(current)}`" class="cctv-ev__img" />
51
- <CctvEngineNotice v-else-if="!mediaLoading && current.hasSnapshot === false" title="No picture saved" body="The engine did not keep a snapshot for this event." />
52
- <CctvEngineNotice v-if="mediaError" :error="mediaError" />
53
-
54
- <video v-if="clip" :src="clip" controls autoplay class="cctv-ev__img mt-3" />
55
- <v-btn v-else-if="current.hasClip" class="mt-3" prepend-icon="mdi-play" :loading="clipLoading" @click="loadClip">Play clip</v-btn>
56
- <div v-else class="hero-muted mt-3">No video clip was saved for this event.</div>
57
-
58
- <v-table density="compact" class="mt-4">
59
- <tbody>
60
- <tr><th>Camera</th><td>{{ current.camera }}</td></tr>
61
- <tr><th>When</th><td>{{ when(current.startTime) }}<template v-if="current.endTime"> to {{ when(current.endTime) }}</template></td></tr>
62
- <tr><th>Object</th><td>{{ current.label }}<template v-if="current.subLabel"> ({{ current.subLabel }})</template></td></tr>
63
- <tr v-if="current.faceName"><th>Face</th><td>{{ current.faceName }}</td></tr>
64
- <tr v-if="current.plate"><th>Plate</th><td>{{ current.plate }}</td></tr>
65
- <tr><th>Zones</th><td>{{ (current.zones ?? []).join(", ") || "None" }}<template v-if="(current.enteredZones ?? []).length"> (entered: {{ current.enteredZones.join(" then ") }})</template></td></tr>
66
- <tr><th>Confidence</th><td>{{ scoreText(current.score) }}</td></tr>
67
- <tr v-if="current.incident"><th>Incident</th><td>An incident report was created for this alert.</td></tr>
68
- </tbody>
69
- </v-table>
70
- </v-card-text>
71
- </v-card>
72
- </v-dialog>
42
+ <CctvEngineEventDetail :event="current" @close="current = null" />
73
43
  </div>
74
44
  </template>
75
45
 
76
46
  <script setup lang="ts">
77
- import { computed, onBeforeUnmount, reactive, ref } from "vue";
47
+ import { computed, reactive, ref } from "vue";
78
48
  import { useDisplay } from "vuetify";
79
- import { EVENT_KINDS, EVENT_SEVERITIES, type TEventFilters } from "../../utils/cctv-engine";
49
+ import { classificationTitle, EVENT_KINDS, EVENT_SEVERITIES, type TEventFilters } from "../../utils/cctv-engine";
80
50
 
81
51
  const props = defineProps<{ site: string; access?: unknown }>();
82
- const { listEvents, eventSnapshot, eventClip } = useCctvEngine();
52
+ const { listEvents } = useCctvEngine();
83
53
  const { smAndDown } = useDisplay();
84
54
 
85
55
  const f = reactive<TEventFilters>({});
@@ -117,59 +87,11 @@ function clear() {
117
87
 
118
88
  const kindTitle = (k: string) => EVENT_KINDS.find((x) => x.value === k)?.title ?? k;
119
89
  const when = (v?: string) => (v ? new Date(v).toLocaleString() : "");
120
- const scoreText = (s?: number) => (typeof s === "number" ? `${Math.round(s <= 1 ? s * 100 : s)}%` : "Not given");
121
- const titleOf = (e: any) => [e.label, e.faceName && `- ${e.faceName}`, e.plate && `- ${e.plate}`].filter(Boolean).join(" ") || "Event";
90
+ const titleOf = (e: any) => e.kind === "classification" ? classificationTitle(e) : [e.label, e.faceName && `- ${e.faceName}`, e.plate && `- ${e.plate}`].filter(Boolean).join(" ") || "Event";
122
91
  const subtitleOf = (e: any) => `${e.camera} - ${when(e.startTime)}${(e.zones ?? []).length ? ` - ${e.zones.join(", ")}` : ""}`;
123
92
 
124
- // ---- detail
125
- const detailOpen = ref(false);
126
93
  const current = ref<any>(null);
127
- const snapshot = ref("");
128
- const clip = ref("");
129
- const mediaLoading = ref(false);
130
- const clipLoading = ref(false);
131
- const mediaError = ref<unknown>(null);
132
-
133
- function freeMedia() {
134
- if (snapshot.value) URL.revokeObjectURL(snapshot.value);
135
- if (clip.value) URL.revokeObjectURL(clip.value);
136
- snapshot.value = clip.value = "";
137
- mediaError.value = null;
138
- }
139
- async function open(e: any) {
140
- freeMedia();
141
- current.value = e;
142
- detailOpen.value = true;
143
- if (e.hasSnapshot === false) return;
144
- mediaLoading.value = true;
145
- try {
146
- snapshot.value = await eventSnapshot(e._id);
147
- } catch (err) {
148
- mediaError.value = err;
149
- } finally {
150
- mediaLoading.value = false;
151
- }
152
- }
153
- async function loadClip() {
154
- clipLoading.value = true;
155
- mediaError.value = null;
156
- try {
157
- clip.value = await eventClip(current.value._id);
158
- } catch (err) {
159
- mediaError.value = err;
160
- } finally {
161
- clipLoading.value = false;
162
- }
163
- }
164
- function closeDetail() {
165
- detailOpen.value = false;
166
- freeMedia();
167
- }
168
- onBeforeUnmount(freeMedia);
94
+ const open = (e: any) => (current.value = e);
169
95
 
170
96
  load();
171
97
  </script>
172
-
173
- <style scoped>
174
- .cctv-ev__img { width: 100%; max-height: 60vh; object-fit: contain; background: #000; border-radius: 8px; }
175
- </style>
@@ -87,16 +87,19 @@ async function tryWebrtc(token: number) {
87
87
  conn.addTransceiver("video", { direction: "recvonly" });
88
88
  conn.addTransceiver("audio", { direction: "recvonly" });
89
89
  const connected = new Promise<void>((resolve, reject) => {
90
+ // A track is announced as soon as the answer is read, before any picture can arrive (the engine
91
+ // may be unreachable for video). "Live" waits for the first decoded frame; otherwise stills.
90
92
  conn.ontrack = (ev) => {
91
93
  if (token !== run || !video.value) return;
92
94
  video.value.srcObject = ev.streams[0] ?? new MediaStream([ev.track]);
93
- resolve();
95
+ video.value.addEventListener("loadeddata", () => resolve(), { once: true });
94
96
  };
95
97
  conn.onconnectionstatechange = () => {
96
98
  if (token !== run) return;
97
- if (conn.connectionState === "failed") reject(new Error("webrtc-failed"));
98
- if (conn.connectionState === "disconnected" || conn.connectionState === "closed") {
99
+ const state = conn.connectionState;
100
+ if (state === "failed" || state === "disconnected" || state === "closed") {
99
101
  if (mode.value === "live") fallbackToStill(token);
102
+ else reject(new Error("webrtc-failed"));
100
103
  }
101
104
  };
102
105
  setTimeout(() => reject(new Error("webrtc-timeout")), 10000);
@@ -0,0 +1,177 @@
1
+ <!--
2
+ Smart search: describe what you are looking for in words ("person with a red umbrella") and the site's own
3
+ engine finds the best matching pictures from past events. Free; nothing leaves the site's engine.
4
+ Opens a result in the same detail window the Events screen uses.
5
+ -->
6
+ <template>
7
+ <div>
8
+ <CctvEngineCameraPicker v-model:engine="engine" :site="site" no-camera />
9
+
10
+ <template v-if="engine">
11
+ <v-form class="mt-3" @submit.prevent="run">
12
+ <v-row dense>
13
+ <v-col cols="12" md="7">
14
+ <v-text-field
15
+ v-model="text"
16
+ label="Describe what you are looking for"
17
+ placeholder="e.g. person with a red umbrella, white van, bicycle"
18
+ density="comfortable"
19
+ prepend-inner-icon="mdi-text-search"
20
+ clearable
21
+ hide-details
22
+ autofocus
23
+ />
24
+ </v-col>
25
+ <v-col cols="8" md="3">
26
+ <v-select
27
+ v-model="camera"
28
+ :items="cameras"
29
+ item-title="name"
30
+ item-value="name"
31
+ label="Camera (optional)"
32
+ density="comfortable"
33
+ clearable
34
+ hide-details
35
+ :no-data-text="'No cameras found for this engine'"
36
+ />
37
+ </v-col>
38
+ <v-col cols="4" md="2" class="d-flex align-center">
39
+ <v-btn type="submit" color="primary" block :loading="loading" :disabled="loading">Search</v-btn>
40
+ </v-col>
41
+ </v-row>
42
+ </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>
44
+
45
+ <CctvEngineNotice v-if="problem" class="mt-3" tone="info" title="Check what you typed" :body="problem" />
46
+ <v-progress-linear v-if="loading" indeterminate class="mt-3" />
47
+ <CctvEngineNotice
48
+ v-else-if="searchOff"
49
+ class="mt-3"
50
+ tone="info"
51
+ title="Smart search is not switched on yet"
52
+ :body="searchOff"
53
+ />
54
+ <CctvEngineNotice v-else-if="error" class="mt-3" :error="error" retry @retry="run" />
55
+ <CctvEngineNotice
56
+ v-else-if="searched && !items.length"
57
+ class="mt-3"
58
+ title="Nothing matched"
59
+ body="Try fewer or simpler words (for example 'van' instead of 'white delivery van'), pick a different camera, or check the engine is Online in Engines & health."
60
+ />
61
+ <CctvEngineNotice
62
+ v-else-if="!searched"
63
+ class="mt-3"
64
+ title="Search the pictures your cameras have saved"
65
+ body="Type what you want to find, for example 'person with a red umbrella', and press Search. The best matches come first."
66
+ />
67
+
68
+ <v-row v-if="items.length" class="mt-1">
69
+ <v-col v-for="e in items" :key="e._id" cols="6" sm="4" md="3">
70
+ <v-card variant="outlined" class="cctv-sr__card" @click="current = e">
71
+ <div class="cctv-sr__thumb">
72
+ <img v-if="thumbs[e._id]" :src="thumbs[e._id]" :alt="`Picture of ${e.label}`" />
73
+ <v-icon v-else icon="mdi-image-off-outline" size="32" />
74
+ </div>
75
+ <div class="pa-2">
76
+ <div class="font-weight-medium text-truncate">{{ classificationTitle(e) || "Event" }}</div>
77
+ <div class="hero-muted text-truncate">{{ e.camera }}</div>
78
+ <div class="hero-muted">{{ when(e.startTime) }}</div>
79
+ </div>
80
+ </v-card>
81
+ </v-col>
82
+ </v-row>
83
+ </template>
84
+
85
+ <CctvEngineEventDetail :event="current" @close="current = null" />
86
+ </div>
87
+ </template>
88
+
89
+ <script setup lang="ts">
90
+ import { onBeforeUnmount, ref, watch } from "vue";
91
+ import { buildSearchQuery, classificationTitle } from "../../utils/cctv-engine";
92
+
93
+ defineProps<{ site: string; access?: unknown }>();
94
+ const { listCameras, searchEvents, eventSnapshot } = useCctvEngine();
95
+
96
+ const engine = ref("");
97
+ const camera = ref<string | null>(null);
98
+ const cameras = ref<any[]>([]);
99
+ const text = ref("");
100
+ const items = ref<any[]>([]);
101
+ const thumbs = ref<Record<string, string>>({});
102
+ const loading = ref(false);
103
+ const searched = ref(false);
104
+ const problem = ref("");
105
+ const searchOff = ref("");
106
+ const error = ref<unknown>(null);
107
+ const current = ref<any>(null);
108
+
109
+ const when = (v?: string) => (v ? new Date(v).toLocaleString() : "");
110
+
111
+ function freeThumbs() {
112
+ Object.values(thumbs.value).forEach((u) => URL.revokeObjectURL(u));
113
+ thumbs.value = {};
114
+ }
115
+
116
+ async function run() {
117
+ problem.value = searchOff.value = "";
118
+ error.value = null;
119
+ const q = buildSearchQuery(text.value, camera.value);
120
+ if (!q.ok) {
121
+ problem.value = q.problem;
122
+ return;
123
+ }
124
+ loading.value = true;
125
+ freeThumbs();
126
+ try {
127
+ const res: any = await searchEvents(engine.value, q.query);
128
+ items.value = res?.items ?? [];
129
+ searched.value = true;
130
+ loadThumbs(items.value);
131
+ } catch (e: any) {
132
+ items.value = [];
133
+ // "Not switched on" is an answer, not a failure: show the server's own words as an info notice.
134
+ if (e?.data?.code === "SEARCH_OFF") searchOff.value = String(e.data.message || "Smart search is not switched on in this camera engine yet. Ask your Seven365 contact to switch it on.");
135
+ else error.value = e;
136
+ } finally {
137
+ loading.value = false;
138
+ }
139
+ }
140
+
141
+ // Pictures need the signed-in session, so each is fetched as a blob; a failed one just shows a placeholder.
142
+ async function loadThumbs(rows: any[]) {
143
+ const shown = items.value;
144
+ await Promise.all(
145
+ rows.filter((e) => e.hasSnapshot !== false).map(async (e) => {
146
+ try {
147
+ const url = await eventSnapshot(e._id);
148
+ if (items.value === shown) thumbs.value = { ...thumbs.value, [e._id]: url };
149
+ else URL.revokeObjectURL(url);
150
+ } catch {
151
+ /* placeholder stays */
152
+ }
153
+ }),
154
+ );
155
+ }
156
+
157
+ watch(engine, async (id) => {
158
+ camera.value = null;
159
+ cameras.value = [];
160
+ items.value = [];
161
+ searched.value = false;
162
+ freeThumbs();
163
+ if (!id) return;
164
+ try {
165
+ cameras.value = ((await listCameras(id)) as any)?.items ?? [];
166
+ } catch {
167
+ /* the camera filter is optional; search still works */
168
+ }
169
+ });
170
+ onBeforeUnmount(freeThumbs);
171
+ </script>
172
+
173
+ <style scoped>
174
+ .cctv-sr__card { cursor: pointer; height: 100%; }
175
+ .cctv-sr__thumb { aspect-ratio: 16 / 9; background: #111; display: flex; align-items: center; justify-content: center; color: #aaa; overflow: hidden; }
176
+ .cctv-sr__thumb img { width: 100%; height: 100%; object-fit: cover; }
177
+ </style>
@@ -8,7 +8,7 @@
8
8
  <div class="cctv-shell">
9
9
  <h2 class="hero-title">CCTV Engine</h2>
10
10
  <p class="hero-muted mb-3">
11
- Cameras analysed by the iSecure365 engine at the site: live view, events, playback, zones, plates and alerts.
11
+ Cameras analysed by the iSecure365 engine at the site: live view, events, smart search, playback, zones, smart detection, plates and alerts.
12
12
  This sits next to the CCTV wall and does not change it.
13
13
  </p>
14
14
 
@@ -77,6 +77,8 @@ const VIEWS: Record<TCctvSection, any> = {
77
77
  faces: resolveComponent("CctvEngineFaces"),
78
78
  alerts: resolveComponent("CctvEngineAlerts"),
79
79
  engines: resolveComponent("CctvEngineEngines"),
80
+ search: resolveComponent("CctvEngineSearch"),
81
+ detections: resolveComponent("CctvEngineDetections"),
80
82
  };
81
83
  const view = computed(() => VIEWS[current.value]);
82
84
 
@@ -143,7 +143,7 @@ const {
143
143
  updateFeedback,
144
144
  updateFeedbackServiceProvider,
145
145
  updateStatusComplete,
146
- deleteFeedback: _deleteFeedback,
146
+ // deleteFeedback: _deleteFeedback, (retired: DELETE /api/feedbacks/:id is turned off)
147
147
  } = useFeedback();
148
148
 
149
149
  const { getServiceProviderNames } = useServiceProvider();
@@ -417,7 +417,9 @@ async function deleteFeedback() {
417
417
  try {
418
418
  deleteLoading.value = true;
419
419
 
420
- const response = await _deleteFeedback(feedback.value._id);
420
+ // RETIRED 2026-10-29: the old /api/feedbacks and /api/work-orders routes are turned off in API-core; use /api/feedbacks2 and /api/work-orders2.
421
+ // const response = await _deleteFeedback(feedback.value._id);
422
+ const response: Record<string, any> = await Promise.reject(new Error("Deleting a feedback is no longer available here."));
421
423
  const message = response?.message || "Feedback deleted successfully";
422
424
  showMessage(message, "success");
423
425
 
@@ -680,7 +680,7 @@ const searchText = ref("");
680
680
 
681
681
  const {
682
682
  getFeedbacks: _getFeedbacks,
683
- deleteFeedback,
683
+ // deleteFeedback, (retired: DELETE /api/feedbacks/:id is turned off)
684
684
  createFeedback,
685
685
  getFeedbackById,
686
686
  updateFeedback,
@@ -805,7 +805,9 @@ async function submitDelete() {
805
805
  if (!feedbackToDelete.value) return;
806
806
  submitting.value = true;
807
807
  try {
808
- const response = await deleteFeedback(feedbackToDelete.value._id);
808
+ // RETIRED 2026-10-29: the old /api/feedbacks and /api/work-orders routes are turned off in API-core; use /api/feedbacks2 and /api/work-orders2.
809
+ // const response = await deleteFeedback(feedbackToDelete.value._id);
810
+ const response: Record<string, any> = await Promise.reject(new Error("Deleting a feedback is no longer available here."));
809
811
  showMessage(response.message, "success");
810
812
  await refreshFeedbacks();
811
813
  } catch (error) {
@@ -48,7 +48,7 @@ const {
48
48
  workOrder,
49
49
  getWorkOrderById,
50
50
  getWorkOrders: _getWorkOrders,
51
- updateWorkOrder,
51
+ // updateWorkOrder, (retired: PUT /api/work-orders/:id is turned off)
52
52
  createWorkOrder,
53
53
  } = useWorkOrder();
54
54
 
@@ -226,7 +226,9 @@ async function submitWorkOrder() {
226
226
  let res: Record<string, any> = {};
227
227
 
228
228
  if (isEditMode.value) {
229
- res = await updateWorkOrder(workOrder.value._id as string, payload);
229
+ // RETIRED 2026-10-29: the old /api/feedbacks and /api/work-orders routes are turned off in API-core; use /api/feedbacks2 and /api/work-orders2.
230
+ // res = await updateWorkOrder(workOrder.value._id as string, payload);
231
+ res = await Promise.reject(new Error("Editing a work order is no longer available here."));
230
232
  } else {
231
233
  res = await createWorkOrder(payload);
232
234
  }