@7365admin1/layer-common 4.17.1-staging.330 → 4.18.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.
- package/CHANGELOG.md +10 -4
- package/components/DocumentForm.vue +112 -407
- package/components/DocumentManagement.vue +12 -213
- package/components/EntryPass/QrTemplatePreview.vue +25 -21
- package/components/EntryPassInformation.vue +24 -119
- package/components/Facility/BookingSetup.vue +0 -63
- package/components/HidIntercomManagement.vue +43 -193
- package/components/HidReaderManagement.vue +0 -26
- package/components/HidReaderUserRoster.vue +2 -32
- package/components/HidUserEnrollment.vue +213 -779
- package/components/InventoryImportDialog.vue +117 -0
- package/components/InventoryItemDetail.vue +158 -0
- package/components/InventoryItemDialog.vue +125 -0
- package/components/InventoryLinesDialog.vue +288 -0
- package/components/InventoryMain.vue +226 -0
- package/components/InventoryMyStockTab.vue +114 -0
- package/components/InventoryPhotoInput.vue +70 -0
- package/components/InventoryReportsTab.vue +181 -0
- package/components/InventoryRequestsTab.vue +218 -0
- package/components/InventorySettingsTab.vue +94 -0
- package/components/InventoryStockTab.vue +177 -0
- package/components/InventoryTechniciansTab.vue +81 -0
- package/components/InventoryUsageDialog.vue +203 -0
- package/components/InvitationClientForm.vue +1 -19
- package/components/Layout/Header.vue +0 -26
- package/components/VisitorManagement.vue +5 -267
- package/composables/useAccessManagement.ts +0 -5
- package/composables/useCleaningPermission.ts +2 -7
- package/composables/useCommonPermission.ts +22 -0
- package/composables/useDocument.ts +0 -7
- package/composables/useFacility.ts +0 -11
- package/composables/useHidAmico.ts +0 -97
- package/composables/useHidNavigation.ts +1 -25
- package/composables/useInventory.ts +97 -0
- package/composables/useInventoryPermission.ts +31 -0
- package/composables/useLandscapingPermission.ts +2 -6
- package/composables/useMechanicalElectricalPermission.ts +2 -0
- package/composables/usePeople.ts +0 -19
- package/composables/usePestControlPermission.ts +2 -0
- package/composables/usePoolMaintenancePermission.ts +2 -0
- package/composables/usePropertyPermission.ts +2 -0
- package/composables/useSecurityPermission.ts +9 -8
- package/composables/useWebUsb.ts +11 -14
- package/constants/permissions.ts +1 -1
- package/package.json +1 -1
- package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
- package/types/document.d.ts +0 -14
- package/types/facility.d.ts +0 -4
- package/types/inventory.d.ts +89 -0
- package/types/people.d.ts +1 -4
- package/utils/materialSymbols.ts +0 -3
- package/utils/module-routes.ts +1 -0
- package/components/HidAccessPermissions.vue +0 -424
- package/components/HidProfileQrCode.vue +0 -323
- package/components/NotificationBell.vue +0 -321
- package/composables/useNotification.ts +0 -78
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +0 -23
- package/utils/hid-permission-assignments.ts +0 -190
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
<AppField
|
|
68
68
|
v-model="search"
|
|
69
69
|
search
|
|
70
|
-
placeholder="Search
|
|
71
|
-
@keyup.enter="
|
|
70
|
+
placeholder="Search"
|
|
71
|
+
@keyup.enter="reloadUsersFromFirstPage"
|
|
72
72
|
/>
|
|
73
73
|
<AppSelect
|
|
74
74
|
v-if="!props.cardManagement"
|
|
@@ -96,12 +96,6 @@
|
|
|
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
|
-
|
|
105
99
|
<!-- The shared chip. `utils/status.ts` now carries Mapped/Unmapped with
|
|
106
100
|
the same tones this screen's private `getMappingStatusClass` gave
|
|
107
101
|
them, so the map is one list rather than a fourth private copy. -->
|
|
@@ -172,12 +166,12 @@
|
|
|
172
166
|
</TableMain>
|
|
173
167
|
|
|
174
168
|
<v-dialog v-model="formDialog" max-width="420" persistent>
|
|
175
|
-
<v-card
|
|
176
|
-
<v-card-title>
|
|
169
|
+
<v-card rounded="lg">
|
|
170
|
+
<v-card-title class="small-title">
|
|
177
171
|
{{ selectedUser ? "Edit User Information" : "Enroll" }}
|
|
178
172
|
</v-card-title>
|
|
179
173
|
|
|
180
|
-
<v-card-text
|
|
174
|
+
<v-card-text>
|
|
181
175
|
<div class="photo-wrap">
|
|
182
176
|
<v-menu>
|
|
183
177
|
<template #activator="{ props: menuProps }">
|
|
@@ -219,15 +213,6 @@
|
|
|
219
213
|
/>
|
|
220
214
|
</v-list>
|
|
221
215
|
</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
|
-
|
|
231
216
|
<input
|
|
232
217
|
ref="photoInput"
|
|
233
218
|
type="file"
|
|
@@ -237,96 +222,29 @@
|
|
|
237
222
|
/>
|
|
238
223
|
</div>
|
|
239
224
|
|
|
240
|
-
|
|
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>
|
|
225
|
+
<div class="field-label">Name <span>*</span></div>
|
|
325
226
|
<AppField
|
|
326
227
|
v-model="form.name"
|
|
327
228
|
aria-label="Name"
|
|
328
|
-
placeholder="
|
|
329
|
-
|
|
229
|
+
placeholder="Enter name"
|
|
230
|
+
klass="mb-3"
|
|
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"
|
|
330
248
|
klass="mb-3"
|
|
331
249
|
/>
|
|
332
250
|
|
|
@@ -338,11 +256,11 @@
|
|
|
338
256
|
v-model="form.registration"
|
|
339
257
|
aria-label="Registration No."
|
|
340
258
|
placeholder="Enter registration no."
|
|
341
|
-
readonly
|
|
259
|
+
:readonly="!selectedUser"
|
|
342
260
|
klass="mb-3"
|
|
343
261
|
/>
|
|
344
262
|
|
|
345
|
-
<div class="field-label">PIN (optional)</div>
|
|
263
|
+
<div class="field-label">Access PIN (optional)</div>
|
|
346
264
|
<!--
|
|
347
265
|
The handoff draws no password field anywhere (the sign-in screens
|
|
348
266
|
are the owner's own), so the reveal toggle is this product's, not
|
|
@@ -352,8 +270,8 @@
|
|
|
352
270
|
-->
|
|
353
271
|
<AppField
|
|
354
272
|
v-model="form.accessPin"
|
|
355
|
-
aria-label="PIN"
|
|
356
|
-
placeholder="Enter
|
|
273
|
+
aria-label="Access PIN"
|
|
274
|
+
placeholder="Enter numeric access PIN"
|
|
357
275
|
inputmode="numeric"
|
|
358
276
|
autocomplete="new-password"
|
|
359
277
|
:type="showPin ? 'text' : 'password'"
|
|
@@ -362,7 +280,7 @@
|
|
|
362
280
|
<button
|
|
363
281
|
type="button"
|
|
364
282
|
class="app-field__trailing"
|
|
365
|
-
:aria-label="showPin ? 'Hide PIN' : 'Show PIN'"
|
|
283
|
+
:aria-label="showPin ? 'Hide access PIN' : 'Show access PIN'"
|
|
366
284
|
@click="showPin = !showPin"
|
|
367
285
|
>
|
|
368
286
|
<v-icon :icon="showPin ? 'mdi-eye-off' : 'mdi-eye'" size="18" />
|
|
@@ -377,62 +295,28 @@
|
|
|
377
295
|
<v-checkbox
|
|
378
296
|
v-if="selectedUser && pinEnrolled"
|
|
379
297
|
v-model="removePinRequested"
|
|
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"
|
|
298
|
+
label="Remove current access PIN"
|
|
414
299
|
density="compact"
|
|
415
300
|
hide-details
|
|
416
301
|
/>
|
|
417
302
|
</v-card-text>
|
|
418
303
|
|
|
419
|
-
<!-- The
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
<v-card-actions class="screen-modal__footer">
|
|
304
|
+
<!-- The split footer bar, as panel 2 keeps it: `v-btn` because it needs
|
|
305
|
+
`:loading` and a full-bleed shape the handoff does not draw. Only
|
|
306
|
+
the colours change - they were fixed hexes on both themes. -->
|
|
307
|
+
<v-card-actions class="pa-0">
|
|
424
308
|
<v-btn
|
|
425
|
-
class="text-none
|
|
309
|
+
class="text-none action-cancel"
|
|
426
310
|
variant="flat"
|
|
311
|
+
height="44"
|
|
427
312
|
@click="formDialog = false"
|
|
313
|
+
>Cancel</v-btn
|
|
428
314
|
>
|
|
429
|
-
Cancel
|
|
430
|
-
</v-btn>
|
|
431
315
|
<v-btn
|
|
432
|
-
class="text-none
|
|
316
|
+
class="text-none action-submit"
|
|
433
317
|
variant="flat"
|
|
318
|
+
height="44"
|
|
434
319
|
:loading="saving"
|
|
435
|
-
:disabled="Boolean(residentConflict) || checkingResident"
|
|
436
320
|
@click="saveUser"
|
|
437
321
|
>
|
|
438
322
|
Save
|
|
@@ -444,9 +328,9 @@
|
|
|
444
328
|
<HidCameraCaptureDialog v-model="cameraDialog" @capture="onCameraCapture" />
|
|
445
329
|
|
|
446
330
|
<v-dialog v-model="viewDialog" max-width="430">
|
|
447
|
-
<v-card
|
|
448
|
-
<v-card-title>User Information</v-card-title>
|
|
449
|
-
<v-card-text
|
|
331
|
+
<v-card rounded="lg">
|
|
332
|
+
<v-card-title class="small-title">User Information</v-card-title>
|
|
333
|
+
<v-card-text>
|
|
450
334
|
<div class="detail-grid">
|
|
451
335
|
<span>Name</span><strong>{{ getName(selectedUser) }}</strong>
|
|
452
336
|
<span>User ID</span
|
|
@@ -463,22 +347,21 @@
|
|
|
463
347
|
><strong>{{
|
|
464
348
|
selectedUser ? getMappingStatus(selectedUser) : "N/A"
|
|
465
349
|
}}</strong>
|
|
466
|
-
<span>PIN</span
|
|
350
|
+
<span>Access PIN</span
|
|
467
351
|
><strong>{{ selectedUser?.metadata?.pinEnrolled ? "Configured" : "N/A" }}</strong>
|
|
468
|
-
<span>Password</span
|
|
469
|
-
><strong>{{ selectedUser?.metadata?.passwordSet ? "Configured" : "N/A" }}</strong>
|
|
470
352
|
</div>
|
|
471
353
|
</v-card-text>
|
|
472
|
-
<v-card-actions
|
|
354
|
+
<v-card-actions>
|
|
355
|
+
<v-spacer />
|
|
473
356
|
<AppButton variant="ghost" @click="viewDialog = false">Close</AppButton>
|
|
474
357
|
</v-card-actions>
|
|
475
358
|
</v-card>
|
|
476
359
|
</v-dialog>
|
|
477
360
|
|
|
478
361
|
<v-dialog v-model="cardDialog" max-width="560" persistent>
|
|
479
|
-
<v-card
|
|
480
|
-
<v-card-title>Physical HID Cards</v-card-title>
|
|
481
|
-
<v-card-text
|
|
362
|
+
<v-card rounded="lg">
|
|
363
|
+
<v-card-title class="small-title">Physical HID Cards</v-card-title>
|
|
364
|
+
<v-card-text>
|
|
482
365
|
<p class="hid-card-user">
|
|
483
366
|
{{ getName(cardUser) }}
|
|
484
367
|
<span>{{ cardUser ? formatHidUid(cardUser.hidUserId) : "" }}</span>
|
|
@@ -559,22 +442,43 @@
|
|
|
559
442
|
/>
|
|
560
443
|
</template>
|
|
561
444
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
445
|
+
<v-alert
|
|
446
|
+
v-if="enrollingCard"
|
|
447
|
+
type="info"
|
|
448
|
+
variant="tonal"
|
|
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
|
+
|
|
566
455
|
<div class="hid-card-actions mt-4">
|
|
567
456
|
<AppButton
|
|
568
457
|
variant="secondary"
|
|
569
|
-
:disabled="savingCard || !cardProfileConfigured"
|
|
458
|
+
:disabled="savingCard || enrollingCard || !cardProfileConfigured"
|
|
570
459
|
@click="assignPhysicalCard"
|
|
571
460
|
>
|
|
572
461
|
Assign Manually
|
|
573
462
|
</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>
|
|
574
477
|
</div>
|
|
575
478
|
</v-card-text>
|
|
576
|
-
<v-card-actions
|
|
577
|
-
<
|
|
479
|
+
<v-card-actions>
|
|
480
|
+
<v-spacer />
|
|
481
|
+
<AppButton variant="ghost" :disabled="enrollingCard" @click="cardDialog = false">
|
|
578
482
|
Close
|
|
579
483
|
</AppButton>
|
|
580
484
|
</v-card-actions>
|
|
@@ -582,31 +486,31 @@
|
|
|
582
486
|
</v-dialog>
|
|
583
487
|
|
|
584
488
|
<v-dialog v-model="deleteDialog" max-width="360" persistent>
|
|
585
|
-
<v-card
|
|
586
|
-
<v-card-title>Delete</v-card-title>
|
|
587
|
-
<v-card-text class="
|
|
489
|
+
<v-card rounded="lg">
|
|
490
|
+
<v-card-title class="small-title">Delete</v-card-title>
|
|
491
|
+
<v-card-text class="text-body-2">
|
|
588
492
|
Are you sure you want to permanently delete this HID user?
|
|
589
493
|
<div class="text-caption text-medium-emphasis mt-2">
|
|
590
494
|
This action will remove the user from the HID reader and mark the
|
|
591
495
|
identity as deleted.
|
|
592
496
|
</div>
|
|
593
497
|
</v-card-text>
|
|
594
|
-
<v-card-actions class="
|
|
498
|
+
<v-card-actions class="pa-0">
|
|
595
499
|
<v-btn
|
|
596
|
-
class="text-none
|
|
500
|
+
class="text-none action-cancel"
|
|
597
501
|
variant="flat"
|
|
502
|
+
height="44"
|
|
598
503
|
@click="deleteDialog = false"
|
|
504
|
+
>Cancel</v-btn
|
|
599
505
|
>
|
|
600
|
-
Cancel
|
|
601
|
-
</v-btn>
|
|
602
506
|
<v-btn
|
|
603
|
-
class="text-none
|
|
507
|
+
class="text-none action-submit"
|
|
604
508
|
variant="flat"
|
|
509
|
+
height="44"
|
|
605
510
|
:loading="deleting"
|
|
606
511
|
@click="deleteUser"
|
|
512
|
+
>Delete</v-btn
|
|
607
513
|
>
|
|
608
|
-
Delete
|
|
609
|
-
</v-btn>
|
|
610
514
|
</v-card-actions>
|
|
611
515
|
</v-card>
|
|
612
516
|
</v-dialog>
|
|
@@ -623,13 +527,6 @@ const props = defineProps({
|
|
|
623
527
|
type: String,
|
|
624
528
|
required: true,
|
|
625
529
|
},
|
|
626
|
-
// Which organisation the access this enrolment grants belongs to. Saving now
|
|
627
|
-
// assigns the person to the reader, and the assignment is stored per
|
|
628
|
-
// organisation - see `schemaCreateHidAmicoIdentity`.
|
|
629
|
-
org: {
|
|
630
|
-
type: String,
|
|
631
|
-
default: "",
|
|
632
|
-
},
|
|
633
530
|
cardManagement: {
|
|
634
531
|
type: Boolean,
|
|
635
532
|
default: false,
|
|
@@ -644,17 +541,17 @@ const {
|
|
|
644
541
|
deleteUserImage,
|
|
645
542
|
getUserCards,
|
|
646
543
|
assignUserCard,
|
|
544
|
+
enrollUserCard,
|
|
545
|
+
cancelUserCardEnrollment,
|
|
647
546
|
deleteUserCard,
|
|
648
547
|
getUserPinStatus,
|
|
649
548
|
setUserPin,
|
|
650
549
|
deleteUserPin,
|
|
651
|
-
getUserPasswordStatus,
|
|
652
|
-
setUserPassword,
|
|
653
|
-
deleteUserPassword,
|
|
654
550
|
runObjectOperation,
|
|
655
551
|
createIdentity,
|
|
656
552
|
updateIdentity,
|
|
657
553
|
deleteIdentity,
|
|
554
|
+
getPermissionCandidates,
|
|
658
555
|
} = useHidAmico();
|
|
659
556
|
|
|
660
557
|
type HidMetadata = Record<string, unknown> & {
|
|
@@ -669,7 +566,6 @@ type HidMetadata = Record<string, unknown> & {
|
|
|
669
566
|
lastAccessAt?: string;
|
|
670
567
|
facialScores?: Record<string, unknown>;
|
|
671
568
|
pinEnrolled?: boolean;
|
|
672
|
-
passwordSet?: boolean;
|
|
673
569
|
hidPhysicalCards?: HidCard[];
|
|
674
570
|
};
|
|
675
571
|
|
|
@@ -742,6 +638,8 @@ const physicalCardsByUserId = ref<Record<string, HidCard[]>>({});
|
|
|
742
638
|
const physicalCardErrorsByUserId = ref<Record<string, string>>({});
|
|
743
639
|
const loadingCards = ref(false);
|
|
744
640
|
const savingCard = ref(false);
|
|
641
|
+
const enrollingCard = ref(false);
|
|
642
|
+
const cardEnrollmentCancelled = ref(false);
|
|
745
643
|
const deletingCardId = ref("");
|
|
746
644
|
const showPin = ref(false);
|
|
747
645
|
const pinEnrolled = ref(false);
|
|
@@ -763,61 +661,13 @@ function hasFacialEnrollment(user?: HidUser | null) {
|
|
|
763
661
|
user?.metadata?.imageTimestamp
|
|
764
662
|
);
|
|
765
663
|
}
|
|
766
|
-
|
|
767
|
-
/**
|
|
768
|
-
* The reader's own reference for the enrolled face, shown while editing.
|
|
769
|
-
*
|
|
770
|
-
* We hold neither the image nor the biometric template - the reader does - so
|
|
771
|
-
* this value is the only handle on the enrollment there is. `getFacialData` is
|
|
772
|
-
* the roster's Facial Data column, reused here so the dialog and the table
|
|
773
|
-
* cannot disagree; it answers "N/A" when there is nothing, which is the case
|
|
774
|
-
* this must not draw a row for.
|
|
775
|
-
*/
|
|
776
|
-
const editFacialData = computed(() => {
|
|
777
|
-
if (!selectedUser.value) return "";
|
|
778
|
-
const value = String(getFacialData(selectedUser.value) ?? "").trim();
|
|
779
|
-
return value && value !== "N/A" ? value : "";
|
|
780
|
-
});
|
|
781
664
|
const removePinRequested = ref(false);
|
|
782
|
-
const passwordSet = ref(false);
|
|
783
|
-
const showPassword = ref(false);
|
|
784
|
-
const removePasswordRequested = ref(false);
|
|
785
665
|
const snackbar = reactive({
|
|
786
666
|
show: false,
|
|
787
667
|
color: "success",
|
|
788
668
|
message: "",
|
|
789
669
|
});
|
|
790
670
|
|
|
791
|
-
type OccupiedUnit = { _id: string; name: string; people: number };
|
|
792
|
-
type OccupiedLevel = { _id: string; name: string; units?: OccupiedUnit[] };
|
|
793
|
-
type OccupiedBlock = {
|
|
794
|
-
_id: string;
|
|
795
|
-
name: string;
|
|
796
|
-
block: number | null;
|
|
797
|
-
levels?: OccupiedLevel[];
|
|
798
|
-
};
|
|
799
|
-
type UnitPerson = {
|
|
800
|
-
_id: string;
|
|
801
|
-
name?: string;
|
|
802
|
-
unitName?: string;
|
|
803
|
-
/**
|
|
804
|
-
* The resident's app account, and the reason this field is read here.
|
|
805
|
-
*
|
|
806
|
-
* A HID identity is refused unless its subject is a valid permission subject
|
|
807
|
-
* at the site, and for a resident that means a `site.people` row WITH a
|
|
808
|
-
* linked user - `assertPermissionSubject` in `iservice365-core` filters on
|
|
809
|
-
* exactly this field. The permission model has no way to represent anyone
|
|
810
|
-
* else: `resolvePermissionUserBindings` binds reader access by user id and
|
|
811
|
-
* drops every row without one, so a resident enrolled without an account
|
|
812
|
-
* would end up on the reader holding no access rules at all.
|
|
813
|
-
*
|
|
814
|
-
* The picker this replaced was fed by that same server-side function, so it
|
|
815
|
-
* could never offer an unenrollable resident. The unit cascade asks People
|
|
816
|
-
* Management instead, which has no such filter - hence this one.
|
|
817
|
-
*/
|
|
818
|
-
user?: string | null;
|
|
819
|
-
};
|
|
820
|
-
|
|
821
671
|
const form = reactive({
|
|
822
672
|
reader: "",
|
|
823
673
|
block: "",
|
|
@@ -828,7 +678,6 @@ const form = reactive({
|
|
|
828
678
|
registration: "",
|
|
829
679
|
isAdministrator: false,
|
|
830
680
|
accessPin: "",
|
|
831
|
-
password: "",
|
|
832
681
|
photoPreview: "",
|
|
833
682
|
subjectCategory: "resident" as THidPermissionCategory,
|
|
834
683
|
subjectId: "",
|
|
@@ -836,131 +685,18 @@ const form = reactive({
|
|
|
836
685
|
|
|
837
686
|
const route = useRoute();
|
|
838
687
|
const orgId = computed(() => String(route.params.org || ""));
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
// it offers and the people this returns are the same set. Asking the two
|
|
850
|
-
// halves different questions is how a unit ends up offered but empty.
|
|
851
|
-
const OCCUPANT_TYPES = "resident,tenant";
|
|
852
|
-
|
|
853
|
-
const occupiedBlocks = ref<OccupiedBlock[]>([]);
|
|
854
|
-
const occupancyLoaded = ref(false);
|
|
855
|
-
const loadingOccupancy = ref(false);
|
|
856
|
-
const unitPeople = ref<UnitPerson[]>([]);
|
|
857
|
-
const loadingUnitPeople = ref(false);
|
|
858
|
-
|
|
859
|
-
// "Is this resident already enrolled on THIS reader?" - the reader keeps its own
|
|
860
|
-
// user table, so the same person at a different gate is normal and does not
|
|
861
|
-
// count. Held here rather than derived, because it is the answer to a request.
|
|
862
|
-
//
|
|
863
|
-
// The server refuses the duplicate as well (`createIdentity` in
|
|
864
|
-
// `iservice365-core`), but by the time it answers, `saveUser` has already
|
|
865
|
-
// created a user on the physical device and has to roll it back. Asking here
|
|
866
|
-
// keeps that off the reader entirely.
|
|
867
|
-
const residentConflict = ref<HidUser | null>(null);
|
|
868
|
-
const checkingResident = ref(false);
|
|
869
|
-
|
|
870
|
-
// One spelling of a block, used by the picker and by the label stamped onto the
|
|
871
|
-
// record. Two copies of this expression is how the dropdown and the Unit column
|
|
872
|
-
// drift apart.
|
|
873
|
-
function formatBlockTitle(block?: OccupiedBlock | null) {
|
|
874
|
-
if (!block) return "";
|
|
875
|
-
return block.name
|
|
876
|
-
? `Block ${block.block} (${block.name})`
|
|
877
|
-
: `Block ${block.block ?? ""}`.trim();
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
const blockOptions = computed(() => occupiedBlocks.value.map((block) => ({
|
|
881
|
-
title: formatBlockTitle(block),
|
|
882
|
-
value: String(block._id ?? ""),
|
|
883
|
-
})));
|
|
884
|
-
|
|
885
|
-
const levelOptions = computed(() => {
|
|
886
|
-
const block = occupiedBlocks.value.find((item) => String(item._id ?? "") === form.block);
|
|
887
|
-
return (block?.levels ?? []).map((level) => ({
|
|
888
|
-
title: String(level.name ?? ""),
|
|
889
|
-
value: String(level._id ?? ""),
|
|
890
|
-
}));
|
|
891
|
-
});
|
|
892
|
-
|
|
893
|
-
const unitOptions = computed(() => {
|
|
894
|
-
const block = occupiedBlocks.value.find((item) => String(item._id ?? "") === form.block);
|
|
895
|
-
const level = (block?.levels ?? []).find((item) => String(item._id ?? "") === form.level);
|
|
896
|
-
return (level?.units ?? []).map((unit) => ({
|
|
897
|
-
title: String(unit.name ?? ""),
|
|
898
|
-
value: String(unit._id ?? ""),
|
|
899
|
-
}));
|
|
900
|
-
});
|
|
901
|
-
|
|
902
|
-
// Only the residents the server will actually accept - see `UnitPerson.user`.
|
|
903
|
-
// Offering the rest produced "The linked HID identity subject is not active at
|
|
904
|
-
// this site." at the very end of enrollment, after a user had already been
|
|
905
|
-
// written to the reader.
|
|
906
|
-
const enrollableUnitPeople = computed(() =>
|
|
907
|
-
unitPeople.value.filter((person) => Boolean(person.user)),
|
|
908
|
-
);
|
|
909
|
-
|
|
910
|
-
const unenrollableUnitPeopleCount = computed(
|
|
911
|
-
() => unitPeople.value.length - enrollableUnitPeople.value.length,
|
|
912
|
-
);
|
|
913
|
-
|
|
914
|
-
// `_id` here is `site.people._id`, which is exactly the `person` that
|
|
915
|
-
// `createIdentity` maps a HID user to.
|
|
916
|
-
const subjectOptions = computed(() => enrollableUnitPeople.value.map((person) => ({
|
|
917
|
-
title: String(person.name ?? "Resident"),
|
|
918
|
-
value: String(person._id ?? ""),
|
|
688
|
+
const permissionCandidates = ref<THidPermissionCandidate[]>([]);
|
|
689
|
+
const loadingSubjects = ref(false);
|
|
690
|
+
const subjectCategoryOptions = [
|
|
691
|
+
{ title: "Resident", value: "resident" },
|
|
692
|
+
{ title: "Property management", value: "property_management" },
|
|
693
|
+
{ title: "Service provider", value: "service_provider" },
|
|
694
|
+
];
|
|
695
|
+
const subjectOptions = computed(() => permissionCandidates.value.map((candidate) => ({
|
|
696
|
+
title: candidate.subtitle ? `${candidate.name} · ${candidate.subtitle}` : candidate.name,
|
|
697
|
+
value: candidate.subjectId,
|
|
919
698
|
})));
|
|
920
699
|
|
|
921
|
-
// Says why somebody the operator can see in People Management is missing here.
|
|
922
|
-
// Without it the unit just looks empty and the screen looks broken.
|
|
923
|
-
const unitResidentNote = computed(() => {
|
|
924
|
-
if (!form.unit || loadingUnitPeople.value || !unenrollableUnitPeopleCount.value) return "";
|
|
925
|
-
const count = unenrollableUnitPeopleCount.value;
|
|
926
|
-
const subject = count === 1 ? "1 resident" : `${count} residents`;
|
|
927
|
-
const verb = count === 1 ? "is" : "are";
|
|
928
|
-
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.`;
|
|
929
|
-
});
|
|
930
|
-
|
|
931
|
-
const blockPlaceholder = computed(() => {
|
|
932
|
-
if (loadingOccupancy.value) return "Loading...";
|
|
933
|
-
if (occupancyLoaded.value && !blockOptions.value.length) {
|
|
934
|
-
return "No occupied units at this site";
|
|
935
|
-
}
|
|
936
|
-
return "Select block";
|
|
937
|
-
});
|
|
938
|
-
|
|
939
|
-
const unitResidentPlaceholder = computed(() => {
|
|
940
|
-
if (!form.unit) return "Select a unit first";
|
|
941
|
-
if (loadingUnitPeople.value) return "Loading residents...";
|
|
942
|
-
if (enrollableUnitPeople.value.length) return "Select a resident";
|
|
943
|
-
// The two empty cases are different problems with different fixes, so they
|
|
944
|
-
// do not share a sentence: nobody lives here, versus nobody here can be
|
|
945
|
-
// enrolled yet. `unitResidentNote` carries the detail for the second.
|
|
946
|
-
return unitPeople.value.length
|
|
947
|
-
? "No resident here can be enrolled yet"
|
|
948
|
-
: "No residents in this unit";
|
|
949
|
-
});
|
|
950
|
-
|
|
951
|
-
// Names the HID user that is in the way, so the operator can go and edit it
|
|
952
|
-
// rather than being told only that something is wrong.
|
|
953
|
-
const residentConflictMessage = computed(() => {
|
|
954
|
-
const conflict = residentConflict.value;
|
|
955
|
-
if (!conflict) return "";
|
|
956
|
-
const label = [getName(conflict), formatHidUid(conflict.hidUserId)]
|
|
957
|
-
.filter(Boolean)
|
|
958
|
-
.join(" · ");
|
|
959
|
-
return label
|
|
960
|
-
? `Already enrolled on this reader as ${label}. Edit that HID user instead of enrolling again.`
|
|
961
|
-
: "Already enrolled on this reader. Edit that HID user instead of enrolling again.";
|
|
962
|
-
});
|
|
963
|
-
|
|
964
700
|
const cardForm = reactive({
|
|
965
701
|
cardType: "pacs" as "pacs" | "csn",
|
|
966
702
|
facilityCode: "",
|
|
@@ -1002,8 +738,6 @@ const userHeaders = [
|
|
|
1002
738
|
{ title: "Name", value: "name", sortable: false },
|
|
1003
739
|
{ title: "Facial Data", value: "facialData", sortable: false },
|
|
1004
740
|
{ title: "UID", value: "hidUserId", sortable: false },
|
|
1005
|
-
// Reads in the same order the dialog asks for them: UID then registration.
|
|
1006
|
-
{ title: "Registration No.", value: "registration", sortable: false },
|
|
1007
741
|
{ title: "Status", value: "status", sortable: false },
|
|
1008
742
|
{ title: "", value: "action-table", sortable: false },
|
|
1009
743
|
];
|
|
@@ -1033,32 +767,6 @@ function reloadUsersFromFirstPage() {
|
|
|
1033
767
|
loadUsers();
|
|
1034
768
|
}
|
|
1035
769
|
|
|
1036
|
-
/**
|
|
1037
|
-
* Typing is the search.
|
|
1038
|
-
*
|
|
1039
|
-
* The field used to reload on `@keyup.enter` and on nothing else, so a screen
|
|
1040
|
-
* that looks like every other search box did nothing at all unless you guessed
|
|
1041
|
-
* that Enter was required - no request left the browser.
|
|
1042
|
-
*
|
|
1043
|
-
* Debounced, because each reload is a login/load/logout round trip to a reader
|
|
1044
|
-
* over a VPN, not a database query. Enter still works and skips the wait.
|
|
1045
|
-
*/
|
|
1046
|
-
const SEARCH_DEBOUNCE_MS = 400;
|
|
1047
|
-
let searchDebounce: ReturnType<typeof setTimeout> | undefined;
|
|
1048
|
-
|
|
1049
|
-
function onSearchInput() {
|
|
1050
|
-
clearTimeout(searchDebounce);
|
|
1051
|
-
searchDebounce = setTimeout(reloadUsersFromFirstPage, SEARCH_DEBOUNCE_MS);
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
function onSearchSubmit() {
|
|
1055
|
-
clearTimeout(searchDebounce);
|
|
1056
|
-
reloadUsersFromFirstPage();
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
watch(search, onSearchInput);
|
|
1060
|
-
onBeforeUnmount(() => clearTimeout(searchDebounce));
|
|
1061
|
-
|
|
1062
770
|
const readerOptions = computed(() =>
|
|
1063
771
|
readers.value.map((reader) => ({
|
|
1064
772
|
title: `${reader.name || reader.deviceId || reader._id} — ${reader.portalName || "Portal not configured"}`,
|
|
@@ -1102,16 +810,6 @@ async function loadReaders() {
|
|
|
1102
810
|
}
|
|
1103
811
|
}
|
|
1104
812
|
|
|
1105
|
-
/**
|
|
1106
|
-
* Discards a load whose answer arrives after a newer one started.
|
|
1107
|
-
*
|
|
1108
|
-
* Each reload is a slow round trip to a reader over a VPN, and typing now fires
|
|
1109
|
-
* them, so "abc" can have three in flight at once. Without this the reply to
|
|
1110
|
-
* "a" can land last and repopulate the table with the wrong rows. Same monotonic
|
|
1111
|
-
* counter `HidAccessLogDashboard` uses.
|
|
1112
|
-
*/
|
|
1113
|
-
const loadUsersSequence = ref(0);
|
|
1114
|
-
|
|
1115
813
|
async function loadUsers() {
|
|
1116
814
|
if (!selectedReaderId.value) {
|
|
1117
815
|
users.value = [];
|
|
@@ -1121,54 +819,18 @@ async function loadUsers() {
|
|
|
1121
819
|
return;
|
|
1122
820
|
}
|
|
1123
821
|
|
|
1124
|
-
const sequence = loadUsersSequence.value + 1;
|
|
1125
|
-
loadUsersSequence.value = sequence;
|
|
1126
822
|
loading.value = true;
|
|
1127
823
|
try {
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
// with each one. This screen enrolls and edits real people; visitors are
|
|
1135
|
-
// owned by the visitor module.
|
|
1136
|
-
let clientFiltersVisitors = false;
|
|
1137
|
-
let response: unknown;
|
|
1138
|
-
try {
|
|
1139
|
-
response = await getReaderUsers(selectedReaderId.value, {
|
|
1140
|
-
page: page.value,
|
|
1141
|
-
limit: limit.value,
|
|
1142
|
-
search: search.value.trim(),
|
|
1143
|
-
status: status.value.toLowerCase() as "mapped" | "unmapped" | "",
|
|
1144
|
-
userType: "user",
|
|
1145
|
-
});
|
|
1146
|
-
} catch (error: unknown) {
|
|
1147
|
-
if (!isUnsupportedUserTypeFilter(error)) throw error;
|
|
1148
|
-
|
|
1149
|
-
// A deployed API can lag behind this shared layer. Keep the roster
|
|
1150
|
-
// correct on one that has not added `userType` yet, the same way
|
|
1151
|
-
// HidReaderUserRoster does, rather than failing the whole screen.
|
|
1152
|
-
clientFiltersVisitors = true;
|
|
1153
|
-
response = await getReaderUsers(selectedReaderId.value, {
|
|
1154
|
-
page: 1,
|
|
1155
|
-
limit: 100,
|
|
1156
|
-
search: search.value.trim(),
|
|
1157
|
-
status: status.value.toLowerCase() as "mapped" | "unmapped" | "",
|
|
1158
|
-
});
|
|
1159
|
-
}
|
|
824
|
+
const response = await getReaderUsers(selectedReaderId.value, {
|
|
825
|
+
page: page.value,
|
|
826
|
+
limit: limit.value,
|
|
827
|
+
search: search.value.trim(),
|
|
828
|
+
status: status.value.toLowerCase() as "mapped" | "unmapped" | "",
|
|
829
|
+
});
|
|
1160
830
|
const responseRecord = toRecord(response);
|
|
1161
831
|
const responseData = toRecord(responseRecord.data);
|
|
1162
832
|
const responseItems = responseRecord.items ?? responseData.items ?? [];
|
|
1163
|
-
const
|
|
1164
|
-
const matchingItems = clientFiltersVisitors
|
|
1165
|
-
? allItems.filter((user) => !isVisitorUser(user))
|
|
1166
|
-
: allItems;
|
|
1167
|
-
const pageStart = (page.value - 1) * limit.value;
|
|
1168
|
-
const pageItems = clientFiltersVisitors
|
|
1169
|
-
? matchingItems.slice(pageStart, pageStart + limit.value)
|
|
1170
|
-
: matchingItems;
|
|
1171
|
-
if (sequence !== loadUsersSequence.value) return;
|
|
833
|
+
const pageItems = (Array.isArray(responseItems) ? responseItems : []).map(toHidUser);
|
|
1172
834
|
administratorUserIds.value = new Set(
|
|
1173
835
|
pageItems
|
|
1174
836
|
.filter((user) => user.isAdministrator === true)
|
|
@@ -1176,22 +838,13 @@ async function loadUsers() {
|
|
|
1176
838
|
.filter((userId: number | undefined): userId is number => Boolean(userId)),
|
|
1177
839
|
);
|
|
1178
840
|
users.value = pageItems;
|
|
1179
|
-
total.value =
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
pages.value = clientFiltersVisitors
|
|
1183
|
-
? Math.max(1, Math.ceil(total.value / limit.value))
|
|
1184
|
-
: Number(responseRecord.pages ?? responseData.pages ?? 1);
|
|
1185
|
-
// The server's `pageRange` counts the unfiltered page, so it cannot be
|
|
1186
|
-
// trusted once this screen has done the filtering itself.
|
|
1187
|
-
serverPageRange.value = clientFiltersVisitors
|
|
1188
|
-
? ""
|
|
1189
|
-
: String(responseRecord.pageRange ?? responseData.pageRange ?? "");
|
|
841
|
+
total.value = Number(responseRecord.total ?? responseData.total ?? users.value.length);
|
|
842
|
+
pages.value = Number(responseRecord.pages ?? responseData.pages ?? 1);
|
|
843
|
+
serverPageRange.value = String(responseRecord.pageRange ?? responseData.pageRange ?? "");
|
|
1190
844
|
if (props.cardManagement) {
|
|
1191
845
|
await loadVisibleUserCards(users.value);
|
|
1192
846
|
}
|
|
1193
847
|
} catch (error) {
|
|
1194
|
-
if (sequence !== loadUsersSequence.value) return;
|
|
1195
848
|
console.error("Unable to load HID reader users:", error);
|
|
1196
849
|
showToast("Unable to load HID users from reader.", "error");
|
|
1197
850
|
users.value = [];
|
|
@@ -1202,9 +855,7 @@ async function loadUsers() {
|
|
|
1202
855
|
pages.value = 1;
|
|
1203
856
|
serverPageRange.value = "";
|
|
1204
857
|
} finally {
|
|
1205
|
-
|
|
1206
|
-
// clear it while that newer one is still running.
|
|
1207
|
-
if (sequence === loadUsersSequence.value) loading.value = false;
|
|
858
|
+
loading.value = false;
|
|
1208
859
|
}
|
|
1209
860
|
}
|
|
1210
861
|
|
|
@@ -1219,10 +870,6 @@ function resetForm() {
|
|
|
1219
870
|
form.registration = "";
|
|
1220
871
|
form.isAdministrator = false;
|
|
1221
872
|
form.accessPin = "";
|
|
1222
|
-
form.password = "";
|
|
1223
|
-
passwordSet.value = false;
|
|
1224
|
-
showPassword.value = false;
|
|
1225
|
-
removePasswordRequested.value = false;
|
|
1226
873
|
pinEnrolled.value = false;
|
|
1227
874
|
showPin.value = false;
|
|
1228
875
|
removePinRequested.value = false;
|
|
@@ -1232,165 +879,32 @@ function resetForm() {
|
|
|
1232
879
|
facialEnrolled.value = false;
|
|
1233
880
|
form.subjectCategory = "resident";
|
|
1234
881
|
form.subjectId = "";
|
|
1235
|
-
residentConflict.value = null;
|
|
1236
|
-
checkingResident.value = false;
|
|
1237
882
|
}
|
|
1238
883
|
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
const data = toRecord(record.data);
|
|
1245
|
-
return toText(data.message) || toText(record.message) || toText(record.statusMessage);
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
// Called when the Block select is first touched, not when the dialog opens.
|
|
1249
|
-
async function ensureOccupancy() {
|
|
1250
|
-
if (!props.site || occupancyLoaded.value || loadingOccupancy.value) return;
|
|
1251
|
-
loadingOccupancy.value = true;
|
|
1252
|
-
try {
|
|
1253
|
-
const response = toRecord(await getOccupiedStructure(props.site, {
|
|
1254
|
-
type: OCCUPANT_TYPES,
|
|
1255
|
-
status: "active",
|
|
1256
|
-
}));
|
|
1257
|
-
const data = toRecord(response.data);
|
|
1258
|
-
const blocks = response.blocks ?? data.blocks ?? [];
|
|
1259
|
-
occupiedBlocks.value = (Array.isArray(blocks) ? blocks : []) as OccupiedBlock[];
|
|
1260
|
-
occupancyLoaded.value = true;
|
|
1261
|
-
} catch (error: unknown) {
|
|
1262
|
-
console.error("Unable to load occupied units:", error);
|
|
1263
|
-
occupiedBlocks.value = [];
|
|
1264
|
-
const reason = apiReason(error);
|
|
1265
|
-
showToast(
|
|
1266
|
-
reason ? `Unable to load units: ${reason}` : "Unable to load units for this site.",
|
|
1267
|
-
"error",
|
|
1268
|
-
);
|
|
1269
|
-
} finally {
|
|
1270
|
-
loadingOccupancy.value = false;
|
|
884
|
+
async function loadSubjectCandidates() {
|
|
885
|
+
const readerId = form.reader || selectedReaderId.value;
|
|
886
|
+
if (!readerId || !orgId.value) {
|
|
887
|
+
permissionCandidates.value = [];
|
|
888
|
+
return;
|
|
1271
889
|
}
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
async function loadUnitPeople() {
|
|
1275
|
-
unitPeople.value = [];
|
|
1276
|
-
if (!form.unit) return;
|
|
1277
|
-
loadingUnitPeople.value = true;
|
|
890
|
+
loadingSubjects.value = true;
|
|
1278
891
|
try {
|
|
1279
|
-
const response = await
|
|
1280
|
-
|
|
1281
|
-
|
|
892
|
+
const response = await getPermissionCandidates(props.site, {
|
|
893
|
+
orgId: orgId.value,
|
|
894
|
+
readerId,
|
|
895
|
+
category: form.subjectCategory,
|
|
896
|
+
page: 1,
|
|
897
|
+
limit: 500,
|
|
1282
898
|
});
|
|
1283
|
-
|
|
1284
|
-
const rows = Array.isArray(response)
|
|
1285
|
-
? response
|
|
1286
|
-
: record.data ?? record.items ?? [];
|
|
1287
|
-
unitPeople.value = (Array.isArray(rows) ? rows : []) as UnitPerson[];
|
|
1288
|
-
} catch (error: unknown) {
|
|
1289
|
-
console.error("Unable to load residents for the unit:", error);
|
|
1290
|
-
const reason = apiReason(error);
|
|
1291
|
-
showToast(
|
|
1292
|
-
reason ? `Unable to load residents: ${reason}` : "Unable to load residents for this unit.",
|
|
1293
|
-
"error",
|
|
1294
|
-
);
|
|
899
|
+
permissionCandidates.value = response.items ?? response.data?.items ?? [];
|
|
1295
900
|
} finally {
|
|
1296
|
-
|
|
901
|
+
loadingSubjects.value = false;
|
|
1297
902
|
}
|
|
1298
903
|
}
|
|
1299
904
|
|
|
1300
|
-
function
|
|
1301
|
-
form.level = "";
|
|
1302
|
-
form.unit = "";
|
|
1303
|
-
unitPeople.value = [];
|
|
1304
|
-
clearResidentSelection();
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
// Wrapper `@click`/`@focusin` on the Block select: load once, on first touch.
|
|
1308
|
-
async function onBlockOpened() {
|
|
1309
|
-
await ensureOccupancy();
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
function onLevelChanged() {
|
|
1313
|
-
form.unit = "";
|
|
1314
|
-
unitPeople.value = [];
|
|
1315
|
-
clearResidentSelection();
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
async function onUnitChanged() {
|
|
1319
|
-
clearResidentSelection();
|
|
1320
|
-
await loadUnitPeople();
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
function clearResidentSelection() {
|
|
905
|
+
async function onSubjectCategoryChanged() {
|
|
1324
906
|
form.subjectId = "";
|
|
1325
|
-
|
|
1326
|
-
// Name only ever mirrors a chosen resident, so it clears with the choice.
|
|
1327
|
-
if (!selectedUser.value) form.name = "";
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
// The auto-fill the whole cascade exists for.
|
|
1331
|
-
async function onResidentChanged() {
|
|
1332
|
-
const person = unitPeople.value.find(
|
|
1333
|
-
(item) => String(item._id) === String(form.subjectId),
|
|
1334
|
-
);
|
|
1335
|
-
form.name = String(person?.name ?? "");
|
|
1336
|
-
await checkResidentEnrollment();
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
/**
|
|
1340
|
-
* The HID user this resident already holds on the selected reader, or null.
|
|
1341
|
-
*
|
|
1342
|
-
* `subject`, not `person`. The same resident is stored under different ids
|
|
1343
|
-
* depending on which screen wrote the row - the permissions screen keys on
|
|
1344
|
-
* their user account, this screen on the record the picker offered - so a
|
|
1345
|
-
* filter on one field alone reports "not enrolled" for somebody who plainly is.
|
|
1346
|
-
* `subject` follows the record to its account and matches every link field,
|
|
1347
|
-
* which is exactly what the server does before it accepts an enrollment.
|
|
1348
|
-
*
|
|
1349
|
-
* Reader-scoped by the endpoint itself.
|
|
1350
|
-
*/
|
|
1351
|
-
async function findResidentIdentity(readerId: string, personId: string) {
|
|
1352
|
-
const response = await getIdentities(readerId, {
|
|
1353
|
-
page: 1,
|
|
1354
|
-
// A resident should hold at most one, but ask for a few: on the edit screen
|
|
1355
|
-
// the first row back can be the very identity being edited, and skipping it
|
|
1356
|
-
// must not hide a real second one behind it.
|
|
1357
|
-
limit: 10,
|
|
1358
|
-
subject: personId,
|
|
1359
|
-
});
|
|
1360
|
-
const responseRecord = toRecord(response);
|
|
1361
|
-
const responseData = toRecord(responseRecord.data);
|
|
1362
|
-
const responseItems =
|
|
1363
|
-
responseRecord.items ?? responseData.items ?? responseData.identities ?? [];
|
|
1364
|
-
const identities = (Array.isArray(responseItems) ? responseItems : []).map(toHidUser);
|
|
1365
|
-
const editingId = String(selectedUser.value?._id ?? "");
|
|
1366
|
-
|
|
1367
|
-
return (
|
|
1368
|
-
identities.find((identity) => !editingId || String(identity._id ?? "") !== editingId) ?? null
|
|
1369
|
-
);
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
/**
|
|
1373
|
-
* Sets `residentConflict` for the currently selected resident.
|
|
1374
|
-
*
|
|
1375
|
-
* Fails OPEN: if the lookup itself errors the operator is not blocked, because
|
|
1376
|
-
* the server refuses the duplicate anyway. This is a courtesy check that keeps
|
|
1377
|
-
* a doomed enrollment off the physical reader, not the guard itself.
|
|
1378
|
-
*/
|
|
1379
|
-
async function checkResidentEnrollment() {
|
|
1380
|
-
residentConflict.value = null;
|
|
1381
|
-
const readerId = selectedReaderId.value || form.reader || readers.value[0]?._id;
|
|
1382
|
-
if (!readerId || !form.subjectId || form.subjectCategory !== "resident") return null;
|
|
1383
|
-
|
|
1384
|
-
checkingResident.value = true;
|
|
1385
|
-
try {
|
|
1386
|
-
residentConflict.value = await findResidentIdentity(readerId, form.subjectId);
|
|
1387
|
-
return residentConflict.value;
|
|
1388
|
-
} catch (error: unknown) {
|
|
1389
|
-
console.error("Unable to check whether this resident is already enrolled:", error);
|
|
1390
|
-
return null;
|
|
1391
|
-
} finally {
|
|
1392
|
-
checkingResident.value = false;
|
|
1393
|
-
}
|
|
907
|
+
await loadSubjectCandidates();
|
|
1394
908
|
}
|
|
1395
909
|
|
|
1396
910
|
async function openEnroll() {
|
|
@@ -1402,6 +916,7 @@ async function openEnroll() {
|
|
|
1402
916
|
]);
|
|
1403
917
|
form.hidUserId = hidUserId;
|
|
1404
918
|
form.registration = registration;
|
|
919
|
+
await loadSubjectCandidates();
|
|
1405
920
|
formDialog.value = true;
|
|
1406
921
|
}
|
|
1407
922
|
|
|
@@ -1416,10 +931,6 @@ async function openEdit(user: HidUser) {
|
|
|
1416
931
|
form.registration = user.registration ?? "";
|
|
1417
932
|
form.isAdministrator = hasAdministratorRule(user);
|
|
1418
933
|
form.accessPin = "";
|
|
1419
|
-
form.password = "";
|
|
1420
|
-
showPassword.value = false;
|
|
1421
|
-
removePasswordRequested.value = false;
|
|
1422
|
-
passwordSet.value = Boolean(user.metadata?.passwordSet);
|
|
1423
934
|
pinEnrolled.value = Boolean(user.metadata?.pinEnrolled);
|
|
1424
935
|
removePinRequested.value = false;
|
|
1425
936
|
form.photoPreview = "";
|
|
@@ -1430,31 +941,17 @@ async function openEdit(user: HidUser) {
|
|
|
1430
941
|
? "service_provider"
|
|
1431
942
|
: "property_management";
|
|
1432
943
|
form.subjectId = String(user.person || user.member || user.serviceProvider || "");
|
|
1433
|
-
|
|
1434
|
-
// one only appears if the operator reassigns the row to somebody else.
|
|
1435
|
-
residentConflict.value = null;
|
|
1436
|
-
// The location is not drawn when editing, but it is still carried: these
|
|
1437
|
-
// three form fields are what `saveUser` writes back and what `buildUnitLabel`
|
|
1438
|
-
// resolves into the Unit column, so a save must not blank them.
|
|
1439
|
-
//
|
|
1440
|
-
// `ensureOccupancy` is what lets `buildUnitLabel` turn them back into names.
|
|
1441
|
-
// The unit's residents are loaded too, because the Resident select IS drawn
|
|
1442
|
-
// here and its options come from that list - without it the select shows the
|
|
1443
|
-
// stored id instead of a name.
|
|
1444
|
-
await ensureOccupancy();
|
|
1445
|
-
if (form.unit) await loadUnitPeople();
|
|
944
|
+
await loadSubjectCandidates();
|
|
1446
945
|
selectedPhotoFile.value = null;
|
|
1447
946
|
removePhotoRequested.value = false;
|
|
1448
947
|
formDialog.value = true;
|
|
1449
948
|
|
|
1450
949
|
try {
|
|
1451
|
-
const
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
pinEnrolled.value = Boolean(pinStatus?.data?.pinEnrolled);
|
|
1457
|
-
passwordSet.value = Boolean(passwordStatus?.data?.passwordSet);
|
|
950
|
+
const status = await getUserPinStatus(
|
|
951
|
+
form.reader,
|
|
952
|
+
toHidNumericId(user.hidUserId),
|
|
953
|
+
);
|
|
954
|
+
pinEnrolled.value = Boolean(status?.data?.pinEnrolled);
|
|
1458
955
|
} catch {
|
|
1459
956
|
// Preserve the last known status if the reader is temporarily offline.
|
|
1460
957
|
}
|
|
@@ -1533,28 +1030,12 @@ function onPhotoChange(event: Event) {
|
|
|
1533
1030
|
async function saveUser() {
|
|
1534
1031
|
const readerId =
|
|
1535
1032
|
selectedReaderId.value || form.reader || readers.value[0]?._id;
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
// enrolled, and changing a photo, a PIN or a password on one of those is a
|
|
1539
|
-
// reader-side operation that has nothing to say about who they are. Demanding
|
|
1540
|
-
// a resident there refuses a save for a field the dialog does not even draw.
|
|
1541
|
-
const missing = !readerId
|
|
1542
|
-
? "a reader"
|
|
1543
|
-
: !selectedUser.value && !form.subjectId
|
|
1544
|
-
? "a resident"
|
|
1545
|
-
: !form.name
|
|
1546
|
-
? "a name"
|
|
1547
|
-
: !form.hidUserId
|
|
1548
|
-
? "an ID"
|
|
1549
|
-
: !form.registration
|
|
1550
|
-
? "a registration number"
|
|
1551
|
-
: "";
|
|
1552
|
-
if (missing) {
|
|
1553
|
-
showToast(`This HID user needs ${missing} before it can be saved.`, "error");
|
|
1033
|
+
if (!readerId || !form.name || !form.hidUserId || !form.registration || !form.subjectId) {
|
|
1034
|
+
showToast("Please complete the required HID user fields.", "error");
|
|
1554
1035
|
return;
|
|
1555
1036
|
}
|
|
1556
1037
|
if (form.accessPin && !/^\d{1,32}$/.test(form.accessPin)) {
|
|
1557
|
-
showToast("PIN must contain numbers only.", "error");
|
|
1038
|
+
showToast("Access PIN must contain numbers only.", "error");
|
|
1558
1039
|
return;
|
|
1559
1040
|
}
|
|
1560
1041
|
if (selectedPhotoFile.value && (!selectedReader.value?.portalId || !selectedReader.value?.portalName)) {
|
|
@@ -1562,16 +1043,6 @@ async function saveUser() {
|
|
|
1562
1043
|
return;
|
|
1563
1044
|
}
|
|
1564
1045
|
|
|
1565
|
-
// Re-asked here, not trusted from the select: the dialog can sit open while
|
|
1566
|
-
// somebody else enrolls the same resident, and the reader is only ever
|
|
1567
|
-
// written to below this line. A duplicate caught here costs one request; the
|
|
1568
|
-
// same duplicate caught by the server costs a created HID user and a rollback.
|
|
1569
|
-
const alreadyEnrolled = await checkResidentEnrollment();
|
|
1570
|
-
if (alreadyEnrolled) {
|
|
1571
|
-
showToast(residentConflictMessage.value, "error");
|
|
1572
|
-
return;
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
1046
|
saving.value = true;
|
|
1576
1047
|
let newlyCreatedHidUserId: number | undefined;
|
|
1577
1048
|
try {
|
|
@@ -1585,33 +1056,22 @@ async function saveUser() {
|
|
|
1585
1056
|
return;
|
|
1586
1057
|
}
|
|
1587
1058
|
|
|
1588
|
-
// The link is sent only when the form actually holds one. Sending
|
|
1589
|
-
// `person: ""` is not "leave it alone", it is "clear it": the server reads
|
|
1590
|
-
// an empty string as a link being removed and then refuses the write for
|
|
1591
|
-
// having no subject at all. Omitting the keys is what makes it keep the
|
|
1592
|
-
// subject the record already has.
|
|
1593
|
-
const subjectLink = form.subjectId
|
|
1594
|
-
? {
|
|
1595
|
-
person: form.subjectCategory === "resident" ? form.subjectId : "",
|
|
1596
|
-
member: form.subjectCategory === "property_management" ? form.subjectId : "",
|
|
1597
|
-
serviceProvider: form.subjectCategory === "service_provider" ? form.subjectId : "",
|
|
1598
|
-
type: (form.subjectCategory === "resident"
|
|
1599
|
-
? "resident"
|
|
1600
|
-
: form.subjectCategory === "service_provider"
|
|
1601
|
-
? "contractor"
|
|
1602
|
-
: "staff") as
|
|
1603
|
-
| "resident"
|
|
1604
|
-
| "staff"
|
|
1605
|
-
| "contractor"
|
|
1606
|
-
| "visitor"
|
|
1607
|
-
| "unknown",
|
|
1608
|
-
}
|
|
1609
|
-
: {};
|
|
1610
|
-
|
|
1611
1059
|
const payload = {
|
|
1612
1060
|
hidUserId: String(hidUser.id),
|
|
1613
1061
|
registration: form.registration,
|
|
1614
|
-
|
|
1062
|
+
person: form.subjectCategory === "resident" ? form.subjectId : "",
|
|
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",
|
|
1615
1075
|
status: "active" as const,
|
|
1616
1076
|
metadata: {
|
|
1617
1077
|
name: form.name,
|
|
@@ -1628,7 +1088,6 @@ async function saveUser() {
|
|
|
1628
1088
|
imageTimestamp: selectedUser.value?.metadata?.imageTimestamp || "",
|
|
1629
1089
|
facialScores: selectedUser.value?.metadata?.facialScores || {},
|
|
1630
1090
|
pinEnrolled: pinEnrolled.value,
|
|
1631
|
-
passwordSet: passwordSet.value,
|
|
1632
1091
|
hidPhysicalCards: selectedUser.value?.metadata?.hidPhysicalCards || [],
|
|
1633
1092
|
},
|
|
1634
1093
|
};
|
|
@@ -1638,22 +1097,17 @@ async function saveUser() {
|
|
|
1638
1097
|
const facialResult = await syncFacialImage(readerId, hidUser.id);
|
|
1639
1098
|
applyFacialResult(payload.metadata, facialResult);
|
|
1640
1099
|
payload.metadata.pinEnrolled = await syncAccessPin(readerId, hidUser.id);
|
|
1641
|
-
payload.metadata.passwordSet = await syncPassword(readerId, hidUser.id);
|
|
1642
1100
|
if (selectedUser.value._id) {
|
|
1643
1101
|
await updateIdentity(selectedUser.value._id, payload);
|
|
1644
|
-
} else
|
|
1102
|
+
} else {
|
|
1645
1103
|
await saveIdentityOnReader(readerId, payload);
|
|
1646
1104
|
}
|
|
1647
|
-
// else: a user the reader holds and we have never linked. The photo, PIN
|
|
1648
|
-
// and password above are already on the device; creating an identity for
|
|
1649
|
-
// it would need a subject we deliberately no longer ask for here.
|
|
1650
1105
|
} else {
|
|
1651
1106
|
const created = await createHidUserOnReader(readerId, hidUser);
|
|
1652
1107
|
if (created) newlyCreatedHidUserId = hidUser.id;
|
|
1653
1108
|
const facialResult = await syncFacialImage(readerId, hidUser.id);
|
|
1654
1109
|
applyFacialResult(payload.metadata, facialResult);
|
|
1655
1110
|
payload.metadata.pinEnrolled = await syncAccessPin(readerId, hidUser.id);
|
|
1656
|
-
payload.metadata.passwordSet = await syncPassword(readerId, hidUser.id);
|
|
1657
1111
|
await saveIdentityOnReader(readerId, payload);
|
|
1658
1112
|
selectedReaderId.value = readerId;
|
|
1659
1113
|
}
|
|
@@ -1689,25 +1143,6 @@ async function saveUser() {
|
|
|
1689
1143
|
}
|
|
1690
1144
|
}
|
|
1691
1145
|
|
|
1692
|
-
async function syncPassword(readerId: string, hidUserId: number) {
|
|
1693
|
-
// Mirrors syncAccessPin. Removal wins over a typed value, and a blank field
|
|
1694
|
-
// means "leave whatever is on the reader alone" - the hash cannot be read
|
|
1695
|
-
// back, so blank can never mean "clear it".
|
|
1696
|
-
if (removePasswordRequested.value) {
|
|
1697
|
-
await deleteUserPassword(readerId, hidUserId);
|
|
1698
|
-
passwordSet.value = false;
|
|
1699
|
-
form.password = "";
|
|
1700
|
-
return false;
|
|
1701
|
-
}
|
|
1702
|
-
if (form.password) {
|
|
1703
|
-
await setUserPassword(readerId, hidUserId, form.password);
|
|
1704
|
-
form.password = "";
|
|
1705
|
-
passwordSet.value = true;
|
|
1706
|
-
return true;
|
|
1707
|
-
}
|
|
1708
|
-
return passwordSet.value;
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
1146
|
async function syncAccessPin(readerId: string, hidUserId: number) {
|
|
1712
1147
|
if (removePinRequested.value) {
|
|
1713
1148
|
await deleteUserPin(readerId, hidUserId);
|
|
@@ -1818,7 +1253,7 @@ async function saveIdentityOnReader(
|
|
|
1818
1253
|
}
|
|
1819
1254
|
|
|
1820
1255
|
try {
|
|
1821
|
-
await createIdentity(readerId, { ...payload, site: props.site
|
|
1256
|
+
await createIdentity(readerId, { ...payload, site: props.site });
|
|
1822
1257
|
} catch (error: unknown) {
|
|
1823
1258
|
const message = getHidErrorMessage(error);
|
|
1824
1259
|
if (!message.toLowerCase().includes("already exists")) throw error;
|
|
@@ -2012,21 +1447,6 @@ function toHidUserObject(identity: Pick<HidUser, "hidUserId" | "name" | "registr
|
|
|
2012
1447
|
};
|
|
2013
1448
|
}
|
|
2014
1449
|
|
|
2015
|
-
function isVisitorUser(user: HidUser) {
|
|
2016
|
-
// The reader marks visitors with `user_type_id = 1`; a real user leaves the
|
|
2017
|
-
// field null. `metadata.hidUserTypeId` is what our API forwards it as.
|
|
2018
|
-
return Number(user.metadata?.hidUserTypeId ?? user.user_type_id) === 1;
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
function isUnsupportedUserTypeFilter(error: unknown) {
|
|
2022
|
-
const record = toRecord(error);
|
|
2023
|
-
const data = toRecord(record.data);
|
|
2024
|
-
const message = toText(data.message) || toText(record.message);
|
|
2025
|
-
const normalized = message.toLowerCase();
|
|
2026
|
-
return normalized.includes("usertype")
|
|
2027
|
-
&& (normalized.includes("not allowed") || normalized.includes("unknown"));
|
|
2028
|
-
}
|
|
2029
|
-
|
|
2030
1450
|
function toHidNumericId(value: unknown) {
|
|
2031
1451
|
const raw = String(value ?? "").trim();
|
|
2032
1452
|
if (!raw) return undefined;
|
|
@@ -2165,6 +1585,38 @@ async function assignPhysicalCard() {
|
|
|
2165
1585
|
}
|
|
2166
1586
|
}
|
|
2167
1587
|
|
|
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
|
+
|
|
2168
1620
|
async function removePhysicalCard(card: HidCard) {
|
|
2169
1621
|
if (!window.confirm(`Remove physical HID card ${formatPhysicalCard(card)}?`)) return;
|
|
2170
1622
|
const { readerId, hidUserId } = getCardReaderAndUser();
|
|
@@ -2197,21 +1649,8 @@ function getPhysicalCardSubtitle(card: HidCard) {
|
|
|
2197
1649
|
}
|
|
2198
1650
|
|
|
2199
1651
|
function buildUnitLabel() {
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
// stamp "665f.../665f.../665f..." onto the record and into the Unit column.
|
|
2203
|
-
const block = occupiedBlocks.value.find((item) => String(item._id ?? "") === form.block);
|
|
2204
|
-
const level = (block?.levels ?? []).find((item) => String(item._id ?? "") === form.level);
|
|
2205
|
-
const unit = (level?.units ?? []).find((item) => String(item._id ?? "") === form.unit);
|
|
2206
|
-
const parts = [
|
|
2207
|
-
formatBlockTitle(block),
|
|
2208
|
-
String(level?.name ?? ""),
|
|
2209
|
-
String(unit?.name ?? ""),
|
|
2210
|
-
].filter(Boolean);
|
|
2211
|
-
// Editing a record enrolled before the cascade existed: keep its stored
|
|
2212
|
-
// label rather than blanking it.
|
|
2213
|
-
if (!parts.length) return String(selectedUser.value?.metadata?.unitLabel ?? "");
|
|
2214
|
-
return parts.join(" / ");
|
|
1652
|
+
const parts = [form.block, form.level, form.unit].filter(Boolean);
|
|
1653
|
+
return parts.length ? `BLK ${parts.join("/")}` : "";
|
|
2215
1654
|
}
|
|
2216
1655
|
|
|
2217
1656
|
function getName(user?: HidUser | null) {
|
|
@@ -2498,6 +1937,12 @@ function toHidCard(value: unknown): HidCard {
|
|
|
2498
1937
|
max-width: 320px;
|
|
2499
1938
|
}
|
|
2500
1939
|
|
|
1940
|
+
.small-title {
|
|
1941
|
+
font-size: 14px;
|
|
1942
|
+
font-weight: 700;
|
|
1943
|
+
color: var(--text);
|
|
1944
|
+
}
|
|
1945
|
+
|
|
2501
1946
|
/* Was `#4f5a66` / `#e53935` - the same two greys on both themes. */
|
|
2502
1947
|
.field-label {
|
|
2503
1948
|
color: var(--text2);
|
|
@@ -2519,42 +1964,12 @@ function toHidCard(value: unknown): HidCard {
|
|
|
2519
1964
|
line-height: 1.45;
|
|
2520
1965
|
}
|
|
2521
1966
|
|
|
2522
|
-
/* Same line, saying the field is refused rather than explained. `--err` is the
|
|
2523
|
-
token the required-field asterisk already uses. */
|
|
2524
|
-
.field-hint--error {
|
|
2525
|
-
color: var(--err);
|
|
2526
|
-
}
|
|
2527
|
-
|
|
2528
1967
|
.photo-wrap {
|
|
2529
1968
|
display: grid;
|
|
2530
1969
|
place-items: center;
|
|
2531
1970
|
margin-bottom: 14px;
|
|
2532
1971
|
}
|
|
2533
1972
|
|
|
2534
|
-
.photo-facial {
|
|
2535
|
-
margin: 10px 0 0;
|
|
2536
|
-
text-align: center;
|
|
2537
|
-
}
|
|
2538
|
-
|
|
2539
|
-
/* The same small muted word `.field-label` uses, so the caption reads as a
|
|
2540
|
-
field label rather than as a second heading. */
|
|
2541
|
-
.photo-facial__label {
|
|
2542
|
-
display: block;
|
|
2543
|
-
color: var(--muted);
|
|
2544
|
-
font-size: 12px;
|
|
2545
|
-
font-weight: 600;
|
|
2546
|
-
}
|
|
2547
|
-
|
|
2548
|
-
.photo-facial__value {
|
|
2549
|
-
display: block;
|
|
2550
|
-
margin-top: 2px;
|
|
2551
|
-
font-size: 13.5px;
|
|
2552
|
-
font-weight: 500;
|
|
2553
|
-
/* The reader's reference is a long unbroken number; let it wrap rather than
|
|
2554
|
-
widen the dialog. */
|
|
2555
|
-
word-break: break-all;
|
|
2556
|
-
}
|
|
2557
|
-
|
|
2558
1973
|
.photo-button {
|
|
2559
1974
|
width: 120px;
|
|
2560
1975
|
height: 120px;
|
|
@@ -2728,6 +2143,25 @@ function toHidCard(value: unknown): HidCard {
|
|
|
2728
2143
|
color: var(--muted);
|
|
2729
2144
|
}
|
|
2730
2145
|
|
|
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
|
+
|
|
2731
2165
|
@media (max-width: 960px) {
|
|
2732
2166
|
.hid-user-filters :deep(.app-field),
|
|
2733
2167
|
.hid-user-filters :deep(.app-select) {
|