MT#60150 sip username changes in pbx group creation

sip username is created removing whitespaces and special chars from
the name input. This logic was handled by a lodash method. This commit
replaces the mentioned method with a custom function that mirrors the
logic we use in ngcp-admin to handle the pbx group creation.
The new method is less aggressive in fact it allows the use of
underscores and doesn't dash numbers. As part of the change we also
expose sip username as read-only field in the edit pbxGroupDetails
page.

Change-Id: I086b3a7011e47d8f542ac92f42bd923c38630331
(cherry picked from commit ccf2b82831)
(cherry picked from commit 2003188754)
mr11.5.1
Debora Crescenzo 11 months ago committed by Crescenzo Debora
parent 57eddca96b
commit 4943a96322

@ -24,9 +24,7 @@ import {
assignNumbers,
getNumbers
} from './user'
import {
getSeatsOnly
} from './pbx-seats'
import { getSeatsOnly } from './pbx-seats'
export function getGroups (options) {
return new Promise((resolve, reject) => {
@ -121,7 +119,7 @@ export function createGroup (group) {
let subscriberId
Promise.resolve().then(() => {
return createSubscriber({
username: _.kebabCase(group.name),
username: createUsername(group.name),
password: createId(),
is_pbx_group: true,
display_name: group.name,
@ -306,3 +304,9 @@ export function setGroupSoundSet (options) {
})
})
}
// This mirrors the logic we use in ngcp-admin to handle the pbx groups creation
// If you change the logic below make sure you make the same changes in ngcp-admin too
function createUsername (name) {
return name.trim().replaceAll(' ', '-').replace(/[^a-zA-Z0-9\-_ ]/g, '')
}

@ -67,6 +67,12 @@
/>
</template>
</q-input>
<q-input
readonly
disable
:model-value="changes.sipUsername"
:label="$t('SIP Username')"
/>
<q-input
v-model="changes.extension"
hide-hint
@ -421,6 +427,7 @@ export default {
return (this.groupSelected)
? {
name: this.groupSelected.display_name,
sipUsername: this.groupSelected.username,
extension: this.groupSelected.pbx_extension,
huntPolicy: this.groupSelected.pbx_hunt_policy,
huntTimeout: this.groupSelected.pbx_hunt_timeout,

Loading…
Cancel
Save