@7365admin1/layer-common 4.15.1 → 4.15.3-staging.326

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +10 -4
  2. package/components/ClientDetailForm.vue +3 -0
  3. package/components/DocumentForm.vue +407 -112
  4. package/components/DocumentManagement.vue +213 -12
  5. package/components/EntryPass/QrTemplatePreview.vue +21 -25
  6. package/components/EntryPassInformation.vue +119 -24
  7. package/components/Facility/BookingSetup.vue +63 -0
  8. package/components/HidIntercomManagement.vue +193 -43
  9. package/components/HidProfileQrCode.vue +323 -0
  10. package/components/HidReaderUserRoster.vue +32 -2
  11. package/components/HidUserEnrollment.vue +771 -212
  12. package/components/InvitationClientForm.vue +19 -1
  13. package/components/Layout/Header.vue +26 -0
  14. package/components/NotificationBell.vue +321 -0
  15. package/components/VehicleAddSelection.vue +7 -2
  16. package/components/VehicleBulkAddForm.vue +1392 -0
  17. package/components/VehicleManagement.vue +31 -3
  18. package/components/VisitorManagement.vue +267 -5
  19. package/composables/useAccessManagement.ts +5 -0
  20. package/composables/useAppLinks.ts +4 -2
  21. package/composables/useDocument.ts +7 -0
  22. package/composables/useFacility.ts +11 -0
  23. package/composables/useHidAmico.ts +97 -0
  24. package/composables/useHidNavigation.ts +25 -1
  25. package/composables/useMember.ts +12 -2
  26. package/composables/useNotification.ts +78 -0
  27. package/composables/usePeople.ts +19 -0
  28. package/composables/useVehicle.ts +35 -0
  29. package/composables/useWebUsb.ts +14 -11
  30. package/package.json +1 -1
  31. package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
  32. package/plugins/secure-member.client.ts +68 -14
  33. package/types/document.d.ts +14 -0
  34. package/types/facility.d.ts +4 -0
  35. package/types/people.d.ts +4 -1
  36. package/utils/materialSymbols.ts +3 -0
  37. package/utils/vehicle-bulk-rows.ts +534 -0
  38. package/utils/vehicle-bulk-sheet.ts +361 -0
@@ -132,15 +132,18 @@
132
132
  </template>
133
133
 
134
134
  <template #[`item.contactStatus`]="{ item }">
135
- <v-btn
136
- size="small"
137
- variant="outlined"
138
- class="text-none"
139
- :loading="testingContactReaderId === item.readerId"
140
- @click="testContactSipStatus(item)"
141
- >
142
- {{ getContactReaderStatus(item) }}
143
- </v-btn>
135
+ <span class="contact-status-cell">
136
+ <StatusChip :status="getContactReaderStatus(item)" />
137
+ <v-btn
138
+ icon="mdi-refresh"
139
+ size="x-small"
140
+ variant="text"
141
+ class="contact-status-refresh"
142
+ aria-label="Check reader SIP status"
143
+ :loading="testingContactReaderId === item.readerId"
144
+ @click="testContactSipStatus(item)"
145
+ />
146
+ </span>
144
147
  </template>
145
148
 
146
149
  <template #[`item.action-table`]="{ item }">
@@ -148,24 +151,26 @@
148
151
  <template #activator="{ props: menuProps }">
149
152
  <AppButton v-bind="menuProps" variant="row" icon="mdi-dots-vertical" />
150
153
  </template>
151
- <v-list v-if="activeTab === 'intercom'" density="compact" class="row-menu">
152
- <v-list-item title="View" @click="openViewDialog(item)" />
154
+ <v-list v-if="activeTab === 'intercom'" density="compact" class="screen-menu">
155
+ <v-list-item class="screen-menu__item" title="View" prepend-icon="mdi-eye" @click="openViewDialog(item)" />
153
156
  <v-list-item
157
+ class="screen-menu__item"
154
158
  title="Test Connection with SIP"
159
+ prepend-icon="mdi-lan-check"
155
160
  :disabled="testingSipReaderId === item.reader._id"
156
161
  @click="testSipConnection(item)"
157
162
  />
