@7365admin1/layer-common 4.97.1-staging.631 → 4.97.1-staging.633
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.
|
@@ -38,6 +38,11 @@ const props = defineProps({
|
|
|
38
38
|
},
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
+
// Only sent after a successful read, so a failed one never looks like "0 spare".
|
|
42
|
+
const emit = defineEmits<{
|
|
43
|
+
(e: "update", counts: { physical: number; nonPhysical: number }): void;
|
|
44
|
+
}>();
|
|
45
|
+
|
|
41
46
|
const { getAllAccessCardsCounts } = useAccessManagement();
|
|
42
47
|
|
|
43
48
|
const availablePhysical = ref(0);
|
|
@@ -50,6 +55,10 @@ async function refresh() {
|
|
|
50
55
|
const res = await getAllAccessCardsCounts({ site: props.siteId, userType: "Visitor/Resident" });
|
|
51
56
|
availablePhysical.value = res?.data?.available_physical ?? 0;
|
|
52
57
|
availableNonPhysical.value = res?.data?.available_non_physical ?? 0;
|
|
58
|
+
emit("update", {
|
|
59
|
+
physical: availablePhysical.value,
|
|
60
|
+
nonPhysical: availableNonPhysical.value,
|
|
61
|
+
});
|
|
53
62
|
} catch (error) {
|
|
54
63
|
console.error("Failed to fetch available card counts:", error);
|
|
55
64
|
} finally {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<v-card-title>Assign Access Card to Unit</v-card-title>
|
|
4
4
|
|
|
5
5
|
<v-card-text class="screen-modal__body pa-0">
|
|
6
|
-
<v-form v-model="validForm" :disabled="loading">
|
|
6
|
+
<v-form v-model="validForm" :disabled="loading || noSpareCards">
|
|
7
7
|
<v-row no-gutters class="px-6 pt-4 pb-2">
|
|
8
8
|
<!-- Building -->
|
|
9
9
|
<v-col cols="12" class="px-1">
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
block
|
|
183
183
|
variant="flat"
|
|
184
184
|
class="text-none screen-btn-primary"
|
|
185
|
-
:disabled="!validForm || loading || availableLoading || notEnoughCards"
|
|
185
|
+
:disabled="!validForm || loading || availableLoading || notEnoughCards || noSpareCards"
|
|
186
186
|
:loading="loading"
|
|
187
187
|
@click="submit"
|
|
188
188
|
>
|
|
@@ -252,6 +252,11 @@ const typeItems = computed(() =>
|
|
|
252
252
|
}))
|
|
253
253
|
);
|
|
254
254
|
|
|
255
|
+
// No spare cards of any type: grey out the whole form, nothing can be assigned.
|
|
256
|
+
const noSpareCards = computed(
|
|
257
|
+
() => spareByType.value.NFC === 0 && spareByType.value.QRCODE === 0
|
|
258
|
+
);
|
|
259
|
+
|
|
255
260
|
// The API needs `quantity` cards for EACH selected unit.
|
|
256
261
|
const totalRequired = computed(
|
|
257
262
|
() => (form.value.quantity || 0) * Math.max(form.value.units.length, 1)
|
|
@@ -11,13 +11,19 @@
|
|
|
11
11
|
the navigation, it is not new copy. -->
|
|
12
12
|
<PageHeader title="Cards">
|
|
13
13
|
<template #actions>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
<!-- The span carries the tooltip: a disabled button gets no hover. -->
|
|
15
|
+
<span v-if="canUpdateAccessCard && canAssignAccessCard">
|
|
16
|
+
<AppButton
|
|
17
|
+
variant="ghost"
|
|
18
|
+
:disabled="noSpareCards"
|
|
19
|
+
@click="assignDialog = true"
|
|
20
|
+
>
|
|
21
|
+
Assign to Unit
|
|
22
|
+
</AppButton>
|
|
23
|
+
<v-tooltip v-if="noSpareCards" activator="parent" location="bottom">
|
|
24
|
+
No spare cards available. Add access cards first.
|
|
25
|
+
</v-tooltip>
|
|
26
|
+
</span>
|
|
21
27
|
<AppButton
|
|
22
28
|
v-if="canCreate && canCreateAccessCard"
|
|
23
29
|
icon="mdi-plus"
|
|
@@ -30,7 +36,11 @@
|
|
|
30
36
|
</v-col>
|
|
31
37
|
<!-- Available Card Stats -->
|
|
32
38
|
<v-col cols="12" class="mb-2" v-if="canViewAllCards">
|
|
33
|
-
<AccessCardAvailableStats
|
|
39
|
+
<AccessCardAvailableStats
|
|
40
|
+
ref="statsRef"
|
|
41
|
+
:site-id="siteId"
|
|
42
|
+
@update="spareCounts = $event"
|
|
43
|
+
/>
|
|
34
44
|
</v-col>
|
|
35
45
|
|
|
36
46
|
<!--
|
|
@@ -255,6 +265,16 @@ const { getUserTypeAccessCards, deleteCard: _deleteCard } = useAccessManagement(
|
|
|
255
265
|
|
|
256
266
|
const statsRef = ref<{ refresh: () => void } | null>(null);
|
|
257
267
|
|
|
268
|
+
// Null until the stats have loaded (or when the viewer cannot see them), so
|
|
269
|
+
// Assign to Unit is only disabled on a count the server actually gave.
|
|
270
|
+
const spareCounts = ref<{ physical: number; nonPhysical: number } | null>(null);
|
|
271
|
+
const noSpareCards = computed(
|
|
272
|
+
() =>
|
|
273
|
+
spareCounts.value !== null &&
|
|
274
|
+
spareCounts.value.physical === 0 &&
|
|
275
|
+
spareCounts.value.nonPhysical === 0
|
|
276
|
+
);
|
|
277
|
+
|
|
258
278
|
const {
|
|
259
279
|
data: getCardReq,
|
|
260
280
|
refresh: getCards,
|
|
@@ -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.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.633",
|
|
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 ?? "");
|