mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-12-02 12:13:54 +01:00
Added message log view in new frontend.
This commit is contained in:
@@ -3,7 +3,10 @@ import repository from './repository'
|
||||
const resource = 'logs'
|
||||
|
||||
export default {
|
||||
getAll (params) {
|
||||
return repository.get(`/${resource}/`, { params })
|
||||
getAuditTrail (params) {
|
||||
return repository.get(`/${resource}/audit-trail/`, { params })
|
||||
},
|
||||
getMessages (params) {
|
||||
return repository.get(`/${resource}/messages/`, { params })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,8 +152,19 @@ export default {
|
||||
{
|
||||
icon: 'mdi-history',
|
||||
text: this.$gettext('Logs'),
|
||||
to: { name: 'AuditTrail' },
|
||||
roles: ['SuperAdmins']
|
||||
roles: ['SuperAdmins', 'Resellers', 'DomainAdmins'],
|
||||
children: [
|
||||
{
|
||||
text: this.$gettext('Audit trail'),
|
||||
to: { name: 'AuditTrail' },
|
||||
roles: ['SuperAdmins']
|
||||
},
|
||||
{
|
||||
text: this.$gettext('Messages'),
|
||||
to: { name: 'MessageLog' },
|
||||
roles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
icon: 'mdi-cog',
|
||||
|
||||
@@ -37,10 +37,10 @@ export default {
|
||||
return {
|
||||
logs: [],
|
||||
headers: [
|
||||
{ text: 'Date', value: 'date_created' },
|
||||
{ text: 'Level', value: 'level' },
|
||||
{ text: 'Logger', value: 'logger' },
|
||||
{ text: 'Message', value: 'message' }
|
||||
{ text: this.$gettext('Date'), value: 'date_created' },
|
||||
{ text: this.$gettext('Level'), value: 'level' },
|
||||
{ text: this.$gettext('Logger'), value: 'logger' },
|
||||
{ text: this.$gettext('Message'), value: 'message' }
|
||||
],
|
||||
loading: true,
|
||||
options: {},
|
||||
@@ -56,7 +56,7 @@ export default {
|
||||
if (level === 'WARNING') {
|
||||
return 'orange'
|
||||
}
|
||||
if (level === 'CRITICAL') {
|
||||
if (level === 'CRITICAL' || level === 'ERROR') {
|
||||
return 'red'
|
||||
}
|
||||
return ''
|
||||
@@ -73,7 +73,7 @@ export default {
|
||||
search: this.search
|
||||
}
|
||||
this.loading = true
|
||||
logs.getAll(params).then(response => {
|
||||
logs.getAuditTrail(params).then(response => {
|
||||
this.logs = response.data.results
|
||||
this.total = response.data.count
|
||||
this.loading = false
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<v-card class="mt-6">
|
||||
<v-toolbar flat>
|
||||
<v-spacer></v-spacer>
|
||||
<v-text-field
|
||||
v-model="search"
|
||||
prepend-inner-icon="mdi-magnify"
|
||||
:placeholder="'Search'|translate"
|
||||
filled
|
||||
outlined
|
||||
dense
|
||||
hide-details
|
||||
/>
|
||||
</v-toolbar>
|
||||
<v-data-table
|
||||
:headers="headers"
|
||||
:items="messages"
|
||||
:search="search"
|
||||
class="elevation-1"
|
||||
:options.sync="options"
|
||||
:server-items-length="total"
|
||||
>
|
||||
<template v-slot:item.date="{ item }">
|
||||
{{ item.date|date }}
|
||||
</template>
|
||||
<template v-slot:item.sender="{ item }">
|
||||
{{ item.sender|truncate(50) }}
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import logs from '@/api/logs'
|
||||
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
messages: [],
|
||||
headers: [
|
||||
{ text: this.$gettext('Queue ID'), value: 'queue_id' },
|
||||
{ text: this.$gettext('Date'), value: 'date', width: '20%' },
|
||||
{ text: this.$gettext('Status'), value: 'status' },
|
||||
{ text: this.$gettext('To'), value: 'rcpt' },
|
||||
{ text: this.$gettext('From'), value: 'sender' }
|
||||
],
|
||||
loading: true,
|
||||
options: {},
|
||||
search: '',
|
||||
total: 0
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fetchMessages () {
|
||||
let order
|
||||
if (this.options.sortBy.length) {
|
||||
order = (this.options.sortDesc[0] ? '-' : '') + this.options.sortBy[0]
|
||||
}
|
||||
const params = {
|
||||
ordering: order,
|
||||
page: this.options.page,
|
||||
page_size: this.options.itemsPerPage,
|
||||
search: this.search
|
||||
}
|
||||
this.loading = true
|
||||
logs.getMessages(params).then(response => {
|
||||
this.messages = response.data.results
|
||||
this.total = response.data.count
|
||||
this.loading = false
|
||||
})
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
options: {
|
||||
handler () {
|
||||
this.fetchMessages()
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
search (val) {
|
||||
this.fetchMessages()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -13,3 +13,11 @@ Vue.filter('yesno', function (value) {
|
||||
Vue.filter('date', function (value) {
|
||||
return DateTime.fromISO(value).setLocale('en').toLocaleString(DateTime.DATETIME_MED)
|
||||
})
|
||||
|
||||
/*
|
||||
** Truncate given string.
|
||||
*/
|
||||
Vue.filter('truncate', function (text, length, clamp) {
|
||||
clamp = clamp || '...'
|
||||
return text.length > length ? text.slice(0, length) + clamp : text
|
||||
})
|
||||
|
||||
@@ -93,13 +93,22 @@ const routes = [
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/logs/',
|
||||
path: '/logs/audit_trail',
|
||||
name: 'AuditTrail',
|
||||
component: () => import('../views/logs/AuditTrail.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
allowedRoles: ['SuperAdmins']
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/logs/messages',
|
||||
name: 'MessageLog',
|
||||
component: () => import('../views/logs/Messages.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
allowedRoles: ['DomainAdmins', 'SuperAdmins']
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-toolbar flat>
|
||||
<v-toolbar-title><translate>Message history</translate></v-toolbar-title>
|
||||
</v-toolbar>
|
||||
<message-list />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MessageList from '@/components/logs/MessageList'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
MessageList
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user