@7365admin1/layer-common 4.8.1-staging.305 → 4.8.1
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/EntryPass/QrTemplatePreview.vue +25 -21
- package/components/Facility/BookingSetup.vue +0 -63
- package/components/HidIntercomManagement.vue +43 -193
- package/components/HidReaderUserRoster.vue +2 -32
- package/components/HidUserEnrollment.vue +212 -771
- package/components/InvitationClientForm.vue +1 -19
- package/components/VisitorManagement.vue +5 -267
- package/composables/useFacility.ts +0 -11
- package/composables/useHidAmico.ts +0 -97
- package/composables/useHidNavigation.ts +1 -25
- package/composables/useMechanicalElectricalPermission.ts +1 -5
- package/composables/usePeople.ts +0 -19
- package/composables/usePestControlPermission.ts +0 -39
- package/composables/usePoolMaintenancePermission.ts +0 -39
- package/composables/usePropertyPermission.ts +0 -9
- package/composables/useSecurityPermission.ts +0 -118
- package/composables/useWebUsb.ts +11 -14
- package/constants/permissions.ts +0 -5
- package/package.json +1 -1
- package/types/facility.d.ts +0 -4
- package/types/people.d.ts +1 -4
- package/utils/materialSymbols.ts +0 -3
- package/components/HidProfileQrCode.vue +0 -323
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +0 -23
|
@@ -511,15 +511,6 @@ export default function usePropertyPermission() {
|
|
|
511
511
|
"Allows the user to view the site's cameras. (Legacy name — this is the camera wall.)",
|
|
512
512
|
},
|
|
513
513
|
},
|
|
514
|
-
// NEW, owner answer Q9, 2026-09-11 — the iMA365 CCTV tile's own right.
|
|
515
|
-
// Same string and description as `useSecurityPermission`. Catalogue-only:
|
|
516
|
-
// nothing reads it yet, and the four `virtual-patrol:` strings above stay.
|
|
517
|
-
"cctv-mgmt": {
|
|
518
|
-
"see-all-cctv": {
|
|
519
|
-
check: true,
|
|
520
|
-
description: "Allows the user to view the site's CCTV cameras.",
|
|
521
|
-
},
|
|
522
|
-
},
|
|
523
514
|
"nfc-patrol": {
|
|
524
515
|
"see-all-nfc-patrol": {
|
|
525
516
|
check: true,
|
|
@@ -427,12 +427,6 @@ export default function useSecurityPermission() {
|
|
|
427
427
|
description:
|
|
428
428
|
"Allows the user to view the details of a specific incident report.",
|
|
429
429
|
},
|
|
430
|
-
// Owner answer Q10, 2026-09-11. Property's spelling and description,
|
|
431
|
-
// verbatim; the iSecure365 mobile app already accepts this string.
|
|
432
|
-
"review-incident-report": {
|
|
433
|
-
check: true,
|
|
434
|
-
description: "Allows the user to approve or reject incident report.",
|
|
435
|
-
},
|
|
436
430
|
"delete-incident-report": {
|
|
437
431
|
check: true,
|
|
438
432
|
description:
|
|
@@ -596,118 +590,6 @@ export default function useSecurityPermission() {
|
|
|
596
590
|
"Allows the user to open the notification feed on the iSecure365 mobile app.",
|
|
597
591
|
},
|
|
598
592
|
},
|
|
599
|
-
|
|
600
|
-
/*
|
|
601
|
-
* THE GUARD APP'S TILES THAT NO ROLE COULD BE GRANTED — owner answers Q5,
|
|
602
|
-
* Q9 and Q10, 2026-09-11: "tiles with no permission: build them".
|
|
603
|
-
*
|
|
604
|
-
* Every string below already exists verbatim in another application's
|
|
605
|
-
* catalogue (Property, or Cleaning for the 3A emergency set) and is copied
|
|
606
|
-
* from there, spelling and description. Two are new, and only two:
|
|
607
|
-
* `nfc-patrol:start-nfc-patrol` (mirrors `start-virtual-patrol-route`) and
|
|
608
|
-
* `cctv-mgmt:see-all-cctv` (today only `site-settings:manage-cctv-camera`,
|
|
609
|
-
* a setup action, exists). Pinned by `test/no-duplicate-spelling.test.mjs`.
|
|
610
|
-
*
|
|
611
|
-
* Catalogue-only: this widens what the role editor may OFFER and grants
|
|
612
|
-
* nobody anything. No gate reads these here yet.
|
|
613
|
-
*/
|
|
614
|
-
"emergency-contact": {
|
|
615
|
-
"see-all": {
|
|
616
|
-
check: true,
|
|
617
|
-
description: "Allows the user to view the list of all emergency contacts.",
|
|
618
|
-
},
|
|
619
|
-
"see-details": {
|
|
620
|
-
check: true,
|
|
621
|
-
description:
|
|
622
|
-
"Allows the user to view the details of a specific emergency contact.",
|
|
623
|
-
},
|
|
624
|
-
"add-emergency-contact": {
|
|
625
|
-
check: true,
|
|
626
|
-
description: "Allows the user to add a new emergency contact to the system.",
|
|
627
|
-
},
|
|
628
|
-
"update-emergency-contact": {
|
|
629
|
-
check: true,
|
|
630
|
-
description: "Allows the user to update emergency contact details.",
|
|
631
|
-
},
|
|
632
|
-
"delete-emergency-contact": {
|
|
633
|
-
check: true,
|
|
634
|
-
description:
|
|
635
|
-
"Allows the user to remove an emergency contact from the system permanently.",
|
|
636
|
-
},
|
|
637
|
-
"add-emergency-contact-category": {
|
|
638
|
-
check: true,
|
|
639
|
-
description:
|
|
640
|
-
"Allows the user to add a new emergency contact category to the system.",
|
|
641
|
-
},
|
|
642
|
-
"delete-emergency-contact-category": {
|
|
643
|
-
check: true,
|
|
644
|
-
description:
|
|
645
|
-
"Allows the user to delete an emergency contact category from the system.",
|
|
646
|
-
},
|
|
647
|
-
},
|
|
648
|
-
"facility-booking-mgmt": {
|
|
649
|
-
"add-facility-booking": {
|
|
650
|
-
check: true,
|
|
651
|
-
description:
|
|
652
|
-
"Allows the user to add a new facility-booking to the system.",
|
|
653
|
-
},
|
|
654
|
-
"see-all-facility-booking": {
|
|
655
|
-
check: true,
|
|
656
|
-
description: "Allows the user to view the list of all facilities.",
|
|
657
|
-
},
|
|
658
|
-
"see-facility-booking-details": {
|
|
659
|
-
check: true,
|
|
660
|
-
description:
|
|
661
|
-
"Allows the user to view the details of a specific facility-booking.",
|
|
662
|
-
},
|
|
663
|
-
"update-facility-booking": {
|
|
664
|
-
check: true,
|
|
665
|
-
description: "Allows the user to update facility-booking details.",
|
|
666
|
-
},
|
|
667
|
-
"delete-facility-booking": {
|
|
668
|
-
check: true,
|
|
669
|
-
description:
|
|
670
|
-
"Allows the user to remove a facility-booking from the system permanently.",
|
|
671
|
-
},
|
|
672
|
-
},
|
|
673
|
-
// Property's descriptions minus its "Checked by the iMA365 mobile app."
|
|
674
|
-
// sentence, which is not true of this application.
|
|
675
|
-
"passes-and-keys-mgmt": {
|
|
676
|
-
"see-all-passes-and-keys": {
|
|
677
|
-
check: true,
|
|
678
|
-
description:
|
|
679
|
-
"Allows the user to view the list of all passes and keys on mobile.",
|
|
680
|
-
},
|
|
681
|
-
},
|
|
682
|
-
"resident-transactions": {
|
|
683
|
-
"see-all-resident-transactions": {
|
|
684
|
-
check: true,
|
|
685
|
-
description:
|
|
686
|
-
"Allows the user to view the list of all resident transactions on mobile.",
|
|
687
|
-
},
|
|
688
|
-
},
|
|
689
|
-
"nfc-patrol": {
|
|
690
|
-
"see-all-nfc-patrol": {
|
|
691
|
-
check: true,
|
|
692
|
-
description:
|
|
693
|
-
"Allows the user to view created routes and patrol logs.",
|
|
694
|
-
},
|
|
695
|
-
// NEW. Mirrors `virtual-patrol:start-virtual-patrol-route`.
|
|
696
|
-
"start-nfc-patrol": {
|
|
697
|
-
check: true,
|
|
698
|
-
description:
|
|
699
|
-
"Allows the user to start NFC patrolling on a specific route.",
|
|
700
|
-
},
|
|
701
|
-
},
|
|
702
|
-
// NEW. Seeing the CCTV wall, as distinct from setting cameras up
|
|
703
|
-
// (`site-settings:manage-cctv-camera`).
|
|
704
|
-
"cctv-mgmt": {
|
|
705
|
-
"see-all-cctv": {
|
|
706
|
-
check: true,
|
|
707
|
-
description: "Allows the user to view the site's CCTV cameras.",
|
|
708
|
-
},
|
|
709
|
-
},
|
|
710
|
-
|
|
711
593
|
members: memberPermissions,
|
|
712
594
|
invitations: invitationPermissions,
|
|
713
595
|
roles: rolePermissions,
|
package/composables/useWebUsb.ts
CHANGED
|
@@ -345,19 +345,16 @@ export default function useWebUsb() {
|
|
|
345
345
|
70,
|
|
346
346
|
);
|
|
347
347
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
// Generated at the size it is drawn at: the old corner copies were
|
|
353
|
-
// downscaled from the 250px canvas, which softened their modules.
|
|
354
|
-
const qrSize = 350;
|
|
355
|
-
const qrCanvas = await QRCode.toCanvas(qrUrlImage, {
|
|
356
|
-
width: qrSize,
|
|
357
|
-
margin: 1,
|
|
358
|
-
});
|
|
348
|
+
const qrSmall = 140;
|
|
349
|
+
const qrCenter = 250;
|
|
350
|
+
const margin = 20;
|
|
351
|
+
const qrCanvas = await QRCode.toCanvas(qrUrlImage, { width: qrCenter });
|
|
359
352
|
|
|
360
|
-
ctx.drawImage(qrCanvas,
|
|
353
|
+
ctx.drawImage(qrCanvas, margin, 90, qrSmall, qrSmall);
|
|
354
|
+
ctx.drawImage(qrCanvas, canvas.width - qrSmall - margin, 90, qrSmall, qrSmall);
|
|
355
|
+
ctx.drawImage(qrCanvas, (canvas.width - qrCenter) / 2, 110, qrCenter, qrCenter);
|
|
356
|
+
ctx.drawImage(qrCanvas, margin, 300, qrSmall, qrSmall);
|
|
357
|
+
ctx.drawImage(qrCanvas, canvas.width - qrSmall - margin, 300, qrSmall, qrSmall);
|
|
361
358
|
|
|
362
359
|
ctx.font = "25px Arial";
|
|
363
360
|
ctx.fillText(companyName || "", canvas.width / 2, 470);
|
|
@@ -404,8 +401,8 @@ export default function useWebUsb() {
|
|
|
404
401
|
/**
|
|
405
402
|
* The self-service onboarding QR: one large QR code, a "SCAN QR CODE"-style
|
|
406
403
|
* subtext, and a dark site-name banner along the bottom - a single-purpose
|
|
407
|
-
* gate sign, not the visitor-pass receipt `createReceiptLayout`
|
|
408
|
-
* (that one
|
|
404
|
+
* gate sign, not the multi-copy visitor-pass receipt `createReceiptLayout`
|
|
405
|
+
* produces (that one prints several QRs to be cut apart and handed out).
|
|
409
406
|
*/
|
|
410
407
|
async function createOnboardingQrLayout(
|
|
411
408
|
qrUrlImage: string,
|
package/constants/permissions.ts
CHANGED
|
@@ -327,12 +327,7 @@ export const PERMISSIONS = {
|
|
|
327
327
|
"add-nfc-patrol",
|
|
328
328
|
"update-nfc-patrol",
|
|
329
329
|
"delete-nfc-patrol",
|
|
330
|
-
// Owner answer Q10, 2026-09-11. Mirrors `start-virtual-patrol-route`.
|
|
331
|
-
"start-nfc-patrol",
|
|
332
330
|
],
|
|
333
|
-
// Owner answer Q9, 2026-09-11: seeing the CCTV wall. Distinct from
|
|
334
|
-
// `site-settings:manage-cctv-camera`, which is camera setup.
|
|
335
|
-
"cctv-mgmt": ["see-all-cctv"],
|
|
336
331
|
"billing-mgmt": [
|
|
337
332
|
"see-all-billing-summary",
|
|
338
333
|
"see-all-billing-items",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.8.1
|
|
5
|
+
"version": "4.8.1",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|
package/types/facility.d.ts
CHANGED
|
@@ -73,10 +73,6 @@ declare type TFacility = {
|
|
|
73
73
|
hourInterval?: number;
|
|
74
74
|
isBookingFeeEnabled: boolean;
|
|
75
75
|
isGuestEnabled: boolean;
|
|
76
|
-
/** Residents may complete this facility's checklist themselves. */
|
|
77
|
-
isResidentChecklistEnabled?: boolean;
|
|
78
|
-
/** Security may complete it. Mutually exclusive with the above. */
|
|
79
|
-
isSecurityChecklistEnabled?: boolean;
|
|
80
76
|
bookingAmount: number | null;
|
|
81
77
|
peakBookingFeeAmount?: number | null;
|
|
82
78
|
bookingFeeGuestAmount?: number | null;
|
package/types/people.d.ts
CHANGED
|
@@ -22,14 +22,11 @@ declare type TPeople = {
|
|
|
22
22
|
email?: string;
|
|
23
23
|
files?: { name: string, id: string }[];
|
|
24
24
|
isOwner?: boolean;
|
|
25
|
-
// Link to this person's `users` row. Empty for the person types that carry
|
|
26
|
-
// no login, and empty for a resident whose account was never written.
|
|
27
|
-
user?: string;
|
|
28
25
|
};
|
|
29
26
|
|
|
30
27
|
declare type TPlateNumber = { plateNumber: string, recNo: string, _id?: string, status: "active" | "deleted" | "pending", type: TVehicleType };
|
|
31
28
|
|
|
32
29
|
|
|
33
|
-
declare type TPeoplePayload = Pick<TGuest, "name" | "block" | "level" | "unit" | "unitName" | "contact" | "plateNumber" | "nric" | "contact" | "remarks" | "org" | "site" | "start" | "end" | "type" | "isOwner"> & { status?: string
|
|
30
|
+
declare type TPeoplePayload = Pick<TGuest, "name" | "block" | "level" | "unit" | "unitName" | "contact" | "plateNumber" | "nric" | "contact" | "remarks" | "org" | "site" | "start" | "end" | "type" | "isOwner"> & { status?: string }
|
|
34
31
|
|
|
35
32
|
declare type TPeopleType = "guest" | "resident" | "tenant"
|
package/utils/materialSymbols.ts
CHANGED
|
@@ -242,9 +242,6 @@ export const MDI_TO_SYMBOL: Record<string, string> = {
|
|
|
242
242
|
"mdi-link-variant": "link",
|
|
243
243
|
"mdi-lan-connect": "lan",
|
|
244
244
|
"mdi-lan-disconnect": "link_off", // NEAREST: no disconnected-LAN glyph
|
|
245
|
-
"mdi-lan-check": "network_check",
|
|
246
|
-
"mdi-dialpad": "dialpad",
|
|
247
|
-
"mdi-headset": "headset_mic",
|
|
248
245
|
"mdi-bluetooth": "bluetooth",
|
|
249
246
|
"mdi-nfc": "nfc",
|
|
250
247
|
|
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
MY HID QR CODE.
|
|
3
|
-
|
|
4
|
-
The signed-in member's own pass for one reader. Every other HID screen acts on
|
|
5
|
-
somebody else - a resident being enrolled, a visitor being issued a pass. This
|
|
6
|
-
one has no subject picker at all, because the server takes the caller from the
|
|
7
|
-
session and there is no user id to send.
|
|
8
|
-
|
|
9
|
-
Issuing a code does NOT grant access. A member's door permission comes from the
|
|
10
|
-
HID permissions screen, and minting an access rule here would let anyone who
|
|
11
|
-
can press Generate admit themselves. So the screen reports what the permissions
|
|
12
|
-
screen says (`assigned`) and warns when a code would be refused at the door,
|
|
13
|
-
rather than handing out something that silently fails.
|
|
14
|
-
-->
|
|
15
|
-
<template>
|
|
16
|
-
<div class="hid-profile-qr">
|
|
17
|
-
<div class="hid-profile-qr__header">
|
|
18
|
-
<h2 class="hid-profile-qr__title">HID QR Code</h2>
|
|
19
|
-
<AppSelect
|
|
20
|
-
v-if="readerOptions.length"
|
|
21
|
-
v-model="selectedReaderId"
|
|
22
|
-
class="reader-select"
|
|
23
|
-
:items="readerOptions"
|
|
24
|
-
@update:model-value="loadProfile"
|
|
25
|
-
/>
|
|
26
|
-
</div>
|
|
27
|
-
|
|
28
|
-
<v-card class="screen-modal hid-profile-qr__card">
|
|
29
|
-
<v-card-text class="screen-modal__body">
|
|
30
|
-
<div v-if="loading" class="hid-profile-qr__state">Loading...</div>
|
|
31
|
-
|
|
32
|
-
<div v-else-if="!readerOptions.length" class="hid-profile-qr__state">
|
|
33
|
-
No HID reader is set up for this site yet.
|
|
34
|
-
</div>
|
|
35
|
-
|
|
36
|
-
<template v-else>
|
|
37
|
-
<p class="hid-profile-qr__reader">
|
|
38
|
-
{{ profile?.readerName || "HID reader" }}
|
|
39
|
-
<span>{{ profile?.portalName || "Portal not configured" }}</span>
|
|
40
|
-
</p>
|
|
41
|
-
|
|
42
|
-
<!-- A code this reader cannot read is worse than no code, so the
|
|
43
|
-
capability is checked before anything is offered. -->
|
|
44
|
-
<v-alert
|
|
45
|
-
v-if="profile && !profile.qrEnabled"
|
|
46
|
-
type="warning"
|
|
47
|
-
variant="tonal"
|
|
48
|
-
density="compact"
|
|
49
|
-
class="mb-4"
|
|
50
|
-
>
|
|
51
|
-
This reader is not set up to read QR codes.
|
|
52
|
-
</v-alert>
|
|
53
|
-
|
|
54
|
-
<!-- The honest part: a code opens the door only for a member the
|
|
55
|
-
permissions screen already admits. `assigned` is null when the
|
|
56
|
-
lookup failed, which is not the same as "no". -->
|
|
57
|
-
<v-alert
|
|
58
|
-
v-else-if="profile && profile.assigned === false"
|
|
59
|
-
type="warning"
|
|
60
|
-
variant="tonal"
|
|
61
|
-
density="compact"
|
|
62
|
-
class="mb-4"
|
|
63
|
-
>
|
|
64
|
-
You are not assigned to this reader, so this code will be refused at
|
|
65
|
-
the door. Ask a property manager to add you on the HID permissions
|
|
66
|
-
screen.
|
|
67
|
-
</v-alert>
|
|
68
|
-
|
|
69
|
-
<div v-if="qrImage" class="hid-profile-qr__code">
|
|
70
|
-
<img :src="qrImage" alt="Your HID QR code" width="220" height="220" />
|
|
71
|
-
<p class="hid-profile-qr__issued">
|
|
72
|
-
Issued {{ formatIssuedAt(profile?.issuedAt) }}
|
|
73
|
-
</p>
|
|
74
|
-
</div>
|
|
75
|
-
<p v-else class="hid-profile-qr__state">
|
|
76
|
-
You have no QR code on this reader yet.
|
|
77
|
-
</p>
|
|
78
|
-
|
|
79
|
-
<div class="hid-profile-qr__actions">
|
|
80
|
-
<AppButton
|
|
81
|
-
:disabled="working || !profile?.qrEnabled"
|
|
82
|
-
@click="generate"
|
|
83
|
-
>
|
|
84
|
-
{{ profile?.issued ? "Regenerate" : "Generate QR Code" }}
|
|
85
|
-
</AppButton>
|
|
86
|
-
<AppButton
|
|
87
|
-
v-if="qrImage"
|
|
88
|
-
variant="ghost"
|
|
89
|
-
icon="mdi-download"
|
|
90
|
-
@click="downloadQr"
|
|
91
|
-
>
|
|
92
|
-
Download
|
|
93
|
-
</AppButton>
|
|
94
|
-
<AppButton
|
|
95
|
-
v-if="profile?.issued"
|
|
96
|
-
variant="ghost"
|
|
97
|
-
:disabled="working"
|
|
98
|
-
@click="remove"
|
|
99
|
-
>
|
|
100
|
-
Remove
|
|
101
|
-
</AppButton>
|
|
102
|
-
</div>
|
|
103
|
-
|
|
104
|
-
<p class="field-hint">
|
|
105
|
-
Regenerating replaces the previous code. The old one stops working
|
|
106
|
-
immediately.
|
|
107
|
-
</p>
|
|
108
|
-
</template>
|
|
109
|
-
</v-card-text>
|
|
110
|
-
</v-card>
|
|
111
|
-
|
|
112
|
-
<v-snackbar v-model="snackbar.show" :color="snackbar.color" timeout="4000">
|
|
113
|
-
{{ snackbar.message }}
|
|
114
|
-
</v-snackbar>
|
|
115
|
-
</div>
|
|
116
|
-
</template>
|
|
117
|
-
|
|
118
|
-
<script setup lang="ts">
|
|
119
|
-
import QRCode from "qrcode";
|
|
120
|
-
import type { HidProfileQr } from "../composables/useHidAmico";
|
|
121
|
-
|
|
122
|
-
const props = defineProps<{ site: string }>();
|
|
123
|
-
|
|
124
|
-
const { getReaders, getProfileQr, issueProfileQr, deleteProfileQr } = useHidAmico();
|
|
125
|
-
|
|
126
|
-
type HidReaderOption = { _id: string; name?: string; portalName?: string };
|
|
127
|
-
|
|
128
|
-
const readers = ref<HidReaderOption[]>([]);
|
|
129
|
-
const selectedReaderId = ref("");
|
|
130
|
-
const profile = ref<HidProfileQr | null>(null);
|
|
131
|
-
const qrImage = ref("");
|
|
132
|
-
const loading = ref(false);
|
|
133
|
-
const working = ref(false);
|
|
134
|
-
const snackbar = reactive({ show: false, color: "success", message: "" });
|
|
135
|
-
|
|
136
|
-
const readerOptions = computed(() => readers.value.map((reader) => ({
|
|
137
|
-
title: `${reader.name || reader._id} — ${reader.portalName || "Portal not configured"}`,
|
|
138
|
-
value: reader._id,
|
|
139
|
-
})));
|
|
140
|
-
|
|
141
|
-
function showToast(message: string, color: "success" | "error" = "success") {
|
|
142
|
-
snackbar.message = message;
|
|
143
|
-
snackbar.color = color;
|
|
144
|
-
snackbar.show = true;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function toRecord(value: unknown): Record<string, any> {
|
|
148
|
-
return value && typeof value === "object" ? (value as Record<string, any>) : {};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function errorMessage(error: unknown) {
|
|
152
|
-
const record = toRecord(error);
|
|
153
|
-
return String(toRecord(record.data).message || record.message || "Something went wrong.");
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function formatIssuedAt(value?: string) {
|
|
157
|
-
if (!value) return "";
|
|
158
|
-
const date = new Date(value);
|
|
159
|
-
return Number.isNaN(date.getTime()) ? "" : date.toLocaleString();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* The image is drawn here, never fetched. The value is the credential itself,
|
|
164
|
-
* so keeping it on this page and out of any URL is the point.
|
|
165
|
-
*/
|
|
166
|
-
async function renderQr(value: string) {
|
|
167
|
-
if (!value) {
|
|
168
|
-
qrImage.value = "";
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
try {
|
|
172
|
-
qrImage.value = await QRCode.toDataURL(value, { width: 440, margin: 1 });
|
|
173
|
-
} catch (error) {
|
|
174
|
-
console.error("Unable to render the HID QR code:", error);
|
|
175
|
-
qrImage.value = "";
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Saves the rendered code as a PNG.
|
|
181
|
-
*
|
|
182
|
-
* Straight off the data URL already in the page - no request, so the credential
|
|
183
|
-
* never travels again to be downloaded. Same anchor-click approach `VisitorForm`
|
|
184
|
-
* uses for a visitor pass, and the reader name is in the file name because a
|
|
185
|
-
* member can hold one code per reader.
|
|
186
|
-
*/
|
|
187
|
-
function downloadQr() {
|
|
188
|
-
if (!qrImage.value) return;
|
|
189
|
-
const slug = String(profile.value?.readerName || "reader")
|
|
190
|
-
.trim()
|
|
191
|
-
.replace(/[^a-z0-9]+/gi, "-")
|
|
192
|
-
.replace(/^-|-$/g, "")
|
|
193
|
-
.toLowerCase();
|
|
194
|
-
const link = document.createElement("a");
|
|
195
|
-
link.href = qrImage.value;
|
|
196
|
-
link.download = `hid-qr-${slug || "reader"}.png`;
|
|
197
|
-
link.click();
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
async function loadReaders() {
|
|
201
|
-
if (!props.site) return;
|
|
202
|
-
const response = toRecord(await getReaders({ site: props.site, page: 1, limit: 100 }));
|
|
203
|
-
const data = toRecord(response.data);
|
|
204
|
-
const items = response.items ?? data.items ?? data.readers ?? [];
|
|
205
|
-
readers.value = (Array.isArray(items) ? items : []).filter((reader) => reader?._id);
|
|
206
|
-
if (!selectedReaderId.value && readers.value.length) {
|
|
207
|
-
selectedReaderId.value = String(readers.value[0]._id);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
async function loadProfile() {
|
|
212
|
-
if (!selectedReaderId.value) return;
|
|
213
|
-
loading.value = true;
|
|
214
|
-
try {
|
|
215
|
-
const response = await getProfileQr(selectedReaderId.value);
|
|
216
|
-
profile.value = response?.data ?? null;
|
|
217
|
-
await renderQr(profile.value?.qrValue || "");
|
|
218
|
-
} catch (error: unknown) {
|
|
219
|
-
profile.value = null;
|
|
220
|
-
qrImage.value = "";
|
|
221
|
-
showToast(errorMessage(error), "error");
|
|
222
|
-
} finally {
|
|
223
|
-
loading.value = false;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
async function generate() {
|
|
228
|
-
if (!selectedReaderId.value) return;
|
|
229
|
-
working.value = true;
|
|
230
|
-
try {
|
|
231
|
-
const response = await issueProfileQr(selectedReaderId.value);
|
|
232
|
-
profile.value = response?.data ?? null;
|
|
233
|
-
await renderQr(profile.value?.qrValue || "");
|
|
234
|
-
showToast("QR code generated.");
|
|
235
|
-
} catch (error: unknown) {
|
|
236
|
-
showToast(errorMessage(error), "error");
|
|
237
|
-
} finally {
|
|
238
|
-
working.value = false;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
async function remove() {
|
|
243
|
-
if (!selectedReaderId.value) return;
|
|
244
|
-
if (!window.confirm("Remove your QR code from this reader?")) return;
|
|
245
|
-
working.value = true;
|
|
246
|
-
try {
|
|
247
|
-
const response = await deleteProfileQr(selectedReaderId.value);
|
|
248
|
-
profile.value = response?.data ?? null;
|
|
249
|
-
await renderQr("");
|
|
250
|
-
showToast("QR code removed.");
|
|
251
|
-
} catch (error: unknown) {
|
|
252
|
-
showToast(errorMessage(error), "error");
|
|
253
|
-
} finally {
|
|
254
|
-
working.value = false;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
watch(
|
|
259
|
-
() => props.site,
|
|
260
|
-
async () => {
|
|
261
|
-
await loadReaders();
|
|
262
|
-
await loadProfile();
|
|
263
|
-
},
|
|
264
|
-
{ immediate: true },
|
|
265
|
-
);
|
|
266
|
-
</script>
|
|
267
|
-
|
|
268
|
-
<style scoped>
|
|
269
|
-
.hid-profile-qr__header {
|
|
270
|
-
display: flex;
|
|
271
|
-
align-items: center;
|
|
272
|
-
gap: 12px;
|
|
273
|
-
flex-wrap: wrap;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
.hid-profile-qr__title {
|
|
277
|
-
margin: 0;
|
|
278
|
-
font-size: 18px;
|
|
279
|
-
font-weight: 600;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
.hid-profile-qr__card {
|
|
283
|
-
margin-top: 16px;
|
|
284
|
-
max-width: 460px;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
.hid-profile-qr__reader {
|
|
288
|
-
margin: 0 0 14px;
|
|
289
|
-
font-size: 14px;
|
|
290
|
-
font-weight: 600;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
.hid-profile-qr__reader span {
|
|
294
|
-
display: block;
|
|
295
|
-
color: var(--muted);
|
|
296
|
-
font-size: 12px;
|
|
297
|
-
font-weight: 500;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
.hid-profile-qr__code {
|
|
301
|
-
display: grid;
|
|
302
|
-
place-items: center;
|
|
303
|
-
margin-bottom: 14px;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
.hid-profile-qr__issued {
|
|
307
|
-
margin: 8px 0 0;
|
|
308
|
-
color: var(--muted);
|
|
309
|
-
font-size: 12px;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
.hid-profile-qr__state {
|
|
313
|
-
color: var(--muted);
|
|
314
|
-
font-size: 13.5px;
|
|
315
|
-
padding: 8px 0 14px;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
.hid-profile-qr__actions {
|
|
319
|
-
display: flex;
|
|
320
|
-
gap: 8px;
|
|
321
|
-
flex-wrap: wrap;
|
|
322
|
-
}
|
|
323
|
-
</style>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<v-container fluid>
|
|
3
|
-
<HidEnabledGate
|
|
4
|
-
:site="siteId"
|
|
5
|
-
:org="orgId"
|
|
6
|
-
message="Enable HID as a service for this site before generating a QR code."
|
|
7
|
-
>
|
|
8
|
-
<HidProfileQrCode :site="siteId" />
|
|
9
|
-
</HidEnabledGate>
|
|
10
|
-
</v-container>
|
|
11
|
-
</template>
|
|
12
|
-
|
|
13
|
-
<script setup lang="ts">
|
|
14
|
-
definePageMeta({
|
|
15
|
-
layout: "default",
|
|
16
|
-
middleware: ["01-auth", "02-org"],
|
|
17
|
-
memberOnly: true,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const route = useRoute();
|
|
21
|
-
const siteId = computed(() => String(route.params.site ?? ""));
|
|
22
|
-
const orgId = computed(() => String(route.params.org ?? ""));
|
|
23
|
-
</script>
|