158
- <v-list-item title="Call Settings" @click="openCallDialog(item)" />
159
- <v-list-item title="Dial Code" @click="openDialCodeDialog(item)" />
160
- <v-list-item title="Make a call" @click="openMakeCallDialog(item)" />
161
- <v-list-item title="Web call" @click="openWebPhoneDialog(item)" />
163
+ <v-list-item class="screen-menu__item" title="Call Settings" prepend-icon="mdi-cog" @click="openCallDialog(item)" />
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)" />
162
167
  </v-list>
163
- <v-list v-else density="compact" class="row-menu">
164
- <v-list-item title="Call" prepend-icon="mdi-phone" @click="openContactCall(item)" />
165
- <v-list-item title="Check reader SIP status" prepend-icon="mdi-lan-check" @click="testContactSipStatus(item)" />
166
- <v-list-item title="View" @click="openContactView(item)" />
167
- <v-list-item title="Edit" @click="openContactDialog(item)" />
168
- <v-list-item title="Delete" @click="openDeleteContact(item)" />
168
+ <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
+ <v-list-item class="screen-menu__item" title="Check reader SIP status" prepend-icon="mdi-lan-check" @click="testContactSipStatus(item)" />
171
+ <v-list-item class="screen-menu__item" title="View" prepend-icon="mdi-eye" @click="openContactView(item)" />
172
+ <v-list-item class="screen-menu__item" title="Edit" prepend-icon="mdi-pencil" @click="openContactDialog(item)" />
173
+ <v-list-item class="screen-menu__item screen-menu__item--danger" title="Delete" prepend-icon="mdi-delete-outline" @click="openDeleteContact(item)" />
169
174
  </v-list>
170
175
  </v-menu>
171
176
  </template>
@@ -574,7 +579,7 @@
574
579
  </v-dialog>
575
580
 
576
581
  <v-dialog v-model="contactDialog" max-width="360" persistent>
577
- <v-card class="form-dialog" rounded="lg">
582
+ <v-card class="form-dialog contact-dialog" rounded="lg">
578
583
  <v-card-title class="dialog-title">{{ contactForm.id ? 'Edit Contact' : 'Add Contact' }}</v-card-title>
579
584
  <v-card-text class="dialog-body">
580
585
  <FieldLabel text="HID Reader" required />
@@ -584,9 +589,10 @@
584
589
  :disabled="Boolean(contactForm.id)"
585
590
  />
586
591
  <FieldLabel text="Name" required />
587
- <AppField v-model="contactForm.name" placeholder="Enter name" />
588
- <FieldLabel text="SIP Number / Address" required />
589
- <AppField v-model="contactForm.serverAddress" placeholder="7100 or user@example.com" />
592
+ <AppField v-model="contactForm.name" placeholder="Name shown on calls" class="my-3" />
593
+ <FieldLabel text="Address" required />
594
+ <AppField v-model="contactForm.serverAddress" :placeholder="contactAddressPlaceholder" />
595
+ <p class="field-hint">{{ contactAddressHint }}</p>
590
596
  </v-card-text>
591
597
  <v-card-actions class="dialog-actions pa-0">
592
598
  <v-btn class="text-none action-cancel" variant="flat" height="44" @click="contactDialog = false">Cancel</v-btn>
@@ -726,6 +732,7 @@ const {
726
732
  makeIntercomCall,
727
733
  finalizeIntercomCall,
728
734
  ensureSipAccount,
735
+ notifyIntercomCall,
729
736
  } = useHidAmico();
730
737
 
731
738
  const activeTab = ref<IntercomTab>("intercom");
@@ -958,6 +965,26 @@ const webPhoneButtonClass = computed(() => ({
958
965
  "has-incoming-call": webPhone.callState.value === "incoming",
959
966
  }));
960
967
  const isPeerToPeerMode = computed(() => sipForm.operatingMode === "peer-to-peer");
968
+
969
+ /**
970
+ * The user guide (6.3 Intercom contacts) gives a contact ONE address field
971
+ * whose meaning follows the reader's operating mode: an extension number in
972
+ * SIP Client mode, a local IP address in Peer-to-Peer mode. The reader chosen
973
+ * in the contact dialog decides which one the field asks for.
974
+ */
975
+ const contactReaderRow = computed(() =>
976
+ intercomRows.value.find((row) => row.reader._id === contactForm.readerId)
977
+ );
978
+ const isContactReaderPeerToPeer = computed(() => contactReaderRow.value?.operatingMode === "Peer-to-Peer");
979
+ const contactAddressPlaceholder = computed(() => (isContactReaderPeerToPeer.value ? "192.168.0.129" : "7100"));
980
+ const contactAddressHint = computed(() => {
981
+ if (!contactReaderRow.value) {
982
+ return "Extension number (SIP Client) or local IP address (Peer-to-Peer), depending on the reader's operating mode.";
983
+ }
984
+ return isContactReaderPeerToPeer.value
985
+ ? "Peer-to-Peer mode: enter the contact's local IP address."
986
+ : "SIP Client mode: enter the contact's extension number.";
987
+ });
961
988
  const areSipCredentialFieldsDisabled = computed(() => !sipForm.enabled || isPeerToPeerMode.value);
