Files
cloudron-box/dashboard/src/components/MailDomainStatus.vue
T

180 lines
5.8 KiB
Vue
Raw Normal View History

2025-03-12 12:49:06 +01:00
<script setup>
import { ref, onMounted } from 'vue';
2025-08-11 19:07:02 +02:00
import { Button, ProgressBar } from '@cloudron/pankow';
import Section from './Section.vue';
2025-03-12 12:49:06 +01:00
import MailModel from '../models/MailModel.js';
const props = defineProps([ 'domain' ]);
const mailModel = MailModel.create();
2025-06-27 18:51:03 +02:00
const dnsRecordLabels = {
'mx': 'MX',
'dkim': 'DKIM',
'spf': 'SPF',
'dmarc': 'DMARC',
'ptr4': 'PTR4',
'ptr6': 'PTR6',
};
2025-06-28 13:19:03 +02:00
const rblTypes = [ 'rbl4', 'rbl6' ];
2025-03-12 12:49:06 +01:00
const busy = ref(false);
const mailConfig = ref({});
2025-06-27 18:51:03 +02:00
const domainStatus = ref({});
2025-03-12 12:49:06 +01:00
async function refresh() {
busy.value = true;
let [error, result] = await mailModel.status(props.domain);
if (error) return console.error(error);
2025-06-27 18:51:03 +02:00
domainStatus.value = result;
2025-03-12 12:49:06 +01:00
[error, result] = await mailModel.config(props.domain);
if (error) return console.error(error);
mailConfig.value = result;
busy.value = false;
}
onMounted(async () => {
await refresh();
});
</script>
<template>
<Section title="Status">
<template #header-buttons>
<Button @click="refresh()" secondary tool icon="fa fa-sync-alt" :disabled="busy" :loading="busy"/>
</template>
<div v-html="$t('email.dnsStatus.description', { emailDnsDocsLink:'https://docs.cloudron.io/email/#dns-records'})"></div>
<br/>
2025-08-11 19:07:02 +02:00
<div v-if="domainStatus.mx">
<div v-for="(label, type) in dnsRecordLabels" :key="type">
<div>
<i v-if="!busy" class="fa-solid" :class="{
'fa-check-circle text-success': domainStatus[type].status === 'passed',
'fa-exclamation-triangle text-danger': domainStatus[type].status === 'failed',
'fa-circle-minus text-warning': domainStatus[type].status === 'skipped',
}"></i>
<i v-else class="fa-solid fa-circle-notch fa-spin"></i>
&nbsp;
<b>{{ label }} record</b>
</div>
2025-06-27 18:51:03 +02:00
2025-08-11 19:07:02 +02:00
<div class="record-details">
<div v-if="type === 'mx' && domain.provider === 'namecheap'">{{ $t('email.dnsStatus.namecheapInfo') }} <sup><a href="https://docs.cloudron.io/domains/#namecheap-dns" class="help" target="_blank"><i class="fa fa-question-circle"></i></a></sup></div>
<div v-if="type === 'ptr4' || type === 'ptr6'">{{ $t('email.dnsStatus.ptrInfo') }} <sup><a href="https://docs.cloudron.io/email/#ptr-record" class="help" target="_blank"><i class="fa fa-question-circle"></i></a></sup></div>
<div v-if="domainStatus[type].status === 'skipped'">{{ domainStatus[type].message }}</div>
<div v-else>
<table class="domain-status">
<tbody>
<tr>
<td>{{ $t('email.dnsStatus.hostname') }}:</td>
<td>{{ domainStatus[type].name }}</td>
</tr>
<tr>
<td>{{ $t('email.dnsStatus.domain') }}:</td>
<td>{{ domainStatus[type].domain }}</td>
</tr>
<tr>
<td>{{ $t('email.dnsStatus.type') }}:</td>
<td>{{ domainStatus[type].type }}</td>
</tr>
<tr>
<td>{{ $t('email.dnsStatus.expected') }}:</td>
<td>{{ domainStatus[type].expected }}</td>
</tr>
<tr>
<td>{{ $t('email.dnsStatus.current') }}:</td>
<td>{{ domainStatus[type].value ? domainStatus[type].value : ('['+$t('email.dnsStatus.recordNotSet')+']') }} {{ domainStatus[type].message }}</td>
</tr>
</tbody>
</table>
</div>
2025-03-12 12:49:06 +01:00
</div>
</div>
</div>
<br/>
<div v-if="domainStatus.relay">
<div>
<i v-if="!busy" class="fa" :class="{
'fa-check-circle text-success': domainStatus.relay.status === 'passed',
'fa-exclamation-triangle text-danger': domainStatus.relay.status === 'failed',
'fa-circle-minus text-warning': domainStatus.relay.status === 'skipped',
}"></i>
<i v-else class="fa-solid fa-circle-notch fa-spin"></i>
&nbsp;
<b>{{ $t('email.smtpStatus.outboundSmtp') }}</b>
</div>
<div class="record-details">
{{ domainStatus.relay.message }}
</div>
</div>
2025-03-12 12:49:06 +01:00
<div v-for="type in rblTypes" :key="type">
<div v-if="domainStatus[type]">
2025-08-11 19:07:02 +02:00
<div>
2025-06-28 13:19:03 +02:00
<i v-if="!busy" class="fa" :class="{
'fa-check-circle text-success': domainStatus[type].status === 'passed',
'fa-exclamation-triangle text-danger': domainStatus[type].status === 'failed',
'fa-circle-minus text-success': domainStatus[type].status === 'skipped',
2025-06-28 13:19:03 +02:00
}"></i>
<i v-else class="fa-solid fa-circle-notch fa-spin"></i>
&nbsp;
<b>{{ type === 'rbl4' ? 'IPv4' : 'IPv6' }} {{ $t('email.smtpStatus.rblCheck') }}</b>
2025-06-28 13:19:03 +02:00
</div>
<div class="record-details">
<div v-if="domainStatus[type].status !== 'failed'">{{ domainStatus[type].message }}</div>
<div v-else>
<div v-if="domainStatus[type].servers.length" v-html="$t('email.smtpStatus.blacklisted', { ip: domainStatus[type].ip })"></div>
<div v-else v-html="$t('email.smtpStatus.notBlacklisted', { ip: domainStatus[type].ip })"></div>
2025-06-28 13:19:03 +02:00
<div v-for="server in domainStatus[type].servers" :key="server.name">
<a :href="server.removal" target="_blank">{{ server.name }}</a>
2025-06-28 13:19:03 +02:00
</div>
2025-06-27 18:51:03 +02:00
</div>
2025-03-12 12:49:06 +01:00
</div>
</div>
</div>
</Section>
2025-03-12 12:49:06 +01:00
</template>
<style scoped>
.record-details {
2025-08-11 19:07:02 +02:00
padding: 10px 30px;
2025-03-12 12:49:06 +01:00
overflow: hidden;
}
.record-details > table {
table-layout: fixed;
width: 100%;
}
.record-details > table > tr > td:nth-child(1) {
width: 150px;
}
.record-details > table > tr > td:nth-child(2) {
display: block;
overflow: scroll;
white-space: nowrap;
text-overflow: auto;
font-weight: bold;
}
2025-08-11 19:07:02 +02:00
.domain-status > tbody > tr > td:first-of-type {
white-space: nowrap;
padding-right: 20px;
}
2025-03-12 12:49:06 +01:00
</style>