diff --git a/quasar.conf.js b/quasar.conf.js index 55237ee7..31c12260 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -26,6 +26,7 @@ module.exports = function (/* ctx */) { // 'axios', 'vue-resource', 'routes', + 'user', 'components', 'vue-scrollto', 'constants', diff --git a/src/api/subscriber.js b/src/api/subscriber.js index d29ae39c..2b96c48d 100644 --- a/src/api/subscriber.js +++ b/src/api/subscriber.js @@ -13,7 +13,6 @@ import { patchRemove, patchReplaceFull, patchAddFull - } from './common' import { @@ -625,3 +624,10 @@ export async function getRecordingStream (fileId) { path: 'api/callrecordingfiles/' + fileId }) } + +export async function getSubscriberProfile (id) { + const profile = await get({ + path: `api/subscriberprofiles/${id}` + }) + return profile +} diff --git a/src/boot/user.js b/src/boot/user.js new file mode 100644 index 00000000..c4a3d520 --- /dev/null +++ b/src/boot/user.js @@ -0,0 +1,7 @@ +import { hasJwt } from 'src/auth' + +export default async ({ store }) => { + if (hasJwt()) { + await store.dispatch('user/initUser') + } +} diff --git a/src/components/CscMainMenuTop.vue b/src/components/CscMainMenuTop.vue index c6c23a2b..5f8bbf26 100644 --- a/src/components/CscMainMenuTop.vue +++ b/src/components/CscMainMenuTop.vue @@ -47,7 +47,8 @@ export default { ...mapGetters('user', [ 'isRtcEngineUiVisible', 'isPbxEnabled', - 'hasFaxCapability' + 'hasFaxCapability', + 'hasSubscriberProfileAttribute' ]), items () { return [ @@ -122,7 +123,7 @@ export default { to: '/user/reminder', icon: 'notification_important', label: this.$t('Reminder'), - visible: true + visible: this.hasSubscriberProfileAttribute('reminder') }, { to: '/user/recordings', diff --git a/src/i18n/de.json b/src/i18n/de.json index c9f1f7ad..e31ed0c5 100644 --- a/src/i18n/de.json +++ b/src/i18n/de.json @@ -146,6 +146,7 @@ "Conference": "", "Conference name": "Konferenzname", "Confirm": "Bestätigen", + "Contact": "", "Content": "Inhalt", "Control your calls": "Anrufe steuern", "Conversations": "Konversationen", @@ -230,6 +231,7 @@ "Established": "Verbunden", "Every caller": "Alle Anrufer", "Exit": "Beenden", + "Expires": "", "Extension": "Rufnummernerweiterung", "Fax": "Fax", "Fax File": "Fax-Datei", @@ -312,6 +314,7 @@ "Leave conference": "Konferenz verlassen", "Leave current conference now!": "Aktuelle Konferenz jetzt verlassen", "List name": "", + "List of registered devices for the subscriber": "", "Load Files": "Sounds laden", "Logged in as": "Angemeldet als", "Login": "", @@ -406,6 +409,7 @@ "Primary number {number} rings before forwarded if the user is available": "", "Privacy": "Datenschutz", "Private": "Private", + "Q-Value": "", "Quality": "Qualität", "Queue Length": "Anzahl der Anrufe", "Random Ringing": "Zufälliges Klingeln", @@ -414,6 +418,7 @@ "Recording successfully deleted": "", "Recordings": "", "Recover password": "", + "Registered Devices": "", "Reloading conversation items failed": "Das Laden der Konversationen ist fehlgeschlagen.", "Reminder": "Erinnerung", "Reminder is disabled": "Erinnerung ist deaktiviert", @@ -593,6 +598,7 @@ "Use RegExp": "", "Use as default for all seats and groups": "Standard für alle Seats und Gruppen", "Use language specific preset": "Sprachspezifische Voreinstellungen verwenden", + "User Agent": "", "User settings": "", "Username": "Benutzername", "Video Call": "Videoanruf", @@ -715,4 +721,4 @@ "{field} must have at most {maxLength} letters": "{field} darf höchstens {maxLength} Buchstaben beinhalten", "{mode} of sources": "{mode} of sources", "{mode} own phone": "Eigene Rufnummer {mode}" -} +} \ No newline at end of file diff --git a/src/i18n/en.json b/src/i18n/en.json index 92323c8d..cfe3d134 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -146,6 +146,7 @@ "Conference": "Conference", "Conference name": "Conference name", "Confirm": "Confirm", + "Contact": "Contact", "Content": "Content", "Control your calls": "Control your calls", "Conversations": "Conversations", @@ -230,6 +231,7 @@ "Established": "Established", "Every caller": "Every caller", "Exit": "Exit", + "Expires": "Expires", "Extension": "Extension", "Fax": "Fax", "Fax File": "Fax File", @@ -312,6 +314,7 @@ "Leave conference": "Leave conference", "Leave current conference now!": "Leave current conference now!", "List name": "List name", + "List of registered devices for the subscriber": "List of registered devices for the subscriber", "Load Files": "Load Files", "Logged in as": "Logged in as", "Login": "Login", @@ -406,6 +409,7 @@ "Primary number {number} rings before forwarded if the user is available": "Primary number {number} rings before forwarded if the user is available", "Privacy": "Privacy", "Private": "Private", + "Q-Value": "Q-Value", "Quality": "Quality", "Queue Length": "Queue Length", "Random Ringing": "Random Ringing", @@ -414,6 +418,7 @@ "Recording successfully deleted": "Recording successfully deleted", "Recordings": "Recordings", "Recover password": "Recover password", + "Registered Devices": "Registered Devices", "Reloading conversation items failed": "Reloading conversation items failed", "Reminder": "Reminder", "Reminder is disabled": "Reminder is disabled", @@ -593,6 +598,7 @@ "Use RegExp": "Use RegExp", "Use as default for all seats and groups": "Use as default for all seats and groups", "Use language specific preset": "Use language specific preset", + "User Agent": "User Agent", "User settings": "User settings", "Username": "Username", "Video Call": "Video Call", @@ -715,4 +721,4 @@ "{field} must have at most {maxLength} letters": "{field} must have at most {maxLength} letters", "{mode} of sources": "{mode} of sources", "{mode} own phone": "{mode} own phone" -} +} \ No newline at end of file diff --git a/src/i18n/es.json b/src/i18n/es.json index b65bdc52..cd44532a 100644 --- a/src/i18n/es.json +++ b/src/i18n/es.json @@ -146,6 +146,7 @@ "Conference": "", "Conference name": "Nombre de la conferencia", "Confirm": "Confirmar", + "Contact": "", "Content": "Contenido", "Control your calls": "Controla tus llamadas", "Conversations": "Conversaciones", @@ -230,6 +231,7 @@ "Established": "Establecida", "Every caller": "", "Exit": "Salir", + "Expires": "", "Extension": "Extensión", "Fax": "Fax", "Fax File": "Archivo de fax", @@ -312,6 +314,7 @@ "Leave conference": "Salir de conferencia", "Leave current conference now!": "¡Salir de la conferencia actual ahora!", "List name": "", + "List of registered devices for the subscriber": "", "Load Files": "Cargar Archivos", "Logged in as": "Conectado como", "Login": "", @@ -406,6 +409,7 @@ "Primary number {number} rings before forwarded if the user is available": "", "Privacy": "Privacidad", "Private": "Privado", + "Q-Value": "", "Quality": "Calidad", "Queue Length": "Longitud de la cola", "Random Ringing": "Llamada aleatoria", @@ -414,6 +418,7 @@ "Recording successfully deleted": "", "Recordings": "", "Recover password": "", + "Registered Devices": "", "Reloading conversation items failed": "Falló la recarga de elementos de conversación", "Reminder": "Recordatorio", "Reminder is disabled": "El recordatorio está deshabilitado", @@ -593,6 +598,7 @@ "Use RegExp": "", "Use as default for all seats and groups": "Usar por defecto para todos los asientos y grupos", "Use language specific preset": "Usar un preajuste específico de idioma", + "User Agent": "", "User settings": "", "Username": "Nombre de usuario", "Video Call": "Videollamada", @@ -715,4 +721,4 @@ "{field} must have at most {maxLength} letters": "{field} debe tener como máximo {maxLength} letras", "{mode} of sources": "{mode} de fuentes", "{mode} own phone": "{mode} teléfono propio" -} +} \ No newline at end of file diff --git a/src/i18n/fr.json b/src/i18n/fr.json index af6ec071..02791124 100644 --- a/src/i18n/fr.json +++ b/src/i18n/fr.json @@ -146,6 +146,7 @@ "Conference": "", "Conference name": "", "Confirm": "", + "Contact": "", "Content": "Contenu", "Control your calls": "Contrôlez vos appels", "Conversations": "Conversations", @@ -230,6 +231,7 @@ "Established": "Établi", "Every caller": "", "Exit": "", + "Expires": "", "Extension": "Extension", "Fax": "Fax", "Fax File": "Fax", @@ -312,6 +314,7 @@ "Leave conference": "", "Leave current conference now!": "", "List name": "", + "List of registered devices for the subscriber": "", "Load Files": "", "Logged in as": "Connecté en tant que", "Login": "", @@ -406,6 +409,7 @@ "Primary number {number} rings before forwarded if the user is available": "", "Privacy": "Confidentialité", "Private": "Privé", + "Q-Value": "", "Quality": "Qualité", "Queue Length": "Longueur de la file d’attente", "Random Ringing": "Sonnerie aléatoire", @@ -414,6 +418,7 @@ "Recording successfully deleted": "", "Recordings": "", "Recover password": "", + "Registered Devices": "", "Reloading conversation items failed": "Le rechargement des conversations a échoué", "Reminder": "Rappel", "Reminder is disabled": "Rappel désactivé", @@ -593,6 +598,7 @@ "Use RegExp": "", "Use as default for all seats and groups": "", "Use language specific preset": "", + "User Agent": "", "User settings": "", "Username": "Identifiant", "Video Call": "Appel vidéo", @@ -715,4 +721,4 @@ "{field} must have at most {maxLength} letters": "{field} doit avoir au maximum {maxLength} caractères", "{mode} of sources": "Sources {mode}", "{mode} own phone": "{mode} téléphone personnel" -} +} \ No newline at end of file diff --git a/src/i18n/it.json b/src/i18n/it.json index 647d098a..d328bab0 100644 --- a/src/i18n/it.json +++ b/src/i18n/it.json @@ -146,6 +146,7 @@ "Conference": "", "Conference name": "Nome conferenza", "Confirm": "Conferma", + "Contact": "", "Content": "Contenuto", "Control your calls": "Controlla le tue chiamate", "Conversations": "Conversazioni", @@ -230,6 +231,7 @@ "Established": "Stabilita", "Every caller": "", "Exit": "Esci", + "Expires": "", "Extension": "Numero dell'interno", "Fax": "Fax", "Fax File": "File Fax", @@ -312,6 +314,7 @@ "Leave conference": "Abbandona la conferenza", "Leave current conference now!": "Abbandona ora la conferenza!", "List name": "", + "List of registered devices for the subscriber": "", "Load Files": "Carica Files", "Logged in as": "Logged in as", "Login": "", @@ -406,6 +409,7 @@ "Primary number {number} rings before forwarded if the user is available": "", "Privacy": "Privacy", "Private": "Privato", + "Q-Value": "", "Quality": "Qualità", "Queue Length": "Lunghezza Coda", "Random Ringing": "Squillo Casuale", @@ -414,6 +418,7 @@ "Recording successfully deleted": "", "Recordings": "", "Recover password": "", + "Registered Devices": "", "Reloading conversation items failed": "Caricamento dell'elenco conversazioni fallito", "Reminder": "Promemoria", "Reminder is disabled": "Promemoria disabilitato", @@ -593,6 +598,7 @@ "Use RegExp": "", "Use as default for all seats and groups": "Configura come predefinito per tutte le postazioni e gruppi", "Use language specific preset": "Usa i valori preimpostati della lingua", + "User Agent": "", "User settings": "", "Username": "Nome Utente", "Video Call": "Video Chiamata", @@ -715,4 +721,4 @@ "{field} must have at most {maxLength} letters": "Il campo {field} può contenere al massimo {maxLength} lettere", "{mode} of sources": "{mode} dei pattern sorgente", "{mode} own phone": "{mode} proprio telefono" -} +} \ No newline at end of file diff --git a/src/layouts/CscLayoutConference.vue b/src/layouts/CscLayoutConference.vue index bfa4a976..8da01ce3 100644 --- a/src/layouts/CscLayoutConference.vue +++ b/src/layouts/CscLayoutConference.vue @@ -290,9 +290,6 @@ export default { } } }, - mounted () { - this.$store.dispatch('user/initUser') - }, methods: { ...mapActions('conference', [ 'leave' diff --git a/src/layouts/CscLayoutMain.vue b/src/layouts/CscLayoutMain.vue index 52a70a6e..ddb0065e 100644 --- a/src/layouts/CscLayoutMain.vue +++ b/src/layouts/CscLayoutMain.vue @@ -456,7 +456,6 @@ export default { } }, async mounted () { - await this.$store.dispatch('user/initUser') window.addEventListener('orientationchange', () => { this.$root.$emit('orientation-changed') }) diff --git a/src/router/routes.js b/src/router/routes.js index 09c53d6c..41d7918b 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -134,6 +134,13 @@ export default function routes (app) { meta: { title: i18n.t('Reminder'), subtitle: i18n.t('Set your personal alarm') + }, + async beforeEnter (routeTo, routeFrom, next) { + if (app.store.getters['user/hasSubscriberProfileAttribute']('reminder')) { + next() + } else { + next('/') + } } }, { @@ -216,7 +223,6 @@ export default function routes (app) { subtitle: i18n.t('Set your fax settings') }, async beforeEnter (routeTo, routeFrom, next) { - await app.store.dispatch('user/initUser') if (app.store.getters['user/hasFaxCapability']) { next() } else { diff --git a/src/store/user.js b/src/store/user.js index 3a418fd7..0e0b41f8 100644 --- a/src/store/user.js +++ b/src/store/user.js @@ -18,7 +18,8 @@ import { resetPassword, recoverPassword, getBrandingLogo, - getSubscriberRegistrations + getSubscriberRegistrations, + getSubscriberProfile } from '../api/subscriber' import { deleteJwt, getJwt, getSubscriberId, setJwt, setSubscriberId } from 'src/auth' import { setSession } from 'src/storage' @@ -30,6 +31,7 @@ export default { subscriberId: null, subscriber: null, capabilities: null, + profile: null, features: { sendFax: true, sendSms: false @@ -182,6 +184,9 @@ export default { }, isLogoRequested (state) { return state.logoRequested + }, + hasSubscriberProfileAttribute: (state) => (attribute) => { + return state.profile?.attributes.includes(attribute) || false } }, mutations: { @@ -291,6 +296,9 @@ export default { }, setSubscriberRegistrations (state, value) { state.subscriberRegistrations = value + }, + setProfile (state, value) { + state.profile = value } }, actions: { @@ -336,6 +344,10 @@ export default { context.commit('rtcEngineInitFailed', err.message) } } + if (userData.subscriber.profile_id) { + const profile = await getSubscriberProfile(userData.subscriber.profile_id) + context.commit('setProfile', profile) + } await context.dispatch('forwardHome') } catch (err) { console.debug(err)