962
989
  const intercomDetailSections = computed(() => {
963
990
  const row = selectedRow.value;
@@ -1416,8 +1443,10 @@ async function disconnectWebPhone() {
1416
1443
 
1417
1444
  async function startWebCall() {
1418
1445
  webPhoneActionLoading.value = true;
1446
+ const destination = webPhoneForm.destination;
1419
1447
  try {
1420
- await webPhone.call(webPhoneForm.destination);
1448
+ await webPhone.call(destination);
1449
+ void ringResidentPhone(destination);
1421
1450
  } catch (error: unknown) {
1422
1451
  showMessage(getErrorMessage(error), "error");
1423
1452
  } finally {
@@ -1425,6 +1454,50 @@ async function startWebCall() {
1425
1454
  }
1426
1455
  }
1427
1456
 
1457
+ /**
1458
+ * Wake the called resident's mobile so they are there to answer.
1459
+ *
1460
+ * Deliberately fired AFTER the INVITE and never awaited. The SIP leg is the
1461
+ * call: it is already ringing by the time this runs, and a resident whose
1462
+ * phone is asleep is the only thing this fixes. So a failure here is logged
1463
+ * and dropped rather than shown — telling the operator "call failed" for a
1464
+ * call that is ringing would be worse than a silent miss.
1465
+ *
1466
+ * A destination with no resident behind it (a staff extension, an external SIP
1467
+ * address) comes back `notified: false` with a reason and is not an error.
1468
+ */
1469
+ async function ringResidentPhone(destination: string) {
1470
+ if (!props.org || !props.site) return;
1471
+
1472
+ try {
1473
+ // No `readerId`: this call came from the web phone, not a door station.
1474
+ // The reader selected in the table above is whatever the operator happens
1475
+ // to be looking at, and sending it would tell the resident's app the call
1476
+ // arrived at a door it never touched.
1477
+ await notifyIntercomCall(props.site, {
1478
+ orgId: props.org,
1479
+ destination,
1480
+ callId: createCallId(),
1481
+ });
1482
+ } catch (error: unknown) {
1483
+ console.warn("[intercom] could not send the incoming-call push", error);
1484
+ }
1485
+ }
1486
+
1487
+ /**
1488
+ * A per-call id, so a second push for the same call replaces the first on the
1489
+ * resident's lock screen rather than stacking a second ringing card.
1490
+ * `randomUUID` needs a secure context, which the web phone already requires —
1491
+ * getUserMedia does not run without one — but the fallback keeps a call from
1492
+ * failing on that account alone.
1493
+ */
1494
+ function createCallId() {
1495
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
1496
+ return crypto.randomUUID();
1497
+ }
1498
+ return `call-${Date.now()}-${Math.random().toString(16).slice(2)}`;
1499
+ }
1500
+
1428
1501
  async function answerWebCall() {
1429
1502
  webPhoneActionLoading.value = true;
1430
1503
  try {
@@ -1466,7 +1539,14 @@ function toggleWebMute() {
1466
1539
  }
1467
1540
  }
1468
1541
 
1542
+ function hasReaderContactId(contact: ContactRow) {
1543
+ if (contact.id !== undefined) return true;
1544
+ showMessage("This contact has no identifier on the HID reader. Refresh the list and try again.", "error");
1545
+ return false;
1546
+ }
1547
+
1469
1548
  function openContactDialog(contact?: ContactRow) {
1549
+ if (contact && !hasReaderContactId(contact)) return;
1470
1550
  selectedContact.value = contact || null;
1471
1551
  contactForm.id = contact?.id;
1472
1552
  contactForm.readerId = contact?.readerId || selectedReaderId.value || readers.value[0]?._id || "";
@@ -1516,10 +1596,20 @@ function openContactCall(contact: ContactRow) {
1516
1596
  }
1517
1597
 
1518
1598
  function openDeleteContact(contact: ContactRow) {
1599
+ if (!hasReaderContactId(contact)) return;
1519
1600
  selectedContact.value = contact;
1520
1601
  deleteContactDialog.value = true;
1521
1602
  }
1522
1603
 
1604
+ /**
1605
+ * modify_objects and destroy_objects answer { changes: n } (API guide, Modify
1606
+ * Objects / Delete Objects). Zero means the where clause matched nothing on the
1607
+ * reader - typically a contact already removed from the touchscreen.
1608
+ */
1609
+ function readChanges(response: unknown) {
1610
+ return toNumber(toRecord(toRecord(response).data ?? response).changes, Number.NaN);
1611
+ }
1612
+
1523
1613
  async function saveSipSettings() {
1524
1614
  if (!selectedRow.value) return;
1525
1615
  const isPeerToPeer = sipForm.operatingMode === "peer-to-peer";
@@ -1620,6 +1710,17 @@ function isSipCallTarget(value = "") {
1620
1710
  return /^(?:sip:)?[A-Za-z0-9_.+-]+(?:@[A-Za-z0-9.-]+(?::\d{1,5})?)?$/.test(value.trim());
1621
1711
  }
1622
1712
 
1713
+ function isIpv4Address(value = "") {
1714
+ const [host, port, ...rest] = value.trim().split(":");
1715
+ if (rest.length || (port !== undefined && !/^\d{1,5}$/.test(port))) return false;
1716
+ const octets = host.split(".");
1717
+ return octets.length === 4 && octets.every((octet) => /^\d{1,3}$/.test(octet) && Number(octet) <= 255);
1718
+ }
1719
+
1720
+ function isContactAddress(value: string, peerToPeer: boolean) {
1721
+ return peerToPeer ? isIpv4Address(value) : isSipCallTarget(value);
1722
+ }
1723
+
1623
1724
  async function runHangupCall() {
1624
1725
  if (!selectedRow.value) return;
1625
1726
  hangingUp.value = true;
@@ -1708,15 +1809,20 @@ async function saveContact() {
1708
1809
  return;
1709
1810
  }
1710
1811
 
1711
- if (!isSipCallTarget(contactForm.serverAddress)) {
1712
- showMessage("Enter a valid extension, SIP address, or IPv4 address.", "warning");
1812
+ if (!isContactAddress(contactForm.serverAddress, isContactReaderPeerToPeer.value)) {
1813
+ showMessage(
1814
+ isContactReaderPeerToPeer.value
1815
+ ? "Enter the contact's local IPv4 address for a Peer-to-Peer reader."
1816
+ : "Enter a valid extension number or SIP address.",
1817
+ "warning",
1818
+ );
1713
1819
  return;
1714
1820
  }
1715
1821
 
1716
1822
  contactsSaving.value = true;
1717
1823
  try {
1718
- if (contactForm.id) {
1719
- await runObjectOperation(contactForm.readerId, {
1824
+ if (contactForm.id !== undefined) {
1825
+ const response = await runObjectOperation(contactForm.readerId, {
1720
1826
  operation: "modify",
1721
1827
  object: "contacts",
1722
1828
  values: {
@@ -1725,8 +1831,14 @@ async function saveContact() {
1725
1831
  },
1726
1832
  where: { contacts: { id: contactForm.id } },
1727
1833
  });
1834
+ if (readChanges(response) === 0) {
1835
+ contactDialog.value = false;
1836
+ await loadContacts();
1837
+ showMessage("The HID reader no longer has this contact. The list has been refreshed.", "warning");
1838
+ return;
1839
+ }
1728
1840
  } else {
1729
- await runObjectOperation(contactForm.readerId, {
1841
+ const response = await runObjectOperation(contactForm.readerId, {
1730
1842
  operation: "create",
1731
1843
  object: "contacts",
1732
1844
  values: [{
@@ -1734,6 +1846,15 @@ async function saveContact() {
1734
1846
  number: contactForm.serverAddress.trim(),
1735
1847
  }],
1736
1848
  });
1849
+ // create_objects answers { ids: [...] } with the id of each created
1850
+ // object. No id means the reader accepted the request but created nothing.
1851
+ const created = toRecord(response?.data ?? response).ids;
1852
+ if (!Array.isArray(created) || created.length === 0) {
1853
+ contactDialog.value = false;
1854
+ await loadContacts();
1855
+ showMessage("The HID reader did not confirm the new contact. Check the contact list.", "warning");
1856
+ return;
1857
+ }
1737
1858
  }
1738
1859
  contactDialog.value = false;
1739
1860
  await loadContacts();
@@ -1746,16 +1867,21 @@ async function saveContact() {
1746
1867
  }
1747
1868
 
1748
1869
  async function deleteContact() {
1749
- if (!selectedContact.value?.id) return;
1870
+ const contact = selectedContact.value;
1871
+ if (!contact || !hasReaderContactId(contact)) return;
1750
1872
  contactsSaving.value = true;
1751
1873
  try {
1752
- await runObjectOperation(selectedContact.value.readerId, {
1874
+ const response = await runObjectOperation(contact.readerId, {
1753
1875
  operation: "destroy",
1754
1876
  object: "contacts",
1755
- where: { contacts: { id: selectedContact.value.id } },
1877
+ where: { contacts: { id: contact.id } },
1756
1878
  });
1757
1879
  deleteContactDialog.value = false;
1758
1880
  await loadContacts();
1881
+ if (readChanges(response) === 0) {
1882
+ showMessage("The HID reader had already removed this contact. The list has been refreshed.", "warning");
1883
+ return;
1884
+ }
1759
1885
  showMessage("Intercom contact deleted.", "success");
1760
1886
  } catch (error: unknown) {
1761
1887
  showMessage(getErrorMessage(error), "error");
@@ -1943,9 +2069,14 @@ export default {
1943
2069
 
1944
2070
 
1945
2071
 
1946
- .row-menu {
1947
- min-width: 160px;
1948
- border-radius: 6px;
2072
+ .contact-status-cell {
2073
+ display: inline-flex;
2074
+ align-items: center;
2075
+ gap: 4px;
2076
+ }
2077
+
2078
+ .contact-status-refresh {
2079
+ color: var(--text2);
1949
2080
  }
1950
2081
 
1951
2082
  .link-text {
@@ -2005,10 +2136,27 @@ export default {
2005
2136
  color: var(--err);
2006
2137
  }
2007
2138
 
2139
+ .field-hint {
2140
+ margin: 6px 0 0;
2141
+ color: var(--text2);
2142
+ font-size: 11px;
2143
+ line-height: 1.4;
2144
+ }
2145
+
2008
2146
  .sip-settings-dialog .field-label {
2009
2147
  margin-top: 14px;
2010
2148
  }
2011
2149
 
2150
+ /* Room between the contact dialog's three inputs; the first label sits
2151
+ against the body padding. */
2152
+ .contact-dialog .field-label {
2153
+ margin-top: 18px;
2154
+ }
2155
+
2156
+ .contact-dialog .field-label:first-child {
2157
+ margin-top: 0;
2158
+ }
2159
+
2012
2160
  .sip-label {
2013
2161
  margin: 12px 0 6px;
2014
2162
  color: var(--text);
@@ -2706,14 +2854,18 @@ export default {
2706
2854
  margin-top: 0;
2707
2855
  }
2708
2856
 
2857
+ .detail-dialog .dialog-title {
2858
+ font-size: var(--fs-card-title);
2859
+ }
2860
+
2709
2861
  .detail-row {
2710
2862
  display: flex;
2711
2863
  align-items: center;
2712
2864
  justify-content: space-between;
2713
2865
  gap: 16px;
2714
- min-height: 26px;
2866
+ min-height: 32px;
2715
2867
  color: var(--muted);
2716
- font-size: 11px;
2868
+ font-size: var(--fs-cell);
2717
2869
  }
2718
2870
 
2719
2871
  .detail-row strong {
@@ -2725,13 +2877,11 @@ export default {
2725
2877
  .dialog-actions {
2726
2878
  display: grid;
2727
2879
  grid-template-columns: 1fr 1fr;
2880
+ gap: 0;
2881
+ min-height: 0;
2728
2882
  border-top: 1px solid var(--border);
2729
2883
  }
2730
2884
 
2731
- .sip-settings-dialog .dialog-actions {
2732
- min-height: 46px;
2733
- }
2734
-
2735
2885
  /* The split footer bar, as panels 2, 4 and 5 keep it: the SHAPE is the
2736
2886
  screen's own (the handoff draws no such bar); only the colours change. The
2737
2887
  navy was a fixed hex that sat on the dark card unchanged. */