@7365admin1/layer-common 4.34.1-staging.369 → 4.35.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +47 -4
  2. package/components/AccessCardAddForm.vue +4 -5
  3. package/components/AccessCardAssignToUnitForm.vue +2 -3
  4. package/components/AccessCardPreviewDialog.vue +3 -4
  5. package/components/Dialog/UpdateMoreAction.vue +1 -11
  6. package/components/DocumentForm.vue +112 -407
  7. package/components/DocumentManagement.vue +12 -213
  8. package/components/EntryPass/QrTemplatePreview.vue +25 -21
  9. package/components/EntryPassInformation.vue +24 -119
  10. package/components/Facility/BookingSetup.vue +0 -63
  11. package/components/HidAccessLogDashboard.vue +8 -41
  12. package/components/HidIntercomManagement.vue +14 -148
  13. package/components/HidQrCodeConfiguration.vue +195 -17
  14. package/components/HidReaderManagement.vue +0 -306
  15. package/components/HidReaderUserRoster.vue +3 -44
  16. package/components/HidUserEnrollment.vue +155 -845
  17. package/components/InvitationClientForm.vue +1 -19
  18. package/components/VisitorForm.vue +0 -12
  19. package/components/VisitorManagement.vue +5 -267
  20. package/composables/useAccessManagement.ts +0 -5
  21. package/composables/useDocument.ts +0 -7
  22. package/composables/useFacility.ts +0 -11
  23. package/composables/useHidAmico.ts +0 -134
  24. package/composables/useHidNavigation.ts +1 -25
  25. package/composables/usePeople.ts +0 -19
  26. package/composables/useSiteEntryPassSettings.ts +0 -26
  27. package/composables/useWebUsb.ts +11 -14
  28. package/package.json +1 -1
  29. package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
  30. package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
  31. package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
  32. package/types/document.d.ts +0 -14
  33. package/types/facility.d.ts +0 -4
  34. package/types/people.d.ts +1 -28
  35. package/components/HidAccessPermissions.vue +0 -424
  36. package/components/HidProfileQrCode.vue +0 -332
  37. package/composables/useHidReaderSelection.ts +0 -50
  38. package/composables/useSiteCategory.ts +0 -45
  39. package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +0 -23
  40. package/utils/hid-permission-assignments.ts +0 -190
  41. package/utils/hid-reader-selection.ts +0 -52
  42. package/utils/occupancy-role.ts +0 -109
@@ -87,8 +87,6 @@
87
87
 
88
88
  <v-list density="compact" min-width="180">
89
89
  <v-list-item title="View" @click="openView(item)" />
90
- <v-list-item title="Access Permissions" @click="openPermissions(item)" />
91
- <v-list-item title="Identification Methods" @click="openIdentification(item)" />
92
90
  <v-list-item title="Sync HID Reader" @click="openSyncConfirm(item)" />
93
91
  <v-list-item title="Test Connection" @click="openTestConfirm(item)" />
94
92
  <v-list-item title="Edit" @click="openEdit(item)" />
@@ -146,108 +144,6 @@
146
144
  </v-card>
147
145
  </v-dialog>
148
146
 
