diff --git a/src/api/fax.js b/src/api/fax.js new file mode 100644 index 00000000..10215509 --- /dev/null +++ b/src/api/fax.js @@ -0,0 +1,34 @@ + +import _ from 'lodash' +import { + get, + patchReplaceFull +} from './common' +import { i18n } from 'src/boot/i18n' + +export async function getFaxServerSettings (subscriberId) { + const result = await get({ + path: `api/faxserversettings/${subscriberId}` + }) + const settings = _.clone(result) + delete settings._links + return settings +} + +export async function setFaxServerField (options) { + if (!['name', 'active', 'ecm', 't38', 'destinations'].includes(options.field)) { + throw Error(`setFaxServerField: unknown field name ${options.field}`) + } + if (options.field === 'destinations') { + // searching for duplicates + const destinationsIds = options.value.map(d => d.destination) + if ((new Set(destinationsIds)).size !== destinationsIds.length) { + throw Error(i18n.t('faxSettings.destinationEmailExists')) + } + } + return patchReplaceFull({ + path: `api/faxserversettings/${options.subscriberId}`, + fieldPath: options.field, + value: options.value + }) +} diff --git a/src/api/user.js b/src/api/user.js index 8a07ee56..8e8318bd 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -6,6 +6,7 @@ import { getList, patchReplace } from './common' +import { getFaxServerSettings } from 'src/api/fax' export function login (username, password) { return new Promise((resolve, reject) => { @@ -36,9 +37,9 @@ export function getUserData (id) { return Promise.all([ getSubscriberById(id), getCapabilities(id), - getFaxServerSettingsById(id) + getFaxServerSettings(id) ]).then((results) => { - results[1].faxactive = results[2] + results[1].faxactive = results[2].active resolve({ subscriber: results[0], capabilities: results[1] @@ -126,15 +127,3 @@ export function getNumbers () { }) }) } - -export function getFaxServerSettingsById (id) { - return new Promise((resolve, reject) => { - get({ - path: 'api/faxserversettings/' + id - }).then((body) => { - resolve(body.active) - }).catch((err) => { - reject(err) - }) - }) -} diff --git a/src/components/CscListMenuItem.vue b/src/components/CscListMenuItem.vue index 3a14bfab..be57f194 100644 --- a/src/components/CscListMenuItem.vue +++ b/src/components/CscListMenuItem.vue @@ -2,6 +2,7 @@ + + + + + + + + diff --git a/src/components/pages/FaxSettings/CscFax2MailDestinationForm.vue b/src/components/pages/FaxSettings/CscFax2MailDestinationForm.vue new file mode 100644 index 00000000..4a39406d --- /dev/null +++ b/src/components/pages/FaxSettings/CscFax2MailDestinationForm.vue @@ -0,0 +1,169 @@ + + + diff --git a/src/i18n/en.json b/src/i18n/en.json index 727f07a0..1f35e982 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -121,6 +121,10 @@ "title": "Voicebox", "subTitle": "Set your voicebox settings" }, + "faxSettings": { + "title": "Fax Settings", + "subTitle": "Set your fax settings" + }, "conference": { "title": "Join conference" }, @@ -736,5 +740,23 @@ "deleteVoicemailButton": "Remove Voicemail", "deleteVoicemailTitle": "Remove Voicemail", "deleteVoicemailText": "You are about to remove this Voicemail" - } + }, + "faxSettings": { + "active": "Active", + "sendfaxHeaderName": "Name in Fax Header for Sendfax", + "T38": "T38", + "ECM": "ECM", + "noDestinationsCreatedYet": "No destinations created yet", + "addDestination": "Add destination", + "createDestination": "Create destination", + "destinationEmail": "Destination Email", + "fileType": "File Type", + "deliverIncomingFaxes": "Deliver Incoming Faxes", + "deliverOutgoingFaxes": "Deliver Outgoing Faxes", + "receiveReports": "Receive Reports", + "deleteDestinationTitle": "Remove Destination", + "deleteDestinationText": "You are about to remove destination {destination}", + "destinationEmailExists": "The Destination Email is already used", + "destinationItemTitle": "<{destination}> as {filetype}" + } } diff --git a/src/pages/CscPageFaxSettings.vue b/src/pages/CscPageFaxSettings.vue new file mode 100644 index 00000000..5220e3fc --- /dev/null +++ b/src/pages/CscPageFaxSettings.vue @@ -0,0 +1,276 @@ + + + diff --git a/src/router/routes.js b/src/router/routes.js index f693525d..3c7185ed 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -23,6 +23,7 @@ import CscPagePbxSoundSets from 'src/pages/CscPagePbxSoundSets' import CscPagePbxMsConfigs from 'src/pages/CscPagePbxMsConfigs' import CscPagePbxSettings from 'src/pages/CscPagePbxSettings' import CscPageVoicebox from 'src/pages/CscPageVoicebox' +import CscPageFaxSettings from 'src/pages/CscPageFaxSettings' import CscPageUserSettings from 'src/pages/CscPageUserSettings' import CscPageError404 from 'src/pages/CscPageError404' import CscRecoverPassword from 'src/pages/CscRecoverPassword' @@ -179,6 +180,14 @@ export default function routes (app) { subtitle: i18n.t('navigation.voicebox.subTitle') } }, + { + path: 'fax-settings', + component: CscPageFaxSettings, + meta: { + title: i18n.t('navigation.faxSettings.title'), + subtitle: i18n.t('navigation.faxSettings.subTitle') + } + }, { path: 'settings', component: CscPageUserSettings, diff --git a/src/store/fax.js b/src/store/fax.js new file mode 100644 index 00000000..cce527d5 --- /dev/null +++ b/src/store/fax.js @@ -0,0 +1,45 @@ +import _ from 'lodash' +import { + getFaxServerSettings, + setFaxServerField +} from '../api/fax' + +export default { + namespaced: true, + state: { + faxServerSettingsInitialized: false, + faxServerSettings: {} + }, + getters: { + subscriberId (state, getters, rootState, rootGetters) { + return parseInt(rootGetters['user/getSubscriberId']) + } + }, + mutations: { + settingsSucceeded (state, res) { + if (_.has(res, 'faxServerSettings')) { + state.faxServerSettings = res.faxServerSettings + state.faxServerSettingsInitialized = true + } + } + }, + actions: { + async loadFaxSettingsAction (context) { + const faxServerSettings = await getFaxServerSettings(context.getters.subscriberId) + context.commit('settingsSucceeded', { + faxServerSettings + }) + }, + async fieldUpdateAction (context, options) { + const faxServerSettings = await setFaxServerField({ + subscriberId: context.getters.subscriberId, + field: options.field, + value: options.value + }) + context.commit('settingsSucceeded', { + faxServerSettings + }) + context.commit('user/updateFaxActiveCapabilityState', faxServerSettings.active, { root: true }) + } + } +} diff --git a/src/store/index.js b/src/store/index.js index 1f82a997..5b27ac10 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -23,6 +23,7 @@ import ReminderModule from './reminder' import SpeedDialModule from './speed-dial' import UserModule from './user' import CommunicationModule from './communication' +import FaxModule from './fax' import VoiceboxModule from './voicebox' import ConferenceModule from './conference' @@ -60,6 +61,7 @@ export default function (/* { ssrContext } */) { speedDial: SpeedDialModule, user: UserModule, communication: CommunicationModule, + fax: FaxModule, voicebox: VoiceboxModule, conference: ConferenceModule, pbx: PbxModule, diff --git a/src/store/user.js b/src/store/user.js index fcf9db4d..039bfcb3 100644 --- a/src/store/user.js +++ b/src/store/user.js @@ -249,6 +249,9 @@ export default { }, newPasswordRequesting (state, isRequesting) { state.newPasswordRequesting = isRequesting + }, + updateFaxActiveCapabilityState (state, value) { + state.capabilities.faxactive = value } }, actions: {