MT#33001 Configure subscriber's CLI via CSC panel

Change-Id: Id0bc8de6880f2ed1916564acafd5c695d40752fb
pull/20/head
CORP\franci11 3 years ago committed by Hugo Zigha
parent 8030e05ed1
commit 168f40357d

@ -2,7 +2,8 @@ import {
createSubscriber, createSubscriber,
deleteSubscriber, deleteSubscriber,
getFullSubscribers, getFullSubscribers,
getSubscriberAndPreferences, getSubscribers, getSubscriberAndPreferences,
getSubscribers,
setDisplayName, setDisplayName,
setPbxExtension, setPbxExtension,
setPbxWebPassword, setPbxWebPassword,
@ -10,6 +11,7 @@ import {
setSubscriberNumbers, setSubscriberNumbers,
setPreferenceIntraPbx, setPreferenceIntraPbx,
setPreferenceMusicOnHold, setPreferenceMusicOnHold,
setPreferenceCli,
getPreferences, getPreferences,
setPbxSIPPassword setPbxSIPPassword
} from './subscriber' } from './subscriber'
@ -110,7 +112,8 @@ export function getSeatList (options) {
all: true all: true
}), }),
getPilot(), getPilot(),
getNumbers() getNumbers(),
getSubscribers()
]).then((result) => { ]).then((result) => {
resolve({ resolve({
seats: result[0].subscribers, seats: result[0].subscribers,
@ -271,6 +274,27 @@ export function setSeatMusicOnHold (seatId, musicOnHold) {
return setPreferenceMusicOnHold(seatId, musicOnHold) return setPreferenceMusicOnHold(seatId, musicOnHold)
} }
/**
* @param seatId
* @param cli
*/
export function setSeatCli (seatId, cli) {
return new Promise((resolve, reject) => {
Promise.resolve().then(() => {
return setPreferenceCli(seatId, cli)
}).then(() => {
return getSubscriberAndPreferences(seatId)
}).then((result) => {
resolve({
seat: result.subscriber,
preferences: result.preferences
})
}).catch((err) => {
reject(err)
})
})
}
/** /**
* @param options * @param options
* @param options.seatId * @param options.seatId

@ -333,6 +333,10 @@ export function setPreferenceMusicOnHold (id, value) {
return setPreference(id, 'music_on_hold', value) return setPreference(id, 'music_on_hold', value)
} }
export function setPreferenceCli (id, value) {
return setPreference(id, 'cli', value)
}
export function getSubscribers (options) { export function getSubscribers (options) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
options = options || {} options = options || {}

@ -113,6 +113,27 @@
/> />
</template> </template>
</q-select> </q-select>
<q-select
v-model="changes.cliNumber"
emit-value
map-options
:options="getCliNumbersOptions"
:disable="isLoading"
:label="$t('CLI')"
>
<template
v-slot:append
>
<csc-input-button-save
v-if="hasCliNumberChanged"
@click.stop="save"
/>
<csc-input-button-reset
v-if="hasCliNumberChanged"
@click.stop="resetCliNumber"
/>
</template>
</q-select>
<q-select <q-select
v-model="changes.groups" v-model="changes.groups"
use-chips use-chips
@ -223,7 +244,8 @@ export default {
return { return {
changes: null, changes: null,
id: this.$route.params.id, id: this.$route.params.id,
soundSet: null soundSet: null,
currentCli: ""
} }
}, },
validations: { validations: {
@ -245,6 +267,7 @@ export default {
'getSoundSetBySeatId', 'getSoundSetBySeatId',
'hasCallQueue', 'hasCallQueue',
'getMusicOnHold', 'getMusicOnHold',
'getCurrentCli',
'getIntraPbx', 'getIntraPbx',
'getSeatUpdateToastMessage', 'getSeatUpdateToastMessage',
'isSeatLoading' 'isSeatLoading'
@ -269,6 +292,9 @@ export default {
hasAliasNumbersChanged () { hasAliasNumbersChanged () {
return !_.isEqual(_.cloneDeep(this.changes.aliasNumbers).sort(), this.getAliasNumberIds().sort()) return !_.isEqual(_.cloneDeep(this.changes.aliasNumbers).sort(), this.getAliasNumberIds().sort())
}, },
hasCliNumberChanged () {
return !_.isEqual(this.changes.cliNumber, this.getCliNumberId())
},
hasGroupsChanged () { hasGroupsChanged () {
return !_.isEqual(_.cloneDeep(this.changes.groups).sort(), _.cloneDeep(this.seatSelected.pbx_group_ids).sort()) return !_.isEqual(_.cloneDeep(this.changes.groups).sort(), _.cloneDeep(this.seatSelected.pbx_group_ids).sort())
}, },
@ -301,14 +327,37 @@ export default {
} }
return items return items
}, },
getCliNumbersOptions () {
let cliOptions = []
const clis = [...this.seatSelected.alias_numbers]
clis.forEach((cli) => {
cliOptions.push({
label: cli.cc + cli.ac + cli.sn,
value: cli.cc + cli.ac + cli.sn
})
})
cliOptions = cliOptions.concat(this.getPrimaryNumberOptions())
return cliOptions
},
isLoading () { isLoading () {
return this.isSeatLoading(this.seatSelected.id) return this.isSeatLoading(this.seatSelected.id)
} }
}, },
watch: { watch: {
seatSelected () { seatSelected () {
this.changes = this.getSeatData()
this.soundSet = this.getSoundSetBySeatId(this.seatSelected.id) this.soundSet = this.getSoundSetBySeatId(this.seatSelected.id)
this.loadPreferences(this.seatSelected.id).then ( (preferences) => {
const clis = [...this.seatSelected.alias_numbers]
this.numbers().forEach((cli) => {
clis.push({ac: cli.ac, cc: cli.cc, sn: cli.sn, number_id: cli.id})
})
const cliFound = clis.find(cli => cli.cc + cli.ac + cli.sn === preferences.cli)
if (cliFound) this.currentCli = {
label: cliFound.cc + cliFound.ac + cliFound.sn,
value: cliFound.cc + cliFound.ac + cliFound.sn
}
this.changes = this.getSeatData()
})
}, },
seatUpdateState (state) { seatUpdateState (state) {
if (state === RequestState.succeeded) { if (state === RequestState.succeeded) {
@ -318,7 +367,7 @@ export default {
} }
} }
}, },
mounted () { async mounted () {
this.selectSeat(this.id) this.selectSeat(this.id)
}, },
beforeDestroy () { beforeDestroy () {
@ -332,7 +381,9 @@ export default {
'setSeatGroups', 'setSeatGroups',
'setIntraPbx', 'setIntraPbx',
'setMusicOnHold', 'setMusicOnHold',
'setSeatSoundSet' 'setSeatSoundSet',
'loadPreferences',
'setCli'
]), ]),
...mapActions('pbxCallQueues', [ ...mapActions('pbxCallQueues', [
'jumpToCallQueue' 'jumpToCallQueue'
@ -341,6 +392,10 @@ export default {
'selectSeat', 'selectSeat',
'resetSelectedSeat' 'resetSelectedSeat'
]), ]),
...mapGetters('pbx', [
'getPrimaryNumberOptions',
'numbers'
]),
getAliasNumberIds () { getAliasNumberIds () {
const numberIds = [] const numberIds = []
this.seatSelected.alias_numbers.forEach((number) => { this.seatSelected.alias_numbers.forEach((number) => {
@ -351,6 +406,9 @@ export default {
getGroupIds () { getGroupIds () {
return _.clone(this.seatSelected.pbx_group_ids) return _.clone(this.seatSelected.pbx_group_ids)
}, },
getCliNumberId () {
return this.currentCli
},
getSoundSetId () { getSoundSetId () {
const soundSet = this.getSoundSetBySeatId(this.seatSelected.id) const soundSet = this.getSoundSetBySeatId(this.seatSelected.id)
if (soundSet) { if (soundSet) {
@ -367,7 +425,8 @@ export default {
clirIntrapbx: this.getIntraPbx(this.seatSelected.id), clirIntrapbx: this.getIntraPbx(this.seatSelected.id),
musicOnHold: this.getMusicOnHold(this.seatSelected.id), musicOnHold: this.getMusicOnHold(this.seatSelected.id),
groups: this.getGroupIds(), groups: this.getGroupIds(),
soundSet: this.getSoundSetId() soundSet: this.getSoundSetId(),
cliNumber: this.getCliNumberId()
} : null } : null
}, },
resetName () { resetName () {
@ -379,6 +438,9 @@ export default {
resetAliasNumbers () { resetAliasNumbers () {
this.changes.aliasNumbers = this.getAliasNumberIds() this.changes.aliasNumbers = this.getAliasNumberIds()
}, },
resetCliNumber () {
this.changes.cliNumber = this.getCliNumberId()
},
resetGroups () { resetGroups () {
this.changes.groups = this.getGroupIds() this.changes.groups = this.getGroupIds()
}, },
@ -405,6 +467,12 @@ export default {
unassignedNumbers: _.difference(this.getAliasNumberIds(), this.changes.aliasNumbers) unassignedNumbers: _.difference(this.getAliasNumberIds(), this.changes.aliasNumbers)
}) })
} }
if (this.hasCliNumberChanged) {
this.setCli({
seatId: this.seatSelected.id,
cli: this.changes.cliNumber
})
}
if (this.hasGroupsChanged) { if (this.hasGroupsChanged) {
this.setSeatGroups({ this.setSeatGroups({
seatId: this.seatSelected.id, seatId: this.seatSelected.id,

@ -20,6 +20,7 @@ import {
setSeatSoundSet, setSeatSoundSet,
setSeatIntraPbx, setSeatIntraPbx,
setSeatMusicOnHold, setSeatMusicOnHold,
setSeatCli,
setSeatWebPassword, setSeatWebPassword,
getSeatPreferences, getSeatPreferences,
setSeatSIPPassword setSeatSIPPassword
@ -99,6 +100,11 @@ export default {
return state?.preferenceMapById[id]?.music_on_hold || false return state?.preferenceMapById[id]?.music_on_hold || false
} }
}, },
getCurrentCli (state) {
return (id) => {
return state?.preferenceMapById[id]?.cli || false
}
},
getSeatCreatingName (state) { getSeatCreatingName (state) {
return _.get(state, 'seatCreating.name', '') return _.get(state, 'seatCreating.name', '')
}, },
@ -438,6 +444,19 @@ export default {
} catch (err) { } catch (err) {
context.commit('seatUpdateFailed', err.message) context.commit('seatUpdateFailed', err.message)
} }
},
async setCli (context, options) {
context.commit('seatUpdateRequesting', {
seatId: options.seatId,
seatField: options.message || i18n.t('cli of the seat')
})
try {
const result = await setSeatCli(options.seatId, options.cli)
context.commit('seatUpdateSucceeded', result)
} catch (err) {
context.commit('seatUpdateFailed', err.message)
}
} }
} }
} }

@ -58,6 +58,18 @@ export default {
}) })
return options return options
}, },
getPrimaryNumberOptions (state) {
const options = []
state.numberList.forEach((number) => {
if (number.is_primary) {
options.push({
label: numberFilter(number),
value: numberFilter(number)
})
}
})
return options
},
getFullNumberOptions (state) { getFullNumberOptions (state) {
const options = [] const options = []
state.numberList.forEach((number) => { state.numberList.forEach((number) => {

Loading…
Cancel
Save