@7365admin1/layer-common 4.13.1 → 4.13.2-staging.322
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/components/CameraWall.vue +161 -2
- package/components/DocumentForm.vue +407 -112
- package/components/DocumentManagement.vue +213 -12
- package/components/EntryPass/QrTemplatePreview.vue +21 -25
- package/components/EntryPassInformation.vue +119 -24
- package/components/Facility/BookingSetup.vue +63 -0
- package/components/HidIntercomManagement.vue +193 -43
- package/components/HidProfileQrCode.vue +323 -0
- package/components/HidReaderUserRoster.vue +32 -2
- package/components/HidUserEnrollment.vue +771 -212
- package/components/InvitationClientForm.vue +19 -1
- package/components/Layout/Header.vue +26 -0
- package/components/NotificationBell.vue +321 -0
- package/components/VehicleAddSelection.vue +7 -2
- package/components/VehicleBulkAddForm.vue +1392 -0
- package/components/VehicleManagement.vue +31 -3
- package/components/VisitorManagement.vue +267 -5
- package/composables/useAccessManagement.ts +5 -0
- package/composables/useDocument.ts +7 -0
- package/composables/useFacility.ts +11 -0
- package/composables/useHidAmico.ts +97 -0
- package/composables/useHidNavigation.ts +25 -1
- package/composables/useNotification.ts +78 -0
- package/composables/usePeople.ts +19 -0
- package/composables/usePropertyPermission.ts +4 -0
- package/composables/useSecurityPermission.ts +4 -0
- package/composables/useSiteSettings.ts +19 -0
- package/composables/useVehicle.ts +35 -0
- package/composables/useWebUsb.ts +14 -11
- package/constants/permissions.ts +1 -1
- package/package.json +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
- package/types/document.d.ts +14 -0
- package/types/facility.d.ts +4 -0
- package/types/people.d.ts +4 -1
- package/utils/camera-wall.ts +47 -1
- package/utils/materialSymbols.ts +3 -0
- package/utils/vehicle-bulk-rows.ts +534 -0
- package/utils/vehicle-bulk-sheet.ts +361 -0
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
<AppField
|
|
68
68
|
v-model="search"
|
|
69
69
|
search
|
|
70
|
-
placeholder="Search"
|
|
71
|
-
@keyup.enter="
|
|
70
|
+
placeholder="Search name, UID or registration no."
|
|
71
|
+
@keyup.enter="onSearchSubmit"
|
|
72
72
|
/>
|
|
73
73
|
<AppSelect
|
|
74
74
|
v-if="!props.cardManagement"
|
|
@@ -96,6 +96,12 @@
|
|
|
96
96
|
<span class="app-cell--num">{{ formatHidUid(item.hidUserId) || "N/A" }}</span>
|
|
97
97
|
</template>
|
|
98
98
|
|
|
99
|
+
<!-- The reader allocates this alongside the UID. A row the reader holds
|
|
100
|
+
that we never enrolled has none, so it is not always present. -->
|
|
101
|
+
<template #[`item.registration`]="{ item }">
|
|
102
|
+
<span class="app-cell--num">{{ item.registration || "N/A" }}</span>
|
|
103
|
+
</template>
|
|
104
|
+
|
|
99
105
|
<!-- The shared chip. `utils/status.ts` now carries Mapped/Unmapped with
|
|
100
106
|
the same tones this screen's private `getMappingStatusClass` gave
|
|
101
107
|
them, so the map is one list rather than a fourth private copy. -->
|
|
@@ -166,12 +172,12 @@
|
|
|
166
172
|
</TableMain>
|
|
167
173
|
|
|
168
174
|
<v-dialog v-model="formDialog" max-width="420" persistent>
|
|
169
|
-
<v-card
|
|
170
|
-
<v-card-title
|
|
175
|
+
<v-card class="screen-modal">
|
|
176
|
+
<v-card-title>
|
|
171
177
|
{{ selectedUser ? "Edit User Information" : "Enroll" }}
|
|
172
178
|
</v-card-title>
|
|
173
179
|
|
|
174
|
-
<v-card-text>
|
|
180
|
+
<v-card-text class="screen-modal__body">
|
|
175
181
|
<div class="photo-wrap">
|
|
176
182
|
<v-menu>
|
|
177
183
|
<template #activator="{ props: menuProps }">
|
|
@@ -213,6 +219,15 @@
|
|
|
213
219
|
/>
|
|
214
220
|
</v-list>
|
|
215
221
|
</v-menu>
|
|
222
|
+
<!-- Sits under the button because it describes what the button
|
|
223
|
+
is reporting: the reader holds a face, and this is its
|
|
224
|
+
reference. Nothing to show while enrolling - the value does not
|
|
225
|
+
exist until the reader has accepted a photo. -->
|
|
226
|
+
<p v-if="editFacialData" class="photo-facial">
|
|
227
|
+
<span class="photo-facial__label">Facial Data</span>
|
|
228
|
+
<span class="photo-facial__value">{{ editFacialData }}</span>
|
|
229
|
+
</p>
|
|
230
|
+
|
|
216
231
|
<input
|
|
217
232
|
ref="photoInput"
|
|
218
233
|
type="file"
|
|
@@ -222,29 +237,96 @@
|
|
|
222
237
|
/>
|
|
223
238
|
</div>
|
|
224
239
|
|
|
225
|
-
|
|
240
|
+
<!-- Block / Level / Unit / Resident. Enrolment only.
|
|
241
|
+
Enrollment is resident-only and the resident must already exist
|
|
242
|
+
in iService365 - you pick a person, you do not type one. Name is
|
|
243
|
+
therefore a mirror of that record, never an input, so the reader
|
|
244
|
+
can never end up holding a name the app does not know.
|
|
245
|
+
Every option is derived from the residents themselves, so a
|
|
246
|
+
block, level or unit only appears when somebody lives there.
|
|
247
|
+
The list loads on first touch of Block, not on dialog open.
|
|
248
|
+
Enrolment only, with no exception. Editing does not move
|
|
249
|
+
anybody: the record already carries its block, level and unit,
|
|
250
|
+
`openEdit` loads them into the form and `saveUser` writes them
|
|
251
|
+
back untouched, so the location survives an edit without being
|
|
252
|
+
asked for. A row that never had one keeps not having one; that
|
|
253
|
+
is not a reason to make somebody fill in a location before they
|
|
254
|
+
can change a PIN. -->
|
|
255
|
+
<template v-if="!selectedUser">
|
|
256
|
+
<div class="field-label">Block <span>*</span></div>
|
|
257
|
+
<!-- The listener sits on a wrapper, NOT on AppSelect: AppSelect
|
|
258
|
+
spreads `$attrs` over its v-menu activator AFTER the activator's
|
|
259
|
+
own bindings, so an `@click` here would replace the handler that
|
|
260
|
+
opens the dropdown. `focusin` covers keyboard users, and both
|
|
261
|
+
are idempotent - `ensureOccupancy()` fetches once.
|
|
262
|
+
AppSelect has no `loading` prop either; the placeholder carries
|
|
263
|
+
the loading and empty states instead. -->
|
|
264
|
+
<div @click="onBlockOpened" @focusin="onBlockOpened">
|
|
265
|
+
<AppSelect
|
|
266
|
+
v-model="form.block"
|
|
267
|
+
:items="blockOptions"
|
|
268
|
+
:placeholder="blockPlaceholder"
|
|
269
|
+
klass="mb-3"
|
|
270
|
+
@update:model-value="onBlockChanged"
|
|
271
|
+
/>
|
|
272
|
+
</div>
|
|
273
|
+
|
|
274
|
+
<div class="field-label">Level <span>*</span></div>
|
|
275
|
+
<AppSelect
|
|
276
|
+
v-model="form.level"
|
|
277
|
+
:items="levelOptions"
|
|
278
|
+
:disabled="!form.block"
|
|
279
|
+
placeholder="Select level"
|
|
280
|
+
klass="mb-3"
|
|
281
|
+
@update:model-value="onLevelChanged"
|
|
282
|
+
/>
|
|
283
|
+
|
|
284
|
+
<div class="field-label">Unit <span>*</span></div>
|
|
285
|
+
<AppSelect
|
|
286
|
+
v-model="form.unit"
|
|
287
|
+
:items="unitOptions"
|
|
288
|
+
:disabled="!form.level"
|
|
289
|
+
placeholder="Select unit"
|
|
290
|
+
klass="mb-3"
|
|
291
|
+
@update:model-value="onUnitChanged"
|
|
292
|
+
/>
|
|
293
|
+
</template>
|
|
294
|
+
|
|
295
|
+
<!-- Drawn only where it can offer something: while enrolling, or
|
|
296
|
+
while editing a record whose stored unit gives it a list. A row
|
|
297
|
+
with no unit has no candidates to show, and the dialog is then
|
|
298
|
+
purely the reader's own credentials - photo, PIN, password -
|
|
299
|
+
which is exactly the edit that must not be blocked. -->
|
|
300
|
+
<template v-if="!selectedUser || form.unit">
|
|
301
|
+
<div class="field-label">Resident <span>*</span></div>
|
|
302
|
+
<AppSelect
|
|
303
|
+
v-model="form.subjectId"
|
|
304
|
+
:items="subjectOptions"
|
|
305
|
+
:disabled="!form.unit"
|
|
306
|
+
:placeholder="unitResidentPlaceholder"
|
|
307
|
+
klass="mb-3"
|
|
308
|
+
@update:model-value="onResidentChanged"
|
|
309
|
+
/>
|
|
310
|
+
</template>
|
|
311
|
+
<!-- The duplicate check. It is reader-scoped: this resident holding a
|
|
312
|
+
HID user on another gate is normal and says nothing here. -->
|
|
313
|
+
<p v-if="checkingResident" class="field-hint">Checking enrollment...</p>
|
|
314
|
+
<p v-else-if="residentConflict" class="field-hint field-hint--error mb-3">
|
|
315
|
+
{{ residentConflictMessage }}
|
|
316
|
+
</p>
|
|
317
|
+
<p v-else-if="unitResidentNote" class="field-hint mb-3">
|
|
318
|
+
{{ unitResidentNote }}
|
|
319
|
+
</p>
|
|
320
|
+
|
|
321
|
+
<!-- Read-only: it restates the chosen resident, it does not collect
|
|
322
|
+
anything. `selectedUser` is the edit case, where the name is
|
|
323
|
+
whatever the reader already holds. -->
|
|
324
|
+
<div class="field-label">Name</div>
|
|
226
325
|
<AppField
|
|
227
326
|
v-model="form.name"
|
|
228
327
|
aria-label="Name"
|
|
229
|
-
placeholder="
|
|
230
|
-
|
|
231
|
-
/>
|
|
232
|
-
|
|
233
|
-
<div class="field-label">Link To <span>*</span></div>
|
|
234
|
-
<AppSelect
|
|
235
|
-
v-model="form.subjectCategory"
|
|
236
|
-
:items="subjectCategoryOptions"
|
|
237
|
-
placeholder="Select person type"
|
|
238
|
-
klass="mb-3"
|
|
239
|
-
@update:model-value="onSubjectCategoryChanged"
|
|
240
|
-
/>
|
|
241
|
-
|
|
242
|
-
<div class="field-label">Resident / Staff / Provider <span>*</span></div>
|
|
243
|
-
<AppSelect
|
|
244
|
-
v-model="form.subjectId"
|
|
245
|
-
:items="subjectOptions"
|
|
246
|
-
:loading="loadingSubjects"
|
|
247
|
-
placeholder="Select an existing site record"
|
|
328
|
+
placeholder="Select a resident above"
|
|
329
|
+
readonly
|
|
248
330
|
klass="mb-3"
|
|
249
331
|
/>
|
|
250
332
|
|
|
@@ -256,11 +338,11 @@
|
|
|
256
338
|
v-model="form.registration"
|
|
257
339
|
aria-label="Registration No."
|
|
258
340
|
placeholder="Enter registration no."
|
|
259
|
-
|
|
341
|
+
readonly
|
|
260
342
|
klass="mb-3"
|
|
261
343
|
/>
|
|
262
344
|
|
|
263
|
-
<div class="field-label">
|
|
345
|
+
<div class="field-label">PIN (optional)</div>
|
|
264
346
|
<!--
|
|
265
347
|
The handoff draws no password field anywhere (the sign-in screens
|
|
266
348
|
are the owner's own), so the reveal toggle is this product's, not
|
|
@@ -270,8 +352,8 @@
|
|
|
270
352
|
-->
|
|
271
353
|
<AppField
|
|
272
354
|
v-model="form.accessPin"
|
|
273
|
-
aria-label="
|
|
274
|
-
placeholder="Enter
|
|
355
|
+
aria-label="PIN"
|
|
356
|
+
placeholder="Enter pin"
|
|
275
357
|
inputmode="numeric"
|
|
276
358
|
autocomplete="new-password"
|
|
277
359
|
:type="showPin ? 'text' : 'password'"
|
|
@@ -280,7 +362,7 @@
|
|
|
280
362
|
<button
|
|
281
363
|
type="button"
|
|
282
364
|
class="app-field__trailing"
|
|
283
|
-
:aria-label="showPin ? 'Hide
|
|
365
|
+
:aria-label="showPin ? 'Hide PIN' : 'Show PIN'"
|
|
284
366
|
@click="showPin = !showPin"
|
|
285
367
|
>
|
|
286
368
|
<v-icon :icon="showPin ? 'mdi-eye-off' : 'mdi-eye'" size="18" />
|
|
@@ -295,28 +377,62 @@
|
|
|
295
377
|
<v-checkbox
|
|
296
378
|
v-if="selectedUser && pinEnrolled"
|
|
297
379
|
v-model="removePinRequested"
|
|
298
|
-
label="Remove current
|
|
380
|
+
label="Remove current PIN"
|
|
381
|
+
density="compact"
|
|
382
|
+
hide-details
|
|
383
|
+
/>
|
|
384
|
+
|
|
385
|
+
<!-- Password: the reader stores only a hash plus its salt, so there
|
|
386
|
+
is nothing to read back and the field is always empty on open.
|
|
387
|
+
Same reveal toggle as the PIN above. -->
|
|
388
|
+
<div class="field-label mt-3">Password (optional)</div>
|
|
389
|
+
<AppField
|
|
390
|
+
v-model="form.password"
|
|
391
|
+
aria-label="Password"
|
|
392
|
+
:placeholder="selectedUser && passwordSet ? 'Enter a new password' : 'Enter password'"
|
|
393
|
+
autocomplete="new-password"
|
|
394
|
+
:type="showPassword ? 'text' : 'password'"
|
|
395
|
+
>
|
|
396
|
+
<template #trailing>
|
|
397
|
+
<button
|
|
398
|
+
type="button"
|
|
399
|
+
class="app-field__trailing"
|
|
400
|
+
:aria-label="showPassword ? 'Hide password' : 'Show password'"
|
|
401
|
+
@click="showPassword = !showPassword"
|
|
402
|
+
>
|
|
403
|
+
<v-icon :icon="showPassword ? 'mdi-eye-off' : 'mdi-eye'" size="18" />
|
|
404
|
+
</button>
|
|
405
|
+
</template>
|
|
406
|
+
</AppField>
|
|
407
|
+
<p class="field-hint">
|
|
408
|
+
{{ selectedUser && passwordSet ? "A password is set. Leave blank to keep it." : "Used with the user ID on the reader keypad." }}
|
|
409
|
+
</p>
|
|
410
|
+
<v-checkbox
|
|
411
|
+
v-if="selectedUser && passwordSet"
|
|
412
|
+
v-model="removePasswordRequested"
|
|
413
|
+
label="Remove current password"
|
|
299
414
|
density="compact"
|
|
300
415
|
hide-details
|
|
301
416
|
/>
|
|
302
417
|
</v-card-text>
|
|
303
418
|
|
|
304
|
-
<!-- The
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
419
|
+
<!-- The shared modal footer: `screen-btn-ghost` + `screen-btn-primary`
|
|
420
|
+
on `v-btn`, the same pair every other module's dialog uses
|
|
421
|
+
(`assets/css/screens.css`). `v-btn` stays because the submit needs
|
|
422
|
+
`:loading`, which `AppButton` does not carry. -->
|
|
423
|
+
<v-card-actions class="screen-modal__footer">
|
|
308
424
|
<v-btn
|
|
309
|
-
class="text-none
|
|
425
|
+
class="text-none screen-btn-ghost"
|
|
310
426
|
variant="flat"
|
|
311
|
-
height="44"
|
|
312
427
|
@click="formDialog = false"
|
|
313
|
-
>Cancel</v-btn
|
|
314
428
|
>
|
|
429
|
+
Cancel
|
|
430
|
+
</v-btn>
|
|
315
431
|
<v-btn
|
|
316
|
-
class="text-none
|
|
432
|
+
class="text-none screen-btn-primary"
|
|
317
433
|
variant="flat"
|
|
318
|
-
height="44"
|
|
319
434
|
:loading="saving"
|
|
435
|
+
:disabled="Boolean(residentConflict) || checkingResident"
|
|
320
436
|
@click="saveUser"
|
|
321
437
|
>
|
|
322
438
|
Save
|
|
@@ -328,9 +444,9 @@
|
|
|
328
444
|
<HidCameraCaptureDialog v-model="cameraDialog" @capture="onCameraCapture" />
|
|
329
445
|
|
|
330
446
|
<v-dialog v-model="viewDialog" max-width="430">
|
|
331
|
-
<v-card
|
|
332
|
-
<v-card-title
|
|
333
|
-
<v-card-text>
|
|
447
|
+
<v-card class="screen-modal">
|
|
448
|
+
<v-card-title>User Information</v-card-title>
|
|
449
|
+
<v-card-text class="screen-modal__body">
|
|
334
450
|
<div class="detail-grid">
|
|
335
451
|
<span>Name</span><strong>{{ getName(selectedUser) }}</strong>
|
|
336
452
|
<span>User ID</span
|
|
@@ -347,21 +463,22 @@
|
|
|
347
463
|
><strong>{{
|
|
348
464
|
selectedUser ? getMappingStatus(selectedUser) : "N/A"
|
|
349
465
|
}}</strong>
|
|
350
|
-
<span>
|
|
466
|
+
<span>PIN</span
|
|
351
467
|
><strong>{{ selectedUser?.metadata?.pinEnrolled ? "Configured" : "N/A" }}</strong>
|
|
468
|
+
<span>Password</span
|
|
469
|
+
><strong>{{ selectedUser?.metadata?.passwordSet ? "Configured" : "N/A" }}</strong>
|
|
352
470
|
</div>
|
|
353
471
|
</v-card-text>
|
|
354
|
-
<v-card-actions>
|
|
355
|
-
<v-spacer />
|
|
472
|
+
<v-card-actions class="screen-modal__footer">
|
|
356
473
|
<AppButton variant="ghost" @click="viewDialog = false">Close</AppButton>
|
|
357
474
|
</v-card-actions>
|
|
358
475
|
</v-card>
|
|
359
476
|
</v-dialog>
|
|
360
477
|
|
|
361
478
|
<v-dialog v-model="cardDialog" max-width="560" persistent>
|
|
362
|
-
<v-card
|
|
363
|
-
<v-card-title
|
|
364
|
-
<v-card-text>
|
|
479
|
+
<v-card class="screen-modal">
|
|
480
|
+
<v-card-title>Physical HID Cards</v-card-title>
|
|
481
|
+
<v-card-text class="screen-modal__body">
|
|
365
482
|
<p class="hid-card-user">
|
|
366
483
|
{{ getName(cardUser) }}
|
|
367
484
|
<span>{{ cardUser ? formatHidUid(cardUser.hidUserId) : "" }}</span>
|
|
@@ -442,43 +559,22 @@
|
|
|
442
559
|
/>
|
|
443
560
|
</template>
|
|
444
561
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
density="compact"
|
|
450
|
-
class="mt-4"
|
|
451
|
-
>
|
|
452
|
-
Present the physical card to the selected Amico reader. The request will time out after 30 seconds.
|
|
453
|
-
</v-alert>
|
|
454
|
-
|
|
562
|
+
<!-- Cards are assigned by entering the value. Reading one at the
|
|
563
|
+
reader was removed with its own progress alert and Cancel
|
|
564
|
+
button, which existed only to narrate that wait. The endpoints
|
|
565
|
+
behind it are untouched and still served by the API. -->
|
|
455
566
|
<div class="hid-card-actions mt-4">
|
|
456
567
|
<AppButton
|
|
457
568
|
variant="secondary"
|
|
458
|
-
:disabled="savingCard ||
|
|
569
|
+
:disabled="savingCard || !cardProfileConfigured"
|
|
459
570
|
@click="assignPhysicalCard"
|
|
460
571
|
>
|
|
461
572
|
Assign Manually
|
|
462
573
|
</AppButton>
|
|
463
|
-
<AppButton
|
|
464
|
-
icon="mdi-contactless-payment"
|
|
465
|
-
:disabled="savingCard || enrollingCard || !cardProfileConfigured"
|
|
466
|
-
@click="enrollPhysicalCard"
|
|
467
|
-
>
|
|
468
|
-
Read at Reader
|
|
469
|
-
</AppButton>
|
|
470
|
-
<AppButton
|
|
471
|
-
v-if="enrollingCard"
|
|
472
|
-
variant="ghost"
|
|
473
|
-
@click="cancelPhysicalCardEnrollment"
|
|
474
|
-
>
|
|
475
|
-
Cancel Reading
|
|
476
|
-
</AppButton>
|
|
477
574
|
</div>
|
|
478
575
|
</v-card-text>
|
|
479
|
-
<v-card-actions>
|
|
480
|
-
<
|
|
481
|
-
<AppButton variant="ghost" :disabled="enrollingCard" @click="cardDialog = false">
|
|
576
|
+
<v-card-actions class="screen-modal__footer">
|
|
577
|
+
<AppButton variant="ghost" @click="cardDialog = false">
|
|
482
578
|
Close
|
|
483
579
|
</AppButton>
|
|
484
580
|
</v-card-actions>
|
|
@@ -486,31 +582,31 @@
|
|
|
486
582
|
</v-dialog>
|
|
487
583
|
|
|
488
584
|
<v-dialog v-model="deleteDialog" max-width="360" persistent>
|
|
489
|
-
<v-card
|
|
490
|
-
<v-card-title
|
|
491
|
-
<v-card-text class="text-body-2">
|
|
585
|
+
<v-card class="screen-modal">
|
|
586
|
+
<v-card-title>Delete</v-card-title>
|
|
587
|
+
<v-card-text class="screen-modal__body text-body-2">
|
|
492
588
|
Are you sure you want to permanently delete this HID user?
|
|
493
589
|
<div class="text-caption text-medium-emphasis mt-2">
|
|
494
590
|
This action will remove the user from the HID reader and mark the
|
|
495
591
|
identity as deleted.
|
|
496
592
|
</div>
|
|
497
593
|
</v-card-text>
|
|
498
|
-
<v-card-actions class="
|
|
594
|
+
<v-card-actions class="screen-modal__footer">
|
|
499
595
|
<v-btn
|
|
500
|
-
class="text-none
|
|
596
|
+
class="text-none screen-btn-ghost"
|
|
501
597
|
variant="flat"
|
|
502
|
-
height="44"
|
|
503
598
|
@click="deleteDialog = false"
|
|
504
|
-
>Cancel</v-btn
|
|
505
599
|
>
|
|
600
|
+
Cancel
|
|
601
|
+
</v-btn>
|
|
506
602
|
<v-btn
|
|
507
|
-
class="text-none
|
|
603
|
+
class="text-none screen-btn-primary"
|
|
508
604
|
variant="flat"
|
|
509
|
-
height="44"
|
|
510
605
|
:loading="deleting"
|
|
511
606
|
@click="deleteUser"
|
|
512
|
-
>Delete</v-btn
|
|
513
607
|
>
|
|
608
|
+
Delete
|
|
609
|
+
</v-btn>
|
|
514
610
|
</v-card-actions>
|
|
515
611
|
</v-card>
|
|
516
612
|
</v-dialog>
|
|
@@ -541,17 +637,17 @@ const {
|
|
|
541
637
|
deleteUserImage,
|
|
542
638
|
getUserCards,
|
|
543
639
|
assignUserCard,
|
|
544
|
-
enrollUserCard,
|
|
545
|
-
cancelUserCardEnrollment,
|
|
546
640
|
deleteUserCard,
|
|
547
641
|
getUserPinStatus,
|
|
548
642
|
setUserPin,
|
|
549
643
|
deleteUserPin,
|
|
644
|
+
getUserPasswordStatus,
|
|
645
|
+
setUserPassword,
|
|
646
|
+
deleteUserPassword,
|
|
550
647
|
runObjectOperation,
|
|
551
648
|
createIdentity,
|
|
552
649
|
updateIdentity,
|
|
553
650
|
deleteIdentity,
|
|
554
|
-
getPermissionCandidates,
|
|
555
651
|
} = useHidAmico();
|
|
556
652
|
|
|
557
653
|
type HidMetadata = Record<string, unknown> & {
|
|
@@ -566,6 +662,7 @@ type HidMetadata = Record<string, unknown> & {
|
|
|
566
662
|
lastAccessAt?: string;
|
|
567
663
|
facialScores?: Record<string, unknown>;
|
|
568
664
|
pinEnrolled?: boolean;
|
|
665
|
+
passwordSet?: boolean;
|
|
569
666
|
hidPhysicalCards?: HidCard[];
|
|
570
667
|
};
|
|
571
668
|
|
|
@@ -638,8 +735,6 @@ const physicalCardsByUserId = ref<Record<string, HidCard[]>>({});
|
|
|
638
735
|
const physicalCardErrorsByUserId = ref<Record<string, string>>({});
|
|
639
736
|
const loadingCards = ref(false);
|
|
640
737
|
const savingCard = ref(false);
|
|
641
|
-
const enrollingCard = ref(false);
|
|
642
|
-
const cardEnrollmentCancelled = ref(false);
|
|
643
738
|
const deletingCardId = ref("");
|
|
644
739
|
const showPin = ref(false);
|
|
645
740
|
const pinEnrolled = ref(false);
|
|
@@ -661,13 +756,61 @@ function hasFacialEnrollment(user?: HidUser | null) {
|
|
|
661
756
|
user?.metadata?.imageTimestamp
|
|
662
757
|
);
|
|
663
758
|
}
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* The reader's own reference for the enrolled face, shown while editing.
|
|
762
|
+
*
|
|
763
|
+
* We hold neither the image nor the biometric template - the reader does - so
|
|
764
|
+
* this value is the only handle on the enrollment there is. `getFacialData` is
|
|
765
|
+
* the roster's Facial Data column, reused here so the dialog and the table
|
|
766
|
+
* cannot disagree; it answers "N/A" when there is nothing, which is the case
|
|
767
|
+
* this must not draw a row for.
|
|
768
|
+
*/
|
|
769
|
+
const editFacialData = computed(() => {
|
|
770
|
+
if (!selectedUser.value) return "";
|
|
771
|
+
const value = String(getFacialData(selectedUser.value) ?? "").trim();
|
|
772
|
+
return value && value !== "N/A" ? value : "";
|
|
773
|
+
});
|
|
664
774
|
const removePinRequested = ref(false);
|
|
775
|
+
const passwordSet = ref(false);
|
|
776
|
+
const showPassword = ref(false);
|
|
777
|
+
const removePasswordRequested = ref(false);
|
|
665
778
|
const snackbar = reactive({
|
|
666
779
|
show: false,
|
|
667
780
|
color: "success",
|
|
668
781
|
message: "",
|
|
669
782
|
});
|
|
670
783
|
|
|
784
|
+
type OccupiedUnit = { _id: string; name: string; people: number };
|
|
785
|
+
type OccupiedLevel = { _id: string; name: string; units?: OccupiedUnit[] };
|
|
786
|
+
type OccupiedBlock = {
|
|
787
|
+
_id: string;
|
|
788
|
+
name: string;
|
|
789
|
+
block: number | null;
|
|
790
|
+
levels?: OccupiedLevel[];
|
|
791
|
+
};
|
|
792
|
+
type UnitPerson = {
|
|
793
|
+
_id: string;
|
|
794
|
+
name?: string;
|
|
795
|
+
unitName?: string;
|
|
796
|
+
/**
|
|
797
|
+
* The resident's app account, and the reason this field is read here.
|
|
798
|
+
*
|
|
799
|
+
* A HID identity is refused unless its subject is a valid permission subject
|
|
800
|
+
* at the site, and for a resident that means a `site.people` row WITH a
|
|
801
|
+
* linked user - `assertPermissionSubject` in `iservice365-core` filters on
|
|
802
|
+
* exactly this field. The permission model has no way to represent anyone
|
|
803
|
+
* else: `resolvePermissionUserBindings` binds reader access by user id and
|
|
804
|
+
* drops every row without one, so a resident enrolled without an account
|
|
805
|
+
* would end up on the reader holding no access rules at all.
|
|
806
|
+
*
|
|
807
|
+
* The picker this replaced was fed by that same server-side function, so it
|
|
808
|
+
* could never offer an unenrollable resident. The unit cascade asks People
|
|
809
|
+
* Management instead, which has no such filter - hence this one.
|
|
810
|
+
*/
|
|
811
|
+
user?: string | null;
|
|
812
|
+
};
|
|
813
|
+
|
|
671
814
|
const form = reactive({
|
|
672
815
|
reader: "",
|
|
673
816
|
block: "",
|
|
@@ -678,6 +821,7 @@ const form = reactive({
|
|
|
678
821
|
registration: "",
|
|
679
822
|
isAdministrator: false,
|
|
680
823
|
accessPin: "",
|
|
824
|
+
password: "",
|
|
681
825
|
photoPreview: "",
|
|
682
826
|
subjectCategory: "resident" as THidPermissionCategory,
|
|
683
827
|
subjectId: "",
|
|
@@ -685,18 +829,131 @@ const form = reactive({
|
|
|
685
829
|
|
|
686
830
|
const route = useRoute();
|
|
687
831
|
const orgId = computed(() => String(route.params.org || ""));
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
|
|
832
|
+
|
|
833
|
+
// The cascade runs on People Management's own endpoints, the same pair the
|
|
834
|
+
// resident forms use:
|
|
835
|
+
// GET /api/people/site/:site/occupied-structure - blocks/levels/units that
|
|
836
|
+
// actually have an occupant, so the picker cannot offer an empty unit
|
|
837
|
+
// GET /api/people/unit/:unit - who is in the chosen one
|
|
838
|
+
// Both are fetched on FIRST USE, never when the dialog opens.
|
|
839
|
+
const { getOccupiedStructure, getPeopleByUnit } = usePeople();
|
|
840
|
+
|
|
841
|
+
// `resident,tenant` matches the occupancy endpoint's own default, so the units
|
|
842
|
+
// it offers and the people this returns are the same set. Asking the two
|
|
843
|
+
// halves different questions is how a unit ends up offered but empty.
|
|
844
|
+
const OCCUPANT_TYPES = "resident,tenant";
|
|
845
|
+
|
|
846
|
+
const occupiedBlocks = ref<OccupiedBlock[]>([]);
|
|
847
|
+
const occupancyLoaded = ref(false);
|
|
848
|
+
const loadingOccupancy = ref(false);
|
|
849
|
+
const unitPeople = ref<UnitPerson[]>([]);
|
|
850
|
+
const loadingUnitPeople = ref(false);
|
|
851
|
+
|
|
852
|
+
// "Is this resident already enrolled on THIS reader?" - the reader keeps its own
|
|
853
|
+
// user table, so the same person at a different gate is normal and does not
|
|
854
|
+
// count. Held here rather than derived, because it is the answer to a request.
|
|
855
|
+
//
|
|
856
|
+
// The server refuses the duplicate as well (`createIdentity` in
|
|
857
|
+
// `iservice365-core`), but by the time it answers, `saveUser` has already
|
|
858
|
+
// created a user on the physical device and has to roll it back. Asking here
|
|
859
|
+
// keeps that off the reader entirely.
|
|
860
|
+
const residentConflict = ref<HidUser | null>(null);
|
|
861
|
+
const checkingResident = ref(false);
|
|
862
|
+
|
|
863
|
+
// One spelling of a block, used by the picker and by the label stamped onto the
|
|
864
|
+
// record. Two copies of this expression is how the dropdown and the Unit column
|
|
865
|
+
// drift apart.
|
|
866
|
+
function formatBlockTitle(block?: OccupiedBlock | null) {
|
|
867
|
+
if (!block) return "";
|
|
868
|
+
return block.name
|
|
869
|
+
? `Block ${block.block} (${block.name})`
|
|
870
|
+
: `Block ${block.block ?? ""}`.trim();
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
const blockOptions = computed(() => occupiedBlocks.value.map((block) => ({
|
|
874
|
+
title: formatBlockTitle(block),
|
|
875
|
+
value: String(block._id ?? ""),
|
|
876
|
+
})));
|
|
877
|
+
|
|
878
|
+
const levelOptions = computed(() => {
|
|
879
|
+
const block = occupiedBlocks.value.find((item) => String(item._id ?? "") === form.block);
|
|
880
|
+
return (block?.levels ?? []).map((level) => ({
|
|
881
|
+
title: String(level.name ?? ""),
|
|
882
|
+
value: String(level._id ?? ""),
|
|
883
|
+
}));
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
const unitOptions = computed(() => {
|
|
887
|
+
const block = occupiedBlocks.value.find((item) => String(item._id ?? "") === form.block);
|
|
888
|
+
const level = (block?.levels ?? []).find((item) => String(item._id ?? "") === form.level);
|
|
889
|
+
return (level?.units ?? []).map((unit) => ({
|
|
890
|
+
title: String(unit.name ?? ""),
|
|
891
|
+
value: String(unit._id ?? ""),
|
|
892
|
+
}));
|
|
893
|
+
});
|
|
894
|
+
|
|
895
|
+
// Only the residents the server will actually accept - see `UnitPerson.user`.
|
|
896
|
+
// Offering the rest produced "The linked HID identity subject is not active at
|
|
897
|
+
// this site." at the very end of enrollment, after a user had already been
|
|
898
|
+
// written to the reader.
|
|
899
|
+
const enrollableUnitPeople = computed(() =>
|
|
900
|
+
unitPeople.value.filter((person) => Boolean(person.user)),
|
|
901
|
+
);
|
|
902
|
+
|
|
903
|
+
const unenrollableUnitPeopleCount = computed(
|
|
904
|
+
() => unitPeople.value.length - enrollableUnitPeople.value.length,
|
|
905
|
+
);
|
|
906
|
+
|
|
907
|
+
// `_id` here is `site.people._id`, which is exactly the `person` that
|
|
908
|
+
// `createIdentity` maps a HID user to.
|
|
909
|
+
const subjectOptions = computed(() => enrollableUnitPeople.value.map((person) => ({
|
|
910
|
+
title: String(person.name ?? "Resident"),
|
|
911
|
+
value: String(person._id ?? ""),
|
|
698
912
|
})));
|
|
699
913
|
|
|
914
|
+
// Says why somebody the operator can see in People Management is missing here.
|
|
915
|
+
// Without it the unit just looks empty and the screen looks broken.
|
|
916
|
+
const unitResidentNote = computed(() => {
|
|
917
|
+
if (!form.unit || loadingUnitPeople.value || !unenrollableUnitPeopleCount.value) return "";
|
|
918
|
+
const count = unenrollableUnitPeopleCount.value;
|
|
919
|
+
const subject = count === 1 ? "1 resident" : `${count} residents`;
|
|
920
|
+
const verb = count === 1 ? "is" : "are";
|
|
921
|
+
return `${subject} in this unit ${verb} not listed: HID enrollment needs a resident app account, and ${count === 1 ? "that person has" : "they have"} none yet.`;
|
|
922
|
+
});
|
|
923
|
+
|
|
924
|
+
const blockPlaceholder = computed(() => {
|
|
925
|
+
if (loadingOccupancy.value) return "Loading...";
|
|
926
|
+
if (occupancyLoaded.value && !blockOptions.value.length) {
|
|
927
|
+
return "No occupied units at this site";
|
|
928
|
+
}
|
|
929
|
+
return "Select block";
|
|
930
|
+
});
|
|
931
|
+
|
|
932
|
+
const unitResidentPlaceholder = computed(() => {
|
|
933
|
+
if (!form.unit) return "Select a unit first";
|
|
934
|
+
if (loadingUnitPeople.value) return "Loading residents...";
|
|
935
|
+
if (enrollableUnitPeople.value.length) return "Select a resident";
|
|
936
|
+
// The two empty cases are different problems with different fixes, so they
|
|
937
|
+
// do not share a sentence: nobody lives here, versus nobody here can be
|
|
938
|
+
// enrolled yet. `unitResidentNote` carries the detail for the second.
|
|
939
|
+
return unitPeople.value.length
|
|
940
|
+
? "No resident here can be enrolled yet"
|
|
941
|
+
: "No residents in this unit";
|
|
942
|
+
});
|
|
943
|
+
|
|
944
|
+
// Names the HID user that is in the way, so the operator can go and edit it
|
|
945
|
+
// rather than being told only that something is wrong.
|
|
946
|
+
const residentConflictMessage = computed(() => {
|
|
947
|
+
const conflict = residentConflict.value;
|
|
948
|
+
if (!conflict) return "";
|
|
949
|
+
const label = [getName(conflict), formatHidUid(conflict.hidUserId)]
|
|
950
|
+
.filter(Boolean)
|
|
951
|
+
.join(" · ");
|
|
952
|
+
return label
|
|
953
|
+
? `Already enrolled on this reader as ${label}. Edit that HID user instead of enrolling again.`
|
|
954
|
+
: "Already enrolled on this reader. Edit that HID user instead of enrolling again.";
|
|
955
|
+
});
|
|
956
|
+
|
|
700
957
|
const cardForm = reactive({
|
|
701
958
|
cardType: "pacs" as "pacs" | "csn",
|
|
702
959
|
facilityCode: "",
|
|
@@ -738,6 +995,8 @@ const userHeaders = [
|
|
|
738
995
|
{ title: "Name", value: "name", sortable: false },
|
|
739
996
|
{ title: "Facial Data", value: "facialData", sortable: false },
|
|
740
997
|
{ title: "UID", value: "hidUserId", sortable: false },
|
|
998
|
+
// Reads in the same order the dialog asks for them: UID then registration.
|
|
999
|
+
{ title: "Registration No.", value: "registration", sortable: false },
|
|
741
1000
|
{ title: "Status", value: "status", sortable: false },
|
|
742
1001
|
{ title: "", value: "action-table", sortable: false },
|
|
743
1002
|
];
|
|
@@ -767,6 +1026,32 @@ function reloadUsersFromFirstPage() {
|
|
|
767
1026
|
loadUsers();
|
|
768
1027
|
}
|
|
769
1028
|
|
|
1029
|
+
/**
|
|
1030
|
+
* Typing is the search.
|
|
1031
|
+
*
|
|
1032
|
+
* The field used to reload on `@keyup.enter` and on nothing else, so a screen
|
|
1033
|
+
* that looks like every other search box did nothing at all unless you guessed
|
|
1034
|
+
* that Enter was required - no request left the browser.
|
|
1035
|
+
*
|
|
1036
|
+
* Debounced, because each reload is a login/load/logout round trip to a reader
|
|
1037
|
+
* over a VPN, not a database query. Enter still works and skips the wait.
|
|
1038
|
+
*/
|
|
1039
|
+
const SEARCH_DEBOUNCE_MS = 400;
|
|
1040
|
+
let searchDebounce: ReturnType<typeof setTimeout> | undefined;
|
|
1041
|
+
|
|
1042
|
+
function onSearchInput() {
|
|
1043
|
+
clearTimeout(searchDebounce);
|
|
1044
|
+
searchDebounce = setTimeout(reloadUsersFromFirstPage, SEARCH_DEBOUNCE_MS);
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
function onSearchSubmit() {
|
|
1048
|
+
clearTimeout(searchDebounce);
|
|
1049
|
+
reloadUsersFromFirstPage();
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
watch(search, onSearchInput);
|
|
1053
|
+
onBeforeUnmount(() => clearTimeout(searchDebounce));
|
|
1054
|
+
|
|
770
1055
|
const readerOptions = computed(() =>
|
|
771
1056
|
readers.value.map((reader) => ({
|
|
772
1057
|
title: `${reader.name || reader.deviceId || reader._id} — ${reader.portalName || "Portal not configured"}`,
|
|
@@ -810,6 +1095,16 @@ async function loadReaders() {
|
|
|
810
1095
|
}
|
|
811
1096
|
}
|
|
812
1097
|
|
|
1098
|
+
/**
|
|
1099
|
+
* Discards a load whose answer arrives after a newer one started.
|
|
1100
|
+
*
|
|
1101
|
+
* Each reload is a slow round trip to a reader over a VPN, and typing now fires
|
|
1102
|
+
* them, so "abc" can have three in flight at once. Without this the reply to
|
|
1103
|
+
* "a" can land last and repopulate the table with the wrong rows. Same monotonic
|
|
1104
|
+
* counter `HidAccessLogDashboard` uses.
|
|
1105
|
+
*/
|
|
1106
|
+
const loadUsersSequence = ref(0);
|
|
1107
|
+
|
|
813
1108
|
async function loadUsers() {
|
|
814
1109
|
if (!selectedReaderId.value) {
|
|
815
1110
|
users.value = [];
|
|
@@ -819,18 +1114,54 @@ async function loadUsers() {
|
|
|
819
1114
|
return;
|
|
820
1115
|
}
|
|
821
1116
|
|
|
1117
|
+
const sequence = loadUsersSequence.value + 1;
|
|
1118
|
+
loadUsersSequence.value = sequence;
|
|
822
1119
|
loading.value = true;
|
|
823
1120
|
try {
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
1121
|
+
// `userType: "user"` is REQUIRED here, not a nicety. The reader keeps
|
|
1122
|
+
// visitors in the same `users` table, marked `user_type_id = 1`, and the
|
|
1123
|
+
// API's default is `all`. Visitor rows are written by our own visitor-QR
|
|
1124
|
+
// issuance and are never removed - revoke only pushes `end_time` into the
|
|
1125
|
+
// past - so without this filter the enrollment roster counts every visitor
|
|
1126
|
+
// pass ever issued and drifts further from the reader's own Users screen
|
|
1127
|
+
// with each one. This screen enrolls and edits real people; visitors are
|
|
1128
|
+
// owned by the visitor module.
|
|
1129
|
+
let clientFiltersVisitors = false;
|
|
1130
|
+
let response: unknown;
|
|
1131
|
+
try {
|
|
1132
|
+
response = await getReaderUsers(selectedReaderId.value, {
|
|
1133
|
+
page: page.value,
|
|
1134
|
+
limit: limit.value,
|
|
1135
|
+
search: search.value.trim(),
|
|
1136
|
+
status: status.value.toLowerCase() as "mapped" | "unmapped" | "",
|
|
1137
|
+
userType: "user",
|
|
1138
|
+
});
|
|
1139
|
+
} catch (error: unknown) {
|
|
1140
|
+
if (!isUnsupportedUserTypeFilter(error)) throw error;
|
|
1141
|
+
|
|
1142
|
+
// A deployed API can lag behind this shared layer. Keep the roster
|
|
1143
|
+
// correct on one that has not added `userType` yet, the same way
|
|
1144
|
+
// HidReaderUserRoster does, rather than failing the whole screen.
|
|
1145
|
+
clientFiltersVisitors = true;
|
|
1146
|
+
response = await getReaderUsers(selectedReaderId.value, {
|
|
1147
|
+
page: 1,
|
|
1148
|
+
limit: 100,
|
|
1149
|
+
search: search.value.trim(),
|
|
1150
|
+
status: status.value.toLowerCase() as "mapped" | "unmapped" | "",
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
830
1153
|
const responseRecord = toRecord(response);
|
|
831
1154
|
const responseData = toRecord(responseRecord.data);
|
|
832
1155
|
const responseItems = responseRecord.items ?? responseData.items ?? [];
|
|
833
|
-
const
|
|
1156
|
+
const allItems = (Array.isArray(responseItems) ? responseItems : []).map(toHidUser);
|
|
1157
|
+
const matchingItems = clientFiltersVisitors
|
|
1158
|
+
? allItems.filter((user) => !isVisitorUser(user))
|
|
1159
|
+
: allItems;
|
|
1160
|
+
const pageStart = (page.value - 1) * limit.value;
|
|
1161
|
+
const pageItems = clientFiltersVisitors
|
|
1162
|
+
? matchingItems.slice(pageStart, pageStart + limit.value)
|
|
1163
|
+
: matchingItems;
|
|
1164
|
+
if (sequence !== loadUsersSequence.value) return;
|
|
834
1165
|
administratorUserIds.value = new Set(
|
|
835
1166
|
pageItems
|
|
836
1167
|
.filter((user) => user.isAdministrator === true)
|
|
@@ -838,13 +1169,22 @@ async function loadUsers() {
|
|
|
838
1169
|
.filter((userId: number | undefined): userId is number => Boolean(userId)),
|
|
839
1170
|
);
|
|
840
1171
|
users.value = pageItems;
|
|
841
|
-
total.value =
|
|
842
|
-
|
|
843
|
-
|
|
1172
|
+
total.value = clientFiltersVisitors
|
|
1173
|
+
? matchingItems.length
|
|
1174
|
+
: Number(responseRecord.total ?? responseData.total ?? users.value.length);
|
|
1175
|
+
pages.value = clientFiltersVisitors
|
|
1176
|
+
? Math.max(1, Math.ceil(total.value / limit.value))
|
|
1177
|
+
: Number(responseRecord.pages ?? responseData.pages ?? 1);
|
|
1178
|
+
// The server's `pageRange` counts the unfiltered page, so it cannot be
|
|
1179
|
+
// trusted once this screen has done the filtering itself.
|
|
1180
|
+
serverPageRange.value = clientFiltersVisitors
|
|
1181
|
+
? ""
|
|
1182
|
+
: String(responseRecord.pageRange ?? responseData.pageRange ?? "");
|
|
844
1183
|
if (props.cardManagement) {
|
|
845
1184
|
await loadVisibleUserCards(users.value);
|
|
846
1185
|
}
|
|
847
1186
|
} catch (error) {
|
|
1187
|
+
if (sequence !== loadUsersSequence.value) return;
|
|
848
1188
|
console.error("Unable to load HID reader users:", error);
|
|
849
1189
|
showToast("Unable to load HID users from reader.", "error");
|
|
850
1190
|
users.value = [];
|
|
@@ -855,7 +1195,9 @@ async function loadUsers() {
|
|
|
855
1195
|
pages.value = 1;
|
|
856
1196
|
serverPageRange.value = "";
|
|
857
1197
|
} finally {
|
|
858
|
-
|
|
1198
|
+
// Only the newest load owns the spinner; an older one finishing must not
|
|
1199
|
+
// clear it while that newer one is still running.
|
|
1200
|
+
if (sequence === loadUsersSequence.value) loading.value = false;
|
|
859
1201
|
}
|
|
860
1202
|
}
|
|
861
1203
|
|
|
@@ -870,6 +1212,10 @@ function resetForm() {
|
|
|
870
1212
|
form.registration = "";
|
|
871
1213
|
form.isAdministrator = false;
|
|
872
1214
|
form.accessPin = "";
|
|
1215
|
+
form.password = "";
|
|
1216
|
+
passwordSet.value = false;
|
|
1217
|
+
showPassword.value = false;
|
|
1218
|
+
removePasswordRequested.value = false;
|
|
873
1219
|
pinEnrolled.value = false;
|
|
874
1220
|
showPin.value = false;
|
|
875
1221
|
removePinRequested.value = false;
|
|
@@ -879,32 +1225,165 @@ function resetForm() {
|
|
|
879
1225
|
facialEnrolled.value = false;
|
|
880
1226
|
form.subjectCategory = "resident";
|
|
881
1227
|
form.subjectId = "";
|
|
1228
|
+
residentConflict.value = null;
|
|
1229
|
+
checkingResident.value = false;
|
|
882
1230
|
}
|
|
883
1231
|
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
1232
|
+
|
|
1233
|
+
/** Surface what the API actually said - a bare "unable to load" hides the
|
|
1234
|
+
* difference between a permission refusal, a bad id and a server fault. */
|
|
1235
|
+
function apiReason(error: unknown) {
|
|
1236
|
+
const record = toRecord(error);
|
|
1237
|
+
const data = toRecord(record.data);
|
|
1238
|
+
return toText(data.message) || toText(record.message) || toText(record.statusMessage);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
// Called when the Block select is first touched, not when the dialog opens.
|
|
1242
|
+
async function ensureOccupancy() {
|
|
1243
|
+
if (!props.site || occupancyLoaded.value || loadingOccupancy.value) return;
|
|
1244
|
+
loadingOccupancy.value = true;
|
|
1245
|
+
try {
|
|
1246
|
+
const response = toRecord(await getOccupiedStructure(props.site, {
|
|
1247
|
+
type: OCCUPANT_TYPES,
|
|
1248
|
+
status: "active",
|
|
1249
|
+
}));
|
|
1250
|
+
const data = toRecord(response.data);
|
|
1251
|
+
const blocks = response.blocks ?? data.blocks ?? [];
|
|
1252
|
+
occupiedBlocks.value = (Array.isArray(blocks) ? blocks : []) as OccupiedBlock[];
|
|
1253
|
+
occupancyLoaded.value = true;
|
|
1254
|
+
} catch (error: unknown) {
|
|
1255
|
+
console.error("Unable to load occupied units:", error);
|
|
1256
|
+
occupiedBlocks.value = [];
|
|
1257
|
+
const reason = apiReason(error);
|
|
1258
|
+
showToast(
|
|
1259
|
+
reason ? `Unable to load units: ${reason}` : "Unable to load units for this site.",
|
|
1260
|
+
"error",
|
|
1261
|
+
);
|
|
1262
|
+
} finally {
|
|
1263
|
+
loadingOccupancy.value = false;
|
|
889
1264
|
}
|
|
890
|
-
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
async function loadUnitPeople() {
|
|
1268
|
+
unitPeople.value = [];
|
|
1269
|
+
if (!form.unit) return;
|
|
1270
|
+
loadingUnitPeople.value = true;
|
|
891
1271
|
try {
|
|
892
|
-
const response = await
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
category: form.subjectCategory,
|
|
896
|
-
page: 1,
|
|
897
|
-
limit: 500,
|
|
1272
|
+
const response = await getPeopleByUnit(form.unit, {
|
|
1273
|
+
status: "active",
|
|
1274
|
+
type: OCCUPANT_TYPES,
|
|
898
1275
|
});
|
|
899
|
-
|
|
1276
|
+
const record = toRecord(response);
|
|
1277
|
+
const rows = Array.isArray(response)
|
|
1278
|
+
? response
|
|
1279
|
+
: record.data ?? record.items ?? [];
|
|
1280
|
+
unitPeople.value = (Array.isArray(rows) ? rows : []) as UnitPerson[];
|
|
1281
|
+
} catch (error: unknown) {
|
|
1282
|
+
console.error("Unable to load residents for the unit:", error);
|
|
1283
|
+
const reason = apiReason(error);
|
|
1284
|
+
showToast(
|
|
1285
|
+
reason ? `Unable to load residents: ${reason}` : "Unable to load residents for this unit.",
|
|
1286
|
+
"error",
|
|
1287
|
+
);
|
|
900
1288
|
} finally {
|
|
901
|
-
|
|
1289
|
+
loadingUnitPeople.value = false;
|
|
902
1290
|
}
|
|
903
1291
|
}
|
|
904
1292
|
|
|
905
|
-
|
|
1293
|
+
function onBlockChanged() {
|
|
1294
|
+
form.level = "";
|
|
1295
|
+
form.unit = "";
|
|
1296
|
+
unitPeople.value = [];
|
|
1297
|
+
clearResidentSelection();
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
// Wrapper `@click`/`@focusin` on the Block select: load once, on first touch.
|
|
1301
|
+
async function onBlockOpened() {
|
|
1302
|
+
await ensureOccupancy();
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
function onLevelChanged() {
|
|
1306
|
+
form.unit = "";
|
|
1307
|
+
unitPeople.value = [];
|
|
1308
|
+
clearResidentSelection();
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
async function onUnitChanged() {
|
|
1312
|
+
clearResidentSelection();
|
|
1313
|
+
await loadUnitPeople();
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
function clearResidentSelection() {
|
|
906
1317
|
form.subjectId = "";
|
|
907
|
-
|
|
1318
|
+
residentConflict.value = null;
|
|
1319
|
+
// Name only ever mirrors a chosen resident, so it clears with the choice.
|
|
1320
|
+
if (!selectedUser.value) form.name = "";
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
// The auto-fill the whole cascade exists for.
|
|
1324
|
+
async function onResidentChanged() {
|
|
1325
|
+
const person = unitPeople.value.find(
|
|
1326
|
+
(item) => String(item._id) === String(form.subjectId),
|
|
1327
|
+
);
|
|
1328
|
+
form.name = String(person?.name ?? "");
|
|
1329
|
+
await checkResidentEnrollment();
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
/**
|
|
1333
|
+
* The HID user this resident already holds on the selected reader, or null.
|
|
1334
|
+
*
|
|
1335
|
+
* `subject`, not `person`. The same resident is stored under different ids
|
|
1336
|
+
* depending on which screen wrote the row - the permissions screen keys on
|
|
1337
|
+
* their user account, this screen on the record the picker offered - so a
|
|
1338
|
+
* filter on one field alone reports "not enrolled" for somebody who plainly is.
|
|
1339
|
+
* `subject` follows the record to its account and matches every link field,
|
|
1340
|
+
* which is exactly what the server does before it accepts an enrollment.
|
|
1341
|
+
*
|
|
1342
|
+
* Reader-scoped by the endpoint itself.
|
|
1343
|
+
*/
|
|
1344
|
+
async function findResidentIdentity(readerId: string, personId: string) {
|
|
1345
|
+
const response = await getIdentities(readerId, {
|
|
1346
|
+
page: 1,
|
|
1347
|
+
// A resident should hold at most one, but ask for a few: on the edit screen
|
|
1348
|
+
// the first row back can be the very identity being edited, and skipping it
|
|
1349
|
+
// must not hide a real second one behind it.
|
|
1350
|
+
limit: 10,
|
|
1351
|
+
subject: personId,
|
|
1352
|
+
});
|
|
1353
|
+
const responseRecord = toRecord(response);
|
|
1354
|
+
const responseData = toRecord(responseRecord.data);
|
|
1355
|
+
const responseItems =
|
|
1356
|
+
responseRecord.items ?? responseData.items ?? responseData.identities ?? [];
|
|
1357
|
+
const identities = (Array.isArray(responseItems) ? responseItems : []).map(toHidUser);
|
|
1358
|
+
const editingId = String(selectedUser.value?._id ?? "");
|
|
1359
|
+
|
|
1360
|
+
return (
|
|
1361
|
+
identities.find((identity) => !editingId || String(identity._id ?? "") !== editingId) ?? null
|
|
1362
|
+
);
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* Sets `residentConflict` for the currently selected resident.
|
|
1367
|
+
*
|
|
1368
|
+
* Fails OPEN: if the lookup itself errors the operator is not blocked, because
|
|
1369
|
+
* the server refuses the duplicate anyway. This is a courtesy check that keeps
|
|
1370
|
+
* a doomed enrollment off the physical reader, not the guard itself.
|
|
1371
|
+
*/
|
|
1372
|
+
async function checkResidentEnrollment() {
|
|
1373
|
+
residentConflict.value = null;
|
|
1374
|
+
const readerId = selectedReaderId.value || form.reader || readers.value[0]?._id;
|
|
1375
|
+
if (!readerId || !form.subjectId || form.subjectCategory !== "resident") return null;
|
|
1376
|
+
|
|
1377
|
+
checkingResident.value = true;
|
|
1378
|
+
try {
|
|
1379
|
+
residentConflict.value = await findResidentIdentity(readerId, form.subjectId);
|
|
1380
|
+
return residentConflict.value;
|
|
1381
|
+
} catch (error: unknown) {
|
|
1382
|
+
console.error("Unable to check whether this resident is already enrolled:", error);
|
|
1383
|
+
return null;
|
|
1384
|
+
} finally {
|
|
1385
|
+
checkingResident.value = false;
|
|
1386
|
+
}
|
|
908
1387
|
}
|
|
909
1388
|
|
|
910
1389
|
async function openEnroll() {
|
|
@@ -916,7 +1395,6 @@ async function openEnroll() {
|
|
|
916
1395
|
]);
|
|
917
1396
|
form.hidUserId = hidUserId;
|
|
918
1397
|
form.registration = registration;
|
|
919
|
-
await loadSubjectCandidates();
|
|
920
1398
|
formDialog.value = true;
|
|
921
1399
|
}
|
|
922
1400
|
|
|
@@ -931,6 +1409,10 @@ async function openEdit(user: HidUser) {
|
|
|
931
1409
|
form.registration = user.registration ?? "";
|
|
932
1410
|
form.isAdministrator = hasAdministratorRule(user);
|
|
933
1411
|
form.accessPin = "";
|
|
1412
|
+
form.password = "";
|
|
1413
|
+
showPassword.value = false;
|
|
1414
|
+
removePasswordRequested.value = false;
|
|
1415
|
+
passwordSet.value = Boolean(user.metadata?.passwordSet);
|
|
934
1416
|
pinEnrolled.value = Boolean(user.metadata?.pinEnrolled);
|
|
935
1417
|
removePinRequested.value = false;
|
|
936
1418
|
form.photoPreview = "";
|
|
@@ -941,17 +1423,31 @@ async function openEdit(user: HidUser) {
|
|
|
941
1423
|
? "service_provider"
|
|
942
1424
|
: "property_management";
|
|
943
1425
|
form.subjectId = String(user.person || user.member || user.serviceProvider || "");
|
|
944
|
-
|
|
1426
|
+
// The resident this user already holds is not a conflict with itself. A real
|
|
1427
|
+
// one only appears if the operator reassigns the row to somebody else.
|
|
1428
|
+
residentConflict.value = null;
|
|
1429
|
+
// The location is not drawn when editing, but it is still carried: these
|
|
1430
|
+
// three form fields are what `saveUser` writes back and what `buildUnitLabel`
|
|
1431
|
+
// resolves into the Unit column, so a save must not blank them.
|
|
1432
|
+
//
|
|
1433
|
+
// `ensureOccupancy` is what lets `buildUnitLabel` turn them back into names.
|
|
1434
|
+
// The unit's residents are loaded too, because the Resident select IS drawn
|
|
1435
|
+
// here and its options come from that list - without it the select shows the
|
|
1436
|
+
// stored id instead of a name.
|
|
1437
|
+
await ensureOccupancy();
|
|
1438
|
+
if (form.unit) await loadUnitPeople();
|
|
945
1439
|
selectedPhotoFile.value = null;
|
|
946
1440
|
removePhotoRequested.value = false;
|
|
947
1441
|
formDialog.value = true;
|
|
948
1442
|
|
|
949
1443
|
try {
|
|
950
|
-
const
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1444
|
+
const hidUserId = toHidNumericId(user.hidUserId);
|
|
1445
|
+
const [pinStatus, passwordStatus] = await Promise.all([
|
|
1446
|
+
getUserPinStatus(form.reader, hidUserId),
|
|
1447
|
+
getUserPasswordStatus(form.reader, hidUserId),
|
|
1448
|
+
]);
|
|
1449
|
+
pinEnrolled.value = Boolean(pinStatus?.data?.pinEnrolled);
|
|
1450
|
+
passwordSet.value = Boolean(passwordStatus?.data?.passwordSet);
|
|
955
1451
|
} catch {
|
|
956
1452
|
// Preserve the last known status if the reader is temporarily offline.
|
|
957
1453
|
}
|
|
@@ -1030,12 +1526,28 @@ function onPhotoChange(event: Event) {
|
|
|
1030
1526
|
async function saveUser() {
|
|
1031
1527
|
const readerId =
|
|
1032
1528
|
selectedReaderId.value || form.reader || readers.value[0]?._id;
|
|
1033
|
-
|
|
1034
|
-
|
|
1529
|
+
// A resident is required to ENROL, because an identity has to be linked to
|
|
1530
|
+
// somebody. It is not required to edit: the reader holds users we never
|
|
1531
|
+
// enrolled, and changing a photo, a PIN or a password on one of those is a
|
|
1532
|
+
// reader-side operation that has nothing to say about who they are. Demanding
|
|
1533
|
+
// a resident there refuses a save for a field the dialog does not even draw.
|
|
1534
|
+
const missing = !readerId
|
|
1535
|
+
? "a reader"
|
|
1536
|
+
: !selectedUser.value && !form.subjectId
|
|
1537
|
+
? "a resident"
|
|
1538
|
+
: !form.name
|
|
1539
|
+
? "a name"
|
|
1540
|
+
: !form.hidUserId
|
|
1541
|
+
? "an ID"
|
|
1542
|
+
: !form.registration
|
|
1543
|
+
? "a registration number"
|
|
1544
|
+
: "";
|
|
1545
|
+
if (missing) {
|
|
1546
|
+
showToast(`This HID user needs ${missing} before it can be saved.`, "error");
|
|
1035
1547
|
return;
|
|
1036
1548
|
}
|
|
1037
1549
|
if (form.accessPin && !/^\d{1,32}$/.test(form.accessPin)) {
|
|
1038
|
-
showToast("
|
|
1550
|
+
showToast("PIN must contain numbers only.", "error");
|
|
1039
1551
|
return;
|
|
1040
1552
|
}
|
|
1041
1553
|
if (selectedPhotoFile.value && (!selectedReader.value?.portalId || !selectedReader.value?.portalName)) {
|
|
@@ -1043,6 +1555,16 @@ async function saveUser() {
|
|
|
1043
1555
|
return;
|
|
1044
1556
|
}
|
|
1045
1557
|
|
|
1558
|
+
// Re-asked here, not trusted from the select: the dialog can sit open while
|
|
1559
|
+
// somebody else enrolls the same resident, and the reader is only ever
|
|
1560
|
+
// written to below this line. A duplicate caught here costs one request; the
|
|
1561
|
+
// same duplicate caught by the server costs a created HID user and a rollback.
|
|
1562
|
+
const alreadyEnrolled = await checkResidentEnrollment();
|
|
1563
|
+
if (alreadyEnrolled) {
|
|
1564
|
+
showToast(residentConflictMessage.value, "error");
|
|
1565
|
+
return;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1046
1568
|
saving.value = true;
|
|
1047
1569
|
let newlyCreatedHidUserId: number | undefined;
|
|
1048
1570
|
try {
|
|
@@ -1056,22 +1578,33 @@ async function saveUser() {
|
|
|
1056
1578
|
return;
|
|
1057
1579
|
}
|
|
1058
1580
|
|
|
1581
|
+
// The link is sent only when the form actually holds one. Sending
|
|
1582
|
+
// `person: ""` is not "leave it alone", it is "clear it": the server reads
|
|
1583
|
+
// an empty string as a link being removed and then refuses the write for
|
|
1584
|
+
// having no subject at all. Omitting the keys is what makes it keep the
|
|
1585
|
+
// subject the record already has.
|
|
1586
|
+
const subjectLink = form.subjectId
|
|
1587
|
+
? {
|
|
1588
|
+
person: form.subjectCategory === "resident" ? form.subjectId : "",
|
|
1589
|
+
member: form.subjectCategory === "property_management" ? form.subjectId : "",
|
|
1590
|
+
serviceProvider: form.subjectCategory === "service_provider" ? form.subjectId : "",
|
|
1591
|
+
type: (form.subjectCategory === "resident"
|
|
1592
|
+
? "resident"
|
|
1593
|
+
: form.subjectCategory === "service_provider"
|
|
1594
|
+
? "contractor"
|
|
1595
|
+
: "staff") as
|
|
1596
|
+
| "resident"
|
|
1597
|
+
| "staff"
|
|
1598
|
+
| "contractor"
|
|
1599
|
+
| "visitor"
|
|
1600
|
+
| "unknown",
|
|
1601
|
+
}
|
|
1602
|
+
: {};
|
|
1603
|
+
|
|
1059
1604
|
const payload = {
|
|
1060
1605
|
hidUserId: String(hidUser.id),
|
|
1061
1606
|
registration: form.registration,
|
|
1062
|
-
|
|
1063
|
-
member: form.subjectCategory === "property_management" ? form.subjectId : "",
|
|
1064
|
-
serviceProvider: form.subjectCategory === "service_provider" ? form.subjectId : "",
|
|
1065
|
-
type: (form.subjectCategory === "resident"
|
|
1066
|
-
? "resident"
|
|
1067
|
-
: form.subjectCategory === "service_provider"
|
|
1068
|
-
? "contractor"
|
|
1069
|
-
: "staff") as
|
|
1070
|
-
| "resident"
|
|
1071
|
-
| "staff"
|
|
1072
|
-
| "contractor"
|
|
1073
|
-
| "visitor"
|
|
1074
|
-
| "unknown",
|
|
1607
|
+
...subjectLink,
|
|
1075
1608
|
status: "active" as const,
|
|
1076
1609
|
metadata: {
|
|
1077
1610
|
name: form.name,
|
|
@@ -1088,6 +1621,7 @@ async function saveUser() {
|
|
|
1088
1621
|
imageTimestamp: selectedUser.value?.metadata?.imageTimestamp || "",
|
|
1089
1622
|
facialScores: selectedUser.value?.metadata?.facialScores || {},
|
|
1090
1623
|
pinEnrolled: pinEnrolled.value,
|
|
1624
|
+
passwordSet: passwordSet.value,
|
|
1091
1625
|
hidPhysicalCards: selectedUser.value?.metadata?.hidPhysicalCards || [],
|
|
1092
1626
|
},
|
|
1093
1627
|
};
|
|
@@ -1097,17 +1631,22 @@ async function saveUser() {
|
|
|
1097
1631
|
const facialResult = await syncFacialImage(readerId, hidUser.id);
|
|
1098
1632
|
applyFacialResult(payload.metadata, facialResult);
|
|
1099
1633
|
payload.metadata.pinEnrolled = await syncAccessPin(readerId, hidUser.id);
|
|
1634
|
+
payload.metadata.passwordSet = await syncPassword(readerId, hidUser.id);
|
|
1100
1635
|
if (selectedUser.value._id) {
|
|
1101
1636
|
await updateIdentity(selectedUser.value._id, payload);
|
|
1102
|
-
} else {
|
|
1637
|
+
} else if (form.subjectId) {
|
|
1103
1638
|
await saveIdentityOnReader(readerId, payload);
|
|
1104
1639
|
}
|
|
1640
|
+
// else: a user the reader holds and we have never linked. The photo, PIN
|
|
1641
|
+
// and password above are already on the device; creating an identity for
|
|
1642
|
+
// it would need a subject we deliberately no longer ask for here.
|
|
1105
1643
|
} else {
|
|
1106
1644
|
const created = await createHidUserOnReader(readerId, hidUser);
|
|
1107
1645
|
if (created) newlyCreatedHidUserId = hidUser.id;
|
|
1108
1646
|
const facialResult = await syncFacialImage(readerId, hidUser.id);
|
|
1109
1647
|
applyFacialResult(payload.metadata, facialResult);
|
|
1110
1648
|
payload.metadata.pinEnrolled = await syncAccessPin(readerId, hidUser.id);
|
|
1649
|
+
payload.metadata.passwordSet = await syncPassword(readerId, hidUser.id);
|
|
1111
1650
|
await saveIdentityOnReader(readerId, payload);
|
|
1112
1651
|
selectedReaderId.value = readerId;
|
|
1113
1652
|
}
|
|
@@ -1143,6 +1682,25 @@ async function saveUser() {
|
|
|
1143
1682
|
}
|
|
1144
1683
|
}
|
|
1145
1684
|
|
|
1685
|
+
async function syncPassword(readerId: string, hidUserId: number) {
|
|
1686
|
+
// Mirrors syncAccessPin. Removal wins over a typed value, and a blank field
|
|
1687
|
+
// means "leave whatever is on the reader alone" - the hash cannot be read
|
|
1688
|
+
// back, so blank can never mean "clear it".
|
|
1689
|
+
if (removePasswordRequested.value) {
|
|
1690
|
+
await deleteUserPassword(readerId, hidUserId);
|
|
1691
|
+
passwordSet.value = false;
|
|
1692
|
+
form.password = "";
|
|
1693
|
+
return false;
|
|
1694
|
+
}
|
|
1695
|
+
if (form.password) {
|
|
1696
|
+
await setUserPassword(readerId, hidUserId, form.password);
|
|
1697
|
+
form.password = "";
|
|
1698
|
+
passwordSet.value = true;
|
|
1699
|
+
return true;
|
|
1700
|
+
}
|
|
1701
|
+
return passwordSet.value;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1146
1704
|
async function syncAccessPin(readerId: string, hidUserId: number) {
|
|
1147
1705
|
if (removePinRequested.value) {
|
|
1148
1706
|
await deleteUserPin(readerId, hidUserId);
|
|
@@ -1447,6 +2005,21 @@ function toHidUserObject(identity: Pick<HidUser, "hidUserId" | "name" | "registr
|
|
|
1447
2005
|
};
|
|
1448
2006
|
}
|
|
1449
2007
|
|
|
2008
|
+
function isVisitorUser(user: HidUser) {
|
|
2009
|
+
// The reader marks visitors with `user_type_id = 1`; a real user leaves the
|
|
2010
|
+
// field null. `metadata.hidUserTypeId` is what our API forwards it as.
|
|
2011
|
+
return Number(user.metadata?.hidUserTypeId ?? user.user_type_id) === 1;
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
function isUnsupportedUserTypeFilter(error: unknown) {
|
|
2015
|
+
const record = toRecord(error);
|
|
2016
|
+
const data = toRecord(record.data);
|
|
2017
|
+
const message = toText(data.message) || toText(record.message);
|
|
2018
|
+
const normalized = message.toLowerCase();
|
|
2019
|
+
return normalized.includes("usertype")
|
|
2020
|
+
&& (normalized.includes("not allowed") || normalized.includes("unknown"));
|
|
2021
|
+
}
|
|
2022
|
+
|
|
1450
2023
|
function toHidNumericId(value: unknown) {
|
|
1451
2024
|
const raw = String(value ?? "").trim();
|
|
1452
2025
|
if (!raw) return undefined;
|
|
@@ -1585,38 +2158,6 @@ async function assignPhysicalCard() {
|
|
|
1585
2158
|
}
|
|
1586
2159
|
}
|
|
1587
2160
|
|
|
1588
|
-
async function enrollPhysicalCard() {
|
|
1589
|
-
const { readerId, hidUserId } = getCardReaderAndUser();
|
|
1590
|
-
if (!readerId || !hidUserId) return;
|
|
1591
|
-
|
|
1592
|
-
enrollingCard.value = true;
|
|
1593
|
-
cardEnrollmentCancelled.value = false;
|
|
1594
|
-
try {
|
|
1595
|
-
await enrollUserCard(readerId, hidUserId, cardForm.cardType, 30);
|
|
1596
|
-
await loadPhysicalCards();
|
|
1597
|
-
await loadUsers();
|
|
1598
|
-
showToast("Physical HID card read and enrolled on the reader.");
|
|
1599
|
-
} catch (error: unknown) {
|
|
1600
|
-
if (!cardEnrollmentCancelled.value) {
|
|
1601
|
-
showToast(getHidErrorMessage(error), "error");
|
|
1602
|
-
}
|
|
1603
|
-
} finally {
|
|
1604
|
-
enrollingCard.value = false;
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
|
|
1608
|
-
async function cancelPhysicalCardEnrollment() {
|
|
1609
|
-
const { readerId } = getCardReaderAndUser();
|
|
1610
|
-
if (!readerId) return;
|
|
1611
|
-
cardEnrollmentCancelled.value = true;
|
|
1612
|
-
try {
|
|
1613
|
-
await cancelUserCardEnrollment(readerId);
|
|
1614
|
-
showToast("Physical HID card reading cancelled.");
|
|
1615
|
-
} catch (error: unknown) {
|
|
1616
|
-
showToast(getHidErrorMessage(error), "error");
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
2161
|
async function removePhysicalCard(card: HidCard) {
|
|
1621
2162
|
if (!window.confirm(`Remove physical HID card ${formatPhysicalCard(card)}?`)) return;
|
|
1622
2163
|
const { readerId, hidUserId } = getCardReaderAndUser();
|
|
@@ -1649,8 +2190,21 @@ function getPhysicalCardSubtitle(card: HidCard) {
|
|
|
1649
2190
|
}
|
|
1650
2191
|
|
|
1651
2192
|
function buildUnitLabel() {
|
|
1652
|
-
|
|
1653
|
-
|
|
2193
|
+
// `form.block/level/unit` hold ObjectIds, so the label has to resolve them
|
|
2194
|
+
// back to names through the occupancy tree. Joining the raw values would
|
|
2195
|
+
// stamp "665f.../665f.../665f..." onto the record and into the Unit column.
|
|
2196
|
+
const block = occupiedBlocks.value.find((item) => String(item._id ?? "") === form.block);
|
|
2197
|
+
const level = (block?.levels ?? []).find((item) => String(item._id ?? "") === form.level);
|
|
2198
|
+
const unit = (level?.units ?? []).find((item) => String(item._id ?? "") === form.unit);
|
|
2199
|
+
const parts = [
|
|
2200
|
+
formatBlockTitle(block),
|
|
2201
|
+
String(level?.name ?? ""),
|
|
2202
|
+
String(unit?.name ?? ""),
|
|
2203
|
+
].filter(Boolean);
|
|
2204
|
+
// Editing a record enrolled before the cascade existed: keep its stored
|
|
2205
|
+
// label rather than blanking it.
|
|
2206
|
+
if (!parts.length) return String(selectedUser.value?.metadata?.unitLabel ?? "");
|
|
2207
|
+
return parts.join(" / ");
|
|
1654
2208
|
}
|
|
1655
2209
|
|
|
1656
2210
|
function getName(user?: HidUser | null) {
|
|
@@ -1937,12 +2491,6 @@ function toHidCard(value: unknown): HidCard {
|
|
|
1937
2491
|
max-width: 320px;
|
|
1938
2492
|
}
|
|
1939
2493
|
|
|
1940
|
-
.small-title {
|
|
1941
|
-
font-size: 14px;
|
|
1942
|
-
font-weight: 700;
|
|
1943
|
-
color: var(--text);
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
2494
|
/* Was `#4f5a66` / `#e53935` - the same two greys on both themes. */
|
|
1947
2495
|
.field-label {
|
|
1948
2496
|
color: var(--text2);
|
|
@@ -1964,12 +2512,42 @@ function toHidCard(value: unknown): HidCard {
|
|
|
1964
2512
|
line-height: 1.45;
|
|
1965
2513
|
}
|
|
1966
2514
|
|
|
2515
|
+
/* Same line, saying the field is refused rather than explained. `--err` is the
|
|
2516
|
+
token the required-field asterisk already uses. */
|
|
2517
|
+
.field-hint--error {
|
|
2518
|
+
color: var(--err);
|
|
2519
|
+
}
|
|
2520
|
+
|
|
1967
2521
|
.photo-wrap {
|
|
1968
2522
|
display: grid;
|
|
1969
2523
|
place-items: center;
|
|
1970
2524
|
margin-bottom: 14px;
|
|
1971
2525
|
}
|
|
1972
2526
|
|
|
2527
|
+
.photo-facial {
|
|
2528
|
+
margin: 10px 0 0;
|
|
2529
|
+
text-align: center;
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
/* The same small muted word `.field-label` uses, so the caption reads as a
|
|
2533
|
+
field label rather than as a second heading. */
|
|
2534
|
+
.photo-facial__label {
|
|
2535
|
+
display: block;
|
|
2536
|
+
color: var(--muted);
|
|
2537
|
+
font-size: 12px;
|
|
2538
|
+
font-weight: 600;
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
.photo-facial__value {
|
|
2542
|
+
display: block;
|
|
2543
|
+
margin-top: 2px;
|
|
2544
|
+
font-size: 13.5px;
|
|
2545
|
+
font-weight: 500;
|
|
2546
|
+
/* The reader's reference is a long unbroken number; let it wrap rather than
|
|
2547
|
+
widen the dialog. */
|
|
2548
|
+
word-break: break-all;
|
|
2549
|
+
}
|
|
2550
|
+
|
|
1973
2551
|
.photo-button {
|
|
1974
2552
|
width: 120px;
|
|
1975
2553
|
height: 120px;
|
|
@@ -2143,25 +2721,6 @@ function toHidCard(value: unknown): HidCard {
|
|
|
2143
2721
|
color: var(--muted);
|
|
2144
2722
|
}
|
|
2145
2723
|
|
|
2146
|
-
/* The split footer bar. The handoff does not draw one, so the SHAPE is the
|
|
2147
|
-
screen's own; only the colours change - `#062d42` was a fixed navy that sat
|
|
2148
|
-
on the dark card unchanged. Same treatment as panel 2. */
|
|
2149
|
-
.action-cancel,
|
|
2150
|
-
.action-submit {
|
|
2151
|
-
flex: 1;
|
|
2152
|
-
border-radius: 0;
|
|
2153
|
-
}
|
|
2154
|
-
|
|
2155
|
-
.action-cancel {
|
|
2156
|
-
background: var(--card);
|
|
2157
|
-
color: var(--text2);
|
|
2158
|
-
}
|
|
2159
|
-
|
|
2160
|
-
.action-submit {
|
|
2161
|
-
background: var(--accent-strong);
|
|
2162
|
-
color: var(--on-accent-strong);
|
|
2163
|
-
}
|
|
2164
|
-
|
|
2165
2724
|
@media (max-width: 960px) {
|
|
2166
2725
|
.hid-user-filters :deep(.app-field),
|
|
2167
2726
|
.hid-user-filters :deep(.app-select) {
|