149
- <!--
150
- IDENTIFICATION METHODS - what this reader accepts at the door.
151
-
152
- Per reader, not per site: the device's own `identifier` module is the
153
- authority, and a site-wide copy could only ever describe one of them.
154
-
155
- There is deliberately no Bluetooth control. The HID API has no Bluetooth
156
- identification field; the old site-level toggle of that name referred to
157
- the phone-as-a-card feature in the mobile app, which is a different thing.
158
- -->
159
- <v-dialog v-model="identificationDialog" max-width="430" persistent>
160
- <v-card rounded="lg">
161
- <v-card-title class="screen-card-title">Identification Methods</v-card-title>
162
-
163
- <v-card-text v-if="identificationStage === 'edit'">
164
- <p class="identification-lead">
165
- Credentials {{ selectedReader?.name || "this HID Reader" }} will accept at the door.
166
- </p>
167
-
168
- <div class="identification-grid">
169
- <div
170
- v-for="method in identificationMethodRows"
171
- :key="method.key"
172
- class="identification-row"
173
- >
174
- <div class="identification-copy">
175
- <span>{{ method.label }}</span>
176
- <small v-if="!method.supported">Not supported by this reader</small>
177
- </div>
178
- <v-switch
179
- v-model="identificationForm[method.key]"
180
- class="app-switch"
181
- hide-details
182
- density="compact"
183
- :disabled="!method.supported || identificationSaving"
184
- />
185
- </div>
186
- </div>
187
-
188
- <!--
189
- One reader setting with two modes, not two switches:
190
- `pin_identification_enabled` is 1 for PIN and 0 for ID-and-password.
191
- A reader without the PIN capability can be given neither.
192
- -->
193
- <div class="identification-credential">
194
- <div class="identification-copy">
195
- <span>Credential entry</span>
196
- <small v-if="!credentialModeSupported">Not supported by this reader</small>
197
- </div>
198
- <v-radio-group
199
- v-model="identificationForm.credentialMode"
200
- hide-details
201
- density="compact"
202
- :disabled="!credentialModeSupported || identificationSaving"
203
- >
204
- <v-radio label="PIN" value="pin" />
205
- <v-radio label="ID and password" value="idPassword" />
206
- </v-radio-group>
207
- </div>
208
-
209
- <p class="identification-applied">
210
- Confirmed on the reader:
211
- <strong>{{ formatDate(selectedReader?.identificationMethodsAppliedAt) }}</strong>
212
- </p>
213
- </v-card-text>
214
-
215
- <v-card-text v-else class="reader-action-content">
216
- <v-icon icon="mdi-shield-key-outline" class="dialog-mark" size="48" />
217
- <h3>Change what opens this door?</h3>
218
- <p>
219
- You are about to change the credentials {{ selectedReader?.name || "this HID Reader" }}
220
- accepts.
221
- </p>
222
- <p v-if="identificationBeingDisabled.length" class="identification-warning">
223
- Turning off: <strong>{{ identificationBeingDisabled.join(", ") }}</strong>.
224
- Anyone relying on that credential will stop getting in at this reader.
225
- </p>
226
- </v-card-text>
227
-
228
- <v-card-actions>
229
- <v-spacer />
230
- <AppButton
231
- variant="ghost"
232
- :disabled="identificationSaving"
233
- @click="identificationStage === 'confirm' ? (identificationStage = 'edit') : (identificationDialog = false)"
234
- >
235
- {{ identificationStage === "confirm" ? "Back" : "Cancel" }}
236
- </AppButton>
237
- <AppButton
238
- v-if="identificationStage === 'edit'"
239
- :disabled="!identificationChanged"
240
- @click="identificationStage = 'confirm'"
241
- >
242
- Save
243
- </AppButton>
244
- <AppButton v-else :disabled="identificationSaving" @click="saveIdentificationMethods">
245
- {{ identificationSaving ? "Applying..." : "Apply to reader" }}
246
- </AppButton>
247
- </v-card-actions>
248
- </v-card>
249
- </v-dialog>
250
-
251
147
  <v-dialog v-model="confirmDialog" max-width="390" persistent>
252
148
  <v-card rounded="lg" class="reader-action-dialog">
253
149
  <v-card-title class="screen-card-title">{{ confirmTitle }}</v-card-title>
@@ -345,18 +241,6 @@
345
241
  </v-card-actions>
346
242
  </v-card>
347
243
  </v-dialog>
348
-
349
- <!-- Who may actually pass this reader. Enrolment makes a person
350
- RECOGNISABLE; this is what puts them in the group the access rule is
351
- attached to, and without it a recognised person is refused at the
352
- door. Reloads the list on save so the reader's own counts stay true. -->
353
- <HidAccessPermissions
354
- v-model="permissionsDialog"
355
- :site="props.site"
356
- :org="props.org"
357
- :reader="selectedReader"
358
- @saved="loadReaders"
359
- />
360
244
  </section>
361
245
  </template>
362
246
 
@@ -400,21 +284,6 @@ type HidRecord = {
400
284
  cardReadingMode?: "unconfigured" | "pacs" | "csn" | "csn_for_mifare";
401
285
  csnByteOrder?: "msb" | "lsb";
402
286
  pacsFormat?: "raw" | "wiegand";
403
- capabilities?: {
404
- card?: boolean;
405
- facial?: boolean;
406
- qr?: boolean;
407
- pin?: boolean;
408
- intercom?: boolean;
409
- };
410
- identificationMethods?: {
411
- facial?: boolean;
412
- card?: boolean;
413
- qrCode?: boolean;
414
- credentialMode?: "pin" | "idPassword";
415
- };
416
- /** When the READER confirmed the methods, not when they were saved here. */
417
- identificationMethodsAppliedAt?: string;
418
287
  };
