@7365admin1/layer-common 4.163.7 → 4.165.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/Live.vue +146 -5
- package/components/CctvEngine/LiveTile.vue +6 -4
- package/package.json +1 -1
- package/utils/cctv-engine.ts +26 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.165.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d52ad00: CCTV Engine Live: "Combined" view - one live picture of the cameras with activity (the engine's birdseye stream). Live tiles take an optional title.
|
|
8
|
+
|
|
9
|
+
## 4.164.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 0305d43: CCTV Engine Live: saved camera groups - pick a group to show its cameras; users who manage engines can save the picked cameras as a group or delete one.
|
|
14
|
+
|
|
3
15
|
## 4.163.7
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -3748,11 +3760,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
|
|
|
3748
3760
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
3749
3761
|
own rule from two endpoints the console already calls, unprojected:
|
|
3750
3762
|
|
|
3751
|
-
|
|
3752
|
-
|
|
3763
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
3764
|
+
GET /api/roles/id/:role that membership's role document
|
|
3753
3765
|
|
|
3754
|
-
|
|
3755
|
-
|
|
3766
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
3767
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
3756
3768
|
|
|
3757
3769
|
`role.default` is the marker because it is the only property of a platform
|
|
3758
3770
|
staff role no API caller can set - `role.controller.ts` validates create and
|
|
@@ -9,10 +9,27 @@
|
|
|
9
9
|
|
|
10
10
|
<template v-if="engine">
|
|
11
11
|
<div class="d-flex flex-wrap align-center ga-3 my-3">
|
|
12
|
-
<v-
|
|
12
|
+
<v-select
|
|
13
|
+
v-if="groups.length && !combined"
|
|
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
|
+
/>
|
|
27
|
+
<v-btn-toggle v-model="view" 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>
|
|
29
|
+
<v-btn :value="COMBINED" size="small" prepend-icon="mdi-view-dashboard-outline" data-test="combined-view">Combined</v-btn>
|
|
14
30
|
</v-btn-toggle>
|
|
15
31
|
<v-select
|
|
32
|
+
v-if="!combined"
|
|
16
33
|
v-model="picked"
|
|
17
34
|
:items="cameras"
|
|
18
35
|
item-title="name"
|
|
@@ -26,8 +43,16 @@
|
|
|
26
43
|
:hint="`Up to ${tiles}. Empty = the first ${tiles} on this engine.`"
|
|
27
44
|
class="cctv-live__picker"
|
|
28
45
|
:max-width="smAndDown ? undefined : 420"
|
|
46
|
+
@update:model-value="group = null"
|
|
29
47
|
/>
|
|
48
|
+
<template v-if="canManage && cameras.length && !combined">
|
|
49
|
+
<v-btn size="small" variant="tonal" prepend-icon="mdi-content-save-outline" :disabled="!picked.length" @click="openSave">Save as group</v-btn>
|
|
50
|
+
<v-btn v-if="group" size="small" variant="text" color="error" prepend-icon="mdi-delete-outline" @click="removeOpen = true">Delete group</v-btn>
|
|
51
|
+
</template>
|
|
30
52
|
</div>
|
|
53
|
+
<p v-if="canManage && cameras.length && !groups.length && !combined" class="hero-muted mt-n1 mb-2">
|
|
54
|
+
Tip: pick the cameras you watch together, then press Save as group. Everyone on this site can then show them with one choice.
|
|
55
|
+
</p>
|
|
31
56
|
|
|
32
57
|
<v-progress-linear v-if="loading" indeterminate />
|
|
33
58
|
<CctvEngineNotice v-else-if="error" :error="error" retry @retry="loadCameras" />
|
|
@@ -36,40 +61,113 @@
|
|
|
36
61
|
title="This engine has no cameras yet"
|
|
37
62
|
body="Cameras are added to the engine itself. Once the engine reports them they appear here; if you just set it up, check it shows Online in Engines & health."
|
|
38
63
|
/>
|
|
64
|
+
<template v-else-if="combined">
|
|
65
|
+
<p class="hero-muted mt-n1 mb-2">
|
|
66
|
+
One picture with the cameras where people or vehicles are moving right now. It is empty while nothing is happening.
|
|
67
|
+
If it says the camera was not found, the combined view is not switched on for this engine.
|
|
68
|
+
</p>
|
|
69
|
+
<CctvEngineLiveTile :key="`${engine}/${COMBINED}`" :engine-id="engine" :camera="COMBINED" title="Combined view (cameras with activity)" big />
|
|
70
|
+
</template>
|
|
39
71
|
<div v-else class="cctv-live__grid" :style="{ gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` }">
|
|
40
72
|
<CctvEngineLiveTile v-for="c in shown" :key="`${engine}/${c.name}`" :engine-id="engine" :camera="c.name" />
|
|
41
73
|
</div>
|
|
42
74
|
</template>
|
|
75
|
+
|
|
76
|
+
<v-dialog v-model="saveOpen" max-width="460">
|
|
77
|
+
<v-card>
|
|
78
|
+
<v-card-title>Save these cameras as a group</v-card-title>
|
|
79
|
+
<v-card-text>
|
|
80
|
+
<p class="hero-muted">{{ picked.length }} camera{{ picked.length === 1 ? "" : "s" }}: {{ picked.slice(0, MAX_GROUP_CAMERAS).join(", ") }}</p>
|
|
81
|
+
<v-text-field v-model="groupName" label="Group name (e.g. Gate cameras)" density="comfortable" counter="40" maxlength="40" autofocus />
|
|
82
|
+
<p class="hero-muted mb-0">A group with the same name is replaced.</p>
|
|
83
|
+
<CctvEngineNotice v-if="saveError" class="mt-2" :error="saveError" />
|
|
84
|
+
</v-card-text>
|
|
85
|
+
<v-card-actions>
|
|
86
|
+
<v-spacer />
|
|
87
|
+
<v-btn variant="text" @click="saveOpen = false">Cancel</v-btn>
|
|
88
|
+
<v-btn color="primary" :loading="saving" :disabled="!groupName.trim()" @click="saveGroup">Save group</v-btn>
|
|
89
|
+
</v-card-actions>
|
|
90
|
+
</v-card>
|
|
91
|
+
</v-dialog>
|
|
92
|
+
|
|
93
|
+
<v-dialog v-model="removeOpen" max-width="420">
|
|
94
|
+
<v-card>
|
|
95
|
+
<v-card-title>Delete the group "{{ group }}"?</v-card-title>
|
|
96
|
+
<v-card-text>
|
|
97
|
+
Only the saved group is removed. The cameras keep working.
|
|
98
|
+
<CctvEngineNotice v-if="saveError" class="mt-2" :error="saveError" />
|
|
99
|
+
</v-card-text>
|
|
100
|
+
<v-card-actions>
|
|
101
|
+
<v-spacer />
|
|
102
|
+
<v-btn variant="text" @click="removeOpen = false">Keep</v-btn>
|
|
103
|
+
<v-btn color="error" :loading="saving" @click="removeGroup">Delete</v-btn>
|
|
104
|
+
</v-card-actions>
|
|
105
|
+
</v-card>
|
|
106
|
+
</v-dialog>
|
|
43
107
|
</div>
|
|
44
108
|
</template>
|
|
45
109
|
|
|
46
110
|
<script setup lang="ts">
|
|
47
111
|
import { computed, ref, watch } from "vue";
|
|
48
112
|
import { useDisplay } from "vuetify";
|
|
49
|
-
import {
|
|
113
|
+
import {
|
|
114
|
+
CCTV_PERMISSIONS,
|
|
115
|
+
GRID_LAYOUTS,
|
|
116
|
+
MAX_GROUP_CAMERAS,
|
|
117
|
+
gridColumns,
|
|
118
|
+
groupCameras,
|
|
119
|
+
layoutFor,
|
|
120
|
+
pickGridCameras,
|
|
121
|
+
saveGroupIn,
|
|
122
|
+
type TCameraGroup,
|
|
123
|
+
} from "../../utils/cctv-engine";
|
|
50
124
|
|
|
51
|
-
defineProps<{ site: string; access?:
|
|
125
|
+
const props = defineProps<{ site: string; access?: { can: (p: any) => boolean } }>();
|
|
52
126
|
|
|
53
|
-
const { listCameras } = useCctvEngine();
|
|
127
|
+
const { listCameras, updateEngine } = useCctvEngine();
|
|
54
128
|
const { smAndDown } = useDisplay();
|
|
129
|
+
const canManage = computed(() => props.access?.can(CCTV_PERMISSIONS.manageEngine) ?? false);
|
|
55
130
|
|
|
56
131
|
const engine = ref("");
|
|
57
|
-
const
|
|
132
|
+
const engines = ref<any[]>([]);
|
|
133
|
+
/** The engine's combined live view (its stream name). */
|
|
134
|
+
const COMBINED = "birdseye";
|
|
135
|
+
const view = ref<number | string>(4);
|
|
136
|
+
const combined = computed(() => view.value === COMBINED);
|
|
137
|
+
const lastTiles = ref(4);
|
|
138
|
+
// The grid size; the combined view keeps the last one for when the user goes back.
|
|
139
|
+
const tiles = computed<number>({
|
|
140
|
+
get: () => (typeof view.value === "number" ? view.value : lastTiles.value),
|
|
141
|
+
set: (n) => (view.value = n),
|
|
142
|
+
});
|
|
143
|
+
watch(view, (v) => typeof v === "number" && (lastTiles.value = v));
|
|
58
144
|
const picked = ref<string[]>([]);
|
|
145
|
+
const group = ref<string | null>(null);
|
|
59
146
|
const cameras = ref<{ name: string }[]>([]);
|
|
60
147
|
const loading = ref(false);
|
|
61
148
|
const error = ref<unknown>(null);
|
|
62
149
|
|
|
150
|
+
const groups = computed<TCameraGroup[]>(() => engines.value.find((e) => e._id === engine.value)?.cameraGroups ?? []);
|
|
63
151
|
const shown = computed(() => pickGridCameras(cameras.value, picked.value.slice(0, tiles.value), tiles.value));
|
|
64
152
|
const columns = computed(() => gridColumns(tiles.value, smAndDown.value));
|
|
65
153
|
|
|
66
154
|
function onEngines(list: any[]) {
|
|
155
|
+
engines.value = list;
|
|
67
156
|
if (!engine.value && list[0]) engine.value = list[0]._id;
|
|
68
157
|
}
|
|
69
158
|
|
|
159
|
+
function pickGroup(name: string | null) {
|
|
160
|
+
group.value = name;
|
|
161
|
+
if (!name) return;
|
|
162
|
+
const names = groupCameras(groups.value.find((g) => g.name === name), cameras.value);
|
|
163
|
+
picked.value = names;
|
|
164
|
+
tiles.value = layoutFor(names.length);
|
|
165
|
+
}
|
|
166
|
+
|
|
70
167
|
async function loadCameras() {
|
|
71
168
|
cameras.value = [];
|
|
72
169
|
picked.value = [];
|
|
170
|
+
group.value = null;
|
|
73
171
|
error.value = null;
|
|
74
172
|
if (!engine.value) return;
|
|
75
173
|
loading.value = true;
|
|
@@ -83,10 +181,53 @@ async function loadCameras() {
|
|
|
83
181
|
}
|
|
84
182
|
}
|
|
85
183
|
|
|
184
|
+
// ---- save / delete groups (manage-engine)
|
|
185
|
+
const saveOpen = ref(false);
|
|
186
|
+
const removeOpen = ref(false);
|
|
187
|
+
const groupName = ref("");
|
|
188
|
+
const saving = ref(false);
|
|
189
|
+
const saveError = ref<unknown>(null);
|
|
190
|
+
|
|
191
|
+
function openSave() {
|
|
192
|
+
groupName.value = group.value ?? "";
|
|
193
|
+
saveError.value = null;
|
|
194
|
+
saveOpen.value = true;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async function store(next: TCameraGroup[]) {
|
|
198
|
+
saving.value = true;
|
|
199
|
+
saveError.value = null;
|
|
200
|
+
try {
|
|
201
|
+
const res: any = await updateEngine(engine.value, { cameraGroups: next });
|
|
202
|
+
const saved = res?.cameraGroups ?? next;
|
|
203
|
+
engines.value = engines.value.map((e) => (e._id === engine.value ? { ...e, cameraGroups: saved } : e));
|
|
204
|
+
return true;
|
|
205
|
+
} catch (e) {
|
|
206
|
+
saveError.value = e;
|
|
207
|
+
return false;
|
|
208
|
+
} finally {
|
|
209
|
+
saving.value = false;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function saveGroup() {
|
|
214
|
+
const next = saveGroupIn(groups.value, groupName.value, picked.value);
|
|
215
|
+
if (!next || !(await store(next))) return;
|
|
216
|
+
saveOpen.value = false;
|
|
217
|
+
group.value = next.find((g) => g.name.toLowerCase() === groupName.value.trim().toLowerCase())?.name ?? null;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async function removeGroup() {
|
|
221
|
+
if (!(await store(groups.value.filter((g) => g.name !== group.value)))) return;
|
|
222
|
+
removeOpen.value = false;
|
|
223
|
+
group.value = null;
|
|
224
|
+
}
|
|
225
|
+
|
|
86
226
|
watch(engine, loadCameras, { immediate: true });
|
|
87
227
|
</script>
|
|
88
228
|
|
|
89
229
|
<style scoped>
|
|
90
230
|
.cctv-live__grid { display: grid; gap: 8px; }
|
|
91
231
|
.cctv-live__picker { min-width: 220px; flex: 1; }
|
|
232
|
+
.cctv-live__group { min-width: 180px; }
|
|
92
233
|
</style>
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
data-test="cctv-tile"
|
|
12
12
|
>
|
|
13
13
|
<video v-show="mode === 'live'" ref="video" autoplay muted playsinline class="cctv-tile__media" @loadedmetadata="fit($event)" @resize="fit($event)" />
|
|
14
|
-
<img v-if="mode === 'still' && still" :src="still" :alt="`Latest picture from ${
|
|
14
|
+
<img v-if="mode === 'still' && still" :src="still" :alt="`Latest picture from ${label}`" class="cctv-tile__media" @load="fit($event)" />
|
|
15
15
|
|
|
16
16
|
<div v-if="mode === 'connecting'" class="cctv-tile__msg" role="status">
|
|
17
|
-
<v-progress-circular indeterminate size="22" /> <span>Connecting to {{
|
|
17
|
+
<v-progress-circular indeterminate size="22" /> <span>Connecting to {{ label }}...</span>
|
|
18
18
|
</div>
|
|
19
19
|
<div v-else-if="mode === 'error'" class="cctv-tile__msg" role="alert">
|
|
20
20
|
<strong>{{ notice.title }}</strong>
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
25
|
<div class="cctv-tile__bar">
|
|
26
|
-
<span class="cctv-tile__name">{{
|
|
26
|
+
<span class="cctv-tile__name">{{ label }}</span>
|
|
27
27
|
<v-chip v-if="mode === 'live'" size="x-small" color="success" label>Live</v-chip>
|
|
28
28
|
<v-chip
|
|
29
29
|
v-else-if="mode === 'still'"
|
|
@@ -43,7 +43,9 @@ import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
|
43
43
|
import { cctvNotice, STILL_REFRESH_MS } from "../../utils/cctv-engine";
|
|
44
44
|
|
|
45
45
|
// natural: keep the camera's own shape (no 16:9 box) so drawings laid over the tile line up with the picture.
|
|
46
|
-
|
|
46
|
+
// title: shown instead of the camera name (e.g. the combined view, whose stream name is "birdseye").
|
|
47
|
+
const props = defineProps<{ engineId: string; camera: string; title?: string; big?: boolean; natural?: boolean }>();
|
|
48
|
+
const label = computed(() => props.title || props.camera);
|
|
47
49
|
|
|
48
50
|
const { webrtcAnswer, latestImage } = useCctvEngine();
|
|
49
51
|
|
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.165.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
|
@@ -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
|
|