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
mr13.4
nidrissi-zouggari 8 months ago
parent e314c96c3c
commit 9911ccd7bb

@ -90,7 +90,9 @@ import CscMoreMenu from 'components/CscMoreMenu'
import CscPopupMenuItem from 'components/CscPopupMenuItem' import CscPopupMenuItem from 'components/CscPopupMenuItem'
import CscPopupMenuItemDelete from 'components/CscPopupMenuItemDelete' import CscPopupMenuItemDelete from 'components/CscPopupMenuItemDelete'
import CscPopupMenuItemStartCall from 'components/CscPopupMenuItemStartCall' 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 { export default {
name: 'CscVoiceMailItem', name: 'CscVoiceMailItem',
@ -138,6 +140,10 @@ export default {
'playVoiceMailState', 'playVoiceMailState',
'playVoiceMailUrl' 'playVoiceMailUrl'
]), ]),
...mapState('conversations', [
'playVoiceMailErrors',
'playVoiceMailStates'
]),
direction () { direction () {
if (this.voiceMail.direction === 'out') { if (this.voiceMail.direction === 'out') {
return 'to' return 'to'
@ -155,6 +161,16 @@ export default {
return this.playVoiceMailState(this.voiceMail.id) === 'succeeded' 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: { methods: {
playVoiceMail () { playVoiceMail () {
this.$emit('play-voice-mail', { this.$emit('play-voice-mail', {

@ -89,6 +89,8 @@
import CscPbxAutoAttendantSelection from 'components/pages/PbxConfiguration/CscPbxAutoAttendantSelection' import CscPbxAutoAttendantSelection from 'components/pages/PbxConfiguration/CscPbxAutoAttendantSelection'
import CscPbxModelSelect from 'components/pages/PbxConfiguration/CscPbxModelSelect' import CscPbxModelSelect from 'components/pages/PbxConfiguration/CscPbxModelSelect'
import _ from 'lodash' import _ from 'lodash'
import { showGlobalError } from 'src/helpers/ui'
import { RequestState } from 'src/store/common'
import { mapActions, mapState } from 'vuex' import { mapActions, mapState } from 'vuex'
export default { export default {
@ -116,7 +118,9 @@ export default {
...mapState('pbx', [ ...mapState('pbx', [
'deviceProfileMap', 'deviceProfileMap',
'deviceProfileList', 'deviceProfileList',
'subscriberList' 'subscriberList',
'subcriberListState',
'subcriberListError'
]), ]),
subscribersOptions () { subscribersOptions () {
const options = [] const options = []
@ -191,6 +195,11 @@ export default {
watch: { watch: {
filterTypeModel () { filterTypeModel () {
this.typedFilter = null this.typedFilter = null
},
subcriberListState (state) {
if (state === RequestState.failed) {
showGlobalError(this.subcriberListError)
}
} }
}, },
mounted () { mounted () {

@ -118,7 +118,9 @@ import CscConversationItem from 'components/pages/Conversations/CscConversationI
import CscConversationsCallsFilter from 'components/pages/Conversations/CscConversationsCallsFilter' import CscConversationsCallsFilter from 'components/pages/Conversations/CscConversationsCallsFilter'
import CscConversationsFilter from 'components/pages/Conversations/CscConversationsFilter' import CscConversationsFilter from 'components/pages/Conversations/CscConversationsFilter'
import { LICENSES } from 'src/constants' import { LICENSES } from 'src/constants'
import { showGlobalError } from 'src/helpers/ui'
import platformMixin from 'src/mixins/platform' import platformMixin from 'src/mixins/platform'
import { RequestState } from 'src/store/common'
import { mapWaitingActions } from 'vue-wait' import { mapWaitingActions } from 'vue-wait'
import { import {
mapGetters, mapMutations, mapGetters, mapMutations,
@ -151,7 +153,19 @@ export default {
'isLicenseActive' 'isLicenseActive'
]), ]),
...mapState('conversations', [ ...mapState('conversations', [
'reachedLastPage' 'reachedLastPage',
'downloadVoiceMailState',
'downloadVoiceMailError',
'downloadFaxState',
'downloadFaxError',
'blockedIncomingState',
'blockedIncomingError',
'blockedOutgoingState',
'blockedOutgoingError',
'toggleBlockedState',
'toggleBlockedError',
'deletionState',
'deletionError'
]), ]),
...mapGetters('conversations', [ ...mapGetters('conversations', [
'items', 'items',
@ -232,6 +246,38 @@ export default {
return this.$wait.is('csc-conversations') 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 () { async mounted () {
this.topMargin = this.$refs.pageSticky.$el.offsetHeight this.topMargin = this.$refs.pageSticky.$el.offsetHeight
this.resetList() this.resetList()

@ -126,6 +126,8 @@ import CscPage from 'components/CscPage'
import CscInputButtonReset from 'components/form/CscInputButtonReset' import CscInputButtonReset from 'components/form/CscInputButtonReset'
import CscInputButtonSave from 'components/form/CscInputButtonSave' import CscInputButtonSave from 'components/form/CscInputButtonSave'
import _ from 'lodash' import _ from 'lodash'
import { showGlobalError } from 'src/helpers/ui'
import { RequestState } from 'src/store/common'
import { import {
mapActions, mapActions,
mapGetters, mapGetters,
@ -163,7 +165,9 @@ export default {
]), ]),
...mapState('customer', [ ...mapState('customer', [
'customerPreferences', 'customerPreferences',
'customerPreferencesSelected' 'customerPreferencesSelected',
'customerPreferencesLoadingState',
'customerPreferencesError'
]), ]),
hasBlockOutOverridePinChanged () { hasBlockOutOverridePinChanged () {
return this.changes.block_out_override_pin !== this.customerPreferences.block_out_override_pin return this.changes.block_out_override_pin !== this.customerPreferences.block_out_override_pin
@ -172,6 +176,11 @@ export default {
watch: { watch: {
customerPreferences () { customerPreferences () {
this.changes = this.getCustomerPreferencesData() this.changes = this.getCustomerPreferencesData()
},
customerPreferencesLoadingState (state) {
if (state === RequestState.failed) {
showGlobalError(this.customerPreferencesError)
}
} }
}, },
mounted () { mounted () {

@ -67,6 +67,7 @@ import {
callIconColor callIconColor
} from 'src/helpers/call-utils' } from 'src/helpers/call-utils'
import { showGlobalError } from 'src/helpers/ui' import { showGlobalError } from 'src/helpers/ui'
import { RequestState } from 'src/store/common'
import { mapWaitingActions } from 'vue-wait' import { mapWaitingActions } from 'vue-wait'
import { mapGetters, mapState } from 'vuex' import { mapGetters, mapState } from 'vuex'
export default { export default {
@ -93,6 +94,10 @@ export default {
...mapState('call', [ ...mapState('call', [
'callEnabled' 'callEnabled'
]), ]),
...mapState('conversations', [
'downloadVoiceMailState',
'downloadVoiceMailError'
]),
...mapGetters('user', [ ...mapGetters('user', [
'hasSubscriberProfileAttribute' 'hasSubscriberProfileAttribute'
]), ]),
@ -112,6 +117,11 @@ export default {
this.registeredDevicesError = true this.registeredDevicesError = true
showGlobalError(err.message) showGlobalError(err.message)
} }
},
downloadVoiceMailState (state) {
if (state === RequestState.failed) {
showGlobalError(this.downloadVoiceMailError)
}
} }
}, },
mounted () { mounted () {

@ -137,7 +137,9 @@ export default {
'callQueueRemovalState', 'callQueueRemovalState',
'callQueueCreationError', 'callQueueCreationError',
'callQueueUpdateError', 'callQueueUpdateError',
'callQueueRemovalError' 'callQueueRemovalError',
'callQueueListState',
'callQueueListError'
]), ]),
...mapGetters('pbxCallQueues', [ ...mapGetters('pbxCallQueues', [
'isCallQueueListEmpty', 'isCallQueueListEmpty',
@ -150,6 +152,10 @@ export default {
'getCallQueueCreationToastMessage', 'getCallQueueCreationToastMessage',
'getCallQueueUpdateToastMessage', 'getCallQueueUpdateToastMessage',
'getCallQueueRemovalToastMessage' 'getCallQueueRemovalToastMessage'
]),
...mapState('pbx', [
'subcriberListState',
'subcriberListError'
]) ])
}, },
watch: { watch: {
@ -175,6 +181,16 @@ export default {
} else if (state === RequestState.failed) { } else if (state === RequestState.failed) {
showGlobalError(this.callQueueRemovalError) showGlobalError(this.callQueueRemovalError)
} }
},
callQueueListState (state) {
if (state === RequestState.failed) {
showGlobalError(this.callQueueListError)
}
},
subcriberListState (state) {
if (state === RequestState.failed) {
showGlobalError(this.subcriberListError)
}
} }
}, },
mounted () { mounted () {

@ -242,7 +242,9 @@ export default {
'devicePreferencesUpdateError', 'devicePreferencesUpdateError',
'deviceUpdateState', 'deviceUpdateState',
'devicePreferencesUpdateState', 'devicePreferencesUpdateState',
'devicePreferencesSelected' 'devicePreferencesSelected',
'devicePreferencesListState',
'devicePreferencesError'
]), ]),
...mapState('pbx', [ ...mapState('pbx', [
'deviceProfileList', 'deviceProfileList',
@ -250,7 +252,9 @@ export default {
'deviceModelImageMap', 'deviceModelImageMap',
'deviceModelMap', 'deviceModelMap',
'subscriberList', 'subscriberList',
'subscriberMap' 'subscriberMap',
'subcriberListState',
'subcriberListError'
]), ]),
...mapGetters('pbx', [ ...mapGetters('pbx', [
'getSubscriberOptions', 'getSubscriberOptions',
@ -335,6 +339,16 @@ export default {
} else if (state === RequestState.failed) { } else if (state === RequestState.failed) {
showGlobalError(this.devicePreferencesUpdateError) showGlobalError(this.devicePreferencesUpdateError)
} }
},
devicePreferencesListState (state) {
if (state === RequestState.failed) {
showGlobalError(this.devicePreferencesError)
}
},
subcriberListState (state) {
if (state === RequestState.failed) {
showGlobalError(this.subcriberListError)
}
} }
}, },
async created () { async created () {

@ -170,7 +170,11 @@ export default {
'deviceModelMap', 'deviceModelMap',
'deviceModelImageMap', 'deviceModelImageMap',
'subscriberList', 'subscriberList',
'subscriberMap' 'subscriberMap',
'deviceModelListState',
'deviceModelError',
'deviceProfileListState',
'deviceProfileListError'
]), ]),
...mapGetters('pbx', [ ...mapGetters('pbx', [
'getSubscriberOptions', 'getSubscriberOptions',
@ -183,7 +187,9 @@ export default {
'deviceListLastPage', 'deviceListLastPage',
'deviceListVisibility', 'deviceListVisibility',
'deviceCreationState', 'deviceCreationState',
'deviceRemovalState' 'deviceRemovalState',
'deviceListState',
'deviceListError'
]), ]),
...mapGetters('pbxDevices', [ ...mapGetters('pbxDevices', [
'isDeviceListEmpty', 'isDeviceListEmpty',
@ -220,6 +226,21 @@ export default {
} else if (state === RequestState.failed) { } else if (state === RequestState.failed) {
showGlobalError(this.deviceRemovalError) 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 () { mounted () {

@ -187,7 +187,9 @@ export default {
'groupRemoving', 'groupRemoving',
'groupRemovalState', 'groupRemovalState',
'groupRemovalError', 'groupRemovalError',
'groupListVisibility' 'groupListVisibility',
'groupListState',
'groupListError'
]), ]),
...mapGetters('pbx', [ ...mapGetters('pbx', [
'getNumberOptions', 'getNumberOptions',
@ -231,6 +233,11 @@ export default {
} else if (state === RequestState.failed) { } else if (state === RequestState.failed) {
showGlobalError(this.groupRemovalError) showGlobalError(this.groupRemovalError)
} }
},
groupListState (state) {
if (state === RequestState.failed) {
showGlobalError(this.groupListError)
}
} }
}, },
mounted () { mounted () {

@ -135,7 +135,16 @@ export default {
'msConfigRemovalState', 'msConfigRemovalState',
'msConfigCreationError', 'msConfigCreationError',
'msConfigUpdateError', 'msConfigUpdateError',
'msConfigRemovalError' 'msConfigRemovalError',
'msConfigListState',
'msConfigListError'
]),
...mapState('pbx', [
'numberListState',
'numberListError',
'subcriberListState',
'subcriberListError'
]), ]),
...mapGetters('pbxMsConfigs', [ ...mapGetters('pbxMsConfigs', [
'isMsConfigListEmpty', 'isMsConfigListEmpty',
@ -173,6 +182,21 @@ export default {
} else if (state === RequestState.failed) { } else if (state === RequestState.failed) {
showGlobalError(this.msConfigRemovalError) 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 () { mounted () {

@ -159,7 +159,9 @@ export default {
'seatRemoving', 'seatRemoving',
'seatRemovalState', 'seatRemovalState',
'seatRemovalError', 'seatRemovalError',
'seatListVisibility' 'seatListVisibility',
'seatListState',
'seatListError'
]), ]),
...mapGetters('pbx', [ ...mapGetters('pbx', [
'getNumberOptions', 'getNumberOptions',
@ -207,6 +209,11 @@ export default {
} else if (state === RequestState.failed) { } else if (state === RequestState.failed) {
showGlobalError(this.seatRemovalError) showGlobalError(this.seatRemovalError)
} }
},
seatListState (state) {
if (state === RequestState.failed) {
showGlobalError(this.seatListError)
}
} }
}, },
mounted () { mounted () {

@ -221,7 +221,17 @@ export default {
'soundFileUploadState', 'soundFileUploadState',
'soundFileUploadProgress', 'soundFileUploadProgress',
'soundFileUpdateState', 'soundFileUpdateState',
'soundHandleGroups' 'soundHandleGroups',
'soundHandleListState',
'soundHandleListError',
'soundFileListStates',
'soundFileError',
'soundFileRemoveError',
'soundFileState',
'soundFileUploadState',
'soundFileUploadError',
'soundFileUpdateError',
'soundFileRemoveState'
]), ]),
...mapGetters('pbxSoundSets', [ ...mapGetters('pbxSoundSets', [
'isSoundFileListRequesting', 'isSoundFileListRequesting',
@ -279,6 +289,51 @@ export default {
return group 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 () { async mounted () {

@ -131,7 +131,9 @@ export default {
'soundSetRemovalState', 'soundSetRemovalState',
'soundSetRemovalError', 'soundSetRemovalError',
'soundSetUpdateState', 'soundSetUpdateState',
'soundSetUpdateError' 'soundSetUpdateError',
'soundSetListState',
'soundSetListError'
]), ]),
...mapGetters('pbxSoundSets', [ ...mapGetters('pbxSoundSets', [
'isSoundSetListEmpty', 'isSoundSetListEmpty',
@ -171,6 +173,11 @@ export default {
} else if (state === RequestState.failed) { } else if (state === RequestState.failed) {
showGlobalError(this.soundSetRemovalError) showGlobalError(this.soundSetRemovalError)
} }
},
soundSetListState (state) {
if (state === RequestState.failed) {
showGlobalError(this.soundSetListError)
}
} }
}, },
mounted () { mounted () {

@ -77,6 +77,8 @@ import CscSpinner from 'components/CscSpinner'
import CscCdrFilters from 'components/pages/PbxStatistics/CscCdrFilters' import CscCdrFilters from 'components/pages/PbxStatistics/CscCdrFilters'
import _ from 'lodash' import _ from 'lodash'
import { LIST_DEFAULT_ROWS } from 'src/api/common' 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 { mapWaitingActions } from 'vue-wait'
import { mapState } from 'vuex' import { mapState } from 'vuex'
export default { export default {
@ -107,7 +109,9 @@ export default {
}, },
computed: { computed: {
...mapState('conversations', [ ...mapState('conversations', [
'conversations' 'conversations',
'conversationError',
'conversationState'
]), ]),
columns () { columns () {
return [ return [
@ -170,6 +174,13 @@ export default {
] ]
} }
}, },
watch: {
conversationState (state) {
if (state === RequestState.failed) {
showGlobalError(this.conversationError)
}
}
},
async mounted () { async mounted () {
await this.refresh() await this.refresh()
}, },

@ -106,10 +106,12 @@
import CscPage from 'components/CscPage' import CscPage from 'components/CscPage'
import CscSpinner from 'components/CscSpinner' import CscSpinner from 'components/CscSpinner'
import { date } from 'quasar' import { date } from 'quasar'
import { showToast } from 'src/helpers/ui' import { showGlobalError, showToast } from 'src/helpers/ui'
import { RequestState } from 'src/store/common'
import { import {
mapActions, mapActions,
mapGetters mapGetters,
mapState
} from 'vuex' } from 'vuex'
export default { export default {
@ -133,6 +135,9 @@ export default {
'isReminderLoading', 'isReminderLoading',
'reminderUpdated' 'reminderUpdated'
]), ]),
...mapState('reminder', [
'reminderLoadingState'
]),
recurrenceOptions () { recurrenceOptions () {
return [ return [
{ {
@ -172,6 +177,11 @@ export default {
recurrence: this.mapRecurrence(this.reminderRecurrence) recurrence: this.mapRecurrence(this.reminderRecurrence)
})) }))
} }
},
reminderLoadingState () {
if (this.reminderLoadingState === RequestState.failed) {
showGlobalError(this.reminderError)
}
} }
}, },
mounted () { mounted () {

@ -102,7 +102,8 @@ import {
showGlobalError, showGlobalError,
showToast showToast
} from 'src/helpers/ui' } from 'src/helpers/ui'
import { mapGetters } from 'vuex' import { RequestState } from 'src/store/common'
import { mapGetters, mapState } from 'vuex'
export default { export default {
name: 'CscPageSpeedDial', name: 'CscPageSpeedDial',
@ -131,11 +132,17 @@ export default {
'assignSlotError', 'assignSlotError',
'lastAssignedSlot', 'lastAssignedSlot',
'isAdding' 'isAdding'
]),
...mapState('speedDial', [
'speedDialLoadingState',
'speedDialLoadingError',
'unassignSlotState',
'unassignSlotError'
]) ])
}, },
watch: { watch: {
assignSlotState (state) { assignSlotState (state) {
if (state === 'failed') { if (state === RequestState.failed) {
showGlobalError(this.assignSlotError) showGlobalError(this.assignSlotError)
} else if (state === 'succeeded') { } else if (state === 'succeeded') {
this.$refs.addForm.cancel() this.$refs.addForm.cancel()
@ -143,6 +150,16 @@ export default {
slot: this.lastAssignedSlot slot: this.lastAssignedSlot
})) }))
} }
},
speedDialLoadingState () {
if (this.speedDialLoadingState === RequestState.failed) {
showGlobalError(this.speedDialLoadingError)
}
},
unassignSlotState () {
if (this.unassignSlotState === RequestState.failed) {
showGlobalError(this.unassignSlotError)
}
} }
}, },
mounted () { mounted () {

@ -219,6 +219,7 @@ import {
showGlobalError, showGlobalError,
showToast showToast
} from 'src/helpers/ui' } from 'src/helpers/ui'
import { RequestState } from 'src/store/common'
import { mapWaitingActions } from 'vue-wait' import { mapWaitingActions } from 'vue-wait'
import { import {
mapActions, mapActions,
@ -283,7 +284,35 @@ export default {
'tempGreetingUploadProgress', 'tempGreetingUploadProgress',
'greetGreetingId', 'greetGreetingId',
'greetGreetingUrl', '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', [ ...mapGetters('voicebox', [
'settingsLoading', 'settingsLoading',
@ -388,6 +417,76 @@ export default {
}, },
deleteValue (value) { deleteValue (value) {
this.formData.delete = 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 () { async mounted () {

@ -28,14 +28,14 @@ const ReloadConfig = {
export default { export default {
async loadConversations ({ commit, dispatch, state, rootGetters }, options) { async loadConversations ({ commit, dispatch, state, rootGetters }, options) {
try { try {
commit('loadConversationsRequesting')
const list = await getConversations({ const list = await getConversations({
...options ...options
}) })
commit('setConversations', list.items) commit('loadConversationsSucceeded', list.items)
return list.totalCount return list.totalCount
} catch (err) { } catch (err) {
commit('setConversations', []) commit('loadConversationsFailed', err.message)
throw err
} }
}, },
reloadItems (context, options) { reloadItems (context, options) {
@ -75,7 +75,7 @@ export default {
downloadVoiceMail(id).then(() => { downloadVoiceMail(id).then(() => {
context.commit('downloadVoiceMailSucceeded') context.commit('downloadVoiceMailSucceeded')
}).catch((err) => { }).catch((err) => {
context.commit('downloadVoiceMailFailed', err.response.data.message) context.commit('downloadVoiceMailFailed', err.message)
}) })
}, },
downloadFax (context, id) { downloadFax (context, id) {
@ -83,7 +83,7 @@ export default {
downloadFax(id).then(() => { downloadFax(id).then(() => {
context.commit('downloadFaxSucceeded') context.commit('downloadFaxSucceeded')
}).catch((err) => { }).catch((err) => {
context.commit('downloadFaxFailed', err.response.data.message) context.commit('downloadFaxFailed', err.message)
}) })
}, },
playVoiceMail (context, options) { playVoiceMail (context, options) {
@ -94,7 +94,10 @@ export default {
url url
}) })
}).catch((err) => { }).catch((err) => {
context.commit('playVoiceMailFailed', options.id, err.mesage) context.commit('playVoiceMailFailed', {
id: options.id,
error: err.message
})
}) })
}, },
async nextPage (context, options) { async nextPage (context, options) {

@ -68,10 +68,10 @@ export default {
state.playVoiceMailStates[options.id] = RequestState.succeeded state.playVoiceMailStates[options.id] = RequestState.succeeded
state.playVoiceMailErrors[options.id] = null state.playVoiceMailErrors[options.id] = null
}, },
playVoiceMailFailed (state, id, err) { playVoiceMailFailed (state, options) {
state.playVoiceMailUrls[id] = null state.playVoiceMailUrls[options.id] = null
state.playVoiceMailStates[id] = RequestState.failed state.playVoiceMailStates[options.id] = RequestState.failed
state.playVoiceMailErrors[id] = err state.playVoiceMailErrors[options.id] = options.error
}, },
resetList (state) { resetList (state) {
state.items = [] state.items = []
@ -154,7 +154,15 @@ export default {
state.deletionState = RequestState.failed state.deletionState = RequestState.failed
state.deletionError = err state.deletionError = err
}, },
setConversations (state, value) { loadConversationsSucceeded (state, value) {
state.conversationState = RequestState.succeeded
state.conversations = value state.conversations = value
},
loadConversationsRequesting (state) {
state.conversationState = RequestState.requesting
},
loadConversationsFailed (state, err) {
state.conversationState = RequestState.failed
state.conversationError = err
} }
} }

@ -32,5 +32,7 @@ export default {
toggleBlockedError: null, toggleBlockedError: null,
lastToggledType: null, lastToggledType: null,
deletionState: RequestState.initiated, deletionState: RequestState.initiated,
deletionError: null deletionError: null,
conversationState: RequestState.initiated,
conversationError: null
} }

@ -39,17 +39,14 @@ export default {
} }
}, },
actions: { actions: {
loadCustomerPreferences (context, customerId) { async loadCustomerPreferences (context, customerId) {
return new Promise((resolve, reject) => { context.commit('customerPreferencesLoading')
context.commit('customerPreferencesLoading') try {
getCustomerPreference(customerId).then((customerPreferences) => { const customerPreferences = await getCustomerPreference(customerId)
context.commit('customerPreferencesLoaded', customerPreferences) context.commit('customerPreferencesLoaded', customerPreferences)
resolve() } catch (err) {
}).catch((err) => { context.commit('customerPreferencesLoadingFailed', err.message)
reject(err) }
context.commit('customerPreferencesLoadingFailed', err.message)
})
})
}, },
updateIgnoreMembers (context, options) { updateIgnoreMembers (context, options) {
setCustomerPreference(options.customerId, options.ignore_cf, 'ignore_cf_when_hunting').then((customerPreference) => { setCustomerPreference(options.customerId, options.ignore_cf, 'ignore_cf_when_hunting').then((customerPreference) => {

@ -14,6 +14,7 @@ export default {
state: { state: {
callQueueListState: RequestState.initiated, callQueueListState: RequestState.initiated,
callQueueListVisible: true, callQueueListVisible: true,
callQueueListError: null,
callQueueList: [], callQueueList: [],
callQueueMap: {}, callQueueMap: {},
callQueueSelected: null, callQueueSelected: null,
@ -126,6 +127,10 @@ export default {
}) })
state.callQueueListVisible = true state.callQueueListVisible = true
}, },
callQueueListFailed (state, err) {
state.callQueueListState = RequestState.failed
state.callQueueListError = err
},
callQueueCreationRequesting (state, data) { callQueueCreationRequesting (state, data) {
state.callQueueCreationState = CreationState.creating state.callQueueCreationState = CreationState.creating
state.callQueueCreationData = data state.callQueueCreationData = data
@ -189,25 +194,20 @@ export default {
} }
}, },
actions: { actions: {
loadCallQueueList (context, options) { async loadCallQueueList (context, options) {
return new Promise((resolve) => { const listVisible = _.get(options, 'listVisible', false)
const listVisible = _.get(options, 'listVisible', false) const selectedId = _.get(options, 'selectedId', null)
const selectedId = _.get(options, 'selectedId', null) context.commit('callQueueListRequesting', { listVisible })
context.commit('callQueueListRequesting', { try {
listVisible const callQueueList = await getCallQueueList()
}) context.commit('callQueueListSucceeded', callQueueList)
getCallQueueList().then((callQueueList) => { if (selectedId !== null) {
context.commit('callQueueListSucceeded', callQueueList) context.commit('expandCallQueue', callQueueList)
if (selectedId !== null) { context.commit('highlightCallQueue', callQueueList)
context.commit('expandCallQueue', callQueueList) }
context.commit('highlightCallQueue', callQueueList) } catch (err) {
} context.commit('callQueueListFailed', err.message)
resolve() }
}).catch(() => {
resolve()
context.commit('callQueueListSucceeded')
})
})
}, },
createCallQueue (context, callQueueData) { createCallQueue (context, callQueueData) {
context.commit('callQueueCreationRequesting', callQueueData) context.commit('callQueueCreationRequesting', callQueueData)

@ -27,6 +27,8 @@ export default {
deviceListVisibility: 'visible', deviceListVisibility: 'visible',
deviceMapById: {}, deviceMapById: {},
devicePreferencesList: [], devicePreferencesList: [],
deviceListError: null,
deviceMap: {},
devicePreferencesListState: RequestState.initiated, devicePreferencesListState: RequestState.initiated,
devicePreferencesMap: {}, devicePreferencesMap: {},
devicePreferencesRemovalState: RequestState.initiated, devicePreferencesRemovalState: RequestState.initiated,
@ -36,6 +38,7 @@ export default {
devicePreferencesUpdateState: RequestState.initiated, devicePreferencesUpdateState: RequestState.initiated,
devicePreferencesUpdating: null, devicePreferencesUpdating: null,
devicePreferencesUpdatingField: null, devicePreferencesUpdatingField: null,
devicePreferencesError: null,
deviceRemovalError: null, deviceRemovalError: null,
deviceRemovalState: RequestState.initiated, deviceRemovalState: RequestState.initiated,
deviceRemoving: null, deviceRemoving: null,
@ -194,11 +197,13 @@ export default {
state.devicePreferencesMap[devicePreferences.id] = devicePreferences state.devicePreferencesMap[devicePreferences.id] = devicePreferences
}) })
}, },
deviceListFailed (state) { deviceListFailed (state, err) {
state.deviceListState = RequestState.failed state.deviceListState = RequestState.failed
state.deviceListError = err
}, },
devicePreferencesListFailed (state) { devicePreferencesListFailed (state, err) {
state.devicePreferencesListState = RequestState.failed state.devicePreferencesListState = RequestState.failed
state.devicePreferencesError = err
}, },
deviceCreationRequesting (state, device) { deviceCreationRequesting (state, device) {
state.deviceCreationState = CreationState.creating state.deviceCreationState = CreationState.creating

@ -20,6 +20,7 @@ export default {
state: { state: {
groupListState: RequestState.initiated, groupListState: RequestState.initiated,
groupListVisibility: 'visible', groupListVisibility: 'visible',
groupListError: null,
groupListItems: [], groupListItems: [],
groupListCurrentPage: 1, groupListCurrentPage: 1,
groupListLastPage: null, groupListLastPage: null,
@ -187,8 +188,9 @@ export default {
state.groupListVisibility = 'visible' state.groupListVisibility = 'visible'
} }
}, },
groupListItemsFailed (state) { groupListItemsFailed (state, err) {
state.groupListState = RequestState.failed state.groupListState = RequestState.failed
state.groupListError = err
}, },
groupCreationRequesting (state, group) { groupCreationRequesting (state, group) {
state.groupCreationState = CreationState.creating state.groupCreationState = CreationState.creating
@ -261,33 +263,25 @@ export default {
} }
}, },
actions: { actions: {
loadGroupListItems (context, options) { async loadGroupListItems (context, options) {
return new Promise((resolve, reject) => { const page = _.get(options, 'page', context.state.groupListCurrentPage)
const page = _.get(options, 'page', context.state.groupListCurrentPage) const filters = _.get(options, 'filters', {})
const filters = _.get(options, 'filters', {}) const clearList = _.get(options, 'clearList', true)
const clearList = _.get(options, 'clearList', true) context.commit('groupListItemsRequesting', { clearList })
context.commit('groupListItemsRequesting', { try {
clearList const groupList = await getGroupList({ page, filters })
}) context.commit('pbx/pilotSucceeded', groupList.pilot, { root: true })
getGroupList({ context.commit('pbx/numbersSucceeded', groupList.numbers, { root: true })
page, context.commit('pbx/soundSetsSucceeded', groupList.soundSets, { root: true })
filters context.commit('pbx/seatsSucceeded', groupList.seats, { root: true })
}).then((groupList) => { context.commit('groupListItemsSucceeded', {
context.commit('pbx/pilotSucceeded', groupList.pilot, { root: true }) groups: groupList.groups,
context.commit('pbx/numbersSucceeded', groupList.numbers, { root: true }) preferences: groupList.preferences,
context.commit('pbx/soundSetsSucceeded', groupList.soundSets, { root: true }) page
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)
}) })
}) } catch (err) {
context.commit('groupListItemsFailed', err.message)
}
}, },
createGroup (context, groupData) { createGroup (context, groupData) {
context.commit('groupCreationRequesting', groupData) context.commit('groupCreationRequesting', groupData)

@ -13,6 +13,7 @@ export default {
state: { state: {
msConfigListState: RequestState.initiated, msConfigListState: RequestState.initiated,
msConfigListVisible: true, msConfigListVisible: true,
msConfigListError: null,
msConfigList: [], msConfigList: [],
msConfigMap: {}, msConfigMap: {},
msConfigSelected: null, msConfigSelected: null,
@ -123,6 +124,10 @@ export default {
}) })
state.msConfigListVisible = true state.msConfigListVisible = true
}, },
msConfigListFailed (state, err) {
state.msConfigListState = RequestState.failed
state.msConfigListError = err
},
msConfigCreationRequesting (state, data) { msConfigCreationRequesting (state, data) {
state.msConfigCreationState = CreationState.creating state.msConfigCreationState = CreationState.creating
state.msConfigCreationData = data state.msConfigCreationData = data
@ -186,25 +191,20 @@ export default {
} }
}, },
actions: { actions: {
loadMsConfigList (context, options) { async loadMsConfigList (context, options) {
return new Promise((resolve) => { const listVisible = _.get(options, 'listVisible', false)
const listVisible = _.get(options, 'listVisible', false) const selectedId = _.get(options, 'selectedId', null)
const selectedId = _.get(options, 'selectedId', null) context.commit('msConfigListRequesting', { listVisible })
context.commit('msConfigListRequesting', { try {
listVisible const msConfigList = await getMsConfigList()
}) context.commit('msConfigListSucceeded', msConfigList)
getMsConfigList().then((msConfigList) => { if (selectedId !== null) {
context.commit('msConfigListSucceeded', msConfigList) context.commit('expandMsConfig', msConfigList)
if (selectedId !== null) { context.commit('highlightMsConfig', msConfigList)
context.commit('expandMsConfig', msConfigList) }
context.commit('highlightMsConfig', msConfigList) } catch (err) {
} context.commit('msConfigListFailed', err.message)
resolve() }
}).catch(() => {
resolve()
context.commit('msConfigListSucceeded')
})
})
}, },
createMsConfig (context, msConfigData) { createMsConfig (context, msConfigData) {
context.commit('msConfigCreationRequesting', msConfigData) context.commit('msConfigCreationRequesting', msConfigData)

@ -37,6 +37,7 @@ export default {
state: { state: {
seatListState: RequestState.initiated, seatListState: RequestState.initiated,
seatListVisibility: 'visible', seatListVisibility: 'visible',
seatListError: null,
seatListItems: [], seatListItems: [],
seatListCurrentPage: 1, seatListCurrentPage: 1,
seatListLastPage: null, seatListLastPage: null,
@ -247,8 +248,9 @@ export default {
state.seatListVisibility = 'visible' state.seatListVisibility = 'visible'
} }
}, },
seatListItemsFailed (state) { seatListItemsFailed (state, err) {
state.seatListState = RequestState.failed state.seatListState = RequestState.failed
state.seatListError = err
}, },
seatCreationRequesting (state, seat) { seatCreationRequesting (state, seat) {
state.seatCreationState = CreationState.creating state.seatCreationState = CreationState.creating
@ -324,39 +326,34 @@ export default {
loadPreferences (context, seatId) { loadPreferences (context, seatId) {
return getSeatPreferences(seatId) return getSeatPreferences(seatId)
}, },
loadSeatListItems (context, options) { async loadSeatListItems (context, options) {
return new Promise((resolve, reject) => { const page = _.get(options, 'page', context.state.seatListCurrentPage)
const page = _.get(options, 'page', context.state.seatListCurrentPage) const clearList = _.get(options, 'clearList', true)
const clearList = _.get(options, 'clearList', true) const displayName = _.get(options, 'display_name', null)
const displayName = _.get(options, 'display_name', null) const pbxExtension = _.get(options, 'pbx_extension', null)
const pbxExtension = _.get(options, 'pbx_extension', null) const primaryNumber = _.get(options, 'primary_number', null)
const primaryNumber = _.get(options, 'primary_number', null) const aliasNumber = _.get(options, 'alias_number', null)
const aliasNumber = _.get(options, 'alias_number', null) context.commit('seatListItemsRequesting', { clearList })
context.commit('seatListItemsRequesting', { try {
clearList const seatList = await getSeatList({
})
getSeatList({
page, page,
display_name: displayName, display_name: displayName,
pbx_extension: pbxExtension, pbx_extension: pbxExtension,
primary_number: primaryNumber, primary_number: primaryNumber,
alias_number: aliasNumber 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) { createSeat (context, seatData) {
context.commit('seatCreationRequesting', seatData) context.commit('seatCreationRequesting', seatData)
@ -468,23 +465,22 @@ export default {
context.commit('seatUpdateFailed', err.message) context.commit('seatUpdateFailed', err.message)
}) })
}, },
setSeatNumbers (context, options) { async setSeatNumbers (context, options) {
context.commit('seatUpdateRequesting', { context.commit('seatUpdateRequesting', {
seatId: options.seatId, seatId: options.seatId,
seatField: i18n.global.t('Alias Numbers') seatField: i18n.global.t('Alias Numbers')
}) })
setSeatNumbers({ try {
seatId: options.seatId, const result = await setSeatNumbers({
pilotId: context.rootGetters['pbx/pilot'].id, seatId: options.seatId,
assignedNumbers: options.assignedNumbers, pilotId: context.rootGetters['pbx/pilot'].id,
unassignedNumbers: options.unassignedNumbers assignedNumbers: options.assignedNumbers,
}).then((result) => { unassignedNumbers: options.unassignedNumbers
return Promise.resolve(result) })
}).then((result) => {
context.commit('seatUpdateSucceeded', result) context.commit('seatUpdateSucceeded', result)
}).catch((err) => { } catch (err) {
context.commit('seatUpdateFailed', err.message) context.commit('seatUpdateFailed', err.message)
}) }
}, },
setSeatSoundSet (context, options) { setSeatSoundSet (context, options) {
context.commit('seatUpdateRequesting', { context.commit('seatUpdateRequesting', {

@ -30,6 +30,7 @@ export default {
state: { state: {
soundSetListState: RequestState.initiated, soundSetListState: RequestState.initiated,
soundSetListVisible: true, soundSetListVisible: true,
soundSetListError: null,
soundSetList: [], soundSetList: [],
soundSetMap: {}, soundSetMap: {},
soundSetListCurrentPage: 1, soundSetListCurrentPage: 1,
@ -47,13 +48,18 @@ export default {
soundSetSelected: null, soundSetSelected: null,
soundHandleList: {}, soundHandleList: {},
soundHandleListState: RequestState.initiated, soundHandleListState: RequestState.initiated,
soundHandleListError: null,
soundFileMap: {}, soundFileMap: {},
soundFileUrlMap: {}, soundFileUrlMap: {},
soundFileListStates: {}, soundFileListStates: {},
soundFileState: {}, soundFileState: {},
soundFileError: null,
soundFileRemoveError: null,
soundFileUploadState: {}, soundFileUploadState: {},
soundFileUploadError: null,
soundFileUploadProgress: {}, soundFileUploadProgress: {},
soundFileUpdateState: {}, soundFileUpdateState: {},
soundFileUpdateError: null,
soundFileRemoveState: {}, soundFileRemoveState: {},
soundHandleGroups: [] soundHandleGroups: []
}, },
@ -160,6 +166,10 @@ export default {
state.soundSetMap[soundSet.id] = soundSet state.soundSetMap[soundSet.id] = soundSet
}) })
}, },
soundSetListFailed (state, err) {
state.soundSetListState = RequestState.failed
state.soundSetListError = err
},
soundSetCreationRequesting (state, options) { soundSetCreationRequesting (state, options) {
state.soundSetCreationState = CreationState.creating state.soundSetCreationState = CreationState.creating
state.soundSetCreationData = options state.soundSetCreationData = options
@ -238,6 +248,10 @@ export default {
return group return group
}) })
}, },
soundHandlesFailed (state, err) {
state.soundHandleListState = RequestState.failed
state.soundHandleListError = err
},
soundFilesRequesting (state, soundSetId) { soundFilesRequesting (state, soundSetId) {
delete state.soundFileListStates[soundSetId] delete state.soundFileListStates[soundSetId]
state.soundFileListStates[soundSetId] = RequestState.requesting state.soundFileListStates[soundSetId] = RequestState.requesting
@ -253,6 +267,11 @@ export default {
})] = soundFile })] = soundFile
}) })
}, },
soundFilesFailed (state, err, soundSetId) {
delete state.soundFileListStates[soundSetId]
state.soundFileListStates[soundSetId] = RequestState.failed
state.soundFileError = err
},
soundFileRequesting (state, options) { soundFileRequesting (state, options) {
delete state.soundFileState[options.soundFile.id] delete state.soundFileState[options.soundFile.id]
state.soundFileState[options.soundFile.id] = RequestState.requesting state.soundFileState[options.soundFile.id] = RequestState.requesting
@ -270,6 +289,7 @@ export default {
soundFileFailed (state, options) { soundFileFailed (state, options) {
delete state.soundFileState[options.soundFile.id] delete state.soundFileState[options.soundFile.id]
state.soundFileState[options.soundFile.id] = RequestState.failed state.soundFileState[options.soundFile.id] = RequestState.failed
state.soundFileError = options.error
}, },
soundFileUploadRequesting (state, soundFileId) { soundFileUploadRequesting (state, soundFileId) {
delete state.soundFileUploadState[soundFileId] delete state.soundFileUploadState[soundFileId]
@ -296,6 +316,7 @@ export default {
soundFileUploadAborted (state, options) { soundFileUploadAborted (state, options) {
delete state.soundFileUploadState[options.soundFileId] delete state.soundFileUploadState[options.soundFileId]
state.soundFileUploadState[options.soundFileId] = RequestState.failed state.soundFileUploadState[options.soundFileId] = RequestState.failed
state.soundFileUploadError = options.error
}, },
soundFileUpdateRequesting (state, options) { soundFileUpdateRequesting (state, options) {
const soundFileIntId = toFileId({ const soundFileIntId = toFileId({
@ -324,6 +345,7 @@ export default {
}) })
delete state.soundFileUpdateState[soundFileIntId] delete state.soundFileUpdateState[soundFileIntId]
state.soundFileUpdateState[soundFileIntId] = RequestState.failed state.soundFileUpdateState[soundFileIntId] = RequestState.failed
state.soundFileUpdateError = options.error
}, },
soundFileRemoveRequesting (state, options) { soundFileRemoveRequesting (state, options) {
const soundFileIntId = toFileId({ const soundFileIntId = toFileId({
@ -349,6 +371,7 @@ export default {
}) })
delete state.soundFileRemoveState[soundFileIntId] delete state.soundFileRemoveState[soundFileIntId]
state.soundFileRemoveState[soundFileIntId] = RequestState.failed state.soundFileRemoveState[soundFileIntId] = RequestState.failed
state.soundFileRemoveError = options.error
}, },
selectSoundSet (state, soundSetId) { selectSoundSet (state, soundSetId) {
state.soundSetSelected = state.soundSetMap[soundSetId] state.soundSetSelected = state.soundSetMap[soundSetId]
@ -358,29 +381,20 @@ export default {
} }
}, },
actions: { actions: {
loadSoundSetList (context, options) { async loadSoundSetList (context, options) {
return new Promise((resolve) => { const listVisible = _.get(options, 'listVisible', false)
const listVisible = _.get(options, 'listVisible', false) context.commit('soundSetListRequesting', { listVisible })
context.commit('soundSetListRequesting', { let page = _.get(options, 'page', context.state.soundSetListCurrentPage)
listVisible page = (page === null) ? 1 : page
}) try {
let page = _.get(options, 'page', context.state.soundSetListCurrentPage) const soundSetList = await getSoundSetList({ page })
page = (page === null) ? 1 : page context.commit('soundSetListSucceeded', {
getSoundSetList({ soundSets: soundSetList.soundSets,
page 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) { createSoundSet (context, options) {
context.commit('soundSetCreationRequesting', options) context.commit('soundSetCreationRequesting', options)
@ -456,10 +470,8 @@ export default {
context.commit('soundHandlesRequesting') context.commit('soundHandlesRequesting')
getAllSoundHandles().then((soundHandles) => { getAllSoundHandles().then((soundHandles) => {
context.commit('soundHandlesSucceeded', soundHandles) context.commit('soundHandlesSucceeded', soundHandles)
}).catch(() => { }).catch((err) => {
context.commit('soundHandlesSucceeded', { context.commit('soundHandlesFailed', err.message)
items: []
})
}) })
} }
if (context.state.soundFileListStates[soundSetId] !== RequestState.succeeded) { if (context.state.soundFileListStates[soundSetId] !== RequestState.succeeded) {
@ -469,13 +481,8 @@ export default {
soundSetId, soundSetId,
soundFiles soundFiles
}) })
}).catch(() => { }).catch((err) => {
context.commit('soundFilesSucceeded', { context.commit('soundFilesFailed', err.message, soundSetId)
soundSetId,
soundFiles: {
items: []
}
})
}) })
} }
}, },
@ -490,9 +497,10 @@ export default {
soundFile, soundFile,
soundFileUrl soundFileUrl
}) })
}).catch(() => { }).catch((err) => {
context.commit('soundFileFailed', { context.commit('soundFileFailed', {
soundFile soundFile,
error: err.message
}) })
}) })
}, },
@ -522,12 +530,13 @@ export default {
} }
}).then((res) => { }).then((res) => {
context.commit('soundFileUploadSucceeded', res) context.commit('soundFileUploadSucceeded', res)
}).catch(() => { }).catch((err) => {
context.commit('soundFileUploadAborted', { context.commit('soundFileUploadAborted', {
soundFileId: toFileId({ soundFileId: toFileId({
soundSetId: options.soundSetId, soundSetId: options.soundSetId,
soundHandle: options.soundHandle soundHandle: options.soundHandle
}) }),
error: err.message
}) })
}) })
}, },
@ -535,24 +544,24 @@ export default {
context.commit('soundFileUpdateRequesting', options) context.commit('soundFileUpdateRequesting', options)
setLoopPlay(options).then((soundFile) => { setLoopPlay(options).then((soundFile) => {
context.commit('soundFileUpdateSucceeded', soundFile) context.commit('soundFileUpdateSucceeded', soundFile)
}).catch(() => { }).catch((err) => {
context.commit('soundFileUpdateFailed', options) context.commit('soundFileUpdateFailed', { ...options, error: err.message })
}) })
}, },
setUseParent (context, options) { setUseParent (context, options) {
context.commit('soundFileUpdateRequesting', options) context.commit('soundFileUpdateRequesting', options)
setUseParent(options).then((soundFile) => { setUseParent(options).then((soundFile) => {
context.commit('soundFileUpdateSucceeded', soundFile) context.commit('soundFileUpdateSucceeded', soundFile)
}).catch(() => { }).catch((err) => {
context.commit('soundFileUpdateFailed', options) context.commit('soundFileUpdateFailed', { ...options, error: err.message })
}) })
}, },
removeSoundFile (context, options) { removeSoundFile (context, options) {
context.commit('soundFileRemoveRequesting', options) context.commit('soundFileRemoveRequesting', options)
removeSoundFile(options.soundFileId).then(() => { removeSoundFile(options.soundFileId).then(() => {
context.commit('soundFileRemoveSucceeded', options) context.commit('soundFileRemoveSucceeded', options)
}).catch(() => { }).catch((err) => {
context.commit('soundFileRemoveFailed', options) context.commit('soundFileRemoveFailed', { ...options, error: err.message })
}) })
} }
} }

@ -19,6 +19,7 @@ export default {
numberList: [], numberList: [],
numberMapById: {}, numberMapById: {},
numberListState: RequestState.initiated, numberListState: RequestState.initiated,
numberListError: null,
groupList: [], groupList: [],
groupMapById: {}, groupMapById: {},
seatList: [], seatList: [],
@ -29,13 +30,17 @@ export default {
deviceProfileList: [], deviceProfileList: [],
deviceProfileMap: {}, deviceProfileMap: {},
deviceModelList: [], deviceModelList: [],
deviceModelListState: RequestState.initiated,
deviceModelMap: {}, deviceModelMap: {},
deviceModelImageMap: {}, deviceModelImageMap: {},
deviceModelImageSmallMap: {}, deviceModelImageSmallMap: {},
subscriberList: [], subscriberList: [],
subscriberListState: RequestState.initiated, subscriberListState: RequestState.initiated,
subcriberListError: null,
subscriberMap: {}, subscriberMap: {},
ncosMapByName: {} ncosMapByName: {},
deviceProfileListState: RequestState.initiated,
deviceProfileListError: null
}, },
getters: { getters: {
pilot (state) { pilot (state) {
@ -204,6 +209,10 @@ export default {
state.numberMapById[number.id] = number state.numberMapById[number.id] = number
}) })
}, },
numbersFailed (state, err) {
state.numberListState = RequestState.failed
state.numberListError = err
},
seatsSucceeded (state, seatList) { seatsSucceeded (state, seatList) {
state.seatList = _.get(seatList, 'items', []) state.seatList = _.get(seatList, 'items', [])
state.seatMapById = {} state.seatMapById = {}
@ -251,6 +260,7 @@ export default {
state.deviceProfilesListState = RequestState.failed state.deviceProfilesListState = RequestState.failed
}, },
deviceModelSucceeded (state, deviceModel) { deviceModelSucceeded (state, deviceModel) {
state.deviceModelListState = RequestState.succeeded
const model = _.get(deviceModel, 'model', null) const model = _.get(deviceModel, 'model', null)
const modelImage = _.get(deviceModel, 'modelImage', null) const modelImage = _.get(deviceModel, 'modelImage', null)
const modelImageThumbnail = _.get(deviceModel, 'modelImageThumbnail', null) const modelImageThumbnail = _.get(deviceModel, 'modelImageThumbnail', null)
@ -264,10 +274,15 @@ export default {
state.deviceModelImageSmallMap[modelImageThumbnail.id] = modelImageThumbnail state.deviceModelImageSmallMap[modelImageThumbnail.id] = modelImageThumbnail
} }
}, },
deviceModelFailed (state, deviceModelId) { deviceModelRequesting (state) {
delete state.deviceModelMap[deviceModelId] state.deviceModelListState = RequestState.requesting
delete state.deviceModelImageMap[deviceModelId] },
delete state.deviceModelImageSmallMap[deviceModelId] 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) { subscribersRequesting (state) {
state.subcriberListState = RequestState.requesting state.subcriberListState = RequestState.requesting
@ -279,24 +294,23 @@ export default {
state.subscriberList.forEach((subscriber) => { state.subscriberList.forEach((subscriber) => {
state.subscriberMap[subscriber.id] = subscriber state.subscriberMap[subscriber.id] = subscriber
}) })
},
subscribersFailed (state, err) {
state.subcriberListState = RequestState.failed
state.subcriberListError = err
} }
}, },
actions: { actions: {
loadProfiles (context) { async loadProfiles (context) {
return new Promise((resolve, reject) => { if (context.state.deviceProfileList.length === 0) {
context.commit('deviceProfilesListStateRequesting') context.commit('deviceProfilesListStateRequesting')
if (context.state.deviceProfileList.length === 0) { try {
getAllProfiles().then((profiles) => { const profiles = await getAllProfiles()
context.commit('deviceProfilesListSucceeded', profiles) context.commit('deviceProfilesListSucceeded', profiles)
resolve(profiles) } catch (err) {
}).catch((err) => { context.commit('deviceProfilesListFailed', err.message)
context.commit('deviceProfilesListFailed')
reject(err)
})
} else {
resolve()
} }
}) }
}, },
async loadProfileById (context, deviceId) { async loadProfileById (context, deviceId) {
context.commit('deviceProfileRequesting') context.commit('deviceProfileRequesting')
@ -319,6 +333,7 @@ export default {
} }
const requests = [] const requests = []
let isFrontImageRequested = false let isFrontImageRequested = false
context.commit('deviceModelRequesting')
if (!isFrontCached && (payload.type === 'front' || payload.type === 'all')) { if (!isFrontCached && (payload.type === 'front' || payload.type === 'all')) {
requests.push(getModelFrontImage(payload.deviceId)) requests.push(getModelFrontImage(payload.deviceId))
isFrontImageRequested = true isFrontImageRequested = true
@ -358,7 +373,10 @@ export default {
} }
context.commit('deviceModelSucceeded', deviceModel) context.commit('deviceModelSucceeded', deviceModel)
} catch (err) { } catch (err) {
context.commit('deviceModelFailed', payload.deviceId) context.commit('deviceModelFailed', {
deviceModelId: payload.deviceId,
error: err.message
})
} }
}, },
async loadDeviceModels (context, imageType) { async loadDeviceModels (context, imageType) {
@ -378,10 +396,8 @@ export default {
all: true all: true
}).then((subscribers) => { }).then((subscribers) => {
context.commit('subscribersSucceeded', subscribers) context.commit('subscribersSucceeded', subscribers)
}).catch(() => { }).catch((err) => {
context.commit('subscribersSucceeded', { context.commit('subscribersFailed', err.message)
items: []
})
}) })
} }
}, },
@ -393,10 +409,8 @@ export default {
all: true all: true
}).then((numbers) => { }).then((numbers) => {
context.commit('numbersSucceeded', numbers) context.commit('numbersSucceeded', numbers)
}).catch(() => { }).catch((err) => {
context.commit('numbersSucceeded', { context.commit('numbersFailed', err.message)
items: []
})
}) })
} }
} }

@ -76,17 +76,14 @@ export default {
} }
}, },
actions: { actions: {
loadReminder (context) { async loadReminder (context) {
return new Promise((resolve, reject) => { context.commit('reminderLoading')
context.commit('reminderLoading') try {
getReminder(context.getters.subscriberId).then((reminder) => { const reminder = await getReminder(context.getters.subscriberId)
context.commit('reminderLoaded', reminder) context.commit('reminderLoaded', reminder)
resolve() } catch (err) {
}).catch((err) => { context.commit('reminderLoadingFailed', err.message)
reject(err) }
context.commit('reminderLoadingFailed', err.message)
})
})
}, },
toggleReminder (context) { toggleReminder (context) {
context.commit('reminderUpdating', 'active') context.commit('reminderUpdating', 'active')

@ -50,6 +50,7 @@ export default {
busyGreetingUploadProgress: 0, busyGreetingUploadProgress: 0,
busyGreetingDeletionState: RequestState.initiated, busyGreetingDeletionState: RequestState.initiated,
busyGreetingDeletionError: null, busyGreetingDeletionError: null,
busyGreetingLoadError: null,
unavailableGreetingId: null, unavailableGreetingId: null,
unavailableGreetingUrl: null, unavailableGreetingUrl: null,
@ -59,6 +60,7 @@ export default {
unavailableGreetingUploadProgress: 0, unavailableGreetingUploadProgress: 0,
unavailableGreetingDeletionState: RequestState.initiated, unavailableGreetingDeletionState: RequestState.initiated,
unavailableGreetingDeletionError: null, unavailableGreetingDeletionError: null,
unavailableGreetingLoadError: null,
uploadCancelActions: {}, uploadCancelActions: {},
@ -70,6 +72,7 @@ export default {
tempGreetingUploadProgress: 0, tempGreetingUploadProgress: 0,
tempGreetingDeletionState: RequestState.initiated, tempGreetingDeletionState: RequestState.initiated,
tempGreetingDeletionError: null, tempGreetingDeletionError: null,
tempGreetingLoadError: null,
greetGreetingId: null, greetGreetingId: null,
greetGreetingUrl: null, greetGreetingUrl: null,
@ -78,7 +81,8 @@ export default {
greetGreetingUploadError: null, greetGreetingUploadError: null,
greetGreetingUploadProgress: 0, greetGreetingUploadProgress: 0,
greetGreetingDeletionState: RequestState.initiated, greetGreetingDeletionState: RequestState.initiated,
greetGreetingDeletionError: null greetGreetingDeletionError: null,
greetGreetingLoadError: null
}, },
getters: { getters: {
subscriberId (state, getters, rootState, rootGetters) { subscriberId (state, getters, rootState, rootGetters) {
@ -296,9 +300,10 @@ export default {
state.busyGreetingLoadState = RequestState.succeeded state.busyGreetingLoadState = RequestState.succeeded
state.busyGreetingUrl = url state.busyGreetingUrl = url
}, },
busyGreetingPlayFailed (state) { busyGreetingPlayFailed (state, err) {
state.busyGreetingLoadState = RequestState.failed state.busyGreetingLoadState = RequestState.failed
state.busyGreetingUrl = null state.busyGreetingUrl = null
state.busyGreetingLoadError = err
}, },
busyGreetingDeletionRequesting (state) { busyGreetingDeletionRequesting (state) {
state.busyGreetingDeletionState = RequestState.requesting state.busyGreetingDeletionState = RequestState.requesting
@ -342,9 +347,10 @@ export default {
state.unavailableGreetingLoadState = RequestState.succeeded state.unavailableGreetingLoadState = RequestState.succeeded
state.unavailableGreetingUrl = url state.unavailableGreetingUrl = url
}, },
unavailableGreetingPlayFailed (state) { unavailableGreetingPlayFailed (state, err) {
state.unavailableGreetingLoadState = RequestState.failed state.unavailableGreetingLoadState = RequestState.failed
state.unavailableGreetingUrl = null state.unavailableGreetingUrl = null
state.unavailableGreetingLoadError = err
}, },
unavailableGreetingDeletionRequesting (state) { unavailableGreetingDeletionRequesting (state) {
state.unavailableGreetingDeletionState = RequestState.requesting state.unavailableGreetingDeletionState = RequestState.requesting
@ -390,9 +396,10 @@ export default {
state.tempGreetingLoadState = RequestState.succeeded state.tempGreetingLoadState = RequestState.succeeded
state.tempGreetingUrl = url state.tempGreetingUrl = url
}, },
tempGreetingPlayFailed (state) { tempGreetingPlayFailed (state, err) {
state.tempGreetingLoadState = RequestState.failed state.tempGreetingLoadState = RequestState.failed
state.tempGreetingUrl = null state.tempGreetingUrl = null
state.tempGreetingLoadError = err
}, },
tempGreetingDeletionRequesting (state) { tempGreetingDeletionRequesting (state) {
state.tempGreetingDeletionState = RequestState.requesting state.tempGreetingDeletionState = RequestState.requesting
@ -435,9 +442,10 @@ export default {
state.greetGreetingLoadState = RequestState.succeeded state.greetGreetingLoadState = RequestState.succeeded
state.greetGreetingUrl = url state.greetGreetingUrl = url
}, },
greetGreetingPlayFailed (state) { greetGreetingPlayFailed (state, err) {
state.tgreetGreetingLoadState = RequestState.failed state.greetGreetingLoadState = RequestState.failed
state.greetGreetingUrl = null state.greetGreetingUrl = null
state.greetGreetingLoadError = err
}, },
greetGreetingDeletionRequesting (state) { greetGreetingDeletionRequesting (state) {
state.greetGreetingDeletionState = RequestState.requesting state.greetGreetingDeletionState = RequestState.requesting

Loading…
Cancel
Save