@7365admin1/layer-common 4.25.0 → 4.26.1-staging.354
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 +18 -4
- package/components/AccessCardAddForm.vue +5 -4
- package/components/AccessCardAssignToUnitForm.vue +3 -2
- package/components/AccessCardPreviewDialog.vue +4 -3
- package/components/Dialog/UpdateMoreAction.vue +11 -1
- package/components/DocumentForm.vue +407 -112
- package/components/DocumentManagement.vue +213 -12
- package/components/EntryPass/QrTemplatePreview.vue +21 -25
- package/components/EntryPassInformation.vue +119 -24
- package/components/Facility/BookingSetup.vue +63 -0
- package/components/HidAccessLogDashboard.vue +29 -5
- package/components/HidAccessPermissions.vue +424 -0
- package/components/HidIntercomManagement.vue +148 -14
- package/components/HidProfileQrCode.vue +323 -0
- package/components/HidReaderManagement.vue +26 -0
- package/components/HidReaderUserRoster.vue +32 -2
- package/components/HidUserEnrollment.vue +833 -152
- package/components/InvitationClientForm.vue +19 -1
- package/components/Robot/Fleet.vue +182 -2
- package/components/Robot/Form.vue +37 -12
- package/components/Robot/Map3D.vue +803 -40
- package/components/Robot/Plans.vue +63 -0
- package/components/Robot/SpotClean.vue +174 -0
- package/components/RolePermissionFormCreate.vue +163 -19
- package/components/RolePermissionFormPreviewUpdate.vue +230 -19
- package/components/RolePermissionMain.vue +19 -0
- package/components/VisitorManagement.vue +267 -5
- package/composables/useAccessManagement.ts +5 -0
- package/composables/useDocument.ts +7 -0
- package/composables/useFacility.ts +11 -0
- package/composables/useHidAmico.ts +117 -0
- package/composables/useHidNavigation.ts +25 -1
- package/composables/usePeople.ts +19 -0
- package/composables/useRobots.ts +111 -0
- package/composables/useSiteCategory.ts +45 -0
- package/composables/useSiteEntryPassSettings.ts +26 -0
- package/composables/useWebUsb.ts +14 -11
- 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-qr-code/index.vue +23 -0
- package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
- package/types/document.d.ts +14 -0
- package/types/facility.d.ts +4 -0
- package/types/people.d.ts +28 -1
- package/utils/building-map.ts +179 -8
- package/utils/hid-permission-assignments.ts +190 -0
- package/utils/occupancy-role.ts +109 -0
- package/utils/permission-labels.ts +30 -0
- package/utils/robot-display.ts +89 -0
|
@@ -162,11 +162,8 @@
|
|
|
162
162
|
/>
|
|
163
163
|
<v-list-item class="screen-menu__item" title="Call Settings" prepend-icon="mdi-cog" @click="openCallDialog(item)" />
|
|
164
164
|
<v-list-item class="screen-menu__item" title="Dial Code" prepend-icon="mdi-dialpad" @click="openDialCodeDialog(item)" />
|
|
165
|
-
<v-list-item class="screen-menu__item" title="Make a call" prepend-icon="mdi-phone" @click="openMakeCallDialog(item)" />
|
|
166
|
-
<v-list-item class="screen-menu__item" title="Web call" prepend-icon="mdi-headset" @click="openWebPhoneDialog(item)" />
|
|
167
165
|
</v-list>
|
|
168
166
|
<v-list v-else density="compact" class="screen-menu">
|
|
169
|
-
<v-list-item class="screen-menu__item" title="Call" prepend-icon="mdi-phone" @click="openContactCall(item)" />
|
|
170
167
|
<v-list-item class="screen-menu__item" title="Check reader SIP status" prepend-icon="mdi-lan-check" @click="testContactSipStatus(item)" />
|
|
171
168
|
<v-list-item class="screen-menu__item" title="View" prepend-icon="mdi-eye" @click="openContactView(item)" />
|
|
172
169
|
<v-list-item class="screen-menu__item" title="Edit" prepend-icon="mdi-pencil" @click="openContactDialog(item)" />
|
|
@@ -589,9 +586,31 @@
|
|
|
589
586
|
:disabled="Boolean(contactForm.id)"
|
|
590
587
|
/>
|
|
591
588
|
<FieldLabel text="Name" required />
|
|
592
|
-
|
|
589
|
+
<!-- The name is picked from the site's SIP accounts (`hid-sip-accounts`)
|
|
590
|
+
rather than typed, so a contact always names a person who holds an
|
|
591
|
+
extension. The model stays the plain name string the reader stores,
|
|
592
|
+
so `saveContact` is unchanged; an existing contact whose name is not
|
|
593
|
+
in the list still displays it (AppSelect falls back to the raw value). -->
|
|
594
|
+
<AppSelect
|
|
595
|
+
v-model="contactForm.name"
|
|
596
|
+
:items="sipAccountOptions"
|
|
597
|
+
:disabled="sipAccountsLoading"
|
|
598
|
+
:placeholder="sipAccountsLoading ? 'Loading SIP accounts…' : 'Name shown on calls'"
|
|
599
|
+
class="my-3"
|
|
600
|
+
@update:model-value="applySipAccountToContact"
|
|
601
|
+
/>
|
|
602
|
+
<p v-if="sipAccountsError" class="field-hint field-hint--error">{{ sipAccountsError }}</p>
|
|
603
|
+
<p v-else-if="!sipAccountsLoading && !sipAccounts.length" class="field-hint">
|
|
604
|
+
No SIP accounts on this site yet. An account is created the first time a user opens Web Call.
|
|
605
|
+
</p>
|
|
593
606
|
<FieldLabel text="Address" required />
|
|
594
|
-
|
|
607
|
+
<!-- Always read-only: it shows the extension of the chosen SIP account
|
|
608
|
+
and is never typed into. -->
|
|
609
|
+
<AppField
|
|
610
|
+
v-model="contactForm.serverAddress"
|
|
611
|
+
:placeholder="contactAddressPlaceholder"
|
|
612
|
+
disabled
|
|
613
|
+
/>
|
|
595
614
|
<p class="field-hint">{{ contactAddressHint }}</p>
|
|
596
615
|
</v-card-text>
|
|
597
616
|
<v-card-actions class="dialog-actions pa-0">
|
|
@@ -636,6 +655,8 @@
|
|
|
636
655
|
</template>
|
|
637
656
|
|
|
638
657
|
<script setup lang="ts">
|
|
658
|
+
import type { HidSipAccountListItem } from "../composables/useHidAmico";
|
|
659
|
+
|
|
639
660
|
const props = defineProps({
|
|
640
661
|
org: {
|
|
641
662
|
type: String,
|
|
@@ -732,6 +753,8 @@ const {
|
|
|
732
753
|
makeIntercomCall,
|
|
733
754
|
finalizeIntercomCall,
|
|
734
755
|
ensureSipAccount,
|
|
756
|
+
getSipAccounts,
|
|
757
|
+
notifyIntercomCall,
|
|
735
758
|
} = useHidAmico();
|
|
736
759
|
|
|
737
760
|
const activeTab = ref<IntercomTab>("intercom");
|
|
@@ -760,6 +783,11 @@ const webPhoneActionLoading = ref(false);
|
|
|
760
783
|
const sipAccount = ref<SipAccount | null>(null);
|
|
761
784
|
const sipAccountLoading = ref(false);
|
|
762
785
|
const sipAccountError = ref("");
|
|
786
|
+
// The site's SIP account list for the contact dialog's name picker. Distinct
|
|
787
|
+
// from `sipAccount` above, which is the CALLER's own account for the web phone.
|
|
788
|
+
const sipAccounts = ref<HidSipAccountListItem[]>([]);
|
|
789
|
+
const sipAccountsLoading = ref(false);
|
|
790
|
+
const sipAccountsError = ref("");
|
|
763
791
|
const remoteVideoEl = ref<HTMLVideoElement | null>(null);
|
|
764
792
|
const remoteAudioEl = ref<HTMLAudioElement | null>(null);
|
|
765
793
|
const webPhone = useSipWebPhone();
|
|
@@ -864,6 +892,31 @@ const readerOptions = computed(() => readers.value.map((reader) => ({
|
|
|
864
892
|
value: reader._id,
|
|
865
893
|
})));
|
|
866
894
|
|
|
895
|
+
/**
|
|
896
|
+
* The contact name picker. `value` is the bare name because that is what the
|
|
897
|
+
* reader stores and what `saveContact` sends; the extension goes into the
|
|
898
|
+
* Address field, not the label. A name that already sits on the contact being
|
|
899
|
+
* edited but is no longer in the SIP list is kept as an option so the picker
|
|
900
|
+
* does not silently drop it.
|
|
901
|
+
*/
|
|
902
|
+
const sipAccountOptions = computed(() => {
|
|
903
|
+
const options: Array<{ title: string; value: string }> = sipAccounts.value
|
|
904
|
+
.filter((account: HidSipAccountListItem) => account.name)
|
|
905
|
+
.map((account: HidSipAccountListItem) => ({ title: account.name, value: account.name }));
|
|
906
|
+
const current = contactForm.name.trim();
|
|
907
|
+
if (current && !options.some((option) => option.value === current)) {
|
|
908
|
+
options.unshift({ title: current, value: current });
|
|
909
|
+
}
|
|
910
|
+
return options;
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
/** The SIP account behind the picked name, or null for a legacy / unpicked name. */
|
|
914
|
+
const selectedSipAccount = computed(() => {
|
|
915
|
+
const name = contactForm.name.trim();
|
|
916
|
+
const match = sipAccounts.value.find((account: HidSipAccountListItem) => account.name === name);
|
|
917
|
+
return (match ?? null) as HidSipAccountListItem | null;
|
|
918
|
+
});
|
|
919
|
+
|
|
867
920
|
const visibleRows = computed(() => activeTab.value === "intercom" ? filteredIntercomRows.value : filteredContacts.value);
|
|
868
921
|
const pages = computed(() => Math.max(1, Math.ceil(visibleRows.value.length / limit)));
|
|
869
922
|
const pageRange = computed(() => {
|
|
@@ -976,14 +1029,11 @@ const contactReaderRow = computed(() =>
|
|
|
976
1029
|
);
|
|
977
1030
|
const isContactReaderPeerToPeer = computed(() => contactReaderRow.value?.operatingMode === "Peer-to-Peer");
|
|
978
1031
|
const contactAddressPlaceholder = computed(() => (isContactReaderPeerToPeer.value ? "192.168.0.129" : "7100"));
|
|
979
|
-
const contactAddressHint = computed(() =>
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
? "Peer-to-Peer mode: enter the contact's local IP address."
|
|
985
|
-
: "SIP Client mode: enter the contact's extension number.";
|
|
986
|
-
});
|
|
1032
|
+
const contactAddressHint = computed(() => (
|
|
1033
|
+
selectedSipAccount.value
|
|
1034
|
+
? "Extension of the selected SIP account."
|
|
1035
|
+
: "Filled from the SIP account of the name selected above."
|
|
1036
|
+
));
|
|
987
1037
|
const areSipCredentialFieldsDisabled = computed(() => !sipForm.enabled || isPeerToPeerMode.value);
|
|
988
1038
|
const intercomDetailSections = computed(() => {
|
|
989
1039
|
const row = selectedRow.value;
|
|
@@ -1399,6 +1449,37 @@ async function loadSipAccount() {
|
|
|
1399
1449
|
}
|
|
1400
1450
|
}
|
|
1401
1451
|
|
|
1452
|
+
async function loadSipAccounts() {
|
|
1453
|
+
if (!props.org || !props.site) return;
|
|
1454
|
+
|
|
1455
|
+
sipAccountsLoading.value = true;
|
|
1456
|
+
sipAccountsError.value = "";
|
|
1457
|
+
try {
|
|
1458
|
+
const response = await getSipAccounts(props.site, props.org);
|
|
1459
|
+
const rows = toRecord(response).data;
|
|
1460
|
+
sipAccounts.value = Array.isArray(rows) ? rows as HidSipAccountListItem[] : [];
|
|
1461
|
+
// An existing contact opened before the list arrived: once its name is
|
|
1462
|
+
// matched to an account, show that account's extension in the locked field.
|
|
1463
|
+
applySipAccountToContact(contactForm.name.trim());
|
|
1464
|
+
} catch (error: unknown) {
|
|
1465
|
+
sipAccounts.value = [];
|
|
1466
|
+
sipAccountsError.value = getErrorMessage(error);
|
|
1467
|
+
} finally {
|
|
1468
|
+
sipAccountsLoading.value = false;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
/**
|
|
1473
|
+
* Picking a SIP account sets the address to its extension. The Address field
|
|
1474
|
+
* is always disabled, so this is the only way it gets a value; a name that is
|
|
1475
|
+
* not an account (a legacy contact) leaves whatever address it already had.
|
|
1476
|
+
*/
|
|
1477
|
+
function applySipAccountToContact(name: string) {
|
|
1478
|
+
const account = sipAccounts.value.find((item: HidSipAccountListItem) => item.name === name);
|
|
1479
|
+
if (!account) return;
|
|
1480
|
+
contactForm.serverAddress = account.extension;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1402
1483
|
async function connectWebPhone() {
|
|
1403
1484
|
const account = sipAccount.value;
|
|
1404
1485
|
if (!account) {
|
|
@@ -1442,8 +1523,10 @@ async function disconnectWebPhone() {
|
|
|
1442
1523
|
|
|
1443
1524
|
async function startWebCall() {
|
|
1444
1525
|
webPhoneActionLoading.value = true;
|
|
1526
|
+
const destination = webPhoneForm.destination;
|
|
1445
1527
|
try {
|
|
1446
|
-
await webPhone.call(
|
|
1528
|
+
await webPhone.call(destination);
|
|
1529
|
+
void ringResidentPhone(destination);
|
|
1447
1530
|
} catch (error: unknown) {
|
|
1448
1531
|
showMessage(getErrorMessage(error), "error");
|
|
1449
1532
|
} finally {
|
|
@@ -1451,6 +1534,50 @@ async function startWebCall() {
|
|
|
1451
1534
|
}
|
|
1452
1535
|
}
|
|
1453
1536
|
|
|
1537
|
+
/**
|
|
1538
|
+
* Wake the called resident's mobile so they are there to answer.
|
|
1539
|
+
*
|
|
1540
|
+
* Deliberately fired AFTER the INVITE and never awaited. The SIP leg is the
|
|
1541
|
+
* call: it is already ringing by the time this runs, and a resident whose
|
|
1542
|
+
* phone is asleep is the only thing this fixes. So a failure here is logged
|
|
1543
|
+
* and dropped rather than shown — telling the operator "call failed" for a
|
|
1544
|
+
* call that is ringing would be worse than a silent miss.
|
|
1545
|
+
*
|
|
1546
|
+
* A destination with no resident behind it (a staff extension, an external SIP
|
|
1547
|
+
* address) comes back `notified: false` with a reason and is not an error.
|
|
1548
|
+
*/
|
|
1549
|
+
async function ringResidentPhone(destination: string) {
|
|
1550
|
+
if (!props.org || !props.site) return;
|
|
1551
|
+
|
|
1552
|
+
try {
|
|
1553
|
+
// No `readerId`: this call came from the web phone, not a door station.
|
|
1554
|
+
// The reader selected in the table above is whatever the operator happens
|
|
1555
|
+
// to be looking at, and sending it would tell the resident's app the call
|
|
1556
|
+
// arrived at a door it never touched.
|
|
1557
|
+
await notifyIntercomCall(props.site, {
|
|
1558
|
+
orgId: props.org,
|
|
1559
|
+
destination,
|
|
1560
|
+
callId: createCallId(),
|
|
1561
|
+
});
|
|
1562
|
+
} catch (error: unknown) {
|
|
1563
|
+
console.warn("[intercom] could not send the incoming-call push", error);
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
/**
|
|
1568
|
+
* A per-call id, so a second push for the same call replaces the first on the
|
|
1569
|
+
* resident's lock screen rather than stacking a second ringing card.
|
|
1570
|
+
* `randomUUID` needs a secure context, which the web phone already requires —
|
|
1571
|
+
* getUserMedia does not run without one — but the fallback keeps a call from
|
|
1572
|
+
* failing on that account alone.
|
|
1573
|
+
*/
|
|
1574
|
+
function createCallId() {
|
|
1575
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
1576
|
+
return crypto.randomUUID();
|
|
1577
|
+
}
|
|
1578
|
+
return `call-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1454
1581
|
async function answerWebCall() {
|
|
1455
1582
|
webPhoneActionLoading.value = true;
|
|
1456
1583
|
try {
|
|
@@ -1508,6 +1635,9 @@ function openContactDialog(contact?: ContactRow) {
|
|
|
1508
1635
|
contactForm.location = contact?.location === "N/A" ? "" : contact?.location || selectedReader?.location || "";
|
|
1509
1636
|
contactForm.serverAddress = contact?.serverAddress === "N/A" ? "" : contact?.serverAddress || "";
|
|
1510
1637
|
contactDialog.value = true;
|
|
1638
|
+
// Fetched on every open, not cached: an account is provisioned the first
|
|
1639
|
+
// time a user opens Web Call, so the list can grow between two dialogs.
|
|
1640
|
+
void loadSipAccounts();
|
|
1511
1641
|
}
|
|
1512
1642
|
|
|
1513
1643
|
function openContactView(contact: ContactRow) {
|
|
@@ -2096,6 +2226,10 @@ export default {
|
|
|
2096
2226
|
line-height: 1.4;
|
|
2097
2227
|
}
|
|
2098
2228
|
|
|
2229
|
+
.field-hint--error {
|
|
2230
|
+
color: var(--err);
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2099
2233
|
.sip-settings-dialog .field-label {
|
|
2100
2234
|
margin-top: 14px;
|
|
2101
2235
|
}
|
|
@@ -0,0 +1,323 @@
|
|
|
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>
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
|
|
88
88
|
<v-list density="compact" min-width="180">
|
|
89
89
|
<v-list-item title="View" @click="openView(item)" />
|
|
90
|
+
<v-list-item title="Access Permissions" @click="openPermissions(item)" />
|
|
90
91
|
<v-list-item title="Sync HID Reader" @click="openSyncConfirm(item)" />
|
|
91
92
|
<v-list-item title="Test Connection" @click="openTestConfirm(item)" />
|
|
92
93
|
<v-list-item title="Edit" @click="openEdit(item)" />
|
|
@@ -241,6 +242,18 @@
|
|
|
241
242
|
</v-card-actions>
|
|
242
243
|
</v-card>
|
|
243
244
|
</v-dialog>
|
|
245
|
+
|
|
246
|
+
<!-- Who may actually pass this reader. Enrolment makes a person
|
|
247
|
+
RECOGNISABLE; this is what puts them in the group the access rule is
|
|
248
|
+
attached to, and without it a recognised person is refused at the
|
|
249
|
+
door. Reloads the list on save so the reader's own counts stay true. -->
|
|
250
|
+
<HidAccessPermissions
|
|
251
|
+
v-model="permissionsDialog"
|
|
252
|
+
:site="props.site"
|
|
253
|
+
:org="props.org"
|
|
254
|
+
:reader="selectedReader"
|
|
255
|
+
@saved="loadReaders"
|
|
256
|
+
/>
|
|
244
257
|
</section>
|
|
245
258
|
</template>
|
|
246
259
|
|
|
@@ -322,6 +335,13 @@ const props = defineProps({
|
|
|
322
335
|
type: String,
|
|
323
336
|
required: true,
|
|
324
337
|
},
|
|
338
|
+
// The permission endpoints are org-scoped (`assertOrganizationSiteAccess`),
|
|
339
|
+
// and this component previously had no reason to know the org. Passed from
|
|
340
|
+
// the page, as `HidQrCodeConfiguration` already does.
|
|
341
|
+
org: {
|
|
342
|
+
type: String,
|
|
343
|
+
required: true,
|
|
344
|
+
},
|
|
325
345
|
});
|
|
326
346
|
|
|
327
347
|
const {
|
|
@@ -347,6 +367,7 @@ const viewDialog = ref(false);
|
|
|
347
367
|
const confirmDialog = ref(false);
|
|
348
368
|
const resultDialog = ref(false);
|
|
349
369
|
const selectedReader = ref<HidRecord | null>(null);
|
|
370
|
+
const permissionsDialog = ref(false);
|
|
350
371
|
const pendingAction = ref<"test" | "sync" | "delete" | null>(null);
|
|
351
372
|
const actionStage = ref<"confirm" | "review" | "loading">("confirm");
|
|
352
373
|
const resultSuccess = ref(true);
|
|
@@ -484,6 +505,11 @@ function openView(reader: HidRecord) {
|
|
|
484
505
|
viewDialog.value = true;
|
|
485
506
|
}
|
|
486
507
|
|
|
508
|
+
function openPermissions(reader: HidRecord) {
|
|
509
|
+
selectedReader.value = reader;
|
|
510
|
+
permissionsDialog.value = true;
|
|
511
|
+
}
|
|
512
|
+
|
|
487
513
|
function openTestConfirm(reader?: HidRecord | null) {
|
|
488
514
|
if (reader) selectedReader.value = reader;
|
|
489
515
|
pendingAction.value = "test";
|