MT#57577 subscriber's administrator should be able to configure NCOS and NCOS_SET of seats

Change-Id: I4382cc6d3b2b7795718a9433c633578a28a6078d
mr12.0
Author: Nouhaila Idrissi Zouggari 2 years ago
parent 1406526c7e
commit e02805eb7c

@ -240,3 +240,73 @@ export function setSubscriberSoundSet (id, soundSet) {
})
})
}
export function getNcos (id) {
return new Promise((resolve, reject) => {
get({
path: 'api/ncoslevels/' + id
}).then((ncos) => {
resolve(ncos)
}).catch((err) => {
reject(err)
})
})
}
export function getNcosSet (id) {
return new Promise((resolve, reject) => {
get({
path: 'api/v2/ncos/sets/' + id
}).then((ncosSet) => {
resolve(ncosSet)
}).catch((err) => {
reject(err)
})
})
}
export function setSubscriberNcos (id, ncos) {
return new Promise((resolve, reject) => {
let promise
const path = 'api/subscriberpreferences/' + id
const fieldPath = 'ncos'
if (ncos === null || ncos === undefined) {
promise = patchRemove({
path: path,
fieldPath: 'ncos'
})
} else {
promise = patchAdd({
path: path,
fieldPath: fieldPath,
value: ncos
})
}
promise.then(() => {
resolve()
}).catch((err) => {
reject(err)
})
})
}
export function setSubscriberNcosSet (id, ncosSet) {
return new Promise((resolve, reject) => {
let promise
const path = 'api/subscriberpreferences/' + id
const fieldPath = 'ncos_set'
if (ncosSet === null || ncosSet === undefined) {
promise = patchRemove({
path: path,
fieldPath: 'ncos_set'
})
} else {
promise = patchAdd({
path: path,
fieldPath: fieldPath,
value: ncosSet
})
}
promise.then(() => {
resolve()
}).catch((err) => {
reject(err)
})
})
}

