@7365admin1/layer-common 4.4.2-staging.292 → 4.5.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 +33 -4
- package/components/Facility/BookingSetup.vue +0 -63
- package/components/HidIntercomManagement.vue +42 -145
- package/components/HidUserEnrollment.vue +147 -712
- package/components/InvitationClientForm.vue +1 -19
- package/components/VisitorManagement.vue +5 -267
- package/composables/useFacility.ts +0 -11
- package/composables/useHidAmico.ts +0 -24
- package/composables/useHidNavigation.ts +0 -16
- package/composables/usePeople.ts +0 -19
- package/package.json +1 -1
- package/types/facility.d.ts +0 -4
- package/utils/materialSymbols.ts +0 -3
|
@@ -166,12 +166,12 @@
|
|
|
166
166
|
</TableMain>
|
|
167
167
|
|
|
168
168
|
<v-dialog v-model="formDialog" max-width="420" persistent>
|
|
169
|
-
<v-card
|
|
170
|
-
<v-card-title>
|
|
169
|
+
<v-card rounded="lg">
|
|
170
|
+
<v-card-title class="small-title">
|
|
171
171
|
{{ selectedUser ? "Edit User Information" : "Enroll" }}
|
|
172
172
|
</v-card-title>
|
|
173
173
|
|
|
174
|
-
<v-card-text
|
|
174
|
+
<v-card-text>
|
|
175
175
|
<div class="photo-wrap">
|
|
176
176
|
<v-menu>
|
|
177
177
|
<template #activator="{ props: menuProps }">
|
|
@@ -213,15 +213,6 @@
|
|
|
213
213
|
/>
|
|
214
214
|
</v-list>
|
|
215
215
|
</v-menu>
|
|
216
|
-
<!-- Sits under the button because it describes what the button
|
|
217
|
-
is reporting: the reader holds a face, and this is its
|
|
218
|
-
reference. Nothing to show while enrolling - the value does not
|
|
219
|
-
exist until the reader has accepted a photo. -->
|
|
220
|
-
<p v-if="editFacialData" class="photo-facial">
|
|
221
|
-
<span class="photo-facial__label">Facial Data</span>
|
|
222
|
-
<span class="photo-facial__value">{{ editFacialData }}</span>
|
|
223
|
-
</p>
|
|
224
|
-
|
|
225
216
|
<input
|
|
226
217
|
ref="photoInput"
|
|
227
218
|
type="file"
|
|
@@ -231,96 +222,29 @@
|
|
|
231
222
|
/>
|
|
232
223
|
</div>
|
|
233
224
|
|
|
234
|
-
|
|
235
|
-
Enrollment is resident-only and the resident must already exist
|
|
236
|
-
in iService365 - you pick a person, you do not type one. Name is
|
|
237
|
-
therefore a mirror of that record, never an input, so the reader
|
|
238
|
-
can never end up holding a name the app does not know.
|
|
239
|
-
Every option is derived from the residents themselves, so a
|
|
240
|
-
block, level or unit only appears when somebody lives there.
|
|
241
|
-
The list loads on first touch of Block, not on dialog open.
|
|
242
|
-
Enrolment only, with no exception. Editing does not move
|
|
243
|
-
anybody: the record already carries its block, level and unit,
|
|
244
|
-
`openEdit` loads them into the form and `saveUser` writes them
|
|
245
|
-
back untouched, so the location survives an edit without being
|
|
246
|
-
asked for. A row that never had one keeps not having one; that
|
|
247
|
-
is not a reason to make somebody fill in a location before they
|
|
248
|
-
can change a PIN. -->
|
|
249
|
-
<template v-if="!selectedUser">
|
|
250
|
-
<div class="field-label">Block <span>*</span></div>
|
|
251
|
-
<!-- The listener sits on a wrapper, NOT on AppSelect: AppSelect
|
|
252
|
-
spreads `$attrs` over its v-menu activator AFTER the activator's
|
|
253
|
-
own bindings, so an `@click` here would replace the handler that
|
|
254
|
-
opens the dropdown. `focusin` covers keyboard users, and both
|
|
255
|
-
are idempotent - `ensureOccupancy()` fetches once.
|
|
256
|
-
AppSelect has no `loading` prop either; the placeholder carries
|
|
257
|
-
the loading and empty states instead. -->
|
|
258
|
-
<div @click="onBlockOpened" @focusin="onBlockOpened">
|
|
259
|
-
<AppSelect
|
|
260
|
-
v-model="form.block"
|
|
261
|
-
:items="blockOptions"
|
|
262
|
-
:placeholder="blockPlaceholder"
|
|
263
|
-
klass="mb-3"
|
|
264
|
-
@update:model-value="onBlockChanged"
|
|
265
|
-
/>
|
|
266
|
-
</div>
|
|
267
|
-
|
|
268
|
-
<div class="field-label">Level <span>*</span></div>
|
|
269
|
-
<AppSelect
|
|
270
|
-
v-model="form.level"
|
|
271
|
-
:items="levelOptions"
|
|
272
|
-
:disabled="!form.block"
|
|
273
|
-
placeholder="Select level"
|
|
274
|
-
klass="mb-3"
|
|
275
|
-
@update:model-value="onLevelChanged"
|
|
276
|
-
/>
|
|
277
|
-
|
|
278
|
-
<div class="field-label">Unit <span>*</span></div>
|
|
279
|
-
<AppSelect
|
|
280
|
-
v-model="form.unit"
|
|
281
|
-
:items="unitOptions"
|
|
282
|
-
:disabled="!form.level"
|
|
283
|
-
placeholder="Select unit"
|
|
284
|
-
klass="mb-3"
|
|
285
|
-
@update:model-value="onUnitChanged"
|
|
286
|
-
/>
|
|
287
|
-
</template>
|
|
288
|
-
|
|
289
|
-
<!-- Drawn only where it can offer something: while enrolling, or
|
|
290
|
-
while editing a record whose stored unit gives it a list. A row
|
|
291
|
-
with no unit has no candidates to show, and the dialog is then
|
|
292
|
-
purely the reader's own credentials - photo, PIN, password -
|
|
293
|
-
which is exactly the edit that must not be blocked. -->
|
|
294
|
-
<template v-if="!selectedUser || form.unit">
|
|
295
|
-
<div class="field-label">Resident <span>*</span></div>
|
|
296
|
-
<AppSelect
|
|
297
|
-
v-model="form.subjectId"
|
|
298
|
-
:items="subjectOptions"
|
|
299
|
-
:disabled="!form.unit"
|
|
300
|
-
:placeholder="unitResidentPlaceholder"
|
|
301
|
-
klass="mb-3"
|
|
302
|
-
@update:model-value="onResidentChanged"
|
|
303
|
-
/>
|
|
304
|
-
</template>
|
|
305
|
-
<!-- The duplicate check. It is reader-scoped: this resident holding a
|
|
306
|
-
HID user on another gate is normal and says nothing here. -->
|
|
307
|
-
<p v-if="checkingResident" class="field-hint">Checking enrollment...</p>
|
|
308
|
-
<p v-else-if="residentConflict" class="field-hint field-hint--error mb-3">
|
|
309
|
-
{{ residentConflictMessage }}
|
|
310
|
-
</p>
|
|
311
|
-
<p v-else-if="unitResidentNote" class="field-hint mb-3">
|
|
312
|
-
{{ unitResidentNote }}
|
|
313
|
-
</p>
|
|
314
|
-
|
|
315
|
-
<!-- Read-only: it restates the chosen resident, it does not collect
|
|
316
|
-
anything. `selectedUser` is the edit case, where the name is
|
|
317
|
-
whatever the reader already holds. -->
|
|
318
|
-
<div class="field-label">Name</div>
|
|
225
|
+
<div class="field-label">Name <span>*</span></div>
|
|
319
226
|
<AppField
|
|
320
227
|
v-model="form.name"
|
|
321
228
|
aria-label="Name"
|
|
322
|
-
placeholder="
|
|
323
|
-
|
|
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"
|
|
324
248
|
klass="mb-3"
|
|
325
249
|
/>
|
|
326
250
|
|
|
@@ -332,11 +256,11 @@
|
|
|
332
256
|
v-model="form.registration"
|
|
333
257
|
aria-label="Registration No."
|
|
334
258
|
placeholder="Enter registration no."
|
|
335
|
-
readonly
|
|
259
|
+
:readonly="!selectedUser"
|
|
336
260
|
klass="mb-3"
|
|
337
261
|
/>
|
|
338
262
|
|
|
339
|
-
<div class="field-label">PIN (optional)</div>
|
|
263
|
+
<div class="field-label">Access PIN (optional)</div>
|
|
340
264
|
<!--
|
|
341
265
|
The handoff draws no password field anywhere (the sign-in screens
|
|
342
266
|
are the owner's own), so the reveal toggle is this product's, not
|
|
@@ -346,8 +270,8 @@
|
|
|
346
270
|
-->
|
|
347
271
|
<AppField
|
|
348
272
|
v-model="form.accessPin"
|
|
349
|
-
aria-label="PIN"
|
|
350
|
-
placeholder="Enter
|
|
273
|
+
aria-label="Access PIN"
|
|
274
|
+
placeholder="Enter numeric access PIN"
|
|
351
275
|
inputmode="numeric"
|
|
352
276
|
autocomplete="new-password"
|
|
353
277
|
:type="showPin ? 'text' : 'password'"
|
|
@@ -356,7 +280,7 @@
|
|
|
356
280
|
<button
|
|
357
281
|
type="button"
|
|
358
282
|
class="app-field__trailing"
|
|
359
|
-
:aria-label="showPin ? 'Hide PIN' : 'Show PIN'"
|
|
283
|
+
:aria-label="showPin ? 'Hide access PIN' : 'Show access PIN'"
|
|
360
284
|
@click="showPin = !showPin"
|
|
361
285
|
>
|
|
362
286
|
<v-icon :icon="showPin ? 'mdi-eye-off' : 'mdi-eye'" size="18" />
|
|
@@ -371,62 +295,28 @@
|
|
|
371
295
|
<v-checkbox
|
|
372
296
|
v-if="selectedUser && pinEnrolled"
|
|
373
297
|
v-model="removePinRequested"
|
|
374
|
-
label="Remove current PIN"
|
|
375
|
-
density="compact"
|
|
376
|
-
hide-details
|
|
377
|
-
/>
|
|
378
|
-
|
|
379
|
-
<!-- Password: the reader stores only a hash plus its salt, so there
|
|
380
|
-
is nothing to read back and the field is always empty on open.
|
|
381
|
-
Same reveal toggle as the PIN above. -->
|
|
382
|
-
<div class="field-label mt-3">Password (optional)</div>
|
|
383
|
-
<AppField
|
|
384
|
-
v-model="form.password"
|
|
385
|
-
aria-label="Password"
|
|
386
|
-
:placeholder="selectedUser && passwordSet ? 'Enter a new password' : 'Enter password'"
|
|
387
|
-
autocomplete="new-password"
|
|
388
|
-
:type="showPassword ? 'text' : 'password'"
|
|
389
|
-
>
|
|
390
|
-
<template #trailing>
|
|
391
|
-
<button
|
|
392
|
-
type="button"
|
|
393
|
-
class="app-field__trailing"
|
|
394
|
-
:aria-label="showPassword ? 'Hide password' : 'Show password'"
|
|
395
|
-
@click="showPassword = !showPassword"
|
|
396
|
-
>
|
|
397
|
-
<v-icon :icon="showPassword ? 'mdi-eye-off' : 'mdi-eye'" size="18" />
|
|
398
|
-
</button>
|
|
399
|
-
</template>
|
|
400
|
-
</AppField>
|
|
401
|
-
<p class="field-hint">
|
|
402
|
-
{{ selectedUser && passwordSet ? "A password is set. Leave blank to keep it." : "Used with the user ID on the reader keypad." }}
|
|
403
|
-
</p>
|
|
404
|
-
<v-checkbox
|
|
405
|
-
v-if="selectedUser && passwordSet"
|
|
406
|
-
v-model="removePasswordRequested"
|
|
407
|
-
label="Remove current password"
|
|
298
|
+
label="Remove current access PIN"
|
|
408
299
|
density="compact"
|
|
409
300
|
hide-details
|
|
410
301
|
/>
|
|
411
302
|
</v-card-text>
|
|
412
303
|
|
|
413
|
-
<!-- The
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
<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">
|
|
418
308
|
<v-btn
|
|
419
|
-
class="text-none
|
|
309
|
+
class="text-none action-cancel"
|
|
420
310
|
variant="flat"
|
|
311
|
+
height="44"
|
|
421
312
|
@click="formDialog = false"
|
|
313
|
+
>Cancel</v-btn
|
|
422
314
|
>
|
|
423
|
-
Cancel
|
|
424
|
-
</v-btn>
|
|
425
315
|
<v-btn
|
|
426
|
-
class="text-none
|
|
316
|
+
class="text-none action-submit"
|
|
427
317
|
variant="flat"
|
|
318
|
+
height="44"
|
|
428
319
|
:loading="saving"
|
|
429
|
-
:disabled="Boolean(residentConflict) || checkingResident"
|
|
430
320
|
@click="saveUser"
|
|
431
321
|
>
|
|
432
322
|
Save
|
|
@@ -438,9 +328,9 @@
|
|
|
438
328
|
<HidCameraCaptureDialog v-model="cameraDialog" @capture="onCameraCapture" />
|
|
439
329
|
|
|
440
330
|
<v-dialog v-model="viewDialog" max-width="430">
|
|
441
|
-
<v-card
|
|
442
|
-
<v-card-title>User Information</v-card-title>
|
|
443
|
-
<v-card-text
|
|
331
|
+
<v-card rounded="lg">
|
|
332
|
+
<v-card-title class="small-title">User Information</v-card-title>
|
|
333
|
+
<v-card-text>
|
|
444
334
|
<div class="detail-grid">
|
|
445
335
|
<span>Name</span><strong>{{ getName(selectedUser) }}</strong>
|
|
446
336
|
<span>User ID</span
|
|
@@ -457,22 +347,21 @@
|
|
|
457
347
|
><strong>{{
|
|
458
348
|
selectedUser ? getMappingStatus(selectedUser) : "N/A"
|
|
459
349
|
}}</strong>
|
|
460
|
-
<span>PIN</span
|
|
350
|
+
<span>Access PIN</span
|
|
461
351
|
><strong>{{ selectedUser?.metadata?.pinEnrolled ? "Configured" : "N/A" }}</strong>
|
|
462
|
-
<span>Password</span
|
|
463
|
-
><strong>{{ selectedUser?.metadata?.passwordSet ? "Configured" : "N/A" }}</strong>
|
|
464
352
|
</div>
|
|
465
353
|
</v-card-text>
|
|
466
|
-
<v-card-actions
|
|
354
|
+
<v-card-actions>
|
|
355
|
+
<v-spacer />
|
|
467
356
|
<AppButton variant="ghost" @click="viewDialog = false">Close</AppButton>
|
|
468
357
|
</v-card-actions>
|
|
469
358
|
</v-card>
|
|
470
359
|
</v-dialog>
|
|
471
360
|
|
|
472
361
|
<v-dialog v-model="cardDialog" max-width="560" persistent>
|
|
473
|
-
<v-card
|
|
474
|
-
<v-card-title>Physical HID Cards</v-card-title>
|
|
475
|
-
<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>
|
|
476
365
|
<p class="hid-card-user">
|
|
477
366
|
{{ getName(cardUser) }}
|
|
478
367
|
<span>{{ cardUser ? formatHidUid(cardUser.hidUserId) : "" }}</span>
|
|
@@ -587,7 +476,8 @@
|
|
|
587
476
|
</AppButton>
|
|
588
477
|
</div>
|
|
589
478
|
</v-card-text>
|
|
590
|
-
<v-card-actions
|
|
479
|
+
<v-card-actions>
|
|
480
|
+
<v-spacer />
|
|
591
481
|
<AppButton variant="ghost" :disabled="enrollingCard" @click="cardDialog = false">
|
|
592
482
|
Close
|
|
593
483
|
</AppButton>
|
|
@@ -596,31 +486,31 @@
|
|
|
596
486
|
</v-dialog>
|
|
597
487
|
|
|
598
488
|
<v-dialog v-model="deleteDialog" max-width="360" persistent>
|
|
599
|
-
<v-card
|
|
600
|
-
<v-card-title>Delete</v-card-title>
|
|
601
|
-
<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">
|
|
602
492
|
Are you sure you want to permanently delete this HID user?
|
|
603
493
|
<div class="text-caption text-medium-emphasis mt-2">
|
|
604
494
|
This action will remove the user from the HID reader and mark the
|
|
605
495
|
identity as deleted.
|
|
606
496
|
</div>
|
|
607
497
|
</v-card-text>
|
|
608
|
-
<v-card-actions class="
|
|
498
|
+
<v-card-actions class="pa-0">
|
|
609
499
|
<v-btn
|
|
610
|
-
class="text-none
|
|
500
|
+
class="text-none action-cancel"
|
|
611
501
|
variant="flat"
|
|
502
|
+
height="44"
|
|
612
503
|
@click="deleteDialog = false"
|
|
504
|
+
>Cancel</v-btn
|
|
613
505
|
>
|
|
614
|
-
Cancel
|
|
615
|
-
</v-btn>
|
|
616
506
|
<v-btn
|
|
617
|
-
class="text-none
|
|
507
|
+
class="text-none action-submit"
|
|
618
508
|
variant="flat"
|
|
509
|
+
height="44"
|
|
619
510
|
:loading="deleting"
|
|
620
511
|
@click="deleteUser"
|
|
512
|
+
>Delete</v-btn
|
|
621
513
|
>
|
|
622
|
-
Delete
|
|
623
|
-
</v-btn>
|
|
624
514
|
</v-card-actions>
|
|
625
515
|
</v-card>
|
|
626
516
|
</v-dialog>
|
|
@@ -657,13 +547,11 @@ const {
|
|
|
657
547
|
getUserPinStatus,
|
|
658
548
|
setUserPin,
|
|
659
549
|
deleteUserPin,
|
|
660
|
-
getUserPasswordStatus,
|
|
661
|
-
setUserPassword,
|
|
662
|
-
deleteUserPassword,
|
|
663
550
|
runObjectOperation,
|
|
664
551
|
createIdentity,
|
|
665
552
|
updateIdentity,
|
|
666
553
|
deleteIdentity,
|
|
554
|
+
getPermissionCandidates,
|
|
667
555
|
} = useHidAmico();
|
|
668
556
|
|
|
669
557
|
type HidMetadata = Record<string, unknown> & {
|
|
@@ -678,7 +566,6 @@ type HidMetadata = Record<string, unknown> & {
|
|
|
678
566
|
lastAccessAt?: string;
|
|
679
567
|
facialScores?: Record<string, unknown>;
|
|
680
568
|
pinEnrolled?: boolean;
|
|
681
|
-
passwordSet?: boolean;
|
|
682
569
|
hidPhysicalCards?: HidCard[];
|
|
683
570
|
};
|
|
684
571
|
|
|
@@ -774,61 +661,13 @@ function hasFacialEnrollment(user?: HidUser | null) {
|
|
|
774
661
|
user?.metadata?.imageTimestamp
|
|
775
662
|
);
|
|
776
663
|
}
|
|
777
|
-
|
|
778
|
-
/**
|
|
779
|
-
* The reader's own reference for the enrolled face, shown while editing.
|
|
780
|
-
*
|
|
781
|
-
* We hold neither the image nor the biometric template - the reader does - so
|
|
782
|
-
* this value is the only handle on the enrollment there is. `getFacialData` is
|
|
783
|
-
* the roster's Facial Data column, reused here so the dialog and the table
|
|
784
|
-
* cannot disagree; it answers "N/A" when there is nothing, which is the case
|
|
785
|
-
* this must not draw a row for.
|
|
786
|
-
*/
|
|
787
|
-
const editFacialData = computed(() => {
|
|
788
|
-
if (!selectedUser.value) return "";
|
|
789
|
-
const value = String(getFacialData(selectedUser.value) ?? "").trim();
|
|
790
|
-
return value && value !== "N/A" ? value : "";
|
|
791
|
-
});
|
|
792
664
|
const removePinRequested = ref(false);
|
|
793
|
-
const passwordSet = ref(false);
|
|
794
|
-
const showPassword = ref(false);
|
|
795
|
-
const removePasswordRequested = ref(false);
|
|
796
665
|
const snackbar = reactive({
|
|
797
666
|
show: false,
|
|
798
667
|
color: "success",
|
|
799
668
|
message: "",
|
|
800
669
|
});
|
|
801
670
|
|
|
802
|
-
type OccupiedUnit = { _id: string; name: string; people: number };
|
|
803
|
-
type OccupiedLevel = { _id: string; name: string; units?: OccupiedUnit[] };
|
|
804
|
-
type OccupiedBlock = {
|
|
805
|
-
_id: string;
|
|
806
|
-
name: string;
|
|
807
|
-
block: number | null;
|
|
808
|
-
levels?: OccupiedLevel[];
|
|
809
|
-
};
|
|
810
|
-
type UnitPerson = {
|
|
811
|
-
_id: string;
|
|
812
|
-
name?: string;
|
|
813
|
-
unitName?: string;
|
|
814
|
-
/**
|
|
815
|
-
* The resident's app account, and the reason this field is read here.
|
|
816
|
-
*
|
|
817
|
-
* A HID identity is refused unless its subject is a valid permission subject
|
|
818
|
-
* at the site, and for a resident that means a `site.people` row WITH a
|
|
819
|
-
* linked user - `assertPermissionSubject` in `iservice365-core` filters on
|
|
820
|
-
* exactly this field. The permission model has no way to represent anyone
|
|
821
|
-
* else: `resolvePermissionUserBindings` binds reader access by user id and
|
|
822
|
-
* drops every row without one, so a resident enrolled without an account
|
|
823
|
-
* would end up on the reader holding no access rules at all.
|
|
824
|
-
*
|
|
825
|
-
* The picker this replaced was fed by that same server-side function, so it
|
|
826
|
-
* could never offer an unenrollable resident. The unit cascade asks People
|
|
827
|
-
* Management instead, which has no such filter - hence this one.
|
|
828
|
-
*/
|
|
829
|
-
user?: string | null;
|
|
830
|
-
};
|
|
831
|
-
|
|
832
671
|
const form = reactive({
|
|
833
672
|
reader: "",
|
|
834
673
|
block: "",
|
|
@@ -839,7 +678,6 @@ const form = reactive({
|
|
|
839
678
|
registration: "",
|
|
840
679
|
isAdministrator: false,
|
|
841
680
|
accessPin: "",
|
|
842
|
-
password: "",
|
|
843
681
|
photoPreview: "",
|
|
844
682
|
subjectCategory: "resident" as THidPermissionCategory,
|
|
845
683
|
subjectId: "",
|
|
@@ -847,131 +685,18 @@ const form = reactive({
|
|
|
847
685
|
|
|
848
686
|
const route = useRoute();
|
|
849
687
|
const orgId = computed(() => String(route.params.org || ""));
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
const
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
// it offers and the people this returns are the same set. Asking the two
|
|
861
|
-
// halves different questions is how a unit ends up offered but empty.
|
|
862
|
-
const OCCUPANT_TYPES = "resident,tenant";
|
|
863
|
-
|
|
864
|
-
const occupiedBlocks = ref<OccupiedBlock[]>([]);
|
|
865
|
-
const occupancyLoaded = ref(false);
|
|
866
|
-
const loadingOccupancy = ref(false);
|
|
867
|
-
const unitPeople = ref<UnitPerson[]>([]);
|
|
868
|
-
const loadingUnitPeople = ref(false);
|
|
869
|
-
|
|
870
|
-
// "Is this resident already enrolled on THIS reader?" - the reader keeps its own
|
|
871
|
-
// user table, so the same person at a different gate is normal and does not
|
|
872
|
-
// count. Held here rather than derived, because it is the answer to a request.
|
|
873
|
-
//
|
|
874
|
-
// The server refuses the duplicate as well (`createIdentity` in
|
|
875
|
-
// `iservice365-core`), but by the time it answers, `saveUser` has already
|
|
876
|
-
// created a user on the physical device and has to roll it back. Asking here
|
|
877
|
-
// keeps that off the reader entirely.
|
|
878
|
-
const residentConflict = ref<HidUser | null>(null);
|
|
879
|
-
const checkingResident = ref(false);
|
|
880
|
-
|
|
881
|
-
// One spelling of a block, used by the picker and by the label stamped onto the
|
|
882
|
-
// record. Two copies of this expression is how the dropdown and the Unit column
|
|
883
|
-
// drift apart.
|
|
884
|
-
function formatBlockTitle(block?: OccupiedBlock | null) {
|
|
885
|
-
if (!block) return "";
|
|
886
|
-
return block.name
|
|
887
|
-
? `Block ${block.block} (${block.name})`
|
|
888
|
-
: `Block ${block.block ?? ""}`.trim();
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
const blockOptions = computed(() => occupiedBlocks.value.map((block) => ({
|
|
892
|
-
title: formatBlockTitle(block),
|
|
893
|
-
value: String(block._id ?? ""),
|
|
894
|
-
})));
|
|
895
|
-
|
|
896
|
-
const levelOptions = computed(() => {
|
|
897
|
-
const block = occupiedBlocks.value.find((item) => String(item._id ?? "") === form.block);
|
|
898
|
-
return (block?.levels ?? []).map((level) => ({
|
|
899
|
-
title: String(level.name ?? ""),
|
|
900
|
-
value: String(level._id ?? ""),
|
|
901
|
-
}));
|
|
902
|
-
});
|
|
903
|
-
|
|
904
|
-
const unitOptions = computed(() => {
|
|
905
|
-
const block = occupiedBlocks.value.find((item) => String(item._id ?? "") === form.block);
|
|
906
|
-
const level = (block?.levels ?? []).find((item) => String(item._id ?? "") === form.level);
|
|
907
|
-
return (level?.units ?? []).map((unit) => ({
|
|
908
|
-
title: String(unit.name ?? ""),
|
|
909
|
-
value: String(unit._id ?? ""),
|
|
910
|
-
}));
|
|
911
|
-
});
|
|
912
|
-
|
|
913
|
-
// Only the residents the server will actually accept - see `UnitPerson.user`.
|
|
914
|
-
// Offering the rest produced "The linked HID identity subject is not active at
|
|
915
|
-
// this site." at the very end of enrollment, after a user had already been
|
|
916
|
-
// written to the reader.
|
|
917
|
-
const enrollableUnitPeople = computed(() =>
|
|
918
|
-
unitPeople.value.filter((person) => Boolean(person.user)),
|
|
919
|
-
);
|
|
920
|
-
|
|
921
|
-
const unenrollableUnitPeopleCount = computed(
|
|
922
|
-
() => unitPeople.value.length - enrollableUnitPeople.value.length,
|
|
923
|
-
);
|
|
924
|
-
|
|
925
|
-
// `_id` here is `site.people._id`, which is exactly the `person` that
|
|
926
|
-
// `createIdentity` maps a HID user to.
|
|
927
|
-
const subjectOptions = computed(() => enrollableUnitPeople.value.map((person) => ({
|
|
928
|
-
title: String(person.name ?? "Resident"),
|
|
929
|
-
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,
|
|
930
698
|
})));
|
|
931
699
|
|
|
932
|
-
// Says why somebody the operator can see in People Management is missing here.
|
|
933
|
-
// Without it the unit just looks empty and the screen looks broken.
|
|
934
|
-
const unitResidentNote = computed(() => {
|
|
935
|
-
if (!form.unit || loadingUnitPeople.value || !unenrollableUnitPeopleCount.value) return "";
|
|
936
|
-
const count = unenrollableUnitPeopleCount.value;
|
|
937
|
-
const subject = count === 1 ? "1 resident" : `${count} residents`;
|
|
938
|
-
const verb = count === 1 ? "is" : "are";
|
|
939
|
-
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.`;
|
|
940
|
-
});
|
|
941
|
-
|
|
942
|
-
const blockPlaceholder = computed(() => {
|
|
943
|
-
if (loadingOccupancy.value) return "Loading...";
|
|
944
|
-
if (occupancyLoaded.value && !blockOptions.value.length) {
|
|
945
|
-
return "No occupied units at this site";
|
|
946
|
-
}
|
|
947
|
-
return "Select block";
|
|
948
|
-
});
|
|
949
|
-
|
|
950
|
-
const unitResidentPlaceholder = computed(() => {
|
|
951
|
-
if (!form.unit) return "Select a unit first";
|
|
952
|
-
if (loadingUnitPeople.value) return "Loading residents...";
|
|
953
|
-
if (enrollableUnitPeople.value.length) return "Select a resident";
|
|
954
|
-
// The two empty cases are different problems with different fixes, so they
|
|
955
|
-
// do not share a sentence: nobody lives here, versus nobody here can be
|
|
956
|
-
// enrolled yet. `unitResidentNote` carries the detail for the second.
|
|
957
|
-
return unitPeople.value.length
|
|
958
|
-
? "No resident here can be enrolled yet"
|
|
959
|
-
: "No residents in this unit";
|
|
960
|
-
});
|
|
961
|
-
|
|
962
|
-
// Names the HID user that is in the way, so the operator can go and edit it
|
|
963
|
-
// rather than being told only that something is wrong.
|
|
964
|
-
const residentConflictMessage = computed(() => {
|
|
965
|
-
const conflict = residentConflict.value;
|
|
966
|
-
if (!conflict) return "";
|
|
967
|
-
const label = [getName(conflict), formatHidUid(conflict.hidUserId)]
|
|
968
|
-
.filter(Boolean)
|
|
969
|
-
.join(" · ");
|
|
970
|
-
return label
|
|
971
|
-
? `Already enrolled on this reader as ${label}. Edit that HID user instead of enrolling again.`
|
|
972
|
-
: "Already enrolled on this reader. Edit that HID user instead of enrolling again.";
|
|
973
|
-
});
|
|
974
|
-
|
|
975
700
|
const cardForm = reactive({
|
|
976
701
|
cardType: "pacs" as "pacs" | "csn",
|
|
977
702
|
facilityCode: "",
|
|
@@ -1096,49 +821,16 @@ async function loadUsers() {
|
|
|
1096
821
|
|
|
1097
822
|
loading.value = true;
|
|
1098
823
|
try {
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
// with each one. This screen enrolls and edits real people; visitors are
|
|
1106
|
-
// owned by the visitor module.
|
|
1107
|
-
let clientFiltersVisitors = false;
|
|
1108
|
-
let response: unknown;
|
|
1109
|
-
try {
|
|
1110
|
-
response = await getReaderUsers(selectedReaderId.value, {
|
|
1111
|
-
page: page.value,
|
|
1112
|
-
limit: limit.value,
|
|
1113
|
-
search: search.value.trim(),
|
|
1114
|
-
status: status.value.toLowerCase() as "mapped" | "unmapped" | "",
|
|
1115
|
-
userType: "user",
|
|
1116
|
-
});
|
|
1117
|
-
} catch (error: unknown) {
|
|
1118
|
-
if (!isUnsupportedUserTypeFilter(error)) throw error;
|
|
1119
|
-
|
|
1120
|
-
// A deployed API can lag behind this shared layer. Keep the roster
|
|
1121
|
-
// correct on one that has not added `userType` yet, the same way
|
|
1122
|
-
// HidReaderUserRoster does, rather than failing the whole screen.
|
|
1123
|
-
clientFiltersVisitors = true;
|
|
1124
|
-
response = await getReaderUsers(selectedReaderId.value, {
|
|
1125
|
-
page: 1,
|
|
1126
|
-
limit: 100,
|
|
1127
|
-
search: search.value.trim(),
|
|
1128
|
-
status: status.value.toLowerCase() as "mapped" | "unmapped" | "",
|
|
1129
|
-
});
|
|
1130
|
-
}
|
|
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
|
+
});
|
|
1131
830
|
const responseRecord = toRecord(response);
|
|
1132
831
|
const responseData = toRecord(responseRecord.data);
|
|
1133
832
|
const responseItems = responseRecord.items ?? responseData.items ?? [];
|
|
1134
|
-
const
|
|
1135
|
-
const matchingItems = clientFiltersVisitors
|
|
1136
|
-
? allItems.filter((user) => !isVisitorUser(user))
|
|
1137
|
-
: allItems;
|
|
1138
|
-
const pageStart = (page.value - 1) * limit.value;
|
|
1139
|
-
const pageItems = clientFiltersVisitors
|
|
1140
|
-
? matchingItems.slice(pageStart, pageStart + limit.value)
|
|
1141
|
-
: matchingItems;
|
|
833
|
+
const pageItems = (Array.isArray(responseItems) ? responseItems : []).map(toHidUser);
|
|
1142
834
|
administratorUserIds.value = new Set(
|
|
1143
835
|
pageItems
|
|
1144
836
|
.filter((user) => user.isAdministrator === true)
|
|
@@ -1146,17 +838,9 @@ async function loadUsers() {
|
|
|
1146
838
|
.filter((userId: number | undefined): userId is number => Boolean(userId)),
|
|
1147
839
|
);
|
|
1148
840
|
users.value = pageItems;
|
|
1149
|
-
total.value =
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
pages.value = clientFiltersVisitors
|
|
1153
|
-
? Math.max(1, Math.ceil(total.value / limit.value))
|
|
1154
|
-
: Number(responseRecord.pages ?? responseData.pages ?? 1);
|
|
1155
|
-
// The server's `pageRange` counts the unfiltered page, so it cannot be
|
|
1156
|
-
// trusted once this screen has done the filtering itself.
|
|
1157
|
-
serverPageRange.value = clientFiltersVisitors
|
|
1158
|
-
? ""
|
|
1159
|
-
: 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 ?? "");
|
|
1160
844
|
if (props.cardManagement) {
|
|
1161
845
|
await loadVisibleUserCards(users.value);
|
|
1162
846
|
}
|
|
@@ -1186,10 +870,6 @@ function resetForm() {
|
|
|
1186
870
|
form.registration = "";
|
|
1187
871
|
form.isAdministrator = false;
|
|
1188
872
|
form.accessPin = "";
|
|
1189
|
-
form.password = "";
|
|
1190
|
-
passwordSet.value = false;
|
|
1191
|
-
showPassword.value = false;
|
|
1192
|
-
removePasswordRequested.value = false;
|
|
1193
873
|
pinEnrolled.value = false;
|
|
1194
874
|
showPin.value = false;
|
|
1195
875
|
removePinRequested.value = false;
|
|
@@ -1199,165 +879,32 @@ function resetForm() {
|
|
|
1199
879
|
facialEnrolled.value = false;
|
|
1200
880
|
form.subjectCategory = "resident";
|
|
1201
881
|
form.subjectId = "";
|
|
1202
|
-
residentConflict.value = null;
|
|
1203
|
-
checkingResident.value = false;
|
|
1204
882
|
}
|
|
1205
883
|
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
const data = toRecord(record.data);
|
|
1212
|
-
return toText(data.message) || toText(record.message) || toText(record.statusMessage);
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
// Called when the Block select is first touched, not when the dialog opens.
|
|
1216
|
-
async function ensureOccupancy() {
|
|
1217
|
-
if (!props.site || occupancyLoaded.value || loadingOccupancy.value) return;
|
|
1218
|
-
loadingOccupancy.value = true;
|
|
1219
|
-
try {
|
|
1220
|
-
const response = toRecord(await getOccupiedStructure(props.site, {
|
|
1221
|
-
type: OCCUPANT_TYPES,
|
|
1222
|
-
status: "active",
|
|
1223
|
-
}));
|
|
1224
|
-
const data = toRecord(response.data);
|
|
1225
|
-
const blocks = response.blocks ?? data.blocks ?? [];
|
|
1226
|
-
occupiedBlocks.value = (Array.isArray(blocks) ? blocks : []) as OccupiedBlock[];
|
|
1227
|
-
occupancyLoaded.value = true;
|
|
1228
|
-
} catch (error: unknown) {
|
|
1229
|
-
console.error("Unable to load occupied units:", error);
|
|
1230
|
-
occupiedBlocks.value = [];
|
|
1231
|
-
const reason = apiReason(error);
|
|
1232
|
-
showToast(
|
|
1233
|
-
reason ? `Unable to load units: ${reason}` : "Unable to load units for this site.",
|
|
1234
|
-
"error",
|
|
1235
|
-
);
|
|
1236
|
-
} finally {
|
|
1237
|
-
loadingOccupancy.value = false;
|
|
884
|
+
async function loadSubjectCandidates() {
|
|
885
|
+
const readerId = form.reader || selectedReaderId.value;
|
|
886
|
+
if (!readerId || !orgId.value) {
|
|
887
|
+
permissionCandidates.value = [];
|
|
888
|
+
return;
|
|
1238
889
|
}
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
async function loadUnitPeople() {
|
|
1242
|
-
unitPeople.value = [];
|
|
1243
|
-
if (!form.unit) return;
|
|
1244
|
-
loadingUnitPeople.value = true;
|
|
890
|
+
loadingSubjects.value = true;
|
|
1245
891
|
try {
|
|
1246
|
-
const response = await
|
|
1247
|
-
|
|
1248
|
-
|
|
892
|
+
const response = await getPermissionCandidates(props.site, {
|
|
893
|
+
orgId: orgId.value,
|
|
894
|
+
readerId,
|
|
895
|
+
category: form.subjectCategory,
|
|
896
|
+
page: 1,
|
|
897
|
+
limit: 500,
|
|
1249
898
|
});
|
|
1250
|
-
|
|
1251
|
-
const rows = Array.isArray(response)
|
|
1252
|
-
? response
|
|
1253
|
-
: record.data ?? record.items ?? [];
|
|
1254
|
-
unitPeople.value = (Array.isArray(rows) ? rows : []) as UnitPerson[];
|
|
1255
|
-
} catch (error: unknown) {
|
|
1256
|
-
console.error("Unable to load residents for the unit:", error);
|
|
1257
|
-
const reason = apiReason(error);
|
|
1258
|
-
showToast(
|
|
1259
|
-
reason ? `Unable to load residents: ${reason}` : "Unable to load residents for this unit.",
|
|
1260
|
-
"error",
|
|
1261
|
-
);
|
|
899
|
+
permissionCandidates.value = response.items ?? response.data?.items ?? [];
|
|
1262
900
|
} finally {
|
|
1263
|
-
|
|
901
|
+
loadingSubjects.value = false;
|
|
1264
902
|
}
|
|
1265
903
|
}
|
|
1266
904
|
|
|
1267
|
-
function
|
|
1268
|
-
form.level = "";
|
|
1269
|
-
form.unit = "";
|
|
1270
|
-
unitPeople.value = [];
|
|
1271
|
-
clearResidentSelection();
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
// Wrapper `@click`/`@focusin` on the Block select: load once, on first touch.
|
|
1275
|
-
async function onBlockOpened() {
|
|
1276
|
-
await ensureOccupancy();
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
function onLevelChanged() {
|
|
1280
|
-
form.unit = "";
|
|
1281
|
-
unitPeople.value = [];
|
|
1282
|
-
clearResidentSelection();
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
async function onUnitChanged() {
|
|
1286
|
-
clearResidentSelection();
|
|
1287
|
-
await loadUnitPeople();
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
function clearResidentSelection() {
|
|
905
|
+
async function onSubjectCategoryChanged() {
|
|
1291
906
|
form.subjectId = "";
|
|
1292
|
-
|
|
1293
|
-
// Name only ever mirrors a chosen resident, so it clears with the choice.
|
|
1294
|
-
if (!selectedUser.value) form.name = "";
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
// The auto-fill the whole cascade exists for.
|
|
1298
|
-
async function onResidentChanged() {
|
|
1299
|
-
const person = unitPeople.value.find(
|
|
1300
|
-
(item) => String(item._id) === String(form.subjectId),
|
|
1301
|
-
);
|
|
1302
|
-
form.name = String(person?.name ?? "");
|
|
1303
|
-
await checkResidentEnrollment();
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
/**
|
|
1307
|
-
* The HID user this resident already holds on the selected reader, or null.
|
|
1308
|
-
*
|
|
1309
|
-
* `subject`, not `person`. The same resident is stored under different ids
|
|
1310
|
-
* depending on which screen wrote the row - the permissions screen keys on
|
|
1311
|
-
* their user account, this screen on the record the picker offered - so a
|
|
1312
|
-
* filter on one field alone reports "not enrolled" for somebody who plainly is.
|
|
1313
|
-
* `subject` follows the record to its account and matches every link field,
|
|
1314
|
-
* which is exactly what the server does before it accepts an enrollment.
|
|
1315
|
-
*
|
|
1316
|
-
* Reader-scoped by the endpoint itself.
|
|
1317
|
-
*/
|
|
1318
|
-
async function findResidentIdentity(readerId: string, personId: string) {
|
|
1319
|
-
const response = await getIdentities(readerId, {
|
|
1320
|
-
page: 1,
|
|
1321
|
-
// A resident should hold at most one, but ask for a few: on the edit screen
|
|
1322
|
-
// the first row back can be the very identity being edited, and skipping it
|
|
1323
|
-
// must not hide a real second one behind it.
|
|
1324
|
-
limit: 10,
|
|
1325
|
-
subject: personId,
|
|
1326
|
-
});
|
|
1327
|
-
const responseRecord = toRecord(response);
|
|
1328
|
-
const responseData = toRecord(responseRecord.data);
|
|
1329
|
-
const responseItems =
|
|
1330
|
-
responseRecord.items ?? responseData.items ?? responseData.identities ?? [];
|
|
1331
|
-
const identities = (Array.isArray(responseItems) ? responseItems : []).map(toHidUser);
|
|
1332
|
-
const editingId = String(selectedUser.value?._id ?? "");
|
|
1333
|
-
|
|
1334
|
-
return (
|
|
1335
|
-
identities.find((identity) => !editingId || String(identity._id ?? "") !== editingId) ?? null
|
|
1336
|
-
);
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
/**
|
|
1340
|
-
* Sets `residentConflict` for the currently selected resident.
|
|
1341
|
-
*
|
|
1342
|
-
* Fails OPEN: if the lookup itself errors the operator is not blocked, because
|
|
1343
|
-
* the server refuses the duplicate anyway. This is a courtesy check that keeps
|
|
1344
|
-
* a doomed enrollment off the physical reader, not the guard itself.
|
|
1345
|
-
*/
|
|
1346
|
-
async function checkResidentEnrollment() {
|
|
1347
|
-
residentConflict.value = null;
|
|
1348
|
-
const readerId = selectedReaderId.value || form.reader || readers.value[0]?._id;
|
|
1349
|
-
if (!readerId || !form.subjectId || form.subjectCategory !== "resident") return null;
|
|
1350
|
-
|
|
1351
|
-
checkingResident.value = true;
|
|
1352
|
-
try {
|
|
1353
|
-
residentConflict.value = await findResidentIdentity(readerId, form.subjectId);
|
|
1354
|
-
return residentConflict.value;
|
|
1355
|
-
} catch (error: unknown) {
|
|
1356
|
-
console.error("Unable to check whether this resident is already enrolled:", error);
|
|
1357
|
-
return null;
|
|
1358
|
-
} finally {
|
|
1359
|
-
checkingResident.value = false;
|
|
1360
|
-
}
|
|
907
|
+
await loadSubjectCandidates();
|
|
1361
908
|
}
|
|
1362
909
|
|
|
1363
910
|
async function openEnroll() {
|
|
@@ -1369,6 +916,7 @@ async function openEnroll() {
|
|
|
1369
916
|
]);
|
|
1370
917
|
form.hidUserId = hidUserId;
|
|
1371
918
|
form.registration = registration;
|
|
919
|
+
await loadSubjectCandidates();
|
|
1372
920
|
formDialog.value = true;
|
|
1373
921
|
}
|
|
1374
922
|
|
|
@@ -1383,10 +931,6 @@ async function openEdit(user: HidUser) {
|
|
|
1383
931
|
form.registration = user.registration ?? "";
|
|
1384
932
|
form.isAdministrator = hasAdministratorRule(user);
|
|
1385
933
|
form.accessPin = "";
|
|
1386
|
-
form.password = "";
|
|
1387
|
-
showPassword.value = false;
|
|
1388
|
-
removePasswordRequested.value = false;
|
|
1389
|
-
passwordSet.value = Boolean(user.metadata?.passwordSet);
|
|
1390
934
|
pinEnrolled.value = Boolean(user.metadata?.pinEnrolled);
|
|
1391
935
|
removePinRequested.value = false;
|
|
1392
936
|
form.photoPreview = "";
|
|
@@ -1397,31 +941,17 @@ async function openEdit(user: HidUser) {
|
|
|
1397
941
|
? "service_provider"
|
|
1398
942
|
: "property_management";
|
|
1399
943
|
form.subjectId = String(user.person || user.member || user.serviceProvider || "");
|
|
1400
|
-
|
|
1401
|
-
// one only appears if the operator reassigns the row to somebody else.
|
|
1402
|
-
residentConflict.value = null;
|
|
1403
|
-
// The location is not drawn when editing, but it is still carried: these
|
|
1404
|
-
// three form fields are what `saveUser` writes back and what `buildUnitLabel`
|
|
1405
|
-
// resolves into the Unit column, so a save must not blank them.
|
|
1406
|
-
//
|
|
1407
|
-
// `ensureOccupancy` is what lets `buildUnitLabel` turn them back into names.
|
|
1408
|
-
// The unit's residents are loaded too, because the Resident select IS drawn
|
|
1409
|
-
// here and its options come from that list - without it the select shows the
|
|
1410
|
-
// stored id instead of a name.
|
|
1411
|
-
await ensureOccupancy();
|
|
1412
|
-
if (form.unit) await loadUnitPeople();
|
|
944
|
+
await loadSubjectCandidates();
|
|
1413
945
|
selectedPhotoFile.value = null;
|
|
1414
946
|
removePhotoRequested.value = false;
|
|
1415
947
|
formDialog.value = true;
|
|
1416
948
|
|
|
1417
949
|
try {
|
|
1418
|
-
const
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
pinEnrolled.value = Boolean(pinStatus?.data?.pinEnrolled);
|
|
1424
|
-
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);
|
|
1425
955
|
} catch {
|
|
1426
956
|
// Preserve the last known status if the reader is temporarily offline.
|
|
1427
957
|
}
|
|
@@ -1500,28 +1030,12 @@ function onPhotoChange(event: Event) {
|
|
|
1500
1030
|
async function saveUser() {
|
|
1501
1031
|
const readerId =
|
|
1502
1032
|
selectedReaderId.value || form.reader || readers.value[0]?._id;
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
// enrolled, and changing a photo, a PIN or a password on one of those is a
|
|
1506
|
-
// reader-side operation that has nothing to say about who they are. Demanding
|
|
1507
|
-
// a resident there refuses a save for a field the dialog does not even draw.
|
|
1508
|
-
const missing = !readerId
|
|
1509
|
-
? "a reader"
|
|
1510
|
-
: !selectedUser.value && !form.subjectId
|
|
1511
|
-
? "a resident"
|
|
1512
|
-
: !form.name
|
|
1513
|
-
? "a name"
|
|
1514
|
-
: !form.hidUserId
|
|
1515
|
-
? "an ID"
|
|
1516
|
-
: !form.registration
|
|
1517
|
-
? "a registration number"
|
|
1518
|
-
: "";
|
|
1519
|
-
if (missing) {
|
|
1520
|
-
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");
|
|
1521
1035
|
return;
|
|
1522
1036
|
}
|
|
1523
1037
|
if (form.accessPin && !/^\d{1,32}$/.test(form.accessPin)) {
|
|
1524
|
-
showToast("PIN must contain numbers only.", "error");
|
|
1038
|
+
showToast("Access PIN must contain numbers only.", "error");
|
|
1525
1039
|
return;
|
|
1526
1040
|
}
|
|
1527
1041
|
if (selectedPhotoFile.value && (!selectedReader.value?.portalId || !selectedReader.value?.portalName)) {
|
|
@@ -1529,16 +1043,6 @@ async function saveUser() {
|
|
|
1529
1043
|
return;
|
|
1530
1044
|
}
|
|
1531
1045
|
|
|
1532
|
-
// Re-asked here, not trusted from the select: the dialog can sit open while
|
|
1533
|
-
// somebody else enrolls the same resident, and the reader is only ever
|
|
1534
|
-
// written to below this line. A duplicate caught here costs one request; the
|
|
1535
|
-
// same duplicate caught by the server costs a created HID user and a rollback.
|
|
1536
|
-
const alreadyEnrolled = await checkResidentEnrollment();
|
|
1537
|
-
if (alreadyEnrolled) {
|
|
1538
|
-
showToast(residentConflictMessage.value, "error");
|
|
1539
|
-
return;
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
1046
|
saving.value = true;
|
|
1543
1047
|
let newlyCreatedHidUserId: number | undefined;
|
|
1544
1048
|
try {
|
|
@@ -1552,33 +1056,22 @@ async function saveUser() {
|
|
|
1552
1056
|
return;
|
|
1553
1057
|
}
|
|
1554
1058
|
|
|
1555
|
-
// The link is sent only when the form actually holds one. Sending
|
|
1556
|
-
// `person: ""` is not "leave it alone", it is "clear it": the server reads
|
|
1557
|
-
// an empty string as a link being removed and then refuses the write for
|
|
1558
|
-
// having no subject at all. Omitting the keys is what makes it keep the
|
|
1559
|
-
// subject the record already has.
|
|
1560
|
-
const subjectLink = form.subjectId
|
|
1561
|
-
? {
|
|
1562
|
-
person: form.subjectCategory === "resident" ? form.subjectId : "",
|
|
1563
|
-
member: form.subjectCategory === "property_management" ? form.subjectId : "",
|
|
1564
|
-
serviceProvider: form.subjectCategory === "service_provider" ? form.subjectId : "",
|
|
1565
|
-
type: (form.subjectCategory === "resident"
|
|
1566
|
-
? "resident"
|
|
1567
|
-
: form.subjectCategory === "service_provider"
|
|
1568
|
-
? "contractor"
|
|
1569
|
-
: "staff") as
|
|
1570
|
-
| "resident"
|
|
1571
|
-
| "staff"
|
|
1572
|
-
| "contractor"
|
|
1573
|
-
| "visitor"
|
|
1574
|
-
| "unknown",
|
|
1575
|
-
}
|
|
1576
|
-
: {};
|
|
1577
|
-
|
|
1578
1059
|
const payload = {
|
|
1579
1060
|
hidUserId: String(hidUser.id),
|
|
1580
1061
|
registration: form.registration,
|
|
1581
|
-
|
|
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",
|
|
1582
1075
|
status: "active" as const,
|
|
1583
1076
|
metadata: {
|
|
1584
1077
|
name: form.name,
|
|
@@ -1595,7 +1088,6 @@ async function saveUser() {
|
|
|
1595
1088
|
imageTimestamp: selectedUser.value?.metadata?.imageTimestamp || "",
|
|
1596
1089
|
facialScores: selectedUser.value?.metadata?.facialScores || {},
|
|
1597
1090
|
pinEnrolled: pinEnrolled.value,
|
|
1598
|
-
passwordSet: passwordSet.value,
|
|
1599
1091
|
hidPhysicalCards: selectedUser.value?.metadata?.hidPhysicalCards || [],
|
|
1600
1092
|
},
|
|
1601
1093
|
};
|
|
@@ -1605,22 +1097,17 @@ async function saveUser() {
|
|
|
1605
1097
|
const facialResult = await syncFacialImage(readerId, hidUser.id);
|
|
1606
1098
|
applyFacialResult(payload.metadata, facialResult);
|
|
1607
1099
|
payload.metadata.pinEnrolled = await syncAccessPin(readerId, hidUser.id);
|
|
1608
|
-
payload.metadata.passwordSet = await syncPassword(readerId, hidUser.id);
|
|
1609
1100
|
if (selectedUser.value._id) {
|
|
1610
1101
|
await updateIdentity(selectedUser.value._id, payload);
|
|
1611
|
-
} else
|
|
1102
|
+
} else {
|
|
1612
1103
|
await saveIdentityOnReader(readerId, payload);
|
|
1613
1104
|
}
|
|
1614
|
-
// else: a user the reader holds and we have never linked. The photo, PIN
|
|
1615
|
-
// and password above are already on the device; creating an identity for
|
|
1616
|
-
// it would need a subject we deliberately no longer ask for here.
|
|
1617
1105
|
} else {
|
|
1618
1106
|
const created = await createHidUserOnReader(readerId, hidUser);
|
|
1619
1107
|
if (created) newlyCreatedHidUserId = hidUser.id;
|
|
1620
1108
|
const facialResult = await syncFacialImage(readerId, hidUser.id);
|
|
1621
1109
|
applyFacialResult(payload.metadata, facialResult);
|
|
1622
1110
|
payload.metadata.pinEnrolled = await syncAccessPin(readerId, hidUser.id);
|
|
1623
|
-
payload.metadata.passwordSet = await syncPassword(readerId, hidUser.id);
|
|
1624
1111
|
await saveIdentityOnReader(readerId, payload);
|
|
1625
1112
|
selectedReaderId.value = readerId;
|
|
1626
1113
|
}
|
|
@@ -1656,25 +1143,6 @@ async function saveUser() {
|
|
|
1656
1143
|
}
|
|
1657
1144
|
}
|
|
1658
1145
|
|
|
1659
|
-
async function syncPassword(readerId: string, hidUserId: number) {
|
|
1660
|
-
// Mirrors syncAccessPin. Removal wins over a typed value, and a blank field
|
|
1661
|
-
// means "leave whatever is on the reader alone" - the hash cannot be read
|
|
1662
|
-
// back, so blank can never mean "clear it".
|
|
1663
|
-
if (removePasswordRequested.value) {
|
|
1664
|
-
await deleteUserPassword(readerId, hidUserId);
|
|
1665
|
-
passwordSet.value = false;
|
|
1666
|
-
form.password = "";
|
|
1667
|
-
return false;
|
|
1668
|
-
}
|
|
1669
|
-
if (form.password) {
|
|
1670
|
-
await setUserPassword(readerId, hidUserId, form.password);
|
|
1671
|
-
form.password = "";
|
|
1672
|
-
passwordSet.value = true;
|
|
1673
|
-
return true;
|
|
1674
|
-
}
|
|
1675
|
-
return passwordSet.value;
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
1146
|
async function syncAccessPin(readerId: string, hidUserId: number) {
|
|
1679
1147
|
if (removePinRequested.value) {
|
|
1680
1148
|
await deleteUserPin(readerId, hidUserId);
|
|
@@ -1979,21 +1447,6 @@ function toHidUserObject(identity: Pick<HidUser, "hidUserId" | "name" | "registr
|
|
|
1979
1447
|
};
|
|
1980
1448
|
}
|
|
1981
1449
|
|
|
1982
|
-
function isVisitorUser(user: HidUser) {
|
|
1983
|
-
// The reader marks visitors with `user_type_id = 1`; a real user leaves the
|
|
1984
|
-
// field null. `metadata.hidUserTypeId` is what our API forwards it as.
|
|
1985
|
-
return Number(user.metadata?.hidUserTypeId ?? user.user_type_id) === 1;
|
|
1986
|
-
}
|
|
1987
|
-
|
|
1988
|
-
function isUnsupportedUserTypeFilter(error: unknown) {
|
|
1989
|
-
const record = toRecord(error);
|
|
1990
|
-
const data = toRecord(record.data);
|
|
1991
|
-
const message = toText(data.message) || toText(record.message);
|
|
1992
|
-
const normalized = message.toLowerCase();
|
|
1993
|
-
return normalized.includes("usertype")
|
|
1994
|
-
&& (normalized.includes("not allowed") || normalized.includes("unknown"));
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
1450
|
function toHidNumericId(value: unknown) {
|
|
1998
1451
|
const raw = String(value ?? "").trim();
|
|
1999
1452
|
if (!raw) return undefined;
|
|
@@ -2196,21 +1649,8 @@ function getPhysicalCardSubtitle(card: HidCard) {
|
|
|
2196
1649
|
}
|
|
2197
1650
|
|
|
2198
1651
|
function buildUnitLabel() {
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
// stamp "665f.../665f.../665f..." onto the record and into the Unit column.
|
|
2202
|
-
const block = occupiedBlocks.value.find((item) => String(item._id ?? "") === form.block);
|
|
2203
|
-
const level = (block?.levels ?? []).find((item) => String(item._id ?? "") === form.level);
|
|
2204
|
-
const unit = (level?.units ?? []).find((item) => String(item._id ?? "") === form.unit);
|
|
2205
|
-
const parts = [
|
|
2206
|
-
formatBlockTitle(block),
|
|
2207
|
-
String(level?.name ?? ""),
|
|
2208
|
-
String(unit?.name ?? ""),
|
|
2209
|
-
].filter(Boolean);
|
|
2210
|
-
// Editing a record enrolled before the cascade existed: keep its stored
|
|
2211
|
-
// label rather than blanking it.
|
|
2212
|
-
if (!parts.length) return String(selectedUser.value?.metadata?.unitLabel ?? "");
|
|
2213
|
-
return parts.join(" / ");
|
|
1652
|
+
const parts = [form.block, form.level, form.unit].filter(Boolean);
|
|
1653
|
+
return parts.length ? `BLK ${parts.join("/")}` : "";
|
|
2214
1654
|
}
|
|
2215
1655
|
|
|
2216
1656
|
function getName(user?: HidUser | null) {
|
|
@@ -2497,6 +1937,12 @@ function toHidCard(value: unknown): HidCard {
|
|
|
2497
1937
|
max-width: 320px;
|
|
2498
1938
|
}
|
|
2499
1939
|
|
|
1940
|
+
.small-title {
|
|
1941
|
+
font-size: 14px;
|
|
1942
|
+
font-weight: 700;
|
|
1943
|
+
color: var(--text);
|
|
1944
|
+
}
|
|
1945
|
+
|
|
2500
1946
|
/* Was `#4f5a66` / `#e53935` - the same two greys on both themes. */
|
|
2501
1947
|
.field-label {
|
|
2502
1948
|
color: var(--text2);
|
|
@@ -2518,42 +1964,12 @@ function toHidCard(value: unknown): HidCard {
|
|
|
2518
1964
|
line-height: 1.45;
|
|
2519
1965
|
}
|
|
2520
1966
|
|
|
2521
|
-
/* Same line, saying the field is refused rather than explained. `--err` is the
|
|
2522
|
-
token the required-field asterisk already uses. */
|
|
2523
|
-
.field-hint--error {
|
|
2524
|
-
color: var(--err);
|
|
2525
|
-
}
|
|
2526
|
-
|
|
2527
1967
|
.photo-wrap {
|
|
2528
1968
|
display: grid;
|
|
2529
1969
|
place-items: center;
|
|
2530
1970
|
margin-bottom: 14px;
|
|
2531
1971
|
}
|
|
2532
1972
|
|
|
2533
|
-
.photo-facial {
|
|
2534
|
-
margin: 10px 0 0;
|
|
2535
|
-
text-align: center;
|
|
2536
|
-
}
|
|
2537
|
-
|
|
2538
|
-
/* The same small muted word `.field-label` uses, so the caption reads as a
|
|
2539
|
-
field label rather than as a second heading. */
|
|
2540
|
-
.photo-facial__label {
|
|
2541
|
-
display: block;
|
|
2542
|
-
color: var(--muted);
|
|
2543
|
-
font-size: 12px;
|
|
2544
|
-
font-weight: 600;
|
|
2545
|
-
}
|
|
2546
|
-
|
|
2547
|
-
.photo-facial__value {
|
|
2548
|
-
display: block;
|
|
2549
|
-
margin-top: 2px;
|
|
2550
|
-
font-size: 13.5px;
|
|
2551
|
-
font-weight: 500;
|
|
2552
|
-
/* The reader's reference is a long unbroken number; let it wrap rather than
|
|
2553
|
-
widen the dialog. */
|
|
2554
|
-
word-break: break-all;
|
|
2555
|
-
}
|
|
2556
|
-
|
|
2557
1973
|
.photo-button {
|
|
2558
1974
|
width: 120px;
|
|
2559
1975
|
height: 120px;
|
|
@@ -2727,6 +2143,25 @@ function toHidCard(value: unknown): HidCard {
|
|
|
2727
2143
|
color: var(--muted);
|
|
2728
2144
|
}
|
|
2729
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
|
+
|
|
2730
2165
|
@media (max-width: 960px) {
|
|
2731
2166
|
.hid-user-filters :deep(.app-field),
|
|
2732
2167
|
.hid-user-filters :deep(.app-select) {
|