What has been done: - TT#40083, Voicebox: As a Customer, I want to configure voicebox settings - TT#44658, Voicebox: As a Customer, I want to change the E-Mail-Address - TT#44657, Voicebox: As a Customer, I want to change the PIN - TT#40083, Voicebox: As a Customer, I want to enable/disable deletion of voicemail after mail delivery Change-Id: Ic11973de74e3a3e3d2da320a267182a051fa1571changes/74/23774/7
parent
5f1133a150
commit
74dc8cfe65
@ -0,0 +1,52 @@
|
|||||||
|
|
||||||
|
import _ from 'lodash'
|
||||||
|
import {
|
||||||
|
get,
|
||||||
|
patchReplace
|
||||||
|
} from './common'
|
||||||
|
|
||||||
|
export function getVoiceboxSettings(subscriberId) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
get({
|
||||||
|
path: `api/voicemailsettings/${subscriberId}`
|
||||||
|
}).then((result)=>{
|
||||||
|
let settings = _.clone(result);
|
||||||
|
delete settings._links;
|
||||||
|
resolve(settings);
|
||||||
|
}).catch((err)=>{
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setVoiceboxDelete(options) {
|
||||||
|
return patchReplace({
|
||||||
|
path: `api/voicemailsettings/${options.subscriberId}`,
|
||||||
|
fieldPath: 'delete',
|
||||||
|
value: options.value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setVoiceboxAttach(options) {
|
||||||
|
return patchReplace({
|
||||||
|
path: `api/voicemailsettings/${options.subscriberId}`,
|
||||||
|
fieldPath: 'attach',
|
||||||
|
value: options.value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setVoiceboxPin(options) {
|
||||||
|
return patchReplace({
|
||||||
|
path: `api/voicemailsettings/${options.subscriberId}`,
|
||||||
|
fieldPath: 'pin',
|
||||||
|
value: options.value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setVoiceboxEmail(options) {
|
||||||
|
return patchReplace({
|
||||||
|
path: `api/voicemailsettings/${options.subscriberId}`,
|
||||||
|
fieldPath: 'email',
|
||||||
|
value: options.value
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,202 @@
|
|||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<q-field
|
||||||
|
class="csc-form-field"
|
||||||
|
icon="lock"
|
||||||
|
:error-label="pinErrorMessage"
|
||||||
|
>
|
||||||
|
<q-input
|
||||||
|
:loading="pinRequesting"
|
||||||
|
:disable="pinRequesting"
|
||||||
|
:float-label="$t('voicebox.label.changePin')"
|
||||||
|
v-model="changes.pin"
|
||||||
|
:after="pinButtons"
|
||||||
|
@keyup.enter="updatePin"
|
||||||
|
@input="$v.changes.pin.$touch"
|
||||||
|
@blur="$v.changes.pin.$touch"
|
||||||
|
:error="$v.changes.pin.$error"
|
||||||
|
/>
|
||||||
|
</q-field>
|
||||||
|
<q-field
|
||||||
|
class="csc-form-field"
|
||||||
|
icon="email"
|
||||||
|
:error-label="emailErrorMessage"
|
||||||
|
>
|
||||||
|
<q-input
|
||||||
|
:loading="emailRequesting"
|
||||||
|
:disable="emailRequesting"
|
||||||
|
:float-label="$t('voicebox.label.changeEmail')"
|
||||||
|
v-model="changes.email"
|
||||||
|
:after="emailButtons"
|
||||||
|
@keyup.enter="updateEmail"
|
||||||
|
@input="$v.changes.email.$touch"
|
||||||
|
@blur="$v.changes.email.$touch"
|
||||||
|
:error="$v.changes.email.$error"
|
||||||
|
/>
|
||||||
|
</q-field>
|
||||||
|
<q-field class="csc-form-field">
|
||||||
|
<q-toggle
|
||||||
|
:disable="deleteRequesting || !canToggleDelete"
|
||||||
|
:label="deleteLabel"
|
||||||
|
v-model="changes.delete"
|
||||||
|
@input="toggle('delete')"
|
||||||
|
checked-icon="delete"
|
||||||
|
unchecked-icon="delete"
|
||||||
|
/>
|
||||||
|
</q-field>
|
||||||
|
<q-field class="csc-form-field">
|
||||||
|
<q-toggle
|
||||||
|
:disable="attachRequesting || !canToggleAttachment"
|
||||||
|
:label="attachLabel"
|
||||||
|
v-model="changes.attach"
|
||||||
|
@input="toggle('attach')"
|
||||||
|
checked-icon="attach_file"
|
||||||
|
unchecked-icon="attach_file"
|
||||||
|
/>
|
||||||
|
</q-field>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
maxLength,
|
||||||
|
email
|
||||||
|
} from 'vuelidate/lib/validators'
|
||||||
|
import {
|
||||||
|
QField,
|
||||||
|
QInput,
|
||||||
|
QToggle
|
||||||
|
} from 'quasar-framework'
|
||||||
|
export default {
|
||||||
|
name: 'csc-voicebox-settings',
|
||||||
|
props: [
|
||||||
|
'settings',
|
||||||
|
'deleteRequesting',
|
||||||
|
'attachRequesting',
|
||||||
|
'pinRequesting',
|
||||||
|
'emailRequesting',
|
||||||
|
'attachLabel',
|
||||||
|
'deleteLabel'
|
||||||
|
],
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
changes: this.getSettings()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
QField,
|
||||||
|
QInput,
|
||||||
|
QToggle
|
||||||
|
},
|
||||||
|
validations: {
|
||||||
|
changes: {
|
||||||
|
pin: {
|
||||||
|
maxLength: maxLength(64)
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
email
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
pinErrorMessage() {
|
||||||
|
return this.$t('validationErrors.maxLength', {
|
||||||
|
field: this.$t('voicebox.pin'),
|
||||||
|
maxLength: this.$v.changes.pin.$params.maxLength.max
|
||||||
|
});
|
||||||
|
},
|
||||||
|
emailErrorMessage() {
|
||||||
|
return this.$t('validationErrors.email');
|
||||||
|
},
|
||||||
|
canToggleDelete() {
|
||||||
|
return this.settings.attach;
|
||||||
|
},
|
||||||
|
canToggleAttachment() {
|
||||||
|
return !this.settings.delete;
|
||||||
|
},
|
||||||
|
pinHasChanged() {
|
||||||
|
return this.changes.pin !== this.settings.pin;
|
||||||
|
},
|
||||||
|
emailHasChanged() {
|
||||||
|
return this.changes.email !== this.settings.email;
|
||||||
|
},
|
||||||
|
pinButtons() {
|
||||||
|
let buttons = [];
|
||||||
|
let self = this;
|
||||||
|
if (this.pinHasChanged) {
|
||||||
|
buttons.push({
|
||||||
|
icon: 'check',
|
||||||
|
error: false,
|
||||||
|
handler (event) {
|
||||||
|
event.stopPropagation();
|
||||||
|
self.updatePin();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
icon: 'clear',
|
||||||
|
error: false,
|
||||||
|
handler (event) {
|
||||||
|
event.stopPropagation();
|
||||||
|
self.resetFields();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return buttons;
|
||||||
|
},
|
||||||
|
emailButtons() {
|
||||||
|
let buttons = [];
|
||||||
|
let self = this;
|
||||||
|
if (this.emailHasChanged) {
|
||||||
|
buttons.push({
|
||||||
|
icon: 'check',
|
||||||
|
error: false,
|
||||||
|
handler (event) {
|
||||||
|
event.stopPropagation();
|
||||||
|
self.updateEmail();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
icon: 'clear',
|
||||||
|
error: false,
|
||||||
|
handler (event) {
|
||||||
|
event.stopPropagation();
|
||||||
|
self.resetFields();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return buttons;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getSettings() {
|
||||||
|
return {
|
||||||
|
delete: this.settings.delete,
|
||||||
|
attach: this.settings.attach,
|
||||||
|
pin: this.settings.pin,
|
||||||
|
email: this.settings.email
|
||||||
|
}
|
||||||
|
},
|
||||||
|
resetFields() {
|
||||||
|
this.changes = this.getSettings();
|
||||||
|
},
|
||||||
|
toggle(field) {
|
||||||
|
if (field === 'delete') {
|
||||||
|
this.$store.dispatch('voicebox/toggleDelete');
|
||||||
|
}
|
||||||
|
else if (field === 'attach') {
|
||||||
|
this.$store.dispatch('voicebox/toggleAttach');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
updatePin() {
|
||||||
|
this.$store.dispatch('voicebox/updatePin', this.changes.pin);
|
||||||
|
},
|
||||||
|
updateEmail() {
|
||||||
|
this.$store.dispatch('voicebox/updateEmail', this.changes.email);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="stylus" rel="stylesheet/stylus">
|
||||||
|
</style>
|
@ -0,0 +1,121 @@
|
|||||||
|
|
||||||
|
<template>
|
||||||
|
<csc-page class="csc-simple-page">
|
||||||
|
<csc-voicebox-settings
|
||||||
|
v-if="isSettingsLoaded"
|
||||||
|
:settings="voiceboxSettings"
|
||||||
|
:deleteRequesting="isDeleteRequesting"
|
||||||
|
:attachRequesting="isAttachRequesting"
|
||||||
|
:pinRequesting="isPinRequesting"
|
||||||
|
:emailRequesting="isEmailRequesting"
|
||||||
|
:deleteLabel="deleteLabel"
|
||||||
|
:attachLabel="attachLabel"
|
||||||
|
/>
|
||||||
|
</csc-page>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
import CscPage from '../../CscPage'
|
||||||
|
import CscVoiceboxSettings from './CscVoiceboxSettings'
|
||||||
|
import {
|
||||||
|
startLoading,
|
||||||
|
stopLoading,
|
||||||
|
showToast,
|
||||||
|
showGlobalError
|
||||||
|
} from '../../../helpers/ui'
|
||||||
|
export default {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
CscPage,
|
||||||
|
CscVoiceboxSettings
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.$store.dispatch('voicebox/getVoiceboxSettings');
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters('voicebox', [
|
||||||
|
'voiceboxSettings',
|
||||||
|
'deleteLabel',
|
||||||
|
'attachLabel',
|
||||||
|
'isDeleteRequesting',
|
||||||
|
'isAttachRequesting',
|
||||||
|
'isPinRequesting',
|
||||||
|
'isEmailRequesting',
|
||||||
|
'isSettingsLoaded',
|
||||||
|
'loadingState',
|
||||||
|
'loadingError',
|
||||||
|
'toggleDeleteState',
|
||||||
|
'toggleDeleteError',
|
||||||
|
'toggleAttachState',
|
||||||
|
'toggleAttachError',
|
||||||
|
'updatePinState',
|
||||||
|
'updatePinError',
|
||||||
|
'updateEmailState',
|
||||||
|
'updateEmailError',
|
||||||
|
])
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
loadingState(state) {
|
||||||
|
if (state === 'requesting') {
|
||||||
|
startLoading();
|
||||||
|
}
|
||||||
|
else if (state === 'succeeded') {
|
||||||
|
stopLoading();
|
||||||
|
}
|
||||||
|
else if (state === 'failed') {
|
||||||
|
stopLoading();
|
||||||
|
showGlobalError(this.loadingError);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toggleDeleteState(state) {
|
||||||
|
if (state === 'requesting') {
|
||||||
|
startLoading();
|
||||||
|
}
|
||||||
|
else if (state === 'succeeded') {
|
||||||
|
stopLoading();
|
||||||
|
showToast(this.$t('voicebox.toggleDeleteSuccessMessage'));
|
||||||
|
}
|
||||||
|
else if (state === 'failed') {
|
||||||
|
stopLoading();
|
||||||
|
showGlobalError(this.toggleDeleteError);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toggleAttachState(state) {
|
||||||
|
if (state === 'requesting') {
|
||||||
|
startLoading();
|
||||||
|
}
|
||||||
|
else if (state === 'succeeded') {
|
||||||
|
stopLoading();
|
||||||
|
showToast(this.$t('voicebox.toggleAttachSuccessMessage'));
|
||||||
|
}
|
||||||
|
else if (state === 'failed') {
|
||||||
|
stopLoading();
|
||||||
|
showGlobalError(this.toggleAttachError);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
updatePinState(state) {
|
||||||
|
if (state === 'succeeded') {
|
||||||
|
showToast(this.$t('voicebox.updatePinSuccessMessage'));
|
||||||
|
}
|
||||||
|
else if (state === 'failed') {
|
||||||
|
showGlobalError(this.updatePinError);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
updateEmailState(state) {
|
||||||
|
if (state === 'succeeded') {
|
||||||
|
showToast(this.$t('voicebox.updateEmailSuccessMessage'));
|
||||||
|
}
|
||||||
|
else if (state === 'failed') {
|
||||||
|
showGlobalError(this.updateEmailError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="stylus" rel="stylesheet/stylus">
|
||||||
|
</style>
|
@ -0,0 +1,234 @@
|
|||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import _ from 'lodash'
|
||||||
|
import { RequestState } from './common'
|
||||||
|
import {
|
||||||
|
getVoiceboxSettings,
|
||||||
|
setVoiceboxDelete,
|
||||||
|
setVoiceboxAttach,
|
||||||
|
setVoiceboxPin,
|
||||||
|
setVoiceboxEmail
|
||||||
|
} from '../api/voicebox';
|
||||||
|
import { i18n } from '../i18n';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
namespaced: true,
|
||||||
|
state: {
|
||||||
|
voiceboxSettings: {
|
||||||
|
attach: null,
|
||||||
|
delete: null,
|
||||||
|
email: '',
|
||||||
|
id: null,
|
||||||
|
pin: null,
|
||||||
|
sms_number: ''
|
||||||
|
},
|
||||||
|
loadingState: RequestState.initial,
|
||||||
|
loadingError: null,
|
||||||
|
toggleDeleteState: RequestState.initial,
|
||||||
|
toggleDeleteError: null,
|
||||||
|
toggleAttachState: RequestState.initial,
|
||||||
|
toggleAttachError: null,
|
||||||
|
updatePinState: RequestState.initial,
|
||||||
|
updatePinError: null,
|
||||||
|
updateEmailState: RequestState.initial,
|
||||||
|
updateEmailError: null
|
||||||
|
},
|
||||||
|
getters: {
|
||||||
|
subscriberId(state, getters, rootState, rootGetters) {
|
||||||
|
return parseInt(rootGetters['user/getSubscriberId']);
|
||||||
|
},
|
||||||
|
isSettingsLoaded(state) {
|
||||||
|
return state.loadingState === 'succeeded';
|
||||||
|
},
|
||||||
|
isDeleteRequesting(state) {
|
||||||
|
return state.toggleDeleteState === 'requesting';
|
||||||
|
},
|
||||||
|
isAttachRequesting(state) {
|
||||||
|
return state.toggleAttachState === 'requesting';
|
||||||
|
},
|
||||||
|
isPinRequesting(state) {
|
||||||
|
return state.updatePinState === 'requesting';
|
||||||
|
},
|
||||||
|
isEmailRequesting(state) {
|
||||||
|
return state.updateEmailState === 'requesting';
|
||||||
|
},
|
||||||
|
loadingState(state) {
|
||||||
|
return state.loadingState;
|
||||||
|
},
|
||||||
|
loadingError(state) {
|
||||||
|
return state.loadingError ||
|
||||||
|
i18n.t('voicebox.loadSettingsErrorMessage');
|
||||||
|
},
|
||||||
|
voiceboxDelete(state) {
|
||||||
|
return _.get(state.voiceboxSettings, 'delete', false);
|
||||||
|
},
|
||||||
|
voiceboxAttach(state) {
|
||||||
|
return _.get(state.voiceboxSettings, 'attach', false);
|
||||||
|
},
|
||||||
|
deleteLabel(state) {
|
||||||
|
return state.voiceboxSettings.delete ?
|
||||||
|
i18n.t('voicebox.label.deletionEnabled') :
|
||||||
|
i18n.t('voicebox.label.deletionDisabled');
|
||||||
|
},
|
||||||
|
attachLabel(state) {
|
||||||
|
return state.voiceboxSettings.attach ?
|
||||||
|
i18n.t('voicebox.label.attachmentEnabled') :
|
||||||
|
i18n.t('voicebox.label.attachmentDisabled');
|
||||||
|
},
|
||||||
|
voiceboxSettings(state) {
|
||||||
|
return state.voiceboxSettings;
|
||||||
|
},
|
||||||
|
toggleDeleteState(state) {
|
||||||
|
return state.toggleDeleteState;
|
||||||
|
},
|
||||||
|
toggleDeleteError(state) {
|
||||||
|
return state.toggleDeleteError ||
|
||||||
|
i18n.t('voicebox.toggleDeleteErrorMessage');
|
||||||
|
},
|
||||||
|
toggleAttachState(state) {
|
||||||
|
return state.toggleAttachState;
|
||||||
|
},
|
||||||
|
toggleAttachError(state) {
|
||||||
|
return state.toggleAttachError ||
|
||||||
|
i18n.t('voicebox.toggleAttachErrorMessage');
|
||||||
|
},
|
||||||
|
updatePinState(state) {
|
||||||
|
return state.updatePinState;
|
||||||
|
},
|
||||||
|
updatePinError(state) {
|
||||||
|
return state.updatePinError ||
|
||||||
|
i18n.t('voicebox.updatePinErrorMessage');
|
||||||
|
},
|
||||||
|
updateEmailState(state) {
|
||||||
|
return state.updateEmailState;
|
||||||
|
},
|
||||||
|
updateEmailError(state) {
|
||||||
|
return state.updateEmailError ||
|
||||||
|
i18n.t('voicebox.updateEmailErrorMessage');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
loadingRequesting(state) {
|
||||||
|
state.loadingState = RequestState.requesting;
|
||||||
|
state.loadingError = null;
|
||||||
|
},
|
||||||
|
loadingSucceeded(state, settings) {
|
||||||
|
state.loadingState = RequestState.succeeded;
|
||||||
|
state.voiceboxSettings = settings;
|
||||||
|
state.loadingError = null;
|
||||||
|
},
|
||||||
|
loadingFailed(state, error) {
|
||||||
|
state.loadingState = RequestState.failed;
|
||||||
|
state.loadingError = error;
|
||||||
|
},
|
||||||
|
toggleDeleteRequesting(state) {
|
||||||
|
state.toggleDeleteState = RequestState.requesting;
|
||||||
|
state.toggleDeleteError = null;
|
||||||
|
},
|
||||||
|
toggleDeleteSucceeded(state) {
|
||||||
|
state.toggleDeleteState = RequestState.succeeded;
|
||||||
|
state.toggleDeleteError = null;
|
||||||
|
},
|
||||||
|
toggleDeleteFailed(state, error) {
|
||||||
|
state.toggleDeleteState = RequestState.failed;
|
||||||
|
state.toggleDeleteError = error;
|
||||||
|
},
|
||||||
|
toggleAttachRequesting(state) {
|
||||||
|
state.toggleAttachState = RequestState.requesting;
|
||||||
|
state.toggleAttachError = null;
|
||||||
|
},
|
||||||
|
toggleAttachSucceeded(state) {
|
||||||
|
state.toggleAttachState = RequestState.succeeded;
|
||||||
|
state.toggleAttachError = null;
|
||||||
|
},
|
||||||
|
toggleAttachFailed(state, error) {
|
||||||
|
state.toggleAttachState = RequestState.failed;
|
||||||
|
state.toggleAttachError = error;
|
||||||
|
},
|
||||||
|
updatePinRequesting(state) {
|
||||||
|
state.updatePinState = RequestState.requesting;
|
||||||
|
state.updatePinError = null;
|
||||||
|
},
|
||||||
|
updatePinSucceeded(state) {
|
||||||
|
state.updatePinState = RequestState.succeeded;
|
||||||
|
state.updatePinError = null;
|
||||||
|
},
|
||||||
|
updatePinFailed(state, error) {
|
||||||
|
state.updatePinState = RequestState.failed;
|
||||||
|
state.updatePinError = error;
|
||||||
|
},
|
||||||
|
updateEmailRequesting(state) {
|
||||||
|
state.updateEmailState = RequestState.requesting;
|
||||||
|
state.updateEmailError = null;
|
||||||
|
},
|
||||||
|
updateEmailSucceeded(state) {
|
||||||
|
state.updateEmailState = RequestState.succeeded;
|
||||||
|
state.updateEmailError = null;
|
||||||
|
},
|
||||||
|
updateEmailFailed(state, error) {
|
||||||
|
state.updateEmailState = RequestState.failed;
|
||||||
|
state.updateEmailError = error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
getVoiceboxSettings(context) {
|
||||||
|
context.commit('loadingRequesting');
|
||||||
|
getVoiceboxSettings(context.getters.subscriberId).then((settings) => {
|
||||||
|
context.commit('loadingSucceeded', settings);
|
||||||
|
}).catch((err) => {
|
||||||
|
context.commit('loadingFailed', err.message);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
toggleDelete(context) {
|
||||||
|
context.commit('toggleDeleteRequesting');
|
||||||
|
setVoiceboxDelete({
|
||||||
|
subscriberId: context.getters.subscriberId,
|
||||||
|
value: !context.getters.voiceboxDelete
|
||||||
|
}).then(() => {
|
||||||
|
context.commit('toggleDeleteSucceeded');
|
||||||
|
context.dispatch('getVoiceboxSettings');
|
||||||
|
}).catch((err) => {
|
||||||
|
context.commit('toggleDeleteFailed', err.message);
|
||||||
|
context.dispatch('getVoiceboxSettings');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
toggleAttach(context) {
|
||||||
|
context.commit('toggleAttachRequesting');
|
||||||
|
setVoiceboxAttach({
|
||||||
|
subscriberId: context.getters.subscriberId,
|
||||||
|
value: !context.getters.voiceboxAttach
|
||||||
|
}).then(() => {
|
||||||
|
context.commit('toggleAttachSucceeded');
|
||||||
|
context.dispatch('getVoiceboxSettings');
|
||||||
|
}).catch((err) => {
|
||||||
|
context.commit('toggleAttachFailed', err.message);
|
||||||
|
context.dispatch('getVoiceboxSettings');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
updatePin(context, value) {
|
||||||
|
context.commit('updatePinRequesting');
|
||||||
|
setVoiceboxPin({
|
||||||
|
subscriberId: context.getters.subscriberId,
|
||||||
|
value: value
|
||||||
|
}).then(() => {
|
||||||
|
context.commit('updatePinSucceeded');
|
||||||
|
context.dispatch('getVoiceboxSettings');
|
||||||
|
}).catch((err) => {
|
||||||
|
context.commit('updatePinFailed', err.message);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
updateEmail(context, value) {
|
||||||
|
context.commit('updateEmailRequesting');
|
||||||
|
setVoiceboxEmail({
|
||||||
|
subscriberId: context.getters.subscriberId,
|
||||||
|
value: value
|
||||||
|
}).then(() => {
|
||||||
|
context.commit('updateEmailSucceeded');
|
||||||
|
context.dispatch('getVoiceboxSettings');
|
||||||
|
}).catch((err) => {
|
||||||
|
context.commit('updateEmailFailed', err.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,80 @@
|
|||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import Vue from 'vue';
|
||||||
|
import VueResource from 'vue-resource';
|
||||||
|
import {
|
||||||
|
get
|
||||||
|
} from '../../src/api/common';
|
||||||
|
import {
|
||||||
|
getVoiceboxSettings
|
||||||
|
} from '../../src/api/voicebox';
|
||||||
|
import { assert } from 'chai';
|
||||||
|
|
||||||
|
Vue.use(VueResource);
|
||||||
|
|
||||||
|
describe('Voicebox', function(){
|
||||||
|
|
||||||
|
const subscriberId = 123;
|
||||||
|
|
||||||
|
it('should get subscriber\'s voicebox settings', function(done){
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
"_links" : {
|
||||||
|
"collection" : {
|
||||||
|
"href" : "/api/voicemailsettings/"
|
||||||
|
},
|
||||||
|
"curies" : {
|
||||||
|
"href" : "http://purl.org/sipwise/ngcp-api/#rel-{rel}",
|
||||||
|
"name" : "ngcp",
|
||||||
|
"templated" : true
|
||||||
|
},
|
||||||
|
"ngcp:journal" : [
|
||||||
|
{
|
||||||
|
"href" : "/api/voicemailsettings/123/journal/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ngcp:subscribers" : [
|
||||||
|
{
|
||||||
|
"href" : "/api/subscribers/123"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"profile" : {
|
||||||
|
"href" : "http://purl.org/sipwise/ngcp-api/"
|
||||||
|
},
|
||||||
|
"self" : {
|
||||||
|
"href" : "/api/voicemailsettings/123"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"attach" : true,
|
||||||
|
"delete" : false,
|
||||||
|
"email" : "",
|
||||||
|
"id" : 123,
|
||||||
|
"pin" : "1234",
|
||||||
|
"sms_number" : ""
|
||||||
|
};
|
||||||
|
|
||||||
|
let settings = {
|
||||||
|
"attach" : true,
|
||||||
|
"delete" : false,
|
||||||
|
"email" : "",
|
||||||
|
"id" : 123,
|
||||||
|
"pin" : "1234",
|
||||||
|
"sms_number" : ""
|
||||||
|
};
|
||||||
|
|
||||||
|
Vue.http.interceptors = [];
|
||||||
|
Vue.http.interceptors.unshift((request, next)=>{
|
||||||
|
next(request.respondWith(JSON.stringify(data), {
|
||||||
|
status: 200
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
getVoiceboxSettings(subscriberId).then((result)=>{
|
||||||
|
assert.deepEqual(result, settings);
|
||||||
|
done();
|
||||||
|
}).catch((err)=>{
|
||||||
|
done(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import VoiceboxModule from '../../src/store/voicebox';
|
||||||
|
import { assert } from 'chai';
|
||||||
|
|
||||||
|
describe('Voicebox', function(){
|
||||||
|
|
||||||
|
it('should load all voicebox settings into store', function(){
|
||||||
|
let state = {
|
||||||
|
voiceboxSettings: {
|
||||||
|
attach: null,
|
||||||
|
delete: null,
|
||||||
|
email: '',
|
||||||
|
id: null,
|
||||||
|
pin: null,
|
||||||
|
sms_number: ''
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let settings = {
|
||||||
|
attach: true,
|
||||||
|
delete: false,
|
||||||
|
email: '',
|
||||||
|
id: 123,
|
||||||
|
pin: 1234,
|
||||||
|
sms_number: ''
|
||||||
|
};
|
||||||
|
VoiceboxModule.mutations.loadingSucceeded(state, settings);
|
||||||
|
assert.deepEqual(state.voiceboxSettings, settings);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
Reference in new issue