@7365admin1/layer-common 4.21.3 → 4.21.4-staging.340

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/components/AnprCameraBadge.vue +220 -0
  3. package/components/DocumentForm.vue +407 -112
  4. package/components/DocumentManagement.vue +213 -12
  5. package/components/EntryPass/QrTemplatePreview.vue +21 -25
  6. package/components/EntryPassInformation.vue +119 -24
  7. package/components/Facility/BookingSetup.vue +63 -0
  8. package/components/HidAccessLogDashboard.vue +29 -5
  9. package/components/HidAccessPermissions.vue +424 -0
  10. package/components/HidIntercomManagement.vue +48 -1
  11. package/components/HidProfileQrCode.vue +323 -0
  12. package/components/HidReaderManagement.vue +26 -0
  13. package/components/HidReaderUserRoster.vue +32 -2
  14. package/components/HidUserEnrollment.vue +833 -152
  15. package/components/Input/NRICNumber.vue +14 -2
  16. package/components/InvitationClientForm.vue +19 -1
  17. package/components/PlateNumberDisplay.vue +105 -1
  18. package/components/VehicleForm.vue +324 -3
  19. package/components/VehicleManagement.vue +346 -51
  20. package/components/VisitorManagement.vue +434 -5
  21. package/composables/useAccessManagement.ts +5 -0
  22. package/composables/useDocument.ts +7 -0
  23. package/composables/useFacility.ts +11 -0
  24. package/composables/useHidAmico.ts +97 -0
  25. package/composables/useHidNavigation.ts +25 -1
  26. package/composables/usePeople.ts +19 -0
  27. package/composables/useVehicle.ts +101 -1
  28. package/composables/useWebUsb.ts +14 -11
  29. package/package.json +1 -1
  30. package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
  31. package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
  32. package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
  33. package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
  34. package/types/document.d.ts +14 -0
  35. package/types/facility.d.ts +4 -0
  36. package/types/people.d.ts +5 -2
  37. package/types/vehicle.d.ts +57 -2
  38. package/utils/hid-permission-assignments.ts +190 -0
  39. package/utils/vehicle-actions.ts +45 -17
package/CHANGELOG.md CHANGED
@@ -1252,11 +1252,11 @@
1252
1252
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
1253
1253
  own rule from two endpoints the console already calls, unprojected:
1254
1254
 
1255
- GET /api/members/user/:user/app/admin the Seven365 staff membership
1256
- GET /api/roles/id/:role that membership's role document
1255
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
1256
+ GET /api/roles/id/:role that membership's role document
1257
1257
 
1258
- owner = member.type === "admin" && role.type === "admin" && role.default === true
1259
- staff = member.type === "admin" && role.type === "admin"
1258
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
1259
+ staff = member.type === "admin" && role.type === "admin"
1260
1260
 
1261
1261
  `role.default` is the marker because it is the only property of a platform
