mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Merge pull request #3017 from modoboa/frontend-fix
Multiple frontend fix
This commit is contained in:
@@ -62,9 +62,6 @@ export default {
|
||||
bus.$on('notification', this.showNotification)
|
||||
bus.$on('loggedIn', this.checkAlarms)
|
||||
},
|
||||
mounted () {
|
||||
this.checkAlarms()
|
||||
},
|
||||
beforeDestroy () {
|
||||
clearInterval(this.alarmChecker)
|
||||
},
|
||||
@@ -88,6 +85,9 @@ export default {
|
||||
},
|
||||
checkAlarms () {
|
||||
if (this.isAuthenticated) {
|
||||
if (this.alarmChecker !== null) {
|
||||
return
|
||||
}
|
||||
this.alarmChecker = window.setInterval(() => {
|
||||
const params = {}
|
||||
if (this.lastAlarmDate instanceof Date) {
|
||||
@@ -95,7 +95,7 @@ export default {
|
||||
}
|
||||
alarms.getAll(params).then(resp => {
|
||||
let count = 0
|
||||
for (const alarm of resp.data) {
|
||||
for (const alarm of resp.data.results) {
|
||||
if (alarm.status === 1 && !this.alarmNotified.includes(alarm.id)) {
|
||||
if (this.lastAlarmDate instanceof Date && new Date(alarm.created) > this.lastAlarmDate) {
|
||||
this.lastAlarmDate = new Date(alarm.created)
|
||||
|
||||
@@ -44,7 +44,9 @@ _axios.interceptors.response.use(
|
||||
const refreshToken = Cookies.get('refreshToken')
|
||||
if (error.config.url.endsWith('/token/refresh/') || !refreshToken) {
|
||||
store.dispatch('auth/logout')
|
||||
router.push({ name: 'Login' })
|
||||
if (router.history.current.name !== 'Login') {
|
||||
router.push({ name: 'Login' })
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
return _axios.post('/token/refresh/', { refresh: refreshToken }).then(resp => {
|
||||
|
||||
@@ -284,27 +284,31 @@ export default {
|
||||
}
|
||||
},
|
||||
created () {
|
||||
parameters.getApplications().then(response => {
|
||||
response.data.forEach(item => {
|
||||
this.mainMenuItems[6].children.push({
|
||||
text: item.label,
|
||||
to: { name: 'ParametersEdit', params: { app: item.name } }
|
||||
if (this.isAuthenticated) {
|
||||
parameters.getApplications().then(response => {
|
||||
response.data.forEach(item => {
|
||||
this.mainMenuItems[6].children.push({
|
||||
text: item.label,
|
||||
to: { name: 'ParametersEdit', params: { app: item.name } }
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
parameters.getApplication('imap_migration').then(response => {
|
||||
this.imapMigration = response.data.params.enabled_imapmigration
|
||||
})
|
||||
bus.$on('imapSettingsChanged', (status) => { this.imapMigration = status })
|
||||
parameters.getApplication('imap_migration').then(response => {
|
||||
this.imapMigration = response.data.params.enabled_imapmigration
|
||||
})
|
||||
bus.$on('imapSettingsChanged', (status) => { this.imapMigration = status })
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
displayMenuItem (item) {
|
||||
const condition = (item.roles === undefined || item.roles.indexOf(this.authUser.role) !== -1) && (item.condition === undefined || item.condition()) && (item.activated !== false)
|
||||
if (item.icon === 'mdi-email-sync-outline') {
|
||||
// For imapMigration
|
||||
return condition && this.imapMigration
|
||||
if (this.isAuthenticated) {
|
||||
const condition = (item.roles === undefined || item.roles.indexOf(this.authUser.role) !== -1) && (item.condition === undefined || item.condition()) && (item.activated !== false)
|
||||
if (item.icon === 'mdi-email-sync-outline') {
|
||||
// For imapMigration
|
||||
return condition && this.imapMigration
|
||||
}
|
||||
return condition
|
||||
}
|
||||
return condition
|
||||
},
|
||||
logout () {
|
||||
this.$store.dispatch('auth/logout').then(() => {
|
||||
|
||||
@@ -107,6 +107,9 @@ export default {
|
||||
watch: {
|
||||
'$route' (to, from) {
|
||||
this.loadParams(to.params.app)
|
||||
},
|
||||
'parameters' (to, from) {
|
||||
this.tab_error = []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { bus } from '@/main'
|
||||
import Cookies from 'js-cookie'
|
||||
import account from '@/api/account'
|
||||
|
||||
@@ -67,6 +68,7 @@ export default {
|
||||
Cookies.set('token', resp.data.access, { sameSite: 'strict' })
|
||||
Cookies.set('refreshToken', resp.data.refresh, { sameSite: 'strict' })
|
||||
this.$store.dispatch('auth/initialize').then(() => {
|
||||
bus.$emit('loggedIn')
|
||||
this.$router.push({ name: 'DomainList' })
|
||||
})
|
||||
}).catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user