diff --git a/src/components/CscMainMenuTop.vue b/src/components/CscMainMenuTop.vue index d7137d5c..7e37dc4d 100644 --- a/src/components/CscMainMenuTop.vue +++ b/src/components/CscMainMenuTop.vue @@ -70,6 +70,12 @@ export default { sublabel: this.$t('navigation.conversations.subTitle'), visible: true }, + { + to: '/user/call-settings', + icon: 'fas fa-cogs', + label: this.$t('navigation.callSettings.title'), + visible: true + }, { to: '/user/call-forwarding', icon: 'phone_forwarded', diff --git a/src/i18n/en.json b/src/i18n/en.json index 2597731e..a76fbdd1 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -95,6 +95,10 @@ "outgoing": "Outgoing", "privacy": "Privacy" }, + "callSettings": { + "title": "Call Settings", + "subTitle": "Call Settings" + }, "reminder": { "title": "Reminder", "subTitle": "Set your personal alarm" @@ -761,5 +765,9 @@ "deleteDestinationText": "You are about to remove destination {destination}", "destinationEmailExists": "The Destination Email is already used", "destinationItemTitle": "<{destination}> as {filetype}" + }, + "callSettings": { + "musicOnHold": "Music on Hold", + "musicOnHoldHint": "\"Music on Hold\" - if set to true and a music on hold file is provided, a calling party gets that file played when put on hold" } } diff --git a/src/pages/CscPageCallSettings.vue b/src/pages/CscPageCallSettings.vue new file mode 100644 index 00000000..eec709dd --- /dev/null +++ b/src/pages/CscPageCallSettings.vue @@ -0,0 +1,93 @@ + + + diff --git a/src/router/routes.js b/src/router/routes.js index 512b0c75..943561c0 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -28,6 +28,7 @@ import CscPageUserSettings from 'src/pages/CscPageUserSettings' import CscPageError404 from 'src/pages/CscPageError404' import CscRecoverPassword from 'src/pages/CscRecoverPassword' import CscPageCf from 'pages/CscPageCf' +import CscPageCallSettings from 'pages/CscPageCallSettings' const getToken = (route) => { return { @@ -204,6 +205,14 @@ export default function routes (app) { subtitle: i18n.t('navigation.userSettings.subTitle') } }, + { + path: 'call-settings', + component: CscPageCallSettings, + meta: { + title: i18n.t('navigation.callSettings.title'), + subtitle: i18n.t('navigation.callSettings.subTitle') + } + }, { path: 'pbx-settings', component: CscPagePbxSettings, diff --git a/src/store/call-settings.js b/src/store/call-settings.js new file mode 100644 index 00000000..b2a67158 --- /dev/null +++ b/src/store/call-settings.js @@ -0,0 +1,45 @@ +import { + getPreferences, + setPreference +} from '../api/subscriber' + +export default { + namespaced: true, + state: { + subscriberPreferencesInitialized: false, + subscriberPreferences: {} + }, + getters: { + subscriberId (state, getters, rootState, rootGetters) { + return parseInt(rootGetters['user/getSubscriberId']) + }, + musicOnHold (state) { + return state.subscriberPreferences.music_on_hold + } + }, + mutations: { + subscriberPreferencesSucceeded (state, res) { + state.subscriberPreferences = res + state.subscriberPreferencesInitialized = true + }, + subscriberPreferencesUpdate (state, { field, value }) { + state.subscriberPreferences[field] = value + } + }, + actions: { + async loadSubscriberPreferencesAction (context) { + const subscriberPreferences = await getPreferences(context.getters.subscriberId) + context.commit('subscriberPreferencesSucceeded', subscriberPreferences) + }, + async fieldUpdateAction (context, options) { + await setPreference(context.getters.subscriberId, options.field, options.value) + context.commit('subscriberPreferencesUpdate', { + field: options.field, + value: options.value + }) + }, + async setMusicOnHold (context, value) { + await context.dispatch('fieldUpdateAction', { field: 'music_on_hold', value }) + } + } +} diff --git a/src/store/index.js b/src/store/index.js index ecd0bdea..da45fbfd 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -10,6 +10,7 @@ import CallForwardModule from './call-forward' import CallForwardingModule from './call-forwarding' import NewCallForwardModule from './new-call-forward' import CallModule, { errorVisibilityTimeout } from './call' +import CallSettingsModule from './call-settings' import ConversationsModule from './conversations' import PbxModule from './pbx' @@ -57,6 +58,7 @@ export default function (/* { ssrContext } */) { callForward: CallForwardModule, newCallForward: NewCallForwardModule, call: CallModule, + callSettings: CallSettingsModule, conversations: ConversationsModule, reminder: ReminderModule, speedDial: SpeedDialModule,