2025-03-10 16:16:04 +01:00
|
|
|
<script setup>
|
|
|
|
|
|
|
|
|
|
import { ref, reactive, onMounted, watch } from 'vue';
|
2025-07-10 16:29:48 +02:00
|
|
|
import moment from 'moment';
|
2025-07-10 11:55:11 +02:00
|
|
|
import { Button, TextInput, MultiSelect } from '@cloudron/pankow';
|
2025-07-10 16:29:48 +02:00
|
|
|
import { useDebouncedRef, prettyEmailAddresses } from '@cloudron/pankow/utils';
|
2025-03-10 16:16:04 +01:00
|
|
|
import MailModel from '../models/MailModel.js';
|
|
|
|
|
|
|
|
|
|
const mailModel = MailModel.create();
|
|
|
|
|
|
|
|
|
|
const availableTypes = [
|
|
|
|
|
{ id: 'bounce', name: 'Bounce' },
|
|
|
|
|
{ id: 'deferred', name: 'Deferred' },
|
|
|
|
|
{ id: 'denied', name: 'Denied' },
|
|
|
|
|
{ id: 'queued', name: 'Queued' },
|
|
|
|
|
{ id: 'quota', name: 'Quota' },
|
2025-05-09 19:11:59 +02:00
|
|
|
{ id: 'saved', name: 'Saved' },
|
|
|
|
|
{ id: 'sent', name: 'Sent' },
|
2025-03-10 16:16:04 +01:00
|
|
|
{ id: 'spam', name: 'Spam' },
|
2025-05-09 19:11:59 +02:00
|
|
|
{ id: 'spam-learn', name: 'Spam Training' },
|
2025-03-10 16:16:04 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const refreshBusy = ref(false);
|
|
|
|
|
const eventlogs = ref([]);
|
|
|
|
|
const activeId = ref('');
|
|
|
|
|
const search = useDebouncedRef('');
|
|
|
|
|
const page = ref(1);
|
|
|
|
|
const perPage = ref(20);
|
|
|
|
|
const types = reactive([]);
|
|
|
|
|
|
|
|
|
|
async function onRefresh() {
|
|
|
|
|
refreshBusy.value = true;
|
|
|
|
|
|
|
|
|
|
const [error, result] = await mailModel.eventlog(types.join(','), search.value, page.value, perPage.value);
|
|
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
|
|
|
|
eventlogs.value = result;
|
|
|
|
|
|
|
|
|
|
refreshBusy.value = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onEventLogDetails(id) {
|
|
|
|
|
if (activeId.value === id) activeId.value = '';
|
|
|
|
|
else activeId.value = id;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-11 18:34:52 +02:00
|
|
|
async function onScroll(event) {
|
|
|
|
|
if (event.target.scrollTop + event.target.clientHeight >= event.target.scrollHeight) {
|
|
|
|
|
page.value++;
|
2025-03-10 16:16:04 +01:00
|
|
|
|
2025-04-11 18:34:52 +02:00
|
|
|
const [error, result] = await mailModel.eventlog(types.join(','), search.value, page.value, perPage.value);
|
|
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
2025-09-23 14:36:02 +02:00
|
|
|
eventlogs.value = eventlogs.value.concat(result);
|
2025-04-11 18:34:52 +02:00
|
|
|
}
|
2025-03-10 16:16:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(perPage, onRefresh);
|
|
|
|
|
watch(types, onRefresh);
|
|
|
|
|
watch(search, onRefresh);
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
await onRefresh();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2025-03-25 19:11:40 +01:00
|
|
|
|
2025-09-22 11:09:41 +02:00
|
|
|
<div class="content-large" style="height: 100%; overflow: hidden; display: flex; flex-direction: column;">
|
2025-04-11 18:34:52 +02:00
|
|
|
<!-- cant use Section component as we need control over vertical scrolling -->
|
|
|
|
|
<div class="section" style="overflow: hidden; display: flex; flex-direction: column;">
|
|
|
|
|
<h2 class="section-header">
|
|
|
|
|
{{ $t('emails.eventlog.title') }}
|
|
|
|
|
<div>
|
|
|
|
|
<TextInput :placeholder="$t('main.searchPlaceholder')" style="flex-grow: 1;" v-model="search"/>
|
|
|
|
|
<MultiSelect v-model="types" :options="availableTypes" option-key="id" option-label="name" :selected-label="types.length ? $t('main.multiselect.selected', { n: types.length }) : $t('emails.typeFilterHeader')"/>
|
2025-09-22 16:56:29 +02:00
|
|
|
<Button tool secondary @click="onRefresh()" :loading="refreshBusy" icon="fa-solid fa-sync-alt" />
|
2025-09-22 11:09:41 +02:00
|
|
|
<Button tool secondary href="/logs.html?id=mail" target="_blank">{{ $t('main.action.logs') }}</Button>
|
2025-04-11 18:34:52 +02:00
|
|
|
</div>
|
|
|
|
|
</h2>
|
2025-09-22 11:09:41 +02:00
|
|
|
<div class="section-body" style="margin-top: 16px; overflow: auto; padding-top: 0" @scroll="onScroll">
|
2025-04-11 18:34:52 +02:00
|
|
|
<table class="eventlog-table">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th style="width: 5%"><!-- Icon --></th>
|
2025-07-10 16:29:48 +02:00
|
|
|
<th style="width: 7%">{{ $t('emails.eventlog.time') }}</th>
|
|
|
|
|
<th style="width: 7%"></th>
|
|
|
|
|
<th style="width: 26%">{{ $t('emails.eventlog.mailFrom') }}</th>
|
2025-04-11 18:34:52 +02:00
|
|
|
<th style="width: 25%">{{ $t('emails.eventlog.rcptTo') }}</th>
|
|
|
|
|
<th style="width: 30%">{{ $t('emails.eventlog.details') }}</th>
|
2025-03-25 19:11:40 +01:00
|
|
|
</tr>
|
2025-04-11 18:34:52 +02:00
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
<template v-for="eventlog in eventlogs" :key="eventlog._id">
|
|
|
|
|
<tr @click="onEventLogDetails(eventlog._id)" :class="{ 'active': activeId === eventlog._id }" >
|
|
|
|
|
<td class="no-wrap">
|
2025-05-09 19:11:59 +02:00
|
|
|
<i class="fas fa-arrow-circle-left" v-if="eventlog.type === 'sent'" v-tooltip="$t('emails.eventlog.type.outgoing')"></i>
|
2025-04-11 18:34:52 +02:00
|
|
|
<i class="fas fa-history" v-if="eventlog.type === 'deferred'" v-tooltip="$t('emails.eventlog.type.deferred')"></i>
|
2025-05-09 19:11:59 +02:00
|
|
|
<i class="fas fa-arrow-circle-right" v-if="eventlog.type === 'saved'" v-tooltip="$t('emails.eventlog.type.incoming')"></i>
|
2025-04-11 18:34:52 +02:00
|
|
|
<i class="fas fa-align-justify" v-if="eventlog.type === 'queued' && eventlog.spamStatus && eventlog.spamStatus.indexOf('Yes,') !== 0" v-tooltip="$t('emails.eventlog.type.queued')"></i>
|
|
|
|
|
<i class="fas fa-trash" v-if="eventlog.type === 'queued' && eventlog.spamStatus && eventlog.spamStatus.indexOf('Yes,') === 0" v-tooltip="$t('emails.eventlog.type.queued')"></i>
|
|
|
|
|
<i class="fas fa-minus-circle" v-if="eventlog.type === 'denied'" v-tooltip="$t('emails.eventlog.type.denied')"></i>
|
|
|
|
|
<i class="fas fa-hand-paper" v-if="eventlog.type === 'bounce'" v-tooltip="$t('emails.eventlog.type.bounce')"></i>
|
|
|
|
|
<i class="fas fa-filter" v-if="eventlog.type === 'spam-learn'" v-tooltip="$t('emails.eventlog.type.spamFilterTrained')"></i>
|
|
|
|
|
<i class="fas fa-fill-drip" v-if="eventlog.type === 'quota'" v-tooltip="$t('emails.eventlog.type.quota')"></i>
|
|
|
|
|
</td>
|
2025-07-10 16:29:48 +02:00
|
|
|
<td class="no-wrap">{{ moment(eventlog.ts).format('DD.MM.YYYY') }}</td>
|
|
|
|
|
<td class="no-wrap">{{ moment(eventlog.ts).format('HH:mm:SS') }}</td>
|
2025-04-11 18:34:52 +02:00
|
|
|
<td class="elide-table-cell">{{ prettyEmailAddresses(eventlog.mailFrom) || '-' }}</td>
|
|
|
|
|
<td class="elide-table-cell">{{ prettyEmailAddresses(eventlog.rcptTo) || eventlog.mailbox || '-' }}</td>
|
|
|
|
|
<td>
|
|
|
|
|
<span v-if="eventlog.type === 'bounce'">{{ $t('emails.eventlog.type.bounceInfo') }}. {{ eventlog.message || eventlog.reason }}</span>
|
|
|
|
|
<span v-if="eventlog.type === 'deferred'">{{ $t('emails.eventlog.type.deferredInfo', { delay:eventlog.delay }) }}. {{ eventlog.message || eventlog.reason }} </span>
|
|
|
|
|
<span v-if="eventlog.type === 'queued'">
|
|
|
|
|
<span v-if="eventlog.direction === 'inbound'">{{ $t('emails.eventlog.type.inboundInfo') }}</span>
|
|
|
|
|
<span v-if="eventlog.direction === 'outbound'">{{ $t('emails.eventlog.type.outboundInfo') }}</span>
|
|
|
|
|
</span>
|
2025-05-09 19:11:59 +02:00
|
|
|
<span v-if="eventlog.type === 'saved'">{{ $t('emails.eventlog.type.savedInfo') }}</span>
|
|
|
|
|
<span v-if="eventlog.type === 'sent'">{{ $t('emails.eventlog.type.sentInfo') }}</span>
|
2025-04-11 18:34:52 +02:00
|
|
|
<span v-if="eventlog.type === 'denied'">{{ $t('emails.eventlog.type.deniedInfo') }}. {{ eventlog.message || eventlog.reason }} </span>
|
|
|
|
|
<span v-if="eventlog.type === 'spam-learn'">{{ $t('emails.eventlog.type.spamFilterTrainedInfo') }}</span>
|
|
|
|
|
<span v-if="eventlog.type === 'quota'">
|
|
|
|
|
<span v-if="eventlog.quotaPercent > 0">{{ $t('emails.eventlog.type.overQuotaInfo', { mailbox: eventlog.mailbox, quotaPercent: eventlog.quotaPercent }) }}</span>
|
|
|
|
|
<span v-if="eventlog.quotaPercent < 0">{{ $t('emails.eventlog.type.underQuotaInfo', { mailbox: eventlog.mailbox, quotaPercent: -eventlog.quotaPercent }) }}</span>
|
|
|
|
|
</span>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr v-if="activeId === eventlog._id">
|
|
|
|
|
<td colspan="6" class="eventlog-details">
|
|
|
|
|
<pre>{{ JSON.stringify(eventlog, null, 4) }}</pre>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</template>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-03-10 16:16:04 +01:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
2025-04-11 18:34:52 +02:00
|
|
|
.eventlog-table {
|
|
|
|
|
width: 100%;
|
|
|
|
|
overflow: auto;
|
|
|
|
|
border-spacing: 0px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.eventlog-table thead {
|
|
|
|
|
background-color: var(--pankow-body-background-color);
|
|
|
|
|
top: 0;
|
|
|
|
|
position: sticky;
|
|
|
|
|
z-index: 1; /* avoids see-through table headers if items in the table have opacity set */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.eventlog-table th {
|
|
|
|
|
text-align: left;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.eventlog-table tbody tr {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.eventlog-table tbody tr.active,
|
|
|
|
|
.eventlog-table tbody tr:hover {
|
|
|
|
|
background-color: var(--pankow-color-background-hover);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.eventlog-table tbody tr.active {
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.eventlog-table th,
|
|
|
|
|
.eventlog-table td {
|
|
|
|
|
padding: 5px;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-10 16:16:04 +01:00
|
|
|
.eventlog-filter {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 5px;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
margin: 20px 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.eventlog-details {
|
2025-04-11 18:34:52 +02:00
|
|
|
background-color: var(--pankow-color-background-hover);
|
|
|
|
|
cursor: auto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.eventlog-details pre {
|
2025-03-10 16:16:04 +01:00
|
|
|
white-space: pre-wrap;
|
|
|
|
|
color: var(--pankow-text-color);
|
2025-04-11 18:34:52 +02:00
|
|
|
font-size: 13px;
|
|
|
|
|
padding: 6px;
|
|
|
|
|
margin: 0;
|
2025-03-10 16:16:04 +01:00
|
|
|
border: none;
|
|
|
|
|
border-radius: var(--pankow-border-radius);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|