From 9911ccd7bbcc3df133f6d1ce3515ac37081d9bab Mon Sep 17 00:00:00 2001 From: nidrissi-zouggari Date: Thu, 13 Feb 2025 17:05:36 +0100 Subject: [PATCH] MT#62151 Improve error handling in src/store files All functions in the src/store files handle errors from the backend. We now commit an error message that returns the backend error. All promise-based functions in src/store/files have now been replaced with try/catch. Change-Id: Ia315d122809f0b9ae66230c83fb48454c904d722 --- .../pages/Conversations/CscVoiceMailItem.vue | 18 +++- .../PbxConfiguration/CscPbxDeviceFilters.vue | 11 +- src/pages/CscPageConversations.vue | 48 ++++++++- src/pages/CscPageCustomerPreferences.vue | 11 +- src/pages/CscPageDashboard.vue | 10 ++ src/pages/CscPagePbxCallQueues.vue | 18 +++- src/pages/CscPagePbxDeviceDetails.vue | 18 +++- src/pages/CscPagePbxDevices.vue | 25 ++++- src/pages/CscPagePbxGroups.vue | 9 +- src/pages/CscPagePbxMsConfigs.vue | 26 ++++- src/pages/CscPagePbxSeats.vue | 9 +- src/pages/CscPagePbxSoundSetDetails.vue | 57 +++++++++- src/pages/CscPagePbxSoundSets.vue | 9 +- src/pages/CscPagePbxStatisticsCdr.vue | 13 ++- src/pages/CscPageReminder.vue | 14 ++- src/pages/CscPageSpeedDial.vue | 21 +++- src/pages/CscPageVoicebox.vue | 101 +++++++++++++++++- src/store/conversations/actions.js | 15 +-- src/store/conversations/mutations.js | 18 +++- src/store/conversations/state.js | 4 +- src/store/customer.js | 19 ++-- src/store/pbx-callqueues.js | 38 +++---- src/store/pbx-devices.js | 9 +- src/store/pbx-groups.js | 48 ++++----- src/store/pbx-ms-configs.js | 38 +++---- src/store/pbx-seats.js | 74 ++++++------- src/store/pbx-soundsets.js | 93 ++++++++-------- src/store/pbx.js | 68 +++++++----- src/store/reminder.js | 19 ++-- src/store/voicebox.js | 20 ++-- 30 files changed, 646 insertions(+), 235 deletions(-) diff --git a/src/components/pages/Conversations/CscVoiceMailItem.vue b/src/components/pages/Conversations/CscVoiceMailItem.vue index 6d4925e5..c0d01580 100644 --- a/src/components/pages/Conversations/CscVoiceMailItem.vue +++ b/src/components/pages/Conversations/CscVoiceMailItem.vue @@ -90,7 +90,9 @@ import CscMoreMenu from 'components/CscMoreMenu' import CscPopupMenuItem from 'components/CscPopupMenuItem' import CscPopupMenuItemDelete from 'components/CscPopupMenuItemDelete' import CscPopupMenuItemStartCall from 'components/CscPopupMenuItemStartCall' -import { mapGetters } from 'vuex' +import { showGlobalError } from 'src/helpers/ui' +import { RequestState } from 'src/store/common' +import { mapGetters, mapState } from 'vuex' export default { name: 'CscVoiceMailItem', @@ -138,6 +140,10 @@ export default { 'playVoiceMailState', 'playVoiceMailUrl' ]), + ...mapState('conversations', [ + 'playVoiceMailErrors', + 'playVoiceMailStates' + ]), direction () { if (this.voiceMail.direction === 'out') { return 'to' @@ -155,6 +161,16 @@ export default { return this.playVoiceMailState(this.voiceMail.id) === 'succeeded' } }, + watch: { + playVoiceMailStates: { + deep: true, + handler (state) { + if (state[this.voiceMail.id] === RequestState.failed) { + showGlobalError(this.playVoiceMailErrors[this.voiceMail.id]) + } + } + } + }, methods: { playVoiceMail () { this.$emit('play-voice-mail', { diff --git a/src/components/pages/PbxConfiguration/CscPbxDeviceFilters.vue b/src/components/pages/PbxConfiguration/CscPbxDeviceFilters.vue index 7fbbad08..3b30b98e 100644 --- a/src/components/pages/PbxConfiguration/CscPbxDeviceFilters.vue +++ b/src/components/pages/PbxConfiguration/CscPbxDeviceFilters.vue @@ -89,6 +89,8 @@ import CscPbxAutoAttendantSelection from 'components/pages/PbxConfiguration/CscPbxAutoAttendantSelection' import CscPbxModelSelect from 'components/pages/PbxConfiguration/CscPbxModelSelect' import _ from 'lodash' +import { showGlobalError } from 'src/helpers/ui' +import { RequestState } from 'src/store/common' import { mapActions, mapState } from 'vuex' export default { @@ -116,7 +118,9 @@ export default { ...mapState('pbx', [ 'deviceProfileMap', 'deviceProfileList', - 'subscriberList' + 'subscriberList', + 'subcriberListState', + 'subcriberListError' ]), subscribersOptions () { const options = [] @@ -191,6 +195,11 @@ export default { watch: { filterTypeModel () { this.typedFilter = null + }, + subcriberListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.subcriberListError) + } } }, mounted () { diff --git a/src/pages/CscPageConversations.vue b/src/pages/CscPageConversations.vue index 5a455696..a1049d9e 100644 --- a/src/pages/CscPageConversations.vue +++ b/src/pages/CscPageConversations.vue @@ -118,7 +118,9 @@ import CscConversationItem from 'components/pages/Conversations/CscConversationI import CscConversationsCallsFilter from 'components/pages/Conversations/CscConversationsCallsFilter' import CscConversationsFilter from 'components/pages/Conversations/CscConversationsFilter' import { LICENSES } from 'src/constants' +import { showGlobalError } from 'src/helpers/ui' import platformMixin from 'src/mixins/platform' +import { RequestState } from 'src/store/common' import { mapWaitingActions } from 'vue-wait' import { mapGetters, mapMutations, @@ -151,7 +153,19 @@ export default { 'isLicenseActive' ]), ...mapState('conversations', [ - 'reachedLastPage' + 'reachedLastPage', + 'downloadVoiceMailState', + 'downloadVoiceMailError', + 'downloadFaxState', + 'downloadFaxError', + 'blockedIncomingState', + 'blockedIncomingError', + 'blockedOutgoingState', + 'blockedOutgoingError', + 'toggleBlockedState', + 'toggleBlockedError', + 'deletionState', + 'deletionError' ]), ...mapGetters('conversations', [ 'items', @@ -232,6 +246,38 @@ export default { return this.$wait.is('csc-conversations') } }, + watch: { + downloadVoiceMailState (state) { + if (state === RequestState.failed) { + showGlobalError(this.downloadVoiceMailError) + } + }, + downloadFaxState (state) { + if (state === RequestState.failed) { + showGlobalError(this.downloadFaxError) + } + }, + blockedIncomingState (state) { + if (state === RequestState.failed) { + showGlobalError(this.blockedIncomingError) + } + }, + blockedOutgoingState (state) { + if (state === RequestState.failed) { + showGlobalError(this.blockedOutgoingError) + } + }, + toggleBlockedState (state) { + if (state === RequestState.failed) { + showGlobalError(this.toggleBlockedError) + } + }, + deletionState (state) { + if (state === RequestState.failed) { + showGlobalError(this.deletionError) + } + } + }, async mounted () { this.topMargin = this.$refs.pageSticky.$el.offsetHeight this.resetList() diff --git a/src/pages/CscPageCustomerPreferences.vue b/src/pages/CscPageCustomerPreferences.vue index f677d02f..9b88550e 100644 --- a/src/pages/CscPageCustomerPreferences.vue +++ b/src/pages/CscPageCustomerPreferences.vue @@ -126,6 +126,8 @@ import CscPage from 'components/CscPage' import CscInputButtonReset from 'components/form/CscInputButtonReset' import CscInputButtonSave from 'components/form/CscInputButtonSave' import _ from 'lodash' +import { showGlobalError } from 'src/helpers/ui' +import { RequestState } from 'src/store/common' import { mapActions, mapGetters, @@ -163,7 +165,9 @@ export default { ]), ...mapState('customer', [ 'customerPreferences', - 'customerPreferencesSelected' + 'customerPreferencesSelected', + 'customerPreferencesLoadingState', + 'customerPreferencesError' ]), hasBlockOutOverridePinChanged () { return this.changes.block_out_override_pin !== this.customerPreferences.block_out_override_pin @@ -172,6 +176,11 @@ export default { watch: { customerPreferences () { this.changes = this.getCustomerPreferencesData() + }, + customerPreferencesLoadingState (state) { + if (state === RequestState.failed) { + showGlobalError(this.customerPreferencesError) + } } }, mounted () { diff --git a/src/pages/CscPageDashboard.vue b/src/pages/CscPageDashboard.vue index 2c1600e4..8e19ad11 100644 --- a/src/pages/CscPageDashboard.vue +++ b/src/pages/CscPageDashboard.vue @@ -67,6 +67,7 @@ import { callIconColor } from 'src/helpers/call-utils' import { showGlobalError } from 'src/helpers/ui' +import { RequestState } from 'src/store/common' import { mapWaitingActions } from 'vue-wait' import { mapGetters, mapState } from 'vuex' export default { @@ -93,6 +94,10 @@ export default { ...mapState('call', [ 'callEnabled' ]), + ...mapState('conversations', [ + 'downloadVoiceMailState', + 'downloadVoiceMailError' + ]), ...mapGetters('user', [ 'hasSubscriberProfileAttribute' ]), @@ -112,6 +117,11 @@ export default { this.registeredDevicesError = true showGlobalError(err.message) } + }, + downloadVoiceMailState (state) { + if (state === RequestState.failed) { + showGlobalError(this.downloadVoiceMailError) + } } }, mounted () { diff --git a/src/pages/CscPagePbxCallQueues.vue b/src/pages/CscPagePbxCallQueues.vue index 2ee1a458..c71d6f2a 100644 --- a/src/pages/CscPagePbxCallQueues.vue +++ b/src/pages/CscPagePbxCallQueues.vue @@ -137,7 +137,9 @@ export default { 'callQueueRemovalState', 'callQueueCreationError', 'callQueueUpdateError', - 'callQueueRemovalError' + 'callQueueRemovalError', + 'callQueueListState', + 'callQueueListError' ]), ...mapGetters('pbxCallQueues', [ 'isCallQueueListEmpty', @@ -150,6 +152,10 @@ export default { 'getCallQueueCreationToastMessage', 'getCallQueueUpdateToastMessage', 'getCallQueueRemovalToastMessage' + ]), + ...mapState('pbx', [ + 'subcriberListState', + 'subcriberListError' ]) }, watch: { @@ -175,6 +181,16 @@ export default { } else if (state === RequestState.failed) { showGlobalError(this.callQueueRemovalError) } + }, + callQueueListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.callQueueListError) + } + }, + subcriberListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.subcriberListError) + } } }, mounted () { diff --git a/src/pages/CscPagePbxDeviceDetails.vue b/src/pages/CscPagePbxDeviceDetails.vue index 24b1bf67..db86eb59 100644 --- a/src/pages/CscPagePbxDeviceDetails.vue +++ b/src/pages/CscPagePbxDeviceDetails.vue @@ -242,7 +242,9 @@ export default { 'devicePreferencesUpdateError', 'deviceUpdateState', 'devicePreferencesUpdateState', - 'devicePreferencesSelected' + 'devicePreferencesSelected', + 'devicePreferencesListState', + 'devicePreferencesError' ]), ...mapState('pbx', [ 'deviceProfileList', @@ -250,7 +252,9 @@ export default { 'deviceModelImageMap', 'deviceModelMap', 'subscriberList', - 'subscriberMap' + 'subscriberMap', + 'subcriberListState', + 'subcriberListError' ]), ...mapGetters('pbx', [ 'getSubscriberOptions', @@ -335,6 +339,16 @@ export default { } else if (state === RequestState.failed) { showGlobalError(this.devicePreferencesUpdateError) } + }, + devicePreferencesListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.devicePreferencesError) + } + }, + subcriberListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.subcriberListError) + } } }, async created () { diff --git a/src/pages/CscPagePbxDevices.vue b/src/pages/CscPagePbxDevices.vue index fe643e7c..65e614cf 100644 --- a/src/pages/CscPagePbxDevices.vue +++ b/src/pages/CscPagePbxDevices.vue @@ -170,7 +170,11 @@ export default { 'deviceModelMap', 'deviceModelImageMap', 'subscriberList', - 'subscriberMap' + 'subscriberMap', + 'deviceModelListState', + 'deviceModelError', + 'deviceProfileListState', + 'deviceProfileListError' ]), ...mapGetters('pbx', [ 'getSubscriberOptions', @@ -183,7 +187,9 @@ export default { 'deviceListLastPage', 'deviceListVisibility', 'deviceCreationState', - 'deviceRemovalState' + 'deviceRemovalState', + 'deviceListState', + 'deviceListError' ]), ...mapGetters('pbxDevices', [ 'isDeviceListEmpty', @@ -220,6 +226,21 @@ export default { } else if (state === RequestState.failed) { showGlobalError(this.deviceRemovalError) } + }, + deviceListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.deviceListError) + } + }, + deviceModelListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.deviceModelError) + } + }, + deviceProfileListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.deviceProfileListError) + } } }, mounted () { diff --git a/src/pages/CscPagePbxGroups.vue b/src/pages/CscPagePbxGroups.vue index 8bb77bca..8a89af02 100644 --- a/src/pages/CscPagePbxGroups.vue +++ b/src/pages/CscPagePbxGroups.vue @@ -187,7 +187,9 @@ export default { 'groupRemoving', 'groupRemovalState', 'groupRemovalError', - 'groupListVisibility' + 'groupListVisibility', + 'groupListState', + 'groupListError' ]), ...mapGetters('pbx', [ 'getNumberOptions', @@ -231,6 +233,11 @@ export default { } else if (state === RequestState.failed) { showGlobalError(this.groupRemovalError) } + }, + groupListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.groupListError) + } } }, mounted () { diff --git a/src/pages/CscPagePbxMsConfigs.vue b/src/pages/CscPagePbxMsConfigs.vue index 2ac376dc..ce166c78 100644 --- a/src/pages/CscPagePbxMsConfigs.vue +++ b/src/pages/CscPagePbxMsConfigs.vue @@ -135,7 +135,16 @@ export default { 'msConfigRemovalState', 'msConfigCreationError', 'msConfigUpdateError', - 'msConfigRemovalError' + 'msConfigRemovalError', + 'msConfigListState', + 'msConfigListError' + ]), + ...mapState('pbx', [ + 'numberListState', + 'numberListError', + 'subcriberListState', + 'subcriberListError' + ]), ...mapGetters('pbxMsConfigs', [ 'isMsConfigListEmpty', @@ -173,6 +182,21 @@ export default { } else if (state === RequestState.failed) { showGlobalError(this.msConfigRemovalError) } + }, + msConfigListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.msConfigListError) + } + }, + numberListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.numberListError) + } + }, + subcriberListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.subcriberListError) + } } }, mounted () { diff --git a/src/pages/CscPagePbxSeats.vue b/src/pages/CscPagePbxSeats.vue index 33464c13..167058c4 100644 --- a/src/pages/CscPagePbxSeats.vue +++ b/src/pages/CscPagePbxSeats.vue @@ -159,7 +159,9 @@ export default { 'seatRemoving', 'seatRemovalState', 'seatRemovalError', - 'seatListVisibility' + 'seatListVisibility', + 'seatListState', + 'seatListError' ]), ...mapGetters('pbx', [ 'getNumberOptions', @@ -207,6 +209,11 @@ export default { } else if (state === RequestState.failed) { showGlobalError(this.seatRemovalError) } + }, + seatListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.seatListError) + } } }, mounted () { diff --git a/src/pages/CscPagePbxSoundSetDetails.vue b/src/pages/CscPagePbxSoundSetDetails.vue index 15ce7fc6..f05311dc 100644 --- a/src/pages/CscPagePbxSoundSetDetails.vue +++ b/src/pages/CscPagePbxSoundSetDetails.vue @@ -221,7 +221,17 @@ export default { 'soundFileUploadState', 'soundFileUploadProgress', 'soundFileUpdateState', - 'soundHandleGroups' + 'soundHandleGroups', + 'soundHandleListState', + 'soundHandleListError', + 'soundFileListStates', + 'soundFileError', + 'soundFileRemoveError', + 'soundFileState', + 'soundFileUploadState', + 'soundFileUploadError', + 'soundFileUpdateError', + 'soundFileRemoveState' ]), ...mapGetters('pbxSoundSets', [ 'isSoundFileListRequesting', @@ -279,6 +289,51 @@ export default { return group }) } + }, + soundHandleListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.soundHandleListError) + } + }, + soundFileListStates: { + deep: true, + handler (state) { + if (state[state.soundSetId] === RequestState.failed) { + showGlobalError(this.soundFileError) + } + } + }, + soundFileState: { + deep: true, + handler (state) { + if (state[this.soundSetSelected.id] === RequestState.failed) { + showGlobalError(this.soundFileError) + } + } + }, + soundFileUploadState: { + deep: true, + handler (state) { + if (Object.values(state).includes(RequestState.failed)) { + showGlobalError(this.soundFileUploadError) + } + } + }, + soundFileUpdateState: { + deep: true, + handler (state) { + if (Object.values(state).includes(RequestState.failed)) { + showGlobalError(this.soundFileUpdateError) + } + } + }, + soundFileRemoveState: { + deep: true, + handler (state) { + if (Object.values(state).includes(RequestState.failed)) { + showGlobalError(this.soundFileRemoveError) + } + } } }, async mounted () { diff --git a/src/pages/CscPagePbxSoundSets.vue b/src/pages/CscPagePbxSoundSets.vue index 334c235a..6dca994c 100644 --- a/src/pages/CscPagePbxSoundSets.vue +++ b/src/pages/CscPagePbxSoundSets.vue @@ -131,7 +131,9 @@ export default { 'soundSetRemovalState', 'soundSetRemovalError', 'soundSetUpdateState', - 'soundSetUpdateError' + 'soundSetUpdateError', + 'soundSetListState', + 'soundSetListError' ]), ...mapGetters('pbxSoundSets', [ 'isSoundSetListEmpty', @@ -171,6 +173,11 @@ export default { } else if (state === RequestState.failed) { showGlobalError(this.soundSetRemovalError) } + }, + soundSetListState (state) { + if (state === RequestState.failed) { + showGlobalError(this.soundSetListError) + } } }, mounted () { diff --git a/src/pages/CscPagePbxStatisticsCdr.vue b/src/pages/CscPagePbxStatisticsCdr.vue index d95fc2f0..332c58fe 100644 --- a/src/pages/CscPagePbxStatisticsCdr.vue +++ b/src/pages/CscPagePbxStatisticsCdr.vue @@ -77,6 +77,8 @@ import CscSpinner from 'components/CscSpinner' import CscCdrFilters from 'components/pages/PbxStatistics/CscCdrFilters' import _ from 'lodash' import { LIST_DEFAULT_ROWS } from 'src/api/common' +import { showGlobalError } from 'src/helpers/ui' +import { RequestState } from 'src/store/common' import { mapWaitingActions } from 'vue-wait' import { mapState } from 'vuex' export default { @@ -107,7 +109,9 @@ export default { }, computed: { ...mapState('conversations', [ - 'conversations' + 'conversations', + 'conversationError', + 'conversationState' ]), columns () { return [ @@ -170,6 +174,13 @@ export default { ] } }, + watch: { + conversationState (state) { + if (state === RequestState.failed) { + showGlobalError(this.conversationError) + } + } + }, async mounted () { await this.refresh() }, diff --git a/src/pages/CscPageReminder.vue b/src/pages/CscPageReminder.vue index 2323ba0a..e8d71cc4 100644 --- a/src/pages/CscPageReminder.vue +++ b/src/pages/CscPageReminder.vue @@ -106,10 +106,12 @@ import CscPage from 'components/CscPage' import CscSpinner from 'components/CscSpinner' import { date } from 'quasar' -import { showToast } from 'src/helpers/ui' +import { showGlobalError, showToast } from 'src/helpers/ui' +import { RequestState } from 'src/store/common' import { mapActions, - mapGetters + mapGetters, + mapState } from 'vuex' export default { @@ -133,6 +135,9 @@ export default { 'isReminderLoading', 'reminderUpdated' ]), + ...mapState('reminder', [ + 'reminderLoadingState' + ]), recurrenceOptions () { return [ { @@ -172,6 +177,11 @@ export default { recurrence: this.mapRecurrence(this.reminderRecurrence) })) } + }, + reminderLoadingState () { + if (this.reminderLoadingState === RequestState.failed) { + showGlobalError(this.reminderError) + } } }, mounted () { diff --git a/src/pages/CscPageSpeedDial.vue b/src/pages/CscPageSpeedDial.vue index 1f0e2d7d..670aa8fe 100644 --- a/src/pages/CscPageSpeedDial.vue +++ b/src/pages/CscPageSpeedDial.vue @@ -102,7 +102,8 @@ import { showGlobalError, showToast } from 'src/helpers/ui' -import { mapGetters } from 'vuex' +import { RequestState } from 'src/store/common' +import { mapGetters, mapState } from 'vuex' export default { name: 'CscPageSpeedDial', @@ -131,11 +132,17 @@ export default { 'assignSlotError', 'lastAssignedSlot', 'isAdding' + ]), + ...mapState('speedDial', [ + 'speedDialLoadingState', + 'speedDialLoadingError', + 'unassignSlotState', + 'unassignSlotError' ]) }, watch: { assignSlotState (state) { - if (state === 'failed') { + if (state === RequestState.failed) { showGlobalError(this.assignSlotError) } else if (state === 'succeeded') { this.$refs.addForm.cancel() @@ -143,6 +150,16 @@ export default { slot: this.lastAssignedSlot })) } + }, + speedDialLoadingState () { + if (this.speedDialLoadingState === RequestState.failed) { + showGlobalError(this.speedDialLoadingError) + } + }, + unassignSlotState () { + if (this.unassignSlotState === RequestState.failed) { + showGlobalError(this.unassignSlotError) + } } }, mounted () { diff --git a/src/pages/CscPageVoicebox.vue b/src/pages/CscPageVoicebox.vue index e5ad6126..9eb21df6 100644 --- a/src/pages/CscPageVoicebox.vue +++ b/src/pages/CscPageVoicebox.vue @@ -219,6 +219,7 @@ import { showGlobalError, showToast } from 'src/helpers/ui' +import { RequestState } from 'src/store/common' import { mapWaitingActions } from 'vue-wait' import { mapActions, @@ -283,7 +284,35 @@ export default { 'tempGreetingUploadProgress', 'greetGreetingId', 'greetGreetingUrl', - 'greetGreetingUploadProgress' + 'greetGreetingUploadProgress', + 'attachUpdateState', + 'attachUpdateError', + 'deleteUpdateState', + 'deleteUpdateError', + 'busyGreetingUploadState', + 'busyGreetingUploadError', + 'unavailableGreetingUploadState', + 'unavailableGreetingUploadError', + 'tempGreetingUploadState', + 'tempGreetingUploadError', + 'greetGreetingUploadState', + 'greetGreetingUploadError', + 'busyGreetingLoadState', + 'busyGreetingLoadError', + 'unavailableGreetingLoadState', + 'unavailableGreetingLoadError', + 'tempGreetingLoadState', + 'tempGreetingLoadError', + 'greetGreetingLoadState', + 'greetGreetingLoadError', + 'busyGreetingDeletionState', + 'busyGreetingDeletionError', + 'unavailableGreetingDeletionState', + 'unavailableGreetingDeletionError', + 'tempGreetingdeletionState', + 'tempGreetingDeletionError', + 'greetGreetingDeletionState', + 'greetGreetingDeletionError' ]), ...mapGetters('voicebox', [ 'settingsLoading', @@ -388,6 +417,76 @@ export default { }, deleteValue (value) { this.formData.delete = value + }, + attachUpdateState (state) { + if (state === RequestState.failed) { + showGlobalError(this.attachUpdateError) + } + }, + deleteUpdateState (state) { + if (state === RequestState.failed) { + showGlobalError(this.deleteUpdateError) + } + }, + busyGreetingUploadState (state) { + if (state === RequestState.failed) { + showGlobalError(this.busyGreetingUploadError) + } + }, + unavailableGreetingUploadState (state) { + if (state === RequestState.failed) { + showGlobalError(this.unavailableGreetingUploadError) + } + }, + tempGreetingUploadState (state) { + if (state === RequestState.failed) { + showGlobalError(this.tempGreetingUploadError) + } + }, + greetGreetingUploadState (state) { + if (state === RequestState.failed) { + showGlobalError(this.greetGreetingUploadError) + } + }, + busyGreetingLoadState (state) { + if (state === RequestState.failed) { + showGlobalError(this.busyGreetingLoadError) + } + }, + unavailableGreetingLoadState (state) { + if (state === RequestState.failed) { + showGlobalError(this.unavailableGreetingLoadError) + } + }, + tempGreetingLoadState (state) { + if (state === RequestState.failed) { + showGlobalError(this.tempGreetingLoadError) + } + }, + greetGreetingLoadState (state) { + if (state === RequestState.failed) { + showGlobalError(this.greetGreetingLoadError) + } + }, + busyGreetingDeletionState (state) { + if (state === RequestState.failed) { + showGlobalError(this.busyGreetingDeletionError) + } + }, + unavailableGreetingDeletionState (state) { + if (state === RequestState.failed) { + showGlobalError(this.unavailableGreetingDeletionError) + } + }, + tempGreetingDeletionState (state) { + if (state === RequestState.failed) { + showGlobalError(this.tempGreetingDeletionError) + } + }, + greetGreetingDeletionState (state) { + if (state === RequestState.failed) { + showGlobalError(this.greetGreetingDeletionError) + } } }, async mounted () { diff --git a/src/store/conversations/actions.js b/src/store/conversations/actions.js index b2d7c8d2..5f1b638a 100644 --- a/src/store/conversations/actions.js +++ b/src/store/conversations/actions.js @@ -28,14 +28,14 @@ const ReloadConfig = { export default { async loadConversations ({ commit, dispatch, state, rootGetters }, options) { try { + commit('loadConversationsRequesting') const list = await getConversations({ ...options }) - commit('setConversations', list.items) + commit('loadConversationsSucceeded', list.items) return list.totalCount } catch (err) { - commit('setConversations', []) - throw err + commit('loadConversationsFailed', err.message) } }, reloadItems (context, options) { @@ -75,7 +75,7 @@ export default { downloadVoiceMail(id).then(() => { context.commit('downloadVoiceMailSucceeded') }).catch((err) => { - context.commit('downloadVoiceMailFailed', err.response.data.message) + context.commit('downloadVoiceMailFailed', err.message) }) }, downloadFax (context, id) { @@ -83,7 +83,7 @@ export default { downloadFax(id).then(() => { context.commit('downloadFaxSucceeded') }).catch((err) => { - context.commit('downloadFaxFailed', err.response.data.message) + context.commit('downloadFaxFailed', err.message) }) }, playVoiceMail (context, options) { @@ -94,7 +94,10 @@ export default { url }) }).catch((err) => { - context.commit('playVoiceMailFailed', options.id, err.mesage) + context.commit('playVoiceMailFailed', { + id: options.id, + error: err.message + }) }) }, async nextPage (context, options) { diff --git a/src/store/conversations/mutations.js b/src/store/conversations/mutations.js index 81890e70..bc045fe7 100644 --- a/src/store/conversations/mutations.js +++ b/src/store/conversations/mutations.js @@ -68,10 +68,10 @@ export default { state.playVoiceMailStates[options.id] = RequestState.succeeded state.playVoiceMailErrors[options.id] = null }, - playVoiceMailFailed (state, id, err) { - state.playVoiceMailUrls[id] = null - state.playVoiceMailStates[id] = RequestState.failed - state.playVoiceMailErrors[id] = err + playVoiceMailFailed (state, options) { + state.playVoiceMailUrls[options.id] = null + state.playVoiceMailStates[options.id] = RequestState.failed + state.playVoiceMailErrors[options.id] = options.error }, resetList (state) { state.items = [] @@ -154,7 +154,15 @@ export default { state.deletionState = RequestState.failed state.deletionError = err }, - setConversations (state, value) { + loadConversationsSucceeded (state, value) { + state.conversationState = RequestState.succeeded state.conversations = value + }, + loadConversationsRequesting (state) { + state.conversationState = RequestState.requesting + }, + loadConversationsFailed (state, err) { + state.conversationState = RequestState.failed + state.conversationError = err } } diff --git a/src/store/conversations/state.js b/src/store/conversations/state.js index 3f1351f0..41a5bf02 100644 --- a/src/store/conversations/state.js +++ b/src/store/conversations/state.js @@ -32,5 +32,7 @@ export default { toggleBlockedError: null, lastToggledType: null, deletionState: RequestState.initiated, - deletionError: null + deletionError: null, + conversationState: RequestState.initiated, + conversationError: null } diff --git a/src/store/customer.js b/src/store/customer.js index 2cbe8053..d4fdc90c 100644 --- a/src/store/customer.js +++ b/src/store/customer.js @@ -39,17 +39,14 @@ export default { } }, actions: { - loadCustomerPreferences (context, customerId) { - return new Promise((resolve, reject) => { - context.commit('customerPreferencesLoading') - getCustomerPreference(customerId).then((customerPreferences) => { - context.commit('customerPreferencesLoaded', customerPreferences) - resolve() - }).catch((err) => { - reject(err) - context.commit('customerPreferencesLoadingFailed', err.message) - }) - }) + async loadCustomerPreferences (context, customerId) { + context.commit('customerPreferencesLoading') + try { + const customerPreferences = await getCustomerPreference(customerId) + context.commit('customerPreferencesLoaded', customerPreferences) + } catch (err) { + context.commit('customerPreferencesLoadingFailed', err.message) + } }, updateIgnoreMembers (context, options) { setCustomerPreference(options.customerId, options.ignore_cf, 'ignore_cf_when_hunting').then((customerPreference) => { diff --git a/src/store/pbx-callqueues.js b/src/store/pbx-callqueues.js index 73b272cd..bd3c5170 100644 --- a/src/store/pbx-callqueues.js +++ b/src/store/pbx-callqueues.js @@ -14,6 +14,7 @@ export default { state: { callQueueListState: RequestState.initiated, callQueueListVisible: true, + callQueueListError: null, callQueueList: [], callQueueMap: {}, callQueueSelected: null, @@ -126,6 +127,10 @@ export default { }) state.callQueueListVisible = true }, + callQueueListFailed (state, err) { + state.callQueueListState = RequestState.failed + state.callQueueListError = err + }, callQueueCreationRequesting (state, data) { state.callQueueCreationState = CreationState.creating state.callQueueCreationData = data @@ -189,25 +194,20 @@ export default { } }, actions: { - loadCallQueueList (context, options) { - return new Promise((resolve) => { - const listVisible = _.get(options, 'listVisible', false) - const selectedId = _.get(options, 'selectedId', null) - context.commit('callQueueListRequesting', { - listVisible - }) - getCallQueueList().then((callQueueList) => { - context.commit('callQueueListSucceeded', callQueueList) - if (selectedId !== null) { - context.commit('expandCallQueue', callQueueList) - context.commit('highlightCallQueue', callQueueList) - } - resolve() - }).catch(() => { - resolve() - context.commit('callQueueListSucceeded') - }) - }) + async loadCallQueueList (context, options) { + const listVisible = _.get(options, 'listVisible', false) + const selectedId = _.get(options, 'selectedId', null) + context.commit('callQueueListRequesting', { listVisible }) + try { + const callQueueList = await getCallQueueList() + context.commit('callQueueListSucceeded', callQueueList) + if (selectedId !== null) { + context.commit('expandCallQueue', callQueueList) + context.commit('highlightCallQueue', callQueueList) + } + } catch (err) { + context.commit('callQueueListFailed', err.message) + } }, createCallQueue (context, callQueueData) { context.commit('callQueueCreationRequesting', callQueueData) diff --git a/src/store/pbx-devices.js b/src/store/pbx-devices.js index 680045eb..d522e658 100644 --- a/src/store/pbx-devices.js +++ b/src/store/pbx-devices.js @@ -27,6 +27,8 @@ export default { deviceListVisibility: 'visible', deviceMapById: {}, devicePreferencesList: [], + deviceListError: null, + deviceMap: {}, devicePreferencesListState: RequestState.initiated, devicePreferencesMap: {}, devicePreferencesRemovalState: RequestState.initiated, @@ -36,6 +38,7 @@ export default { devicePreferencesUpdateState: RequestState.initiated, devicePreferencesUpdating: null, devicePreferencesUpdatingField: null, + devicePreferencesError: null, deviceRemovalError: null, deviceRemovalState: RequestState.initiated, deviceRemoving: null, @@ -194,11 +197,13 @@ export default { state.devicePreferencesMap[devicePreferences.id] = devicePreferences }) }, - deviceListFailed (state) { + deviceListFailed (state, err) { state.deviceListState = RequestState.failed + state.deviceListError = err }, - devicePreferencesListFailed (state) { + devicePreferencesListFailed (state, err) { state.devicePreferencesListState = RequestState.failed + state.devicePreferencesError = err }, deviceCreationRequesting (state, device) { state.deviceCreationState = CreationState.creating diff --git a/src/store/pbx-groups.js b/src/store/pbx-groups.js index 9d05bab9..2f8b5c9a 100644 --- a/src/store/pbx-groups.js +++ b/src/store/pbx-groups.js @@ -20,6 +20,7 @@ export default { state: { groupListState: RequestState.initiated, groupListVisibility: 'visible', + groupListError: null, groupListItems: [], groupListCurrentPage: 1, groupListLastPage: null, @@ -187,8 +188,9 @@ export default { state.groupListVisibility = 'visible' } }, - groupListItemsFailed (state) { + groupListItemsFailed (state, err) { state.groupListState = RequestState.failed + state.groupListError = err }, groupCreationRequesting (state, group) { state.groupCreationState = CreationState.creating @@ -261,33 +263,25 @@ export default { } }, actions: { - loadGroupListItems (context, options) { - return new Promise((resolve, reject) => { - const page = _.get(options, 'page', context.state.groupListCurrentPage) - const filters = _.get(options, 'filters', {}) - const clearList = _.get(options, 'clearList', true) - context.commit('groupListItemsRequesting', { - clearList - }) - getGroupList({ - page, - filters - }).then((groupList) => { - context.commit('pbx/pilotSucceeded', groupList.pilot, { root: true }) - context.commit('pbx/numbersSucceeded', groupList.numbers, { root: true }) - context.commit('pbx/soundSetsSucceeded', groupList.soundSets, { root: true }) - context.commit('pbx/seatsSucceeded', groupList.seats, { root: true }) - context.commit('groupListItemsSucceeded', { - groups: groupList.groups, - preferences: groupList.preferences, - page - }) - resolve() - }).catch((err) => { - context.commit('groupListItemsFailed', err.message) - reject(err) + async loadGroupListItems (context, options) { + const page = _.get(options, 'page', context.state.groupListCurrentPage) + const filters = _.get(options, 'filters', {}) + const clearList = _.get(options, 'clearList', true) + context.commit('groupListItemsRequesting', { clearList }) + try { + const groupList = await getGroupList({ page, filters }) + context.commit('pbx/pilotSucceeded', groupList.pilot, { root: true }) + context.commit('pbx/numbersSucceeded', groupList.numbers, { root: true }) + context.commit('pbx/soundSetsSucceeded', groupList.soundSets, { root: true }) + context.commit('pbx/seatsSucceeded', groupList.seats, { root: true }) + context.commit('groupListItemsSucceeded', { + groups: groupList.groups, + preferences: groupList.preferences, + page }) - }) + } catch (err) { + context.commit('groupListItemsFailed', err.message) + } }, createGroup (context, groupData) { context.commit('groupCreationRequesting', groupData) diff --git a/src/store/pbx-ms-configs.js b/src/store/pbx-ms-configs.js index 69380b69..3679306f 100644 --- a/src/store/pbx-ms-configs.js +++ b/src/store/pbx-ms-configs.js @@ -13,6 +13,7 @@ export default { state: { msConfigListState: RequestState.initiated, msConfigListVisible: true, + msConfigListError: null, msConfigList: [], msConfigMap: {}, msConfigSelected: null, @@ -123,6 +124,10 @@ export default { }) state.msConfigListVisible = true }, + msConfigListFailed (state, err) { + state.msConfigListState = RequestState.failed + state.msConfigListError = err + }, msConfigCreationRequesting (state, data) { state.msConfigCreationState = CreationState.creating state.msConfigCreationData = data @@ -186,25 +191,20 @@ export default { } }, actions: { - loadMsConfigList (context, options) { - return new Promise((resolve) => { - const listVisible = _.get(options, 'listVisible', false) - const selectedId = _.get(options, 'selectedId', null) - context.commit('msConfigListRequesting', { - listVisible - }) - getMsConfigList().then((msConfigList) => { - context.commit('msConfigListSucceeded', msConfigList) - if (selectedId !== null) { - context.commit('expandMsConfig', msConfigList) - context.commit('highlightMsConfig', msConfigList) - } - resolve() - }).catch(() => { - resolve() - context.commit('msConfigListSucceeded') - }) - }) + async loadMsConfigList (context, options) { + const listVisible = _.get(options, 'listVisible', false) + const selectedId = _.get(options, 'selectedId', null) + context.commit('msConfigListRequesting', { listVisible }) + try { + const msConfigList = await getMsConfigList() + context.commit('msConfigListSucceeded', msConfigList) + if (selectedId !== null) { + context.commit('expandMsConfig', msConfigList) + context.commit('highlightMsConfig', msConfigList) + } + } catch (err) { + context.commit('msConfigListFailed', err.message) + } }, createMsConfig (context, msConfigData) { context.commit('msConfigCreationRequesting', msConfigData) diff --git a/src/store/pbx-seats.js b/src/store/pbx-seats.js index cb503243..735a5175 100644 --- a/src/store/pbx-seats.js +++ b/src/store/pbx-seats.js @@ -37,6 +37,7 @@ export default { state: { seatListState: RequestState.initiated, seatListVisibility: 'visible', + seatListError: null, seatListItems: [], seatListCurrentPage: 1, seatListLastPage: null, @@ -247,8 +248,9 @@ export default { state.seatListVisibility = 'visible' } }, - seatListItemsFailed (state) { + seatListItemsFailed (state, err) { state.seatListState = RequestState.failed + state.seatListError = err }, seatCreationRequesting (state, seat) { state.seatCreationState = CreationState.creating @@ -324,39 +326,34 @@ export default { loadPreferences (context, seatId) { return getSeatPreferences(seatId) }, - loadSeatListItems (context, options) { - return new Promise((resolve, reject) => { - const page = _.get(options, 'page', context.state.seatListCurrentPage) - const clearList = _.get(options, 'clearList', true) - const displayName = _.get(options, 'display_name', null) - const pbxExtension = _.get(options, 'pbx_extension', null) - const primaryNumber = _.get(options, 'primary_number', null) - const aliasNumber = _.get(options, 'alias_number', null) - context.commit('seatListItemsRequesting', { - clearList - }) - getSeatList({ + async loadSeatListItems (context, options) { + const page = _.get(options, 'page', context.state.seatListCurrentPage) + const clearList = _.get(options, 'clearList', true) + const displayName = _.get(options, 'display_name', null) + const pbxExtension = _.get(options, 'pbx_extension', null) + const primaryNumber = _.get(options, 'primary_number', null) + const aliasNumber = _.get(options, 'alias_number', null) + context.commit('seatListItemsRequesting', { clearList }) + try { + const seatList = await getSeatList({ page, display_name: displayName, pbx_extension: pbxExtension, primary_number: primaryNumber, alias_number: aliasNumber - }).then((seatList) => { - context.commit('pbx/pilotSucceeded', seatList.pilot, { root: true }) - context.commit('pbx/numbersSucceeded', seatList.numbers, { root: true }) - context.commit('pbx/soundSetsSucceeded', seatList.soundSets, { root: true }) - context.commit('pbx/groupsSucceeded', seatList.groups, { root: true }) - context.commit('seatListItemsSucceeded', { - seats: seatList.seats, - preferences: seatList.preferences, - page - }) - resolve() - }).catch((err) => { - context.commit('seatListItemsFailed', err.message) - reject(err) }) - }) + context.commit('pbx/pilotSucceeded', seatList.pilot, { root: true }) + context.commit('pbx/numbersSucceeded', seatList.numbers, { root: true }) + context.commit('pbx/soundSetsSucceeded', seatList.soundSets, { root: true }) + context.commit('pbx/groupsSucceeded', seatList.groups, { root: true }) + context.commit('seatListItemsSucceeded', { + seats: seatList.seats, + preferences: seatList.preferences, + page + }) + } catch (err) { + context.commit('seatListItemsFailed', err.message) + } }, createSeat (context, seatData) { context.commit('seatCreationRequesting', seatData) @@ -468,23 +465,22 @@ export default { context.commit('seatUpdateFailed', err.message) }) }, - setSeatNumbers (context, options) { + async setSeatNumbers (context, options) { context.commit('seatUpdateRequesting', { seatId: options.seatId, seatField: i18n.global.t('Alias Numbers') }) - setSeatNumbers({ - seatId: options.seatId, - pilotId: context.rootGetters['pbx/pilot'].id, - assignedNumbers: options.assignedNumbers, - unassignedNumbers: options.unassignedNumbers - }).then((result) => { - return Promise.resolve(result) - }).then((result) => { + try { + const result = await setSeatNumbers({ + seatId: options.seatId, + pilotId: context.rootGetters['pbx/pilot'].id, + assignedNumbers: options.assignedNumbers, + unassignedNumbers: options.unassignedNumbers + }) context.commit('seatUpdateSucceeded', result) - }).catch((err) => { + } catch (err) { context.commit('seatUpdateFailed', err.message) - }) + } }, setSeatSoundSet (context, options) { context.commit('seatUpdateRequesting', { diff --git a/src/store/pbx-soundsets.js b/src/store/pbx-soundsets.js index 5a969da2..e6a9b6bb 100644 --- a/src/store/pbx-soundsets.js +++ b/src/store/pbx-soundsets.js @@ -30,6 +30,7 @@ export default { state: { soundSetListState: RequestState.initiated, soundSetListVisible: true, + soundSetListError: null, soundSetList: [], soundSetMap: {}, soundSetListCurrentPage: 1, @@ -47,13 +48,18 @@ export default { soundSetSelected: null, soundHandleList: {}, soundHandleListState: RequestState.initiated, + soundHandleListError: null, soundFileMap: {}, soundFileUrlMap: {}, soundFileListStates: {}, soundFileState: {}, + soundFileError: null, + soundFileRemoveError: null, soundFileUploadState: {}, + soundFileUploadError: null, soundFileUploadProgress: {}, soundFileUpdateState: {}, + soundFileUpdateError: null, soundFileRemoveState: {}, soundHandleGroups: [] }, @@ -160,6 +166,10 @@ export default { state.soundSetMap[soundSet.id] = soundSet }) }, + soundSetListFailed (state, err) { + state.soundSetListState = RequestState.failed + state.soundSetListError = err + }, soundSetCreationRequesting (state, options) { state.soundSetCreationState = CreationState.creating state.soundSetCreationData = options @@ -238,6 +248,10 @@ export default { return group }) }, + soundHandlesFailed (state, err) { + state.soundHandleListState = RequestState.failed + state.soundHandleListError = err + }, soundFilesRequesting (state, soundSetId) { delete state.soundFileListStates[soundSetId] state.soundFileListStates[soundSetId] = RequestState.requesting @@ -253,6 +267,11 @@ export default { })] = soundFile }) }, + soundFilesFailed (state, err, soundSetId) { + delete state.soundFileListStates[soundSetId] + state.soundFileListStates[soundSetId] = RequestState.failed + state.soundFileError = err + }, soundFileRequesting (state, options) { delete state.soundFileState[options.soundFile.id] state.soundFileState[options.soundFile.id] = RequestState.requesting @@ -270,6 +289,7 @@ export default { soundFileFailed (state, options) { delete state.soundFileState[options.soundFile.id] state.soundFileState[options.soundFile.id] = RequestState.failed + state.soundFileError = options.error }, soundFileUploadRequesting (state, soundFileId) { delete state.soundFileUploadState[soundFileId] @@ -296,6 +316,7 @@ export default { soundFileUploadAborted (state, options) { delete state.soundFileUploadState[options.soundFileId] state.soundFileUploadState[options.soundFileId] = RequestState.failed + state.soundFileUploadError = options.error }, soundFileUpdateRequesting (state, options) { const soundFileIntId = toFileId({ @@ -324,6 +345,7 @@ export default { }) delete state.soundFileUpdateState[soundFileIntId] state.soundFileUpdateState[soundFileIntId] = RequestState.failed + state.soundFileUpdateError = options.error }, soundFileRemoveRequesting (state, options) { const soundFileIntId = toFileId({ @@ -349,6 +371,7 @@ export default { }) delete state.soundFileRemoveState[soundFileIntId] state.soundFileRemoveState[soundFileIntId] = RequestState.failed + state.soundFileRemoveError = options.error }, selectSoundSet (state, soundSetId) { state.soundSetSelected = state.soundSetMap[soundSetId] @@ -358,29 +381,20 @@ export default { } }, actions: { - loadSoundSetList (context, options) { - return new Promise((resolve) => { - const listVisible = _.get(options, 'listVisible', false) - context.commit('soundSetListRequesting', { - listVisible - }) - let page = _.get(options, 'page', context.state.soundSetListCurrentPage) - page = (page === null) ? 1 : page - getSoundSetList({ + async loadSoundSetList (context, options) { + const listVisible = _.get(options, 'listVisible', false) + context.commit('soundSetListRequesting', { listVisible }) + let page = _.get(options, 'page', context.state.soundSetListCurrentPage) + page = (page === null) ? 1 : page + try { + const soundSetList = await getSoundSetList({ page }) + context.commit('soundSetListSucceeded', { + soundSets: soundSetList.soundSets, page - }).then((soundSetList) => { - context.commit('soundSetListSucceeded', { - soundSets: soundSetList.soundSets, - page - }) - resolve() - }).catch(() => { - context.commit('soundSetListSucceeded', { - soundSets: [] - }) - resolve() }) - }) + } catch (err) { + context.commit('soundSetListFailed', err.message) + } }, createSoundSet (context, options) { context.commit('soundSetCreationRequesting', options) @@ -456,10 +470,8 @@ export default { context.commit('soundHandlesRequesting') getAllSoundHandles().then((soundHandles) => { context.commit('soundHandlesSucceeded', soundHandles) - }).catch(() => { - context.commit('soundHandlesSucceeded', { - items: [] - }) + }).catch((err) => { + context.commit('soundHandlesFailed', err.message) }) } if (context.state.soundFileListStates[soundSetId] !== RequestState.succeeded) { @@ -469,13 +481,8 @@ export default { soundSetId, soundFiles }) - }).catch(() => { - context.commit('soundFilesSucceeded', { - soundSetId, - soundFiles: { - items: [] - } - }) + }).catch((err) => { + context.commit('soundFilesFailed', err.message, soundSetId) }) } }, @@ -490,9 +497,10 @@ export default { soundFile, soundFileUrl }) - }).catch(() => { + }).catch((err) => { context.commit('soundFileFailed', { - soundFile + soundFile, + error: err.message }) }) }, @@ -522,12 +530,13 @@ export default { } }).then((res) => { context.commit('soundFileUploadSucceeded', res) - }).catch(() => { + }).catch((err) => { context.commit('soundFileUploadAborted', { soundFileId: toFileId({ soundSetId: options.soundSetId, soundHandle: options.soundHandle - }) + }), + error: err.message }) }) }, @@ -535,24 +544,24 @@ export default { context.commit('soundFileUpdateRequesting', options) setLoopPlay(options).then((soundFile) => { context.commit('soundFileUpdateSucceeded', soundFile) - }).catch(() => { - context.commit('soundFileUpdateFailed', options) + }).catch((err) => { + context.commit('soundFileUpdateFailed', { ...options, error: err.message }) }) }, setUseParent (context, options) { context.commit('soundFileUpdateRequesting', options) setUseParent(options).then((soundFile) => { context.commit('soundFileUpdateSucceeded', soundFile) - }).catch(() => { - context.commit('soundFileUpdateFailed', options) + }).catch((err) => { + context.commit('soundFileUpdateFailed', { ...options, error: err.message }) }) }, removeSoundFile (context, options) { context.commit('soundFileRemoveRequesting', options) removeSoundFile(options.soundFileId).then(() => { context.commit('soundFileRemoveSucceeded', options) - }).catch(() => { - context.commit('soundFileRemoveFailed', options) + }).catch((err) => { + context.commit('soundFileRemoveFailed', { ...options, error: err.message }) }) } } diff --git a/src/store/pbx.js b/src/store/pbx.js index 474f4bbe..ba4a470e 100644 --- a/src/store/pbx.js +++ b/src/store/pbx.js @@ -19,6 +19,7 @@ export default { numberList: [], numberMapById: {}, numberListState: RequestState.initiated, + numberListError: null, groupList: [], groupMapById: {}, seatList: [], @@ -29,13 +30,17 @@ export default { deviceProfileList: [], deviceProfileMap: {}, deviceModelList: [], + deviceModelListState: RequestState.initiated, deviceModelMap: {}, deviceModelImageMap: {}, deviceModelImageSmallMap: {}, subscriberList: [], subscriberListState: RequestState.initiated, + subcriberListError: null, subscriberMap: {}, - ncosMapByName: {} + ncosMapByName: {}, + deviceProfileListState: RequestState.initiated, + deviceProfileListError: null }, getters: { pilot (state) { @@ -204,6 +209,10 @@ export default { state.numberMapById[number.id] = number }) }, + numbersFailed (state, err) { + state.numberListState = RequestState.failed + state.numberListError = err + }, seatsSucceeded (state, seatList) { state.seatList = _.get(seatList, 'items', []) state.seatMapById = {} @@ -251,6 +260,7 @@ export default { state.deviceProfilesListState = RequestState.failed }, deviceModelSucceeded (state, deviceModel) { + state.deviceModelListState = RequestState.succeeded const model = _.get(deviceModel, 'model', null) const modelImage = _.get(deviceModel, 'modelImage', null) const modelImageThumbnail = _.get(deviceModel, 'modelImageThumbnail', null) @@ -264,10 +274,15 @@ export default { state.deviceModelImageSmallMap[modelImageThumbnail.id] = modelImageThumbnail } }, - deviceModelFailed (state, deviceModelId) { - delete state.deviceModelMap[deviceModelId] - delete state.deviceModelImageMap[deviceModelId] - delete state.deviceModelImageSmallMap[deviceModelId] + deviceModelRequesting (state) { + state.deviceModelListState = RequestState.requesting + }, + deviceModelFailed (state, options) { + state.deviceModelListState = RequestState.failed + delete state.deviceModelMap[options.deviceModelId] + delete state.deviceModelImageMap[options.deviceModelId] + delete state.deviceModelImageSmallMap[options.deviceModelId] + state.deviceModelError = options.error }, subscribersRequesting (state) { state.subcriberListState = RequestState.requesting @@ -279,24 +294,23 @@ export default { state.subscriberList.forEach((subscriber) => { state.subscriberMap[subscriber.id] = subscriber }) + }, + subscribersFailed (state, err) { + state.subcriberListState = RequestState.failed + state.subcriberListError = err } }, actions: { - loadProfiles (context) { - return new Promise((resolve, reject) => { + async loadProfiles (context) { + if (context.state.deviceProfileList.length === 0) { context.commit('deviceProfilesListStateRequesting') - if (context.state.deviceProfileList.length === 0) { - getAllProfiles().then((profiles) => { - context.commit('deviceProfilesListSucceeded', profiles) - resolve(profiles) - }).catch((err) => { - context.commit('deviceProfilesListFailed') - reject(err) - }) - } else { - resolve() + try { + const profiles = await getAllProfiles() + context.commit('deviceProfilesListSucceeded', profiles) + } catch (err) { + context.commit('deviceProfilesListFailed', err.message) } - }) + } }, async loadProfileById (context, deviceId) { context.commit('deviceProfileRequesting') @@ -319,6 +333,7 @@ export default { } const requests = [] let isFrontImageRequested = false + context.commit('deviceModelRequesting') if (!isFrontCached && (payload.type === 'front' || payload.type === 'all')) { requests.push(getModelFrontImage(payload.deviceId)) isFrontImageRequested = true @@ -358,7 +373,10 @@ export default { } context.commit('deviceModelSucceeded', deviceModel) } catch (err) { - context.commit('deviceModelFailed', payload.deviceId) + context.commit('deviceModelFailed', { + deviceModelId: payload.deviceId, + error: err.message + }) } }, async loadDeviceModels (context, imageType) { @@ -378,10 +396,8 @@ export default { all: true }).then((subscribers) => { context.commit('subscribersSucceeded', subscribers) - }).catch(() => { - context.commit('subscribersSucceeded', { - items: [] - }) + }).catch((err) => { + context.commit('subscribersFailed', err.message) }) } }, @@ -393,10 +409,8 @@ export default { all: true }).then((numbers) => { context.commit('numbersSucceeded', numbers) - }).catch(() => { - context.commit('numbersSucceeded', { - items: [] - }) + }).catch((err) => { + context.commit('numbersFailed', err.message) }) } } diff --git a/src/store/reminder.js b/src/store/reminder.js index e25fa42e..2da403ab 100644 --- a/src/store/reminder.js +++ b/src/store/reminder.js @@ -76,17 +76,14 @@ export default { } }, actions: { - loadReminder (context) { - return new Promise((resolve, reject) => { - context.commit('reminderLoading') - getReminder(context.getters.subscriberId).then((reminder) => { - context.commit('reminderLoaded', reminder) - resolve() - }).catch((err) => { - reject(err) - context.commit('reminderLoadingFailed', err.message) - }) - }) + async loadReminder (context) { + context.commit('reminderLoading') + try { + const reminder = await getReminder(context.getters.subscriberId) + context.commit('reminderLoaded', reminder) + } catch (err) { + context.commit('reminderLoadingFailed', err.message) + } }, toggleReminder (context) { context.commit('reminderUpdating', 'active') diff --git a/src/store/voicebox.js b/src/store/voicebox.js index 40ce36f2..6600b13d 100644 --- a/src/store/voicebox.js +++ b/src/store/voicebox.js @@ -50,6 +50,7 @@ export default { busyGreetingUploadProgress: 0, busyGreetingDeletionState: RequestState.initiated, busyGreetingDeletionError: null, + busyGreetingLoadError: null, unavailableGreetingId: null, unavailableGreetingUrl: null, @@ -59,6 +60,7 @@ export default { unavailableGreetingUploadProgress: 0, unavailableGreetingDeletionState: RequestState.initiated, unavailableGreetingDeletionError: null, + unavailableGreetingLoadError: null, uploadCancelActions: {}, @@ -70,6 +72,7 @@ export default { tempGreetingUploadProgress: 0, tempGreetingDeletionState: RequestState.initiated, tempGreetingDeletionError: null, + tempGreetingLoadError: null, greetGreetingId: null, greetGreetingUrl: null, @@ -78,7 +81,8 @@ export default { greetGreetingUploadError: null, greetGreetingUploadProgress: 0, greetGreetingDeletionState: RequestState.initiated, - greetGreetingDeletionError: null + greetGreetingDeletionError: null, + greetGreetingLoadError: null }, getters: { subscriberId (state, getters, rootState, rootGetters) { @@ -296,9 +300,10 @@ export default { state.busyGreetingLoadState = RequestState.succeeded state.busyGreetingUrl = url }, - busyGreetingPlayFailed (state) { + busyGreetingPlayFailed (state, err) { state.busyGreetingLoadState = RequestState.failed state.busyGreetingUrl = null + state.busyGreetingLoadError = err }, busyGreetingDeletionRequesting (state) { state.busyGreetingDeletionState = RequestState.requesting @@ -342,9 +347,10 @@ export default { state.unavailableGreetingLoadState = RequestState.succeeded state.unavailableGreetingUrl = url }, - unavailableGreetingPlayFailed (state) { + unavailableGreetingPlayFailed (state, err) { state.unavailableGreetingLoadState = RequestState.failed state.unavailableGreetingUrl = null + state.unavailableGreetingLoadError = err }, unavailableGreetingDeletionRequesting (state) { state.unavailableGreetingDeletionState = RequestState.requesting @@ -390,9 +396,10 @@ export default { state.tempGreetingLoadState = RequestState.succeeded state.tempGreetingUrl = url }, - tempGreetingPlayFailed (state) { + tempGreetingPlayFailed (state, err) { state.tempGreetingLoadState = RequestState.failed state.tempGreetingUrl = null + state.tempGreetingLoadError = err }, tempGreetingDeletionRequesting (state) { state.tempGreetingDeletionState = RequestState.requesting @@ -435,9 +442,10 @@ export default { state.greetGreetingLoadState = RequestState.succeeded state.greetGreetingUrl = url }, - greetGreetingPlayFailed (state) { - state.tgreetGreetingLoadState = RequestState.failed + greetGreetingPlayFailed (state, err) { + state.greetGreetingLoadState = RequestState.failed state.greetGreetingUrl = null + state.greetGreetingLoadError = err }, greetGreetingDeletionRequesting (state) { state.greetGreetingDeletionState = RequestState.requesting