@7365admin1/layer-common 4.97.1-staging.641 → 4.97.1-staging.643
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.
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
<v-card variant="outlined" :class="{ 'cctv-dd__picked': picked.has(p.file) }">
|
|
58
58
|
<div class="cctv-dd__thumb" @click="togglePick(p.file)">
|
|
59
59
|
<img v-if="thumbs[key(p.file)]" :src="thumbs[key(p.file)]" :alt="`Waiting photo from ${when(p.at)}`" />
|
|
60
|
-
<v-icon v-else icon="mdi-image-
|
|
60
|
+
<v-icon v-else-if="thumbFailed.has(key(p.file))" icon="mdi-image-broken-variant" size="28" />
|
|
61
|
+
<v-progress-circular v-else indeterminate size="24" width="2" aria-label="Loading photo" />
|
|
61
62
|
<v-checkbox-btn :model-value="picked.has(p.file)" class="cctv-dd__check" density="compact" aria-label="Select photo" @click.stop @update:model-value="togglePick(p.file)" />
|
|
62
63
|
</div>
|
|
63
64
|
<div class="pa-2">
|
|
@@ -84,7 +85,8 @@
|
|
|
84
85
|
<v-col v-for="f in data.sorted[s]" :key="f" cols="4" sm="3" md="2">
|
|
85
86
|
<div class="cctv-dd__thumb cctv-dd__thumb--sm">
|
|
86
87
|
<img v-if="thumbs[key(f, s)]" :src="thumbs[key(f, s)]" :alt="`Photo sorted as ${s}`" />
|
|
87
|
-
<v-icon v-else icon="mdi-image-
|
|
88
|
+
<v-icon v-else-if="thumbFailed.has(key(f, s))" icon="mdi-image-broken-variant" size="24" />
|
|
89
|
+
<v-progress-circular v-else indeterminate size="20" width="2" aria-label="Loading photo" />
|
|
88
90
|
<v-btn icon="mdi-close" size="x-small" variant="flat" class="cctv-dd__remove" :disabled="busy" :aria-label="`Remove this photo from ${s}`" @click="discard([f], s)" />
|
|
89
91
|
</div>
|
|
90
92
|
</v-col>
|
|
@@ -122,6 +124,8 @@ const loading = ref(false);
|
|
|
122
124
|
const error = ref<unknown>(null);
|
|
123
125
|
const busy = ref(false);
|
|
124
126
|
const thumbs = ref<Record<string, string>>({});
|
|
127
|
+
// Photos that could not be fetched (shown as a broken picture instead of a spinner).
|
|
128
|
+
const thumbFailed = ref<Set<string>>(new Set());
|
|
125
129
|
const picked = ref<Set<string>>(new Set());
|
|
126
130
|
const alerts = ref<string[]>([]);
|
|
127
131
|
const confirmDiscard = ref(false);
|
|
@@ -158,7 +162,7 @@ async function loadThumbs() {
|
|
|
158
162
|
const url = await classifierPhoto(props.engine, props.name, t.file, t.state);
|
|
159
163
|
thumbs.value = { ...thumbs.value, [t.k]: url };
|
|
160
164
|
} catch {
|
|
161
|
-
|
|
165
|
+
thumbFailed.value = new Set(thumbFailed.value).add(t.k);
|
|
162
166
|
}
|
|
163
167
|
}
|
|
164
168
|
};
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
<tr v-if="event.faceName"><th>Face</th><td>{{ event.faceName }}</td></tr>
|
|
34
34
|
<tr v-if="event.plate"><th>Plate</th><td>{{ event.plate }}</td></tr>
|
|
35
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
|
-
|
|
36
|
+
<!-- A smart detection result carries no score from the engine. -->
|
|
37
|
+
<tr v-if="!isClassification"><th>Confidence</th><td>{{ scoreText(event.score) }}</td></tr>
|
|
37
38
|
<tr v-if="event.incident"><th>Incident</th><td>An incident report was created for this alert.</td></tr>
|
|
38
39
|
</tbody>
|
|
39
40
|
</v-table>
|
|
@@ -9,6 +9,21 @@
|
|
|
9
9
|
|
|
10
10
|
<template v-if="engine">
|
|
11
11
|
<div class="d-flex flex-wrap align-center ga-3 my-3">
|
|
12
|
+
<v-select
|
|
13
|
+
v-if="groups.length"
|
|
14
|
+
:model-value="group"
|
|
15
|
+
:items="groups"
|
|
16
|
+
item-title="name"
|
|
17
|
+
item-value="name"
|
|
18
|
+
label="Camera group"
|
|
19
|
+
density="comfortable"
|
|
20
|
+
hide-details
|
|
21
|
+
clearable
|
|
22
|
+
class="cctv-live__group"
|
|
23
|
+
:max-width="smAndDown ? undefined : 260"
|
|
24
|
+
data-test="camera-group"
|
|
25
|
+
@update:model-value="pickGroup"
|
|
26
|
+
/>
|
|
12
27
|
<v-btn-toggle v-model="tiles" mandatory density="comfortable" divided color="primary" aria-label="Grid size">
|
|
13
28
|
<v-btn v-for="l in GRID_LAYOUTS" :key="l.key" :value="l.key" size="small">{{ l.key === 1 ? "Single" : l.key }}</v-btn>
|
|
14
29
|
</v-btn-toggle>
|
|
@@ -26,8 +41,16 @@
|
|
|
26
41
|
:hint="`Up to ${tiles}. Empty = the first ${tiles} on this engine.`"
|
|
27
42
|
class="cctv-live__picker"
|
|
28
43
|
:max-width="smAndDown ? undefined : 420"
|
|
44
|
+
@update:model-value="group = null"
|
|
29
45
|
/>
|
|
46
|
+
<template v-if="canManage && cameras.length">
|
|
47
|
+
<v-btn size="small" variant="tonal" prepend-icon="mdi-content-save-outline" :disabled="!picked.length" @click="openSave">Save as group</v-btn>
|
|
48
|
+
<v-btn v-if="group" size="small" variant="text" color="error" prepend-icon="mdi-delete-outline" @click="removeOpen = true">Delete group</v-btn>
|
|
49
|
+
</template>
|
|
30
50
|
</div>
|
|
51
|
+
<p v-if="canManage && cameras.length && !groups.length" class="hero-muted mt-n1 mb-2">
|
|
52
|
+
Tip: pick the cameras you watch together, then press Save as group. Everyone on this site can then show them with one choice.
|
|
53
|
+
</p>
|
|
31
54
|
|
|
32
55
|
<v-progress-linear v-if="loading" indeterminate />
|
|
33
56
|
<CctvEngineNotice v-else-if="error" :error="error" retry @retry="loadCameras" />
|
|
@@ -40,36 +63,92 @@
|
|
|
40
63
|
<CctvEngineLiveTile v-for="c in shown" :key="`${engine}/${c.name}`" :engine-id="engine" :camera="c.name" />
|
|
41
64
|
</div>
|
|
42
65
|
</template>
|
|
66
|
+
|
|
67
|
+
<v-dialog v-model="saveOpen" max-width="460">
|
|
68
|
+
<v-card>
|
|
69
|
+
<v-card-title>Save these cameras as a group</v-card-title>
|
|
70
|
+
<v-card-text>
|
|
71
|
+
<p class="hero-muted">{{ picked.length }} camera{{ picked.length === 1 ? "" : "s" }}: {{ picked.slice(0, MAX_GROUP_CAMERAS).join(", ") }}</p>
|
|
72
|
+
<v-text-field v-model="groupName" label="Group name (e.g. Gate cameras)" density="comfortable" counter="40" maxlength="40" autofocus />
|
|
73
|
+
<p class="hero-muted mb-0">A group with the same name is replaced.</p>
|
|
74
|
+
<CctvEngineNotice v-if="saveError" class="mt-2" :error="saveError" />
|
|
75
|
+
</v-card-text>
|
|
76
|
+
<v-card-actions>
|
|
77
|
+
<v-spacer />
|
|
78
|
+
<v-btn variant="text" @click="saveOpen = false">Cancel</v-btn>
|
|
79
|
+
<v-btn color="primary" :loading="saving" :disabled="!groupName.trim()" @click="saveGroup">Save group</v-btn>
|
|
80
|
+
</v-card-actions>
|
|
81
|
+
</v-card>
|
|
82
|
+
</v-dialog>
|
|
83
|
+
|
|
84
|
+
<v-dialog v-model="removeOpen" max-width="420">
|
|
85
|
+
<v-card>
|
|
86
|
+
<v-card-title>Delete the group "{{ group }}"?</v-card-title>
|
|
87
|
+
<v-card-text>
|
|
88
|
+
Only the saved group is removed. The cameras keep working.
|
|
89
|
+
<CctvEngineNotice v-if="saveError" class="mt-2" :error="saveError" />
|
|
90
|
+
</v-card-text>
|
|
91
|
+
<v-card-actions>
|
|
92
|
+
<v-spacer />
|
|
93
|
+
<v-btn variant="text" @click="removeOpen = false">Keep</v-btn>
|
|
94
|
+
<v-btn color="error" :loading="saving" @click="removeGroup">Delete</v-btn>
|
|
95
|
+
</v-card-actions>
|
|
96
|
+
</v-card>
|
|
97
|
+
</v-dialog>
|
|
43
98
|
</div>
|
|
44
99
|
</template>
|
|
45
100
|
|
|
46
101
|
<script setup lang="ts">
|
|
47
102
|
import { computed, ref, watch } from "vue";
|
|
48
103
|
import { useDisplay } from "vuetify";
|
|
49
|
-
import {
|
|
104
|
+
import {
|
|
105
|
+
CCTV_PERMISSIONS,
|
|
106
|
+
GRID_LAYOUTS,
|
|
107
|
+
MAX_GROUP_CAMERAS,
|
|
108
|
+
gridColumns,
|
|
109
|
+
groupCameras,
|
|
110
|
+
layoutFor,
|
|
111
|
+
pickGridCameras,
|
|
112
|
+
saveGroupIn,
|
|
113
|
+
type TCameraGroup,
|
|
114
|
+
} from "../../utils/cctv-engine";
|
|
50
115
|
|
|
51
|
-
defineProps<{ site: string; access?:
|
|
116
|
+
const props = defineProps<{ site: string; access?: { can: (p: any) => boolean } }>();
|
|
52
117
|
|
|
53
|
-
const { listCameras } = useCctvEngine();
|
|
118
|
+
const { listCameras, updateEngine } = useCctvEngine();
|
|
54
119
|
const { smAndDown } = useDisplay();
|
|
120
|
+
const canManage = computed(() => props.access?.can(CCTV_PERMISSIONS.manageEngine) ?? false);
|
|
55
121
|
|
|
56
122
|
const engine = ref("");
|
|
123
|
+
const engines = ref<any[]>([]);
|
|
57
124
|
const tiles = ref<number>(4);
|
|
58
125
|
const picked = ref<string[]>([]);
|
|
126
|
+
const group = ref<string | null>(null);
|
|
59
127
|
const cameras = ref<{ name: string }[]>([]);
|
|
60
128
|
const loading = ref(false);
|
|
61
129
|
const error = ref<unknown>(null);
|
|
62
130
|
|
|
131
|
+
const groups = computed<TCameraGroup[]>(() => engines.value.find((e) => e._id === engine.value)?.cameraGroups ?? []);
|
|
63
132
|
const shown = computed(() => pickGridCameras(cameras.value, picked.value.slice(0, tiles.value), tiles.value));
|
|
64
133
|
const columns = computed(() => gridColumns(tiles.value, smAndDown.value));
|
|
65
134
|
|
|
66
135
|
function onEngines(list: any[]) {
|
|
136
|
+
engines.value = list;
|
|
67
137
|
if (!engine.value && list[0]) engine.value = list[0]._id;
|
|
68
138
|
}
|
|
69
139
|
|
|
140
|
+
function pickGroup(name: string | null) {
|
|
141
|
+
group.value = name;
|
|
142
|
+
if (!name) return;
|
|
143
|
+
const names = groupCameras(groups.value.find((g) => g.name === name), cameras.value);
|
|
144
|
+
picked.value = names;
|
|
145
|
+
tiles.value = layoutFor(names.length);
|
|
146
|
+
}
|
|
147
|
+
|
|
70
148
|
async function loadCameras() {
|
|
71
149
|
cameras.value = [];
|
|
72
150
|
picked.value = [];
|
|
151
|
+
group.value = null;
|
|
73
152
|
error.value = null;
|
|
74
153
|
if (!engine.value) return;
|
|
75
154
|
loading.value = true;
|
|
@@ -83,10 +162,53 @@ async function loadCameras() {
|
|
|
83
162
|
}
|
|
84
163
|
}
|
|
85
164
|
|
|
165
|
+
// ---- save / delete groups (manage-engine)
|
|
166
|
+
const saveOpen = ref(false);
|
|
167
|
+
const removeOpen = ref(false);
|
|
168
|
+
const groupName = ref("");
|
|
169
|
+
const saving = ref(false);
|
|
170
|
+
const saveError = ref<unknown>(null);
|
|
171
|
+
|
|
172
|
+
function openSave() {
|
|
173
|
+
groupName.value = group.value ?? "";
|
|
174
|
+
saveError.value = null;
|
|
175
|
+
saveOpen.value = true;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async function store(next: TCameraGroup[]) {
|
|
179
|
+
saving.value = true;
|
|
180
|
+
saveError.value = null;
|
|
181
|
+
try {
|
|
182
|
+
const res: any = await updateEngine(engine.value, { cameraGroups: next });
|
|
183
|
+
const saved = res?.cameraGroups ?? next;
|
|
184
|
+
engines.value = engines.value.map((e) => (e._id === engine.value ? { ...e, cameraGroups: saved } : e));
|
|
185
|
+
return true;
|
|
186
|
+
} catch (e) {
|
|
187
|
+
saveError.value = e;
|
|
188
|
+
return false;
|
|
189
|
+
} finally {
|
|
190
|
+
saving.value = false;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async function saveGroup() {
|
|
195
|
+
const next = saveGroupIn(groups.value, groupName.value, picked.value);
|
|
196
|
+
if (!next || !(await store(next))) return;
|
|
197
|
+
saveOpen.value = false;
|
|
198
|
+
group.value = next.find((g) => g.name.toLowerCase() === groupName.value.trim().toLowerCase())?.name ?? null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async function removeGroup() {
|
|
202
|
+
if (!(await store(groups.value.filter((g) => g.name !== group.value)))) return;
|
|
203
|
+
removeOpen.value = false;
|
|
204
|
+
group.value = null;
|
|
205
|
+
}
|
|
206
|
+
|
|
86
207
|
watch(engine, loadCameras, { immediate: true });
|
|
87
208
|
</script>
|
|
88
209
|
|
|
89
210
|
<style scoped>
|
|
90
211
|
.cctv-live__grid { display: grid; gap: 8px; }
|
|
91
212
|
.cctv-live__picker { min-width: 220px; flex: 1; }
|
|
213
|
+
.cctv-live__group { min-width: 180px; }
|
|
92
214
|
</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.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.643",
|
|
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
|
@@ -234,6 +234,32 @@ export function pickGridCameras<T extends { name: string }>(all: readonly T[], p
|
|
|
234
234
|
return [...chosen, ...rest].slice(0, tiles);
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
+
// --------------------------------------------------------------------------- saved camera groups
|
|
238
|
+
|
|
239
|
+
export type TCameraGroup = { name: string; cameras: string[] };
|
|
240
|
+
export const MAX_GROUP_CAMERAS = 16;
|
|
241
|
+
|
|
242
|
+
/** The smallest grid that holds `count` cameras (16 at most). */
|
|
243
|
+
export function layoutFor(count: number): number {
|
|
244
|
+
return (GRID_LAYOUTS.find((l) => l.key >= count) ?? GRID_LAYOUTS[GRID_LAYOUTS.length - 1]).key;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** A group's cameras that the engine still has, in the group's order (a removed camera simply drops out). */
|
|
248
|
+
export function groupCameras(group: TCameraGroup | null | undefined, cameras: readonly { name: string }[]): string[] {
|
|
249
|
+
if (!group) return [];
|
|
250
|
+
const have = new Set(cameras.map((c) => c.name));
|
|
251
|
+
return group.cameras.filter((n) => have.has(n));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Add a group, or replace the one with the same name (any case). Returns a new list; null when the name or cameras are missing. */
|
|
255
|
+
export function saveGroupIn(groups: readonly TCameraGroup[], name: string, cameras: readonly string[]): TCameraGroup[] | null {
|
|
256
|
+
const n = name.trim();
|
|
257
|
+
if (!n || !cameras.length) return null;
|
|
258
|
+
const g = { name: n, cameras: cameras.slice(0, MAX_GROUP_CAMERAS) };
|
|
259
|
+
const i = groups.findIndex((x) => x.name.toLowerCase() === n.toLowerCase());
|
|
260
|
+
return i < 0 ? [...groups, g] : groups.map((x, j) => (j === i ? g : x));
|
|
261
|
+
}
|
|
262
|
+
|
|
237
263
|
/** Latest-picture fallback: refresh every 2 s. The tick is part of the address so the browser never reuses a stale frame. */
|
|
238
264
|
export const STILL_REFRESH_MS = 2000;
|
|
239
265
|
|