TT#108160 Branding - As Customer, I want to see the custom primary color if it is available

AC:
Can see the custom primary and secondary color if it is set
Can see the standard colours if not set

Change-Id: Iac09886d1442c145d448e1d0431bf37f1b409f03
mr9.4
Sergii Leonenko 5 years ago
parent 509065dbfa
commit 571ba6917f

@ -30,7 +30,8 @@ module.exports = function (/* ctx */) {
'vue-scrollto', 'vue-scrollto',
'constants', 'constants',
'vue-wait', 'vue-wait',
'e2e-testing' 'e2e-testing',
'branding'
], ],
// https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-css // https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-css

@ -37,12 +37,14 @@ export function getUserData (id) {
return Promise.all([ return Promise.all([
getSubscriberById(id), getSubscriberById(id),
getCapabilities(id), getCapabilities(id),
getFaxServerSettings(id) getFaxServerSettings(id),
getResellerBranding()
]).then((results) => { ]).then((results) => {
results[1].faxactive = results[2].active results[1].faxactive = results[2].active
resolve({ resolve({
subscriber: results[0], subscriber: results[0],
capabilities: results[1] capabilities: results[1],
resellerBranding: results[3]?.items[0] || null
}) })
}).catch((err) => { }).catch((err) => {
reject(err) reject(err)
@ -127,3 +129,9 @@ export function getNumbers () {
}) })
}) })
} }
export async function getResellerBranding () {
return getList({
resource: 'resellerbrandings'
})
}

@ -0,0 +1,8 @@
import { colors } from 'quasar'
export default async ({ Vue, store, app }) => {
await store.dispatch('user/setDefaultBranding', {
primaryColor: colors.getBrand('primary'),
secondaryColor: colors.getBrand('secondary')
})
}

@ -198,6 +198,7 @@
</template> </template>
<script> <script>
import { colors } from 'quasar'
import platformMixin from '../mixins/platform' import platformMixin from '../mixins/platform'
import { import {
startLoading, startLoading,
@ -309,6 +310,10 @@ export default {
'isLogoRequesting', 'isLogoRequesting',
'isLogoRequested' 'isLogoRequested'
]), ]),
...mapState('user', [
'resellerBranding',
'defaultBranding'
]),
...mapGetters('communication', [ ...mapGetters('communication', [
'createFaxState', 'createFaxState',
'createFaxError' 'createFaxError'
@ -409,6 +414,8 @@ export default {
userDataSucceeded (userDataSucceeded) { userDataSucceeded (userDataSucceeded) {
if (userDataSucceeded) { if (userDataSucceeded) {
enableIncomingCallNotifications() enableIncomingCallNotifications()
this.updateBrandings()
} }
}, },
isCallEnabled (value) { isCallEnabled (value) {
@ -449,13 +456,14 @@ export default {
} }
}, },
async mounted () { async mounted () {
this.$store.dispatch('user/initUser') await this.$store.dispatch('user/initUser')
window.addEventListener('orientationchange', () => { window.addEventListener('orientationchange', () => {
this.$root.$emit('orientation-changed') this.$root.$emit('orientation-changed')
}) })
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
this.$root.$emit('window-resized') this.$root.$emit('window-resized')
}) })
this.updateBrandings()
this.customLogo = await this.$store.dispatch('user/getCustomLogo') this.customLogo = await this.$store.dispatch('user/getCustomLogo')
}, },
methods: { methods: {
@ -543,6 +551,16 @@ export default {
}, },
sideStateLeft () { sideStateLeft () {
return this.sideStates.left return this.sideStates.left
},
updateBrandings () {
const primaryColor = this.resellerBranding?.csc_color_primary || this.defaultBranding?.primaryColor
const secondaryColor = this.resellerBranding?.csc_color_secondary || this.defaultBranding?.secondaryColor
if (primaryColor) {
colors.setBrand('primary', primaryColor)
}
if (secondaryColor) {
colors.setBrand('secondary', secondaryColor)
}
} }
} }
} }

@ -45,7 +45,9 @@ export default {
newPasswordRequesting: false, newPasswordRequesting: false,
logo: null, logo: null,
logoRequesting: false, logoRequesting: false,
logoRequested: false logoRequested: false,
resellerBranding: null,
defaultBranding: {}
}, },
getters: { getters: {
isLogged (state) { isLogged (state) {
@ -194,6 +196,8 @@ export default {
state.loginError = error state.loginError = error
}, },
userDataRequesting (state) { userDataRequesting (state) {
state.resellerBranding = null
state.userDataRequesting = true state.userDataRequesting = true
state.userDataSucceeded = false state.userDataSucceeded = false
state.userDataError = null state.userDataError = null
@ -201,6 +205,8 @@ export default {
userDataSucceeded (state, options) { userDataSucceeded (state, options) {
state.subscriber = options.subscriber state.subscriber = options.subscriber
state.capabilities = options.capabilities state.capabilities = options.capabilities
state.resellerBranding = options.resellerBranding
state.userDataSucceeded = true state.userDataSucceeded = true
state.userDataRequesting = false state.userDataRequesting = false
state.userDataError = null state.userDataError = null
@ -272,6 +278,9 @@ export default {
updateLogoRequestState (state, isRequesting) { updateLogoRequestState (state, isRequesting) {
state.logoRequesting = isRequesting state.logoRequesting = isRequesting
state.logoRequested = !isRequesting state.logoRequested = !isRequesting
},
setDefaultBranding (state, value) {
state.defaultBranding = value
} }
}, },
actions: { actions: {
@ -299,11 +308,13 @@ export default {
context.commit('userDataRequesting') context.commit('userDataRequesting')
const userData = await getUserData(getSubscriberId()) const userData = await getUserData(getSubscriberId())
context.commit('userDataSucceeded', userData) context.commit('userDataSucceeded', userData)
if (_.isNumber(context.getters.jwtTTL)) { if (_.isNumber(context.getters.jwtTTL)) {
setTimeout(() => { setTimeout(() => {
context.dispatch('logout') context.dispatch('logout')
}, context.getters.jwtTTL * 1000) }, context.getters.jwtTTL * 1000)
} }
if (context.getters.hasRtcEngineCapabilityEnabled && context.getters.isRtcEngineUiVisible) { if (context.getters.hasRtcEngineCapabilityEnabled && context.getters.isRtcEngineUiVisible) {
context.commit('rtcEngineInitRequesting') context.commit('rtcEngineInitRequesting')
Vue.$rtcEngine.setNgcpApiJwt(getJwt()) Vue.$rtcEngine.setNgcpApiJwt(getJwt())
@ -375,6 +386,11 @@ export default {
context.commit('updateLogoRequestState', false) context.commit('updateLogoRequestState', false)
} }
return context.state.logo return context.state.logo
},
setDefaultBranding (context, value) {
if (value) {
context.commit('setDefaultBranding', value)
}
} }
} }
} }

Loading…
Cancel
Save