419
288
 
420
289
  type HidReaderFormPayload = {
@@ -453,13 +322,6 @@ const props = defineProps({
453
322
  type: String,
454
323
  required: true,
455
324
  },
456
- // The permission endpoints are org-scoped (`assertOrganizationSiteAccess`),
457
- // and this component previously had no reason to know the org. Passed from
458
- // the page, as `HidQrCodeConfiguration` already does.
459
- org: {
460
- type: String,
461
- required: true,
462
- },
463
325
  });
464
326
 
465
327
  const {
@@ -471,7 +333,6 @@ const {
471
333
  configureReaderIntegration,
472
334
  setReaderMonitor,
473
335
  setReaderOperatingMode,
474
- setReaderIdentificationMethods,
475
336
  getReaderUsers,
476
337
  } = useHidAmico();
477
338
 
@@ -486,19 +347,6 @@ const viewDialog = ref(false);
486
347
  const confirmDialog = ref(false);
487
348
  const resultDialog = ref(false);
488
349
  const selectedReader = ref<HidRecord | null>(null);
489
- const permissionsDialog = ref(false);
490
- const identificationDialog = ref(false);
491
- /* Two stages in one dialog, like the sync flow: the controls, then the
492
- confirmation. Switching a credential off decides what stops opening a door,
493
- so it is never one click away. */
494
- const identificationStage = ref<"edit" | "confirm">("edit");
495
- const identificationSaving = ref(false);
496
- const identificationForm = ref<{
497
- facial: boolean;
498
- card: boolean;
499
- qrCode: boolean;
500
- credentialMode: "pin" | "idPassword";
501
- }>({ facial: false, card: false, qrCode: false, credentialMode: "idPassword" });
502
350
  const pendingAction = ref<"test" | "sync" | "delete" | null>(null);
503
351
  const actionStage = ref<"confirm" | "review" | "loading">("confirm");
504
352
  const resultSuccess = ref(true);
@@ -636,109 +484,6 @@ function openView(reader: HidRecord) {
636
484
  viewDialog.value = true;
637
485
  }
638
486
 
639
- function openPermissions(reader: HidRecord) {
640
- selectedReader.value = reader;
641
- permissionsDialog.value = true;
642
- }
643
-
644
- /*
645
- * The reader record is the source of truth, including for what is already on.
646
- * A missing `identificationMethods` means nothing has been applied through this
647
- * screen yet; the switches start off rather than guessing at the device.
648
- */
649
- function openIdentification(reader: HidRecord) {
650
- selectedReader.value = reader;
651
- const current = reader.identificationMethods || {};
652
- identificationForm.value = {
653
- facial: current.facial === true,
654
- card: current.card === true,
655
- qrCode: current.qrCode === true,
656
- credentialMode: current.credentialMode === "pin" ? "pin" : "idPassword",
657
- };
658
- identificationStage.value = "edit";
659
- identificationDialog.value = true;
660
- }
661
-
662
- /*
663
- * A reader saved before capabilities were recorded has none. Those are treated
664
- * as capable rather than having every control disabled on an older record —
665
- * the backend gate makes the same allowance, and it is the one that decides.
666
- */
667
- function readerSupports(key: "facial" | "card" | "qr" | "pin") {
668
- const capabilities = selectedReader.value?.capabilities;
669
- if (!capabilities) return true;
670
- return capabilities[key] === true;
671
- }
672
-
673
- const identificationMethodRows = computed(() => [
674
- { key: "facial" as const, label: "Facial", supported: readerSupports("facial") },
675
- { key: "card" as const, label: "Card", supported: readerSupports("card") },
676
- { key: "qrCode" as const, label: "QR code", supported: readerSupports("qr") },
677
- ]);
678
-
679
- /* Both modes ride the reader's single PIN switch, so the pair stands or falls
680
- together on that one capability. */
681
- const credentialModeSupported = computed(() => readerSupports("pin"));
682
-
683
- const identificationChanged = computed(() => {
684
- const current = selectedReader.value?.identificationMethods || {};
685
- const form = identificationForm.value;
686
- return (
687
- form.facial !== (current.facial === true)
688
- || form.card !== (current.card === true)
689
- || form.qrCode !== (current.qrCode === true)
690
- || form.credentialMode !== (current.credentialMode === "pin" ? "pin" : "idPassword")
691
- );
692
- });
693
-
694
- /* Named in the confirmation, because switching a credential OFF is the change
695
- that locks somebody out. */
696
- const identificationBeingDisabled = computed(() => {
697
- const current = selectedReader.value?.identificationMethods || {};
698
- const form = identificationForm.value;
699
- const disabled: string[] = [];
700
- if (current.facial === true && !form.facial) disabled.push("Facial");
701
- if (current.card === true && !form.card) disabled.push("Card");
702
- if (current.qrCode === true && !form.qrCode) disabled.push("QR code");
703
- if (current.credentialMode === "pin" && form.credentialMode !== "pin") disabled.push("PIN");
704
- return disabled;
705
- });
706
-
707
- /*
708
- * Reload after BOTH outcomes.
709
- *
710
- * The confirmed time and the stored methods must come from the server, which
711
- * only writes them once the reader has echoed the values back. Assuming them
712
- * here would let the screen claim a door accepts something it refused. On
713
- * failure the reload matters just as much: the API names the credential the
714
- * reader would not take, and the controls must go back to what the device
715
- * actually holds rather than keeping the rejected choice on screen.
716
- */
717
- async function saveIdentificationMethods() {
718
- const readerId = String(selectedReader.value?._id || "");
719
- if (!readerId) return;
720
-
721
- const readerName = String(selectedReader.value?.name || "HID Reader");
722
- identificationSaving.value = true;
723
- try {
724
- await setReaderIdentificationMethods(readerId, { ...identificationForm.value });
725
- identificationDialog.value = false;
726
- await loadReaders();
727
- selectedReader.value = readers.value.find((reader) => String(reader._id) === readerId) || null;
728
- showResult(true, "Identification Methods Updated", `${readerName} now accepts the credentials you selected.`, {
729
- readerName,
730
- });
731
- } catch (error: unknown) {
732
- console.error("Unable to set HID identification methods:", error);
733
- identificationDialog.value = false;
734
- await loadReaders();
735
- showResult(false, "Identification Methods Not Applied", getFriendlyHidError(error), { readerName });
736
- } finally {
737
- identificationSaving.value = false;
738
- identificationStage.value = "edit";
739
- }
740
- }
741
-
742
487
  function openTestConfirm(reader?: HidRecord | null) {
743
488
  if (reader) selectedReader.value = reader;
744
489
  pendingAction.value = "test";
@@ -1174,57 +919,6 @@ function formatCallback(reader?: HidRecord | null) {
1174
919
  margin-top: 20px;
1175
920
  }
1176
921
 
1177
- .identification-lead {
1178
- margin: 0 0 14px;
1179
- color: var(--muted);
1180
- font-size: 13px;
1181
- }
1182
-
1183
- .identification-grid {
1184
- display: grid;
1185
- gap: 4px;
1186
- }
1187
-
1188
- .identification-row,
1189
- .identification-credential {
1190
- display: flex;
1191
- align-items: center;
1192
- justify-content: space-between;
1193
- gap: 16px;
1194
- }
1195
-
1196
- .identification-credential {
1197
- align-items: flex-start;
1198
- margin-top: 12px;
1199
- padding-top: 12px;
1200
- border-top: 1px solid var(--border);
1201
- }
1202
-
1203
- .identification-copy {
1204
- display: grid;
1205
- gap: 2px;
1206
- font-size: 13px;
1207
- color: var(--text);
1208
- }
1209
-
1210
- /* The reason a control is dead, next to the control rather than in a tooltip
1211
- nobody opens. */
1212
- .identification-copy small {
1213
- color: var(--muted);
1214
- font-size: 11px;
1215
- }
1216
-
1217
- .identification-applied {
1218
- margin: 16px 0 0;
1219
- color: var(--muted);
1220
- font-size: 12px;
1221
- }
1222
-
1223
- .identification-warning {
1224
- color: var(--text);
1225
- font-size: 13px;
1226
- }
1227
-
1228
922
  .reader-action-dialog {
1229
923
  overflow: hidden;
1230
924
  }
@@ -27,7 +27,7 @@
27
27
  v-model="search"
28
28
  search
29
29
  placeholder="Search Amico user, UID or registration"
30
- @keyup.enter="onSearchSubmit"
30
+ @keyup.enter="reloadFromFirstPage"
31
31
  />
32
32
  <AppSelect
33
33
  v-model="userType"
@@ -208,7 +208,6 @@ const {
208
208
  } = useHidAmico();
209
209
  const readers = ref<HidReader[]>([]);
210
210
  const users = ref<HidReaderUser[]>([]);
211
- const { selectHidReader, resolveForSite } = useHidReaderSelection();
212
211
  const selectedReaderId = ref("");
213
212
  const search = ref("");
214
213
  const userType = ref<"all" | "user" | "visitor">("all");
@@ -271,11 +270,7 @@ async function loadReaders() {
271
270
  readers.value = (Array.isArray(items) ? items : [])
272
271
  .map(toReader)
273
272
  .filter((reader): reader is HidReader => reader !== null);
274
- /* Shared with every other HID screen — see `useHidReaderSelection`. The
275
- resolver refuses a remembered reader that is not this site's, so a site
276
- switch or a deleted reader falls back to the first rather than querying
277
- an id the site does not own. */
278
- selectedReaderId.value = resolveForSite(props.site, readers.value);
273
+ if (!selectedReaderId.value && readers.value.length) selectedReaderId.value = readers.value[0]._id;
279
274
  } catch (error: unknown) {
280
275
  readers.value = [];
281
276
  showToast(getErrorMessage(error), "error");
@@ -289,8 +284,6 @@ async function loadUsers() {
289
284
  return;
290
285
  }
291
286
 
292
- const sequence = loadUsersSequence.value + 1;
293
- loadUsersSequence.value = sequence;
294
287
  loading.value = true;
295
288
  try {
296
289
  let clientFiltersUserType = false;
@@ -326,7 +319,6 @@ async function loadUsers() {
326
319
  const pageItems = clientFiltersUserType
327
320
  ? matchingItems.slice(pageStart, pageStart + 10)
328
321
  : matchingItems;
329
- if (sequence !== loadUsersSequence.value) return;
330
322
  users.value = pageItems.map(toReaderUser);
331
323
  total.value = clientFiltersUserType
332
324
  ? matchingItems.length
@@ -338,15 +330,13 @@ async function loadUsers() {
338
330
  ? ""
339
331
  : toText(response.pageRange ?? data.pageRange);
340
332
  } catch (error: unknown) {
341
- if (sequence !== loadUsersSequence.value) return;
342
333
  users.value = [];
343
334
  total.value = 0;
344
335
  pages.value = 1;
345
336
  serverPageRange.value = "";
346
337
  showToast(getErrorMessage(error), "error");
347
338
  } finally {
348
- // Only the newest load owns the spinner.
349
- if (sequence === loadUsersSequence.value) loading.value = false;
339
+ loading.value = false;
350
340
  }
351
341
  }
352
342
 
@@ -360,31 +350,6 @@ function reloadFromFirstPage() {
360
350
  loadUsers();
361
351
  }
362
352
 
363
- /**
364
- * Typing is the search. It used to reload on `@keyup.enter` and on nothing
365
- * else, so unless you guessed Enter was required the screen sent no request at
366
- * all. Debounced, because each reload is a login/load/logout round trip to a
367
- * reader over a VPN; Enter still works and skips the wait.
368
- */
369
- const SEARCH_DEBOUNCE_MS = 400;
370
- let searchDebounce: ReturnType<typeof setTimeout> | undefined;
371
-
372
- function onSearchInput() {
373
- clearTimeout(searchDebounce);
374
- searchDebounce = setTimeout(reloadFromFirstPage, SEARCH_DEBOUNCE_MS);
375
- }
376
-
377
- function onSearchSubmit() {
378
- clearTimeout(searchDebounce);
379
- reloadFromFirstPage();
380
- }
381
-
382
- watch(search, onSearchInput);
383
- onBeforeUnmount(() => clearTimeout(searchDebounce));
384
-
385
- /** Discards a load whose answer arrives after a newer one started. */
386
- const loadUsersSequence = ref(0);
387
-
388
353
  function hasFacialData(user: HidReaderUser) {
389
354
  return user.metadata?.facialEnrolled === true || Boolean(toText(user.metadata?.facialData));
390
355
  }
@@ -546,12 +511,6 @@ function toNumber(value: unknown, fallback: number) {
546
511
  const number = Number(value);
547
512
  return Number.isFinite(number) ? number : fallback;
548
513
  }
549
-
550
- /* Publish every change, including the seed above: a screen that had to fall
551
- back to the first reader should leave the others agreeing with it. */
552
- watch(selectedReaderId, (value) => {
553
- if (value) selectHidReader(props.site, value);
554
- });
555
514
  </script>
556
515
 
557
516
  <style scoped>