@ -24,7 +24,11 @@ import {
createId,
PBX_CONFIG_ORDER_BY,
PBX_CONFIG_ORDER_DIRECTION,
setSubscriberSoundSet
setSubscriberSoundSet,
getNcos,
getNcosSet,
setSubscriberNcos,
setSubscriberNcosSet
} from './pbx-config'
import {
assignNumbers,
@ -33,7 +37,9 @@ import {
import {
getGroupsOnly
} from './pbx-groups'
import {
getSubscriberId
} from 'src/auth'
export function getSeats (options) {
return new Promise((resolve, reject) => {
options = options || {}
@ -411,3 +417,113 @@ export async function getSeatPreferences (seatId) {
return err
}
}
/**
* @param options
* @param options.seatId
* @param options.ncosId
*/
export function setNcosSet (options) {
return new Promise((resolve, reject) => {
Promise.resolve().then(() => {
if (options.ncosId !== null && options.ncosId !== undefined) {
return getNcos(options.ncosId)
} else {
return Promise.resolve(null)
}
}).then((ncos) => {
const ncosName = _.get(ncos, 'level', null)
return setSubscriberNcos(options.seatId, ncosName)
}).then(() => {
return getSubscriberAndPreferences(options.seatId)
}).then((result) => {
resolve({
seat: result.subscriber,
preferences: result.preferences
})
}).catch((err) => {
reject(err)
})
})
}
/**
* @param options
* @param options.seatId
* @param options.ncosId
*/
export function NcosSet (options) {
return new Promise((resolve, reject) => {
Promise.resolve().then(() => {
if (options.ncosSetId !== null && options.ncosSetId !== undefined) {
return getNcosSet(options.ncosSetId)
} else {
return Promise.resolve(null)
}
}).then((ncosSet) => {
const ncosName = _.get(ncosSet, 'name', null)
return setSubscriberNcosSet(options.seatId, ncosName)
}).then(() => {
return getSubscriberAndPreferences(options.seatId)
}).then((result) => {
resolve({
seat: result.subscriber,
preferences: result.preferences
})
}).catch((err) => {
reject(err)
})
})
}
/**
* @param options
* @param options.ncosId
*/
export function NcosSets (options) {
return new Promise((resolve, reject) => {
Promise.resolve().then(() => {
if (options.ncosSetId !== null && options.ncosSetId !== undefined) {
return getNcosSet(options.ncosSetId)
} else {
return Promise.resolve(null)
}
}).then((ncosSet) => {
const ncosName = _.get(ncosSet, 'name', null)
return setSubscriberNcosSet(getSubscriberId(), ncosName)
}).then(() => {
return getSubscriberAndPreferences(getSubscriberId())
}).then((result) => {
resolve({
seat: result.subscriber,
preferences: result.preferences
})
}).catch((err) => {
reject(err)
})
})
}
/**
* @param options
* @param options.ncosId
*/
export function setNcosLevelSets (options) {
return new Promise((resolve, reject) => {
Promise.resolve().then(() => {
if (options.ncosId !== null && options.ncosId !== undefined) {
return getNcos(options.ncosId)
} else {
return Promise.resolve(null)
}
}).then((ncos) => {
const ncosName = _.get(ncos, 'level', null)
return setSubscriberNcos(getSubscriberId(), ncosName)
}).then(() => {
return getSubscriberAndPreferences(getSubscriberId())
}).then((result) => {
resolve({
seat: result.subscriber,
preferences: result.preferences
})
}).catch((err) => {
reject(err)
})
})
}

@ -76,6 +76,29 @@ export async function setPreferencePhonebook (id, field, value) {
}
}
}
export function getNcosLevels (options) {
return new Promise((resolve, reject) => {
options = options || {}
options = _.merge(options, {
path: 'api/ncoslevels/',
root: '_embedded.ngcp:ncoslevels',
all: true
})
getList(options).then((list) => {
resolve(list)
}).catch((err) => {
reject(err)
})
})
}
export async function getNcosSet () {
let streams = []
const res = await Vue.http.get('api/v2/ncos/sets/')
if (res.body.total_count > 0) {
streams = getJsonBody(res.body)._embedded['ngcp:ncos/sets']
}
return streams
}
export async function removePreference (id, field) {
return await patchRemove({
path: 'api/subscriberpreferences/' + id,

@ -0,0 +1,165 @@
<template>
<div
v-if="pageType === 'typeoutgoing'"
>
<q-item
class="col col-xs-12 col-md-6"
>
<q-list
class="col col-xs-12 col-md-6"
side
top
no-wrap
>
<q-select
v-model="ncosLevel"
use-chips
radio
emit-value
map-options
:options="ncosOptions"
:label="$t('Ncos')"
>
<template
v-slot:append
>
<csc-input-button-save
v-if="hasNcosChanged"
@click.stop="save"
/>
<csc-input-button-reset
v-if="hasNcosChanged"
@click.stop="resetNcos"
/>
</template>
</q-select>
<q-select
v-model="ncosSet"
use-chips
radio
emit-value
map-options
:options="ncosSetOptions"
:label="$t('Ncos Set')"
>
<template
v-slot:append
>
<csc-input-button-save
v-if="hasNcosSetChanged"
@click.stop="save"
/>
<csc-input-button-reset
v-if="hasNcosSetChanged"
@click.stop="resetNcosSet"
/>
</template>
</q-select>
</q-list>
</q-item>
</div>
</template>
<script>
import {
mapActions
} from 'vuex'
import CscInputButtonSave from 'src/components/form/CscInputButtonSave'
import CscInputButtonReset from 'src/components/form/CscInputButtonReset'
export default {
name: 'CscNcos',
components: {
CscInputButtonSave,
CscInputButtonReset
},
props: {
pageType: {
type: String,
default: null
}
},
data () {
return {
ncosLevel: null,
ncosSet: null,
ncosOptions: [],
ncosSetOptions: [],
originalNcosLevel: null,
originalNcosSet: null
}
},
async created() {
await this.getNcosSubscriber();
await this.getCurrentNcosSubscriber();
await this.getNcosSetsSubscriber();
await this.getCurrentNcosSetsSubscriber();
},
computed: {
hasNcosChanged () {
return this.ncosLevel !== this.originalNcosLevel
},
hasNcosSetChanged () {
return this.ncosSet !== this.originalNcosSet
},
},
async mounted () {
await this.getNcosSetSubscriber()
},
methods: {
...mapActions('user', [
'getNcosLevelsSubscriber',
'getCurrentNcosLevelsSubscriber',
'setNcosLevelsSubscriber',
'getNcosSetSubscriber',
'getCurrentNcosSetSubscriber'
]),
...mapActions('pbxSeats', [
'setNcosLevelSet',
'setNcosSets'
]),
async getNcosSubscriber () {
const listNcos = await this.getNcosLevelsSubscriber()
this.ncosOptions = listNcos.map((ncos) => ({
label: ncos.label,
value: ncos.value
}));
},
async getCurrentNcosSubscriber () {
const currentNcos = await this.getCurrentNcosLevelsSubscriber()
this.ncosLevel = currentNcos
this.originalNcosLevel = currentNcos;
},
async getNcosSetsSubscriber () {
const listNcosSet = await this.getNcosSetSubscriber()
this.ncosSetOptions = listNcosSet.map((ncosSet) => ({
label: ncosSet.label,
value: ncosSet.value
}));
},
async getCurrentNcosSetsSubscriber () {
const currentNcosSet = await this.getCurrentNcosSetSubscriber()
this.ncosSet = currentNcosSet
this.originalNcosSet = currentNcosSet;
},
save () {
if (this.hasNcosChanged) {
this.setNcosLevelSet({
ncosId: this.ncosLevel
})
this.originalNcosLevel = this.ncosLevel;
}
if (this.hasNcosSetChanged) {
this.setNcosSets({
ncosSetId: this.ncosSet
})
this.originalNcosSet = this.ncosSet;
}
},
resetNcos () {
this.ncosLevel = this.originalNcosLevel
},
resetNcosSet () {
this.ncosSet = this.originalNcosSet
}
}
}
</script>

@ -24,6 +24,9 @@
/>
</q-item>
</q-list>
<csc-ncos
:page-type=pageType
/>
<div
v-if="hasSubscriberProfileAttribute(blockMode)"
class="row q-mb-lg"
@ -131,12 +134,14 @@ import {
mapGetters
} from 'vuex'
import CscPage from '../../CscPage'
import CscNcos from '../../CscNcos'
import CscCallBlockingAddForm from '../../pages/CallBlocking/CscCallBlockingAddForm'
import CscBlockedNumber from '../../pages/CallBlocking/CscBlockedNumber'
export default {
name: 'CscCallBlocking',
components: {
CscPage,
CscNcos,
CscCallBlockingAddForm,
CscBlockedNumber,
CscSpinner
@ -146,6 +151,10 @@ export default {
type: String,
default: 'incoming'
},
pageType: {
type: String,
default: null
},
blockMode: {
type: String,
default: null
@ -311,4 +320,4 @@ export default {
.csc-block-anonymous
margin-bottom $flex-gutter-md
</style>
</style>

@ -2,6 +2,7 @@
<csc-call-blocking
id="csc-page-call-blocking-outgoing"
page-name="outgoing"
page-type="typeoutgoing"
block-mode="block_out_mode"
block-list="block_out_list"
/>

@ -223,6 +223,52 @@
/>
</template>
</q-select>
<q-select
v-model="changes.ncos"
use-chips
radio
emit-value
map-options
:disable="isLoading"
:options="ncosOptions"
:label="$t('Ncos')"
>
<template
v-slot:append
>
<csc-input-button-save
v-if="hasNcosChanged"
@click.stop="save"
/>
<csc-input-button-reset
v-if="hasNcosChanged"
@click.stop="resetNcos"
/>
</template>
</q-select>
<q-select
v-model="changes.ncosSet"
use-chips
radio
emit-value
map-options
:disable="isLoading"
:options="ncosSetOptions"
:label="$t('Ncos Set')"
>
<template
v-slot:append
>
<csc-input-button-save
v-if="hasNcosSetChanged"
@click.stop="save"
/>
<csc-input-button-reset
v-if="hasNcosSetChanged"
@click.stop="resetNcosSet"
/>
</template>
</q-select>
<q-toggle
v-model="changes.clirIntrapbx"
class="q-pa-sm"
@ -304,9 +350,15 @@ export default {
id: this.$route.params.id,
soundSet: null,
currentCli: "",
selectedTab: this.initialTab
selectedTab: this.initialTab,
ncosOptions: [],
ncosSetOptions: [],
}
},
async created() {
await this.getNcosSubscriber();
await this.getNcosSetsSubscriber();
},
validations: {
changes: {
extension: {
@ -353,8 +405,11 @@ export default {
]),
...mapGetters('pbxSeats', [
'getSoundSetBySeatId',
'getNcosBySeatId',
'hasCallQueue',
'getMusicOnHold',
'getDefaultNcos',
'getDefaultNcosSet',
'getCurrentCli',
'getIntraPbx',
'getSeatUpdateToastMessage',
@ -392,6 +447,12 @@ export default {
hasSoundSetChanged () {
return this.changes.soundSet !== this.getSoundSetId()
},
hasNcosChanged () {
return this.changes.ncos !== this.getDefaultNcos(this.seatSelected.id)
},
hasNcosSetChanged () {
return this.changes.ncosSet !== this.getDefaultNcosSet(this.seatSelected.id)
},
extensionErrorMessage () {
if (!this.$v.changes.extension.isInRange) {
return this.getExtensionHint
@ -489,6 +550,8 @@ export default {
async mounted () {
this.selectSeat(this.id)
await this.loadAnnouncements()
// await this.getNcosLevelsSubscriber()
await this.getNcosSetSubscriber()
},
beforeDestroy () {
this.resetSelectedSeat()
@ -504,7 +567,13 @@ export default {
'setMusicOnHold',
'setSeatSoundSet',
'loadPreferences',
'setCli'
'setCli',
'setNcosSet',
'NcosSet'
]),
...mapActions('user', [
'getNcosLevelsSubscriber',
'getNcosSetSubscriber'
]),
...mapActions('callForwarding', [
'loadAnnouncements'
@ -548,6 +617,13 @@ export default {
}
return null
},
getNcosId () {
const ncos = this.getNcosBySeatId(this.seatSelected.id)
if (ncos) {
return ncos.id
}
return null
},
getSeatData () {
return (this.seatSelected) ? {
displayName: this.seatSelected.display_name,
@ -560,7 +636,9 @@ export default {
musicOnHold: this.getMusicOnHold(this.seatSelected.id),
groups: this.getGroupIds(),
soundSet: this.getSoundSetId(),
cliNumber: this.getCliNumberId()
cliNumber: this.getCliNumberId(),
ncos: this.getDefaultNcos(this.seatSelected.id),
ncosSet:this.getDefaultNcosSet(this.seatSelected.id),
} : null
},
resetDisplayName () {
@ -584,6 +662,12 @@ export default {
resetSoundSet () {
this.changes.soundSet = this.getSoundSetId()
},
resetNcos () {
this.changes.ncos = this.getDefaultNcos(this.seatSelected.id)
},
resetNcosSet () {
this.changes.ncosSet = this.getDefaultNcosSet(this.seatSelected.id)
},
save () {
if (this.hasDisplayNameChanged) {
this.setSeatDisplayName({
@ -628,6 +712,18 @@ export default {
soundSetId: this.changes.soundSet
})
}
if (this.hasNcosChanged) {
this.setNcosSet({
seatId: this.seatSelected.id,
ncosId: this.changes.ncos
})
}
if (this.hasNcosSetChanged) {
this.NcosSet({
seatId: this.seatSelected.id,
ncosSetId: this.changes.ncosSet
})
}
},
changeIntraPbx () {
this.setIntraPbx( {
@ -649,6 +745,20 @@ export default {
goToCallQueue () {
this.jumpToCallQueue(this.seatSelected)
},
async getNcosSubscriber () {
const listNcos = await this.getNcosLevelsSubscriber()
this.ncosOptions = listNcos.map((ncos) => ({
label: ncos.label,
value: ncos.value
}));
},
async getNcosSetsSubscriber () {
const listNcosSet = await this.getNcosSetSubscriber()
this.ncosSetOptions = listNcosSet.map((ncosSet) => ({
label: ncosSet.label,
value: ncosSet.value
}));
}
}
}
</script>

@ -24,9 +24,13 @@ import {
setSeatCli,
setSeatWebPassword,
getSeatPreferences,
setSeatSIPPassword
setSeatSIPPassword,
setNcosSet,
setNcosLevelSets,
NcosSet,
NcosSets
} from '../api/pbx-seats'
import { getSubscriberId } from 'src/auth'
export default {
namespaced: true,
state: {
@ -90,6 +94,26 @@ export default {
return null
}
},
getNcosBySeatId (state, getters, rootState, rootGetters) {
return (seatId) => {
const prefs = state.preferenceMapById[seatId]
const ncosName = _.get(prefs, 'ncos', null)
if (ncosName !== null) {
return rootGetters['pbx/getNcosByName'](ncosName)
}
return null
}
},
getDefaultNcos (state) {
return (id) => {
return state?.preferenceMapById[id]?.ncos
}
},
getDefaultNcosSet (state) {
return (id) => {
return state?.preferenceMapById[id]?.ncos_set
}
},
getIntraPbx (state) {
return (id) => {
const seatPreferences = state.preferenceMapById[id]
@ -436,6 +460,62 @@ export default {
context.commit('seatUpdateFailed', err.message)
})
},
setNcosSet (context, options) {
context.commit('seatUpdateRequesting', {
seatId: options.seatId,
seatField: i18n.t('Ncos')
})
setNcosSet({
seatId: options.seatId,
ncosId: options.ncosId
}).then((result) => {
context.commit('seatUpdateSucceeded', result)
}).catch((err) => {
context.commit('seatUpdateFailed', err.message)
})
},
NcosSet (context, options) {
context.commit('seatUpdateRequesting', {
seatId: options.seatId,
seatField: i18n.t('Ncos Set')
})
NcosSet({
seatId: options.seatId,
ncosSetId: options.ncosSetId
}).then((result) => {
context.commit('seatUpdateSucceeded', result)
}).catch((err) => {
context.commit('seatUpdateFailed', err.message)
})
},
setNcosLevelSet (context, options) {
context.commit('seatUpdateRequesting', {
seatId: getSubscriberId(),
seatField: i18n.t('Ncos')
})
setNcosLevelSets({
seatId: getSubscriberId(),
ncosId: options.ncosId
}).then((result) => {
context.commit('seatUpdateSucceeded', result)
}).catch((err) => {
context.commit('seatUpdateFailed', err.message)
})
},
setNcosSets (context, options) {
context.commit('seatUpdateRequesting', {
seatId: getSubscriberId(),
seatField: i18n.t('Ncos Set')
})
NcosSets({
seatId: getSubscriberId(),
ncosSetId: options.ncosSetId
}).then((result) => {
context.commit('seatUpdateSucceeded', result)
}).catch((err) => {
context.commit('seatUpdateFailed', err.message)
})
},
async setIntraPbx (context, options) {
context.commit('seatUpdateRequesting', {
seatId: options.seatId,

@ -37,7 +37,8 @@ export default {
deviceModelImageSmallMap: {},
subscriberList: [],
subscriberListState: RequestState.initiated,
subscriberMap: {}
subscriberMap: {},
ncosMapByName: {}
},
getters: {
pilot (state) {
@ -115,6 +116,11 @@ export default {
})
return options
},
getNcosByName (state) {
return (level) => {
return _.get(state.ncosMapByName, level, null)
}
},
getSoundSetByName (state) {
return (name) => {
return _.get(state.soundSetMapByName, name, null)

@ -21,7 +21,11 @@ import {
setValueName,
setValueNumber,
changeSIPPassword,
createPhonebook
createPhonebook,
getNcosLevels,
getNcosSet,
getPreferences,
setPreference
} from '../api/subscriber'
import { deleteJwt, getJwt, getSubscriberId, setJwt, setSubscriberId } from 'src/auth'
import QRCode from 'qrcode'
@ -423,6 +427,41 @@ export default {
async removeSubscriberRegistration (context, row) {
await Vue.http.delete('api/subscriberregistrations/' + row.id)
},
async getNcosLevelsSubscriber () {
const ncosLevel = []
const list = await getNcosLevels()
list.items.forEach((ncos) => {
ncosLevel.push({
label: ncos.level,
value: ncos.id
})
})
return ncosLevel
},
async getNcosSetSubscriber () {
const ncosSet = []
const list = await getNcosSet()
list.forEach((setNcos) => {
ncosSet.push({
label: setNcos.name,
value: setNcos.id
})
})
return ncosSet
},
async getCurrentNcosLevelsSubscriber () {
const list = await getPreferences(getSubscriberId())
const currentNcosLevel = list.ncos
return currentNcosLevel
},
async getCurrentNcosSetSubscriber () {
const list = await getPreferences(getSubscriberId())
const currentNcosSet = list.ncos_set
return currentNcosSet
},
async setNcosLevelsSubscriber (value) {
await setPreference(getSubscriberId(), 'ncos', value)
},
async getPhonebookDetails (context, id) {
const list = await Vue.http.get('api/phonebookentries/' + id)
return list

Loading…
Cancel
Save