1262
1262
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -0,0 +1,220 @@
1
+ <!--
2
+ How many ANPR cameras a plate is on, as a small badge beside the vehicle
3
+ number. Clicking it lists those cameras - type and which list (Allowed or
4
+ Blocked) - as recorded by the vehicle's last camera change.
5
+
6
+ `@click.stop` because it sits inside table rows that open the Preview on
7
+ click.
8
+ -->
9
+ <template>
10
+ <!-- Only drawn when the plate is on at least one camera (inactive ones
11
+ included - a camera that went inactive still holds the plate). -->
12
+ <!-- "Sync": the plate is on fewer cameras than the site has active for its
13
+ list (e.g. it was saved while they were inactive). Puts it on every
14
+ active camera of its list that lacks it. -->
15
+ <button
16
+ v-if="showSync"
17
+ type="button"
18
+ class="anpr-badge anpr-badge--sync"
19
+ :disabled="syncing"
20
+ :aria-label="`Sync ${plateNumber} to all active ANPR cameras`"
21
+ v-tooltip:top="`On ${count} of ${expected} active camera${expected === 1 ? '' : 's'} - sync to all`"
22
+ @click.stop="sync"
23
+ >
24
+ <v-progress-circular v-if="syncing" indeterminate size="11" width="2" />
25
+ <v-icon v-else icon="mdi-sync" size="13" />
26
+ Sync
27
+ </button>
28
+
29
+ <v-menu v-if="count > 0" location="bottom start" :close-on-content-click="false">
30
+ <template #activator="{ props: menuProps }">
31
+ <button
32
+ v-bind="menuProps"
33
+ type="button"
34
+ class="anpr-badge"
35
+ :class="{ 'anpr-badge--none': !count, 'anpr-badge--blocked': isBlocked }"
36
+ :aria-label="`On ${count} ANPR camera${count === 1 ? '' : 's'}`"
37
+ v-tooltip:top="'ANPR cameras'"
38
+ @click.stop
39
+ >
40
+ <v-icon icon="mdi-cctv" size="13" />
41
+ {{ count }}
42
+ </button>
43
+ </template>
44
+
45
+ <v-card class="anpr-badge__menu" min-width="260">
46
+ <div class="anpr-badge__head">
47
+ {{ plateNumber ? `${plateNumber} - ` : "" }}{{ count }} ANPR camera{{ count === 1 ? "" : "s" }}
48
+ </div>
49
+ <div v-if="!count" class="anpr-badge__empty">
50
+ Not on any ANPR camera.
51
+ </div>
52
+ <div v-for="cam in uniqueCameras" :key="cam.host || cam.camera || cam.name" class="anpr-badge__row">
53
+ <span class="anpr-badge__type">{{ directionLabel(cam.direction) }}</span>
54
+ <StatusChip
55
+ :tone="cam.list === 'blocked' ? 'err' : 'ok'"
56
+ :dot="false"
57
+ :label="cam.list === 'blocked' ? 'Blocked' : 'Allowed'"
58
+ />
59
+ </div>
60
+ </v-card>
61
+ </v-menu>
62
+ </template>
63
+
64
+ <script setup lang="ts">
65
+ import useVehicle from "../composables/useVehicle";
66
+ import { errorConverter } from "../utils/data";
67
+
68
+ const props = defineProps({
69
+ cameras: {
70
+ type: Array as PropType<TVehicleAnprCamera[]>,
71
+ default: () => [],
72
+ },
73
+ plateNumber: { type: String, default: "" },
74
+ /** For Sync: the plate's own record, its status and list. */
75
+ plateId: { type: String, default: "" },
76
+ status: { type: String, default: "" },
77
+ type: { type: String, default: "" },
78
+ /** Active cameras per list at the site; null hides Sync. */
79
+ activeCounts: {
80
+ type: Object as PropType<{ allowed: number; blocked: number } | null>,
81
+ default: null,
82
+ },
83
+ });
84
+
85
+ const emit = defineEmits<{
86
+ (event: "synced", result: { ok: boolean; message: string }): void;
87
+ }>();
88
+
89
+ const { syncVehicle } = useVehicle();
90
+ const syncing = ref(false);
91
+
92
+ const LIVE = ["active", "temporary", "blocked"];
93
+
94
+ /** Active cameras for this plate's list. */
95
+ const expected = computed(() => {
96
+ if (!props.activeCounts) return 0;
97
+ return props.type === "blocklist"
98
+ ? props.activeCounts.blocked
99
+ : props.activeCounts.allowed;
100
+ });
101
+
102
+ const showSync = computed(
103
+ () =>
104
+ !!props.plateId &&
105
+ LIVE.includes(props.status) &&
106
+ expected.value > 0 &&
107
+ count.value < expected.value
108
+ );
109
+
110
+ async function sync() {
111
+ if (syncing.value) return;
112
+ syncing.value = true;
113
+ try {
114
+ const res: any = await syncVehicle(props.plateId);
115
+ emit("synced", { ok: !res?.failed, message: res?.message || "Synced." });
116
+ } catch (error: any) {
117
+ emit("synced", { ok: false, message: errorConverter(error) });
118
+ } finally {
119
+ syncing.value = false;
120
+ }
121
+ }
122
+
123
+ const DIRECTION_LABELS: Record<string, string> = {
124
+ entry: "Entry",
125
+ exit: "Exit",
126
+ both: "Both Entry and Exit",
127
+ visitors: "Visitors",
128
+ residents: "Residents",
129
+ };
130
+
131
+ function directionLabel(direction: string) {
132
+ return DIRECTION_LABELS[direction] ?? direction ?? "";
133
+ }
134
+
135
+ /** One row per camera URL, even if an older record listed one twice. */
136
+ const uniqueCameras = computed(() => {
137
+ const seen = new Set<string>();
138
+ return (props.cameras ?? []).filter((cam) => {
139
+ const key = String(cam.host || cam.camera || `${cam.name}|${cam.direction}`)
140
+ .trim()
141
+ .toLowerCase()
142
+ .replace(/\/+$/, "");
143
+ if (seen.has(key)) return false;
144
+ seen.add(key);
145
+ return true;
146
+ });
147
+ });
148
+
149
+ const count = computed<number>(() => uniqueCameras.value.length);
150
+ const isBlocked = computed(() => props.cameras?.some((c) => c.list === "blocked"));
151
+ </script>
152
+
153
+ <style scoped>
154
+ .anpr-badge {
155
+ display: inline-flex;
156
+ align-items: center;
157
+ gap: 3px;
158
+ padding: 1px 7px;
159
+ border-radius: 999px;
160
+ border: 1px solid var(--border);
161
+ background: var(--card);
162
+ color: var(--text);
163
+ font-size: 11px;
164
+ line-height: 18px;
165
+ cursor: pointer;
166
+ }
167
+
168
+ .anpr-badge--sync {
169
+ margin-left: 4px;
170
+ color: var(--primary, rgb(var(--v-theme-primary)));
171
+ border-color: currentColor;
172
+ }
173
+
174
+ .anpr-badge--sync:disabled {
175
+ opacity: 0.6;
176
+ cursor: progress;
177
+ }
178
+
179
+ .anpr-badge--blocked {
180
+ color: var(--err);
181
+ }
182
+
183
+ .anpr-badge--none {
184
+ color: var(--muted);
185
+ }
186
+
187
+ .anpr-badge__menu {
188
+ padding: 8px 0;
189
+ background: var(--card);
190
+ border: 1px solid var(--border);
191
+ border-radius: var(--r-inner);
192
+ }
193
+
194
+ .anpr-badge__head {
195
+ padding: 4px 14px 8px;
196
+ font-size: var(--fs-cell);
197
+ font-weight: var(--fw-btn);
198
+ color: var(--text);
199
+ }
200
+
201
+ .anpr-badge__empty {
202
+ padding: 4px 14px;
203
+ font-size: var(--fs-cell);
204
+ color: var(--muted);
205
+ }
206
+
207
+ .anpr-badge__row {
208
+ display: grid;
209
+ grid-template-columns: 1fr auto;
210
+ align-items: center;
211
+ gap: 10px;
212
+ padding: 6px 14px;
213
+ border-top: 1px solid var(--border);
214
+ font-size: var(--fs-cell);
215
+ }
216
+
217
+ .anpr-badge__type {
218
+ color: var(--text);
219
+ }
220
+ </style>