@7365admin1/layer-common 4.97.1-staging.629 → 4.97.1-staging.631
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.
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
hide-details="auto"
|
|
86
86
|
item-title="label"
|
|
87
87
|
item-value="value"
|
|
88
|
+
item-props="props"
|
|
88
89
|
:rules="[requiredRule]"
|
|
89
90
|
/>
|
|
90
91
|
</v-col>
|
|
@@ -147,8 +148,14 @@
|
|
|
147
148
|
<span class="screen-hint">Loading available count...</span>
|
|
148
149
|
</template>
|
|
149
150
|
<template v-else-if="availableCount !== null">
|
|
150
|
-
<span :class="
|
|
151
|
+
<span :class="notEnoughCards ? 'text-error' : 'screen-hint'">
|
|
151
152
|
Available: {{ availableCount }}
|
|
153
|
+
<template v-if="availableCount === 0">
|
|
154
|
+
- No spare cards available. Add access cards first.
|
|
155
|
+
</template>
|
|
156
|
+
<template v-else-if="notEnoughCards">
|
|
157
|
+
- {{ totalRequired }} needed for {{ form.units.length }} units
|
|
158
|
+
</template>
|
|
152
159
|
</span>
|
|
153
160
|
</template>
|
|
154
161
|
</div>
|
|
@@ -175,7 +182,7 @@
|
|
|
175
182
|
block
|
|
176
183
|
variant="flat"
|
|
177
184
|
class="text-none screen-btn-primary"
|
|
178
|
-
:disabled="!validForm || loading ||
|
|
185
|
+
:disabled="!validForm || loading || availableLoading || notEnoughCards"
|
|
179
186
|
:loading="loading"
|
|
180
187
|
@click="submit"
|
|
181
188
|
>
|
|
@@ -200,6 +207,7 @@ const {
|
|
|
200
207
|
getLiftAccessLevels: _getLiftAccessLevels,
|
|
201
208
|
assignAccessCard: _assignAccessCard,
|
|
202
209
|
getAvailableAccessCards: _getAvailableAccessCards,
|
|
210
|
+
getAllAccessCardsCounts: _getAllAccessCardsCounts,
|
|
203
211
|
getBlockLevelUnitList: _getBlockLevelUnitList,
|
|
204
212
|
} = useAccessManagement();
|
|
205
213
|
const { requiredRule } = useUtils();
|
|
@@ -226,10 +234,31 @@ const form = ref({
|
|
|
226
234
|
liftAccessLevel: null as string | null,
|
|
227
235
|
});
|
|
228
236
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
237
|
+
// Site-wide spare cards per type; null until known, so a failed read never
|
|
238
|
+
// disables a type.
|
|
239
|
+
const spareByType = ref<{ NFC: number | null; QRCODE: number | null }>({
|
|
240
|
+
NFC: null,
|
|
241
|
+
QRCODE: null,
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const typeItems = computed(() =>
|
|
245
|
+
[
|
|
246
|
+
{ label: "Physical Access Card", value: "NFC" as const },
|
|
247
|
+
{ label: "Non Physical Access Card", value: "QRCODE" as const },
|
|
248
|
+
].map((t) => ({
|
|
249
|
+
...t,
|
|
250
|
+
label: spareByType.value[t.value] === 0 ? `${t.label} (none spare)` : t.label,
|
|
251
|
+
props: { disabled: spareByType.value[t.value] === 0 },
|
|
252
|
+
}))
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
// The API needs `quantity` cards for EACH selected unit.
|
|
256
|
+
const totalRequired = computed(
|
|
257
|
+
() => (form.value.quantity || 0) * Math.max(form.value.units.length, 1)
|
|
258
|
+
);
|
|
259
|
+
const notEnoughCards = computed(
|
|
260
|
+
() => availableCount.value !== null && totalRequired.value > availableCount.value
|
|
261
|
+
);
|
|
233
262
|
|
|
234
263
|
const NO_SELECTION = { name: "No Selection", no: null };
|
|
235
264
|
const accessLevelItems = ref<{ name: string; no: string | null }[]>([]);
|
|
@@ -248,17 +277,21 @@ function minQuantityRule(v: number) {
|
|
|
248
277
|
}
|
|
249
278
|
|
|
250
279
|
function maxQuantityRule(v: number) {
|
|
251
|
-
|
|
252
|
-
|
|
280
|
+
const units = Math.max(form.value.units.length, 1);
|
|
281
|
+
if (availableCount.value !== null && v * units > availableCount.value) {
|
|
282
|
+
return units > 1
|
|
283
|
+
? `Quantity x ${units} units cannot exceed available (${availableCount.value})`
|
|
284
|
+
: `Quantity cannot exceed available (${availableCount.value})`;
|
|
253
285
|
}
|
|
254
286
|
return true;
|
|
255
287
|
}
|
|
256
288
|
|
|
289
|
+
// Always fetched - with no level picked it counts the cards with no level,
|
|
290
|
+
// which are exactly the ones the API will assign. Only the latest answer is
|
|
291
|
+
// kept, so a slow reply for an old selection cannot overwrite a newer one.
|
|
292
|
+
let availableRequest = 0;
|
|
257
293
|
async function fetchAvailableCount() {
|
|
258
|
-
|
|
259
|
-
availableCount.value = null;
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
294
|
+
const request = ++availableRequest;
|
|
262
295
|
availableLoading.value = true;
|
|
263
296
|
availableCount.value = null;
|
|
264
297
|
try {
|
|
@@ -269,6 +302,7 @@ async function fetchAvailableCount() {
|
|
|
269
302
|
accessLevel: form.value.accessLevel,
|
|
270
303
|
liftAccessLevel: form.value.liftAccessLevel,
|
|
271
304
|
});
|
|
305
|
+
if (request !== availableRequest) return;
|
|
272
306
|
const data: { counts: { count: number }[] }[] = res.data ?? [];
|
|
273
307
|
availableCount.value = data.reduce(
|
|
274
308
|
(total, item) =>
|
|
@@ -276,9 +310,28 @@ async function fetchAvailableCount() {
|
|
|
276
310
|
0
|
|
277
311
|
);
|
|
278
312
|
} catch {
|
|
279
|
-
availableCount.value = null;
|
|
313
|
+
if (request === availableRequest) availableCount.value = null;
|
|
280
314
|
} finally {
|
|
281
|
-
availableLoading.value = false;
|
|
315
|
+
if (request === availableRequest) availableLoading.value = false;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
async function fetchSpareByType() {
|
|
320
|
+
try {
|
|
321
|
+
const res = await _getAllAccessCardsCounts({
|
|
322
|
+
site: siteId.value,
|
|
323
|
+
userType: form.value.userType,
|
|
324
|
+
});
|
|
325
|
+
spareByType.value = {
|
|
326
|
+
NFC: res?.data?.available_physical ?? null,
|
|
327
|
+
QRCODE: res?.data?.available_non_physical ?? null,
|
|
328
|
+
};
|
|
329
|
+
// Start on a type that has spare cards when the default has none.
|
|
330
|
+
if (spareByType.value.NFC === 0 && (spareByType.value.QRCODE ?? 0) > 0) {
|
|
331
|
+
form.value.type = "QRCODE";
|
|
332
|
+
}
|
|
333
|
+
} catch {
|
|
334
|
+
// Leave both unknown; the matching count below still guards Assign.
|
|
282
335
|
}
|
|
283
336
|
}
|
|
284
337
|
|
|
@@ -293,6 +346,8 @@ onMounted(async () => {
|
|
|
293
346
|
buildingLoading.value = true;
|
|
294
347
|
levelsLoading.value = true;
|
|
295
348
|
|
|
349
|
+
fetchSpareByType();
|
|
350
|
+
|
|
296
351
|
const [blockLevelResult, acmResult] = await Promise.allSettled([
|
|
297
352
|
_getBlockLevelUnitList(siteId.value),
|
|
298
353
|
getEncryptedAcmUrl(siteId.value),
|
|
@@ -407,6 +462,8 @@ async function submit() {
|
|
|
407
462
|
error?.data?.message ||
|
|
408
463
|
"Failed to assign access card.";
|
|
409
464
|
emit("error", msg);
|
|
465
|
+
// Cards may have run out since the count was read - show the real number.
|
|
466
|
+
fetchAvailableCount();
|
|
410
467
|
} finally {
|
|
411
468
|
loading.value = false;
|
|
412
469
|
}
|
|
@@ -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.";
|
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.631",
|
|
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.",
|