@7365admin1/layer-common 4.21.4-staging.346 → 4.21.4-staging.347
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.
|
@@ -586,9 +586,31 @@
|
|
|
586
586
|
:disabled="Boolean(contactForm.id)"
|
|
587
587
|
/>
|
|
588
588
|
<FieldLabel text="Name" required />
|
|
589
|
-
|
|
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>
|
|
590
606
|
<FieldLabel text="Address" required />
|
|
591
|
-
|
|
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
|
+
/>
|
|
592
614
|
<p class="field-hint">{{ contactAddressHint }}</p>
|
|
593
615
|
</v-card-text>
|
|
594
616
|
<v-card-actions class="dialog-actions pa-0">
|
|
@@ -633,6 +655,8 @@
|
|
|
633
655
|
</template>
|
|
634
656
|
|
|
635
657
|
<script setup lang="ts">
|
|
658
|
+
import type { HidSipAccountListItem } from "../composables/useHidAmico";
|
|
659
|
+
|
|
636
660
|
const props = defineProps({
|
|
637
661
|
org: {
|
|
638
662
|
type: String,
|
|
@@ -729,6 +753,7 @@ const {
|
|
|
729
753
|
makeIntercomCall,
|
|
730
754
|
finalizeIntercomCall,
|
|
731
755
|
ensureSipAccount,
|
|
756
|
+
getSipAccounts,
|
|
732
757
|
notifyIntercomCall,
|
|
733
758
|
} = useHidAmico();
|
|
734
759
|
|
|
@@ -758,6 +783,11 @@ const webPhoneActionLoading = ref(false);
|
|
|
758
783
|
const sipAccount = ref<SipAccount | null>(null);
|
|
759
784
|
const sipAccountLoading = ref(false);
|
|
760
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("");
|
|
761
791
|
const remoteVideoEl = ref<HTMLVideoElement | null>(null);
|
|
762
792
|
const remoteAudioEl = ref<HTMLAudioElement | null>(null);
|
|
763
793
|
const webPhone = useSipWebPhone();
|
|
@@ -862,6 +892,31 @@ const readerOptions = computed(() => readers.value.map((reader) => ({
|
|
|
862
892
|
value: reader._id,
|
|
863
893
|
})));
|
|
864
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
|
+
|
|
865
920
|
const visibleRows = computed(() => activeTab.value === "intercom" ? filteredIntercomRows.value : filteredContacts.value);
|
|
866
921
|
const pages = computed(() => Math.max(1, Math.ceil(visibleRows.value.length / limit)));
|
|
867
922
|
const pageRange = computed(() => {
|
|
@@ -974,14 +1029,11 @@ const contactReaderRow = computed(() =>
|
|
|
974
1029
|
);
|
|
975
1030
|
const isContactReaderPeerToPeer = computed(() => contactReaderRow.value?.operatingMode === "Peer-to-Peer");
|
|
976
1031
|
const contactAddressPlaceholder = computed(() => (isContactReaderPeerToPeer.value ? "192.168.0.129" : "7100"));
|
|
977
|
-
const contactAddressHint = computed(() =>
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
? "Peer-to-Peer mode: enter the contact's local IP address."
|
|
983
|
-
: "SIP Client mode: enter the contact's extension number.";
|
|
984
|
-
});
|
|
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
|
+
));
|
|
985
1037
|
const areSipCredentialFieldsDisabled = computed(() => !sipForm.enabled || isPeerToPeerMode.value);
|
|
986
1038
|
const intercomDetailSections = computed(() => {
|
|
987
1039
|
const row = selectedRow.value;
|
|
@@ -1397,6 +1449,37 @@ async function loadSipAccount() {
|
|
|
1397
1449
|
}
|
|
1398
1450
|
}
|
|
1399
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
|
+
|
|
1400
1483
|
async function connectWebPhone() {
|
|
1401
1484
|
const account = sipAccount.value;
|
|
1402
1485
|
if (!account) {
|
|
@@ -1552,6 +1635,9 @@ function openContactDialog(contact?: ContactRow) {
|
|
|
1552
1635
|
contactForm.location = contact?.location === "N/A" ? "" : contact?.location || selectedReader?.location || "";
|
|
1553
1636
|
contactForm.serverAddress = contact?.serverAddress === "N/A" ? "" : contact?.serverAddress || "";
|
|
1554
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();
|
|
1555
1641
|
}
|
|
1556
1642
|
|
|
1557
1643
|
function openContactView(contact: ContactRow) {
|
|
@@ -2140,6 +2226,10 @@ export default {
|
|
|
2140
2226
|
line-height: 1.4;
|
|
2141
2227
|
}
|
|
2142
2228
|
|
|
2229
|
+
.field-hint--error {
|
|
2230
|
+
color: var(--err);
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2143
2233
|
.sip-settings-dialog .field-label {
|
|
2144
2234
|
margin-top: 14px;
|
|
2145
2235
|
}
|
|
@@ -155,6 +155,18 @@ export type HidSipAccountData = {
|
|
|
155
155
|
provisionedAt: string;
|
|
156
156
|
};
|
|
157
157
|
|
|
158
|
+
/** One row of the site's SIP account list - who owns the extension, never its password. */
|
|
159
|
+
export type HidSipAccountListItem = {
|
|
160
|
+
_id: string;
|
|
161
|
+
userId: string;
|
|
162
|
+
name: string;
|
|
163
|
+
email: string;
|
|
164
|
+
extension: string;
|
|
165
|
+
username: string;
|
|
166
|
+
status: string;
|
|
167
|
+
provisionedAt: string;
|
|
168
|
+
};
|
|
169
|
+
|
|
158
170
|
/**
|
|
159
171
|
* True only for the specific validation error an API that predates core #1878
|
|
160
172
|
* returns when the discover body carries `site`. Deliberately narrow: after
|
|
@@ -541,6 +553,13 @@ export default function useHidAmico() {
|
|
|
541
553
|
);
|
|
542
554
|
}
|
|
543
555
|
|
|
556
|
+
function getSipAccounts(siteId: string, orgId: string) {
|
|
557
|
+
return useNuxtApp().$api<{ data: HidSipAccountListItem[] }>(
|
|
558
|
+
`${basePath}/sites/${siteId}/intercom/sip-accounts`,
|
|
559
|
+
{ method: "GET", query: { orgId } },
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
|
|
544
563
|
/**
|
|
545
564
|
* Wake the resident's phone for a call the web phone has just placed.
|
|
546
565
|
*
|
|
@@ -636,6 +655,7 @@ export default function useHidAmico() {
|
|
|
636
655
|
makeIntercomCall,
|
|
637
656
|
finalizeIntercomCall,
|
|
638
657
|
ensureSipAccount,
|
|
658
|
+
getSipAccounts,
|
|
639
659
|
notifyIntercomCall,
|
|
640
660
|
getSitePermissions,
|
|
641
661
|
getPermissionCandidates,
|
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.21.4-staging.
|
|
5
|
+
"version": "4.21.4-staging.347",
|
|
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.",
|