mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-12-02 12:13:54 +01:00
New webmail features.
This commit is contained in:
@@ -8,6 +8,26 @@ export default {
|
||||
}
|
||||
return repository.get('/webmail/mailboxes/', { params })
|
||||
},
|
||||
getUserMailboxQuota(mailbox) {
|
||||
const params = { mailbox }
|
||||
return repository.get('/webmail/mailboxes/quota/', { params })
|
||||
},
|
||||
createUserMailbox(body) {
|
||||
return repository.post('/webmail/mailboxes/', body)
|
||||
},
|
||||
renameUserMailbox(body) {
|
||||
return repository.post('/webmail/mailboxes/rename/', body)
|
||||
},
|
||||
compressUserMailbox(body) {
|
||||
return repository.post('/webmail/mailboxes/compress/', body)
|
||||
},
|
||||
deleteUserMailbox(body) {
|
||||
return repository.post('/webmail/mailboxes/delete/', body)
|
||||
},
|
||||
emptyUserMailbox(mailbox) {
|
||||
const body = { name: mailbox }
|
||||
return repository.post('/webmail/mailboxes/empty/', body)
|
||||
},
|
||||
getMailboxEmails(mailbox, options) {
|
||||
const params = {
|
||||
mailbox,
|
||||
@@ -73,4 +93,29 @@ export default {
|
||||
sendEmail(body) {
|
||||
return repository.post('/webmail/emails/send/', body)
|
||||
},
|
||||
createComposeSession() {
|
||||
return repository.post('/webmail/compose-sessions/')
|
||||
},
|
||||
getAllowedSenders() {
|
||||
return repository.get('/webmail/compose-sessions/allowed_senders/')
|
||||
},
|
||||
getUploadedAttachments(sessionUid) {
|
||||
return repository.get(
|
||||
`/webmail/compose-sessions/${sessionUid}/attachments/`
|
||||
)
|
||||
},
|
||||
uploadAttachment(sessionUid, body) {
|
||||
return repository.post(
|
||||
`/webmail/compose-sessions/${sessionUid}/attachments/`,
|
||||
body,
|
||||
{
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
}
|
||||
)
|
||||
},
|
||||
removeAttachment(sessionUid, name) {
|
||||
return repository.delete(
|
||||
`/webmail/compose-sessions/${sessionUid}/attachments/${name}/`
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<div ref="toolbar" class="mt-4">
|
||||
<slot name="append-toolbar"></slot>
|
||||
<v-btn-toggle
|
||||
v-if="editor"
|
||||
v-model="selection"
|
||||
@@ -93,7 +94,7 @@
|
||||
</div>
|
||||
<EditorContent
|
||||
:editor="editor"
|
||||
class="border-sm d-flex flex-column flex-grow-1"
|
||||
class="border-sm d-flex flex-column flex-grow-1 pa-4"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -143,6 +144,7 @@ watch(
|
||||
|
||||
<style lang="scss">
|
||||
.tiptap {
|
||||
flex-grow: 1;
|
||||
:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
@@ -150,7 +152,6 @@ watch(
|
||||
ol {
|
||||
padding: 0 1rem;
|
||||
margin: 1.25rem 1rem 1.25rem 0.4rem;
|
||||
|
||||
li p {
|
||||
margin-top: 0.25em;
|
||||
margin-bottom: 0.25em;
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<v-card>
|
||||
<v-card-title>{{ $gettext('Attachments') }}</v-card-title>
|
||||
<v-card-text>
|
||||
<v-form ref="formRef">
|
||||
<v-file-input
|
||||
v-model="file"
|
||||
density="compact"
|
||||
variant="outlined"
|
||||
:rules="[rules.required]"
|
||||
/>
|
||||
<div class="w-100 d-flex justify-center">
|
||||
<v-btn
|
||||
color="primary"
|
||||
variant="tonal"
|
||||
:text="$gettext('Attach')"
|
||||
@click="submit"
|
||||
/>
|
||||
</div>
|
||||
</v-form>
|
||||
|
||||
<v-table class="mt-4 border-sm">
|
||||
<tbody>
|
||||
<tr v-for="attachment in attachments" :key="attachment.fname">
|
||||
<td>{{ attachment.fname }}</td>
|
||||
<td>
|
||||
<v-btn
|
||||
icon="mdi-trash-can"
|
||||
color="error"
|
||||
size="small"
|
||||
variant="text"
|
||||
@click="removeAttachment(attachment)"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</v-table>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
<v-btn :text="$gettext('Close')" variant="flat" @click="close" />
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import api from '@/api/webmail'
|
||||
import rules from '@/plugins/rules'
|
||||
|
||||
const props = defineProps({
|
||||
sessionUid: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
})
|
||||
const emit = defineEmits(['close'])
|
||||
|
||||
const attachments = ref([])
|
||||
const file = ref()
|
||||
const formRef = ref()
|
||||
const loading = ref(false)
|
||||
|
||||
const close = () => {
|
||||
emit('close')
|
||||
}
|
||||
|
||||
const submit = async () => {
|
||||
const { valid } = await formRef.value.validate()
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
const formData = new FormData()
|
||||
formData.append('attachment', file.value)
|
||||
loading.value = true
|
||||
try {
|
||||
const resp = await api.uploadAttachment(props.sessionUid, formData)
|
||||
attachments.value.push(resp.data)
|
||||
formRef.value.reset()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const removeAttachment = async (attachment) => {
|
||||
await api.removeAttachment(props.sessionUid, attachment.tmpname)
|
||||
const index = attachments.value.findIndex(
|
||||
(item) => item.tmpname === attachment.tmpname
|
||||
)
|
||||
attachments.value.splice(index, 1)
|
||||
}
|
||||
|
||||
api.getUploadedAttachments(props.sessionUid).then((resp) => {
|
||||
attachments.value = resp.data
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,47 @@
|
||||
<template>
|
||||
<HtmlEditor
|
||||
v-if="htmlMode"
|
||||
v-model="model"
|
||||
class="d-flex flex-column flex-grow-1 mt-4"
|
||||
>
|
||||
<template #append-toolbar>
|
||||
<v-btn-toggle
|
||||
v-model="selection"
|
||||
base-color="grey-lighten-3"
|
||||
color="primary"
|
||||
class="mr-2"
|
||||
>
|
||||
<v-btn text="HTML" size="small" @click="toggleHtmlMode" />
|
||||
</v-btn-toggle>
|
||||
</template>
|
||||
</HtmlEditor>
|
||||
<template v-else>
|
||||
<div class="mt-8">
|
||||
<v-btn-toggle
|
||||
v-model="selection"
|
||||
base-color="grey-lighten-3"
|
||||
color="primary"
|
||||
class="mr-2"
|
||||
>
|
||||
<v-btn v-btn text="HTML" size="small" @click="toggleHtmlMode"> </v-btn>
|
||||
</v-btn-toggle>
|
||||
</div>
|
||||
<v-textarea v-model="model" class="border-sm" />
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import HtmlEditor from '@/components/tools/HtmlEditor'
|
||||
|
||||
const model = defineModel()
|
||||
const emit = defineEmits(['onToggleHtmlMode'])
|
||||
|
||||
const htmlMode = ref(false)
|
||||
const selection = ref()
|
||||
|
||||
const toggleHtmlMode = () => {
|
||||
htmlMode.value = !htmlMode.value
|
||||
emit('onToggleHtmlMode', htmlMode.value)
|
||||
}
|
||||
</script>
|
||||
@@ -14,6 +14,13 @@
|
||||
@click="submit"
|
||||
>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
class="ml-2"
|
||||
variant="tonal"
|
||||
prepend-icon="mdi-paperclip"
|
||||
:text="$gettext('Attachments') + ` (${attachmentCount})`"
|
||||
@click="openAttachmentsDialog"
|
||||
/>
|
||||
</v-toolbar>
|
||||
<v-form ref="formRef" class="flex-grow-1 d-flex flex-column">
|
||||
<div>
|
||||
@@ -24,7 +31,9 @@
|
||||
<v-col cols="8">
|
||||
<v-select
|
||||
v-model="form.sender"
|
||||
:items="validSenderAddresses"
|
||||
:items="allowedSenders"
|
||||
item-title="address"
|
||||
item-value="address"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
hide-details="auto"
|
||||
@@ -37,13 +46,17 @@
|
||||
<span>{{ $gettext('To') }}</span>
|
||||
</v-col>
|
||||
<v-col cols="8">
|
||||
<v-text-field
|
||||
<v-combobox
|
||||
v-model="form.to"
|
||||
:items="contacts"
|
||||
item-title="display_name"
|
||||
return-object
|
||||
:placeholder="$gettext('Provide one or more addresses')"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
hide-details="auto"
|
||||
:rules="[rules.required]"
|
||||
@update:search="lookForContacts"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="2">
|
||||
@@ -76,12 +89,19 @@
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="8">
|
||||
<v-text-field
|
||||
<v-combobox
|
||||
v-model="form.cc"
|
||||
:items="contacts"
|
||||
item-title="display_name"
|
||||
return-object
|
||||
:placeholder="$gettext('Provide one or more addresses')"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
hide-details="auto"
|
||||
chips
|
||||
multiple
|
||||
:hide-no-data="false"
|
||||
@update:search="lookForContacts"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -96,12 +116,19 @@
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="8">
|
||||
<v-text-field
|
||||
<v-combobox
|
||||
v-model="form.bcc"
|
||||
:items="contacts"
|
||||
item-title="display_name"
|
||||
return-object
|
||||
:placeholder="$gettext('Provide one or more addresses')"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
hide-details="auto"
|
||||
chips
|
||||
multiple
|
||||
:hide-no-data="false"
|
||||
@update:search="lookForContacts"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -119,45 +146,60 @@
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
<HtmlEditor
|
||||
<BodyEditor
|
||||
v-model="form.body"
|
||||
class="d-flex flex-column flex-grow-1 mt-4"
|
||||
@on-toggle-html-mode="(value) => emit('onToggleHtmlMode', value)"
|
||||
/>
|
||||
</v-form>
|
||||
</div>
|
||||
<v-dialog v-model="showAttachmentsDialog" max-width="800">
|
||||
<AttachmentsDialog
|
||||
:session-uid="route.query.uid"
|
||||
@close="closeAttachmentDialog"
|
||||
/>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useGettext } from 'vue3-gettext'
|
||||
import { useAuthStore, useBusStore } from '@/stores'
|
||||
import HtmlEditor from '@/components/tools/HtmlEditor'
|
||||
import debounce from 'debounce'
|
||||
import AttachmentsDialog from '@/components/webmail/AttachmentsDialog'
|
||||
import BodyEditor from '@/components/webmail/BodyEditor'
|
||||
import rules from '@/plugins/rules'
|
||||
import api from '@/api/webmail'
|
||||
import contactsApi from '@/api/contacts'
|
||||
|
||||
const props = defineProps({
|
||||
originalEmail: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
replyAll: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
})
|
||||
const emit = defineEmits(['onToggleHtmlMode'])
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const { $gettext } = useGettext()
|
||||
const { displayNotification } = useBusStore()
|
||||
const authStore = useAuthStore()
|
||||
|
||||
const allowedSenders = ref([])
|
||||
const attachmentCount = ref(0)
|
||||
const contacts = ref([])
|
||||
const form = ref({})
|
||||
const formRef = ref()
|
||||
const showAttachmentsDialog = ref(false)
|
||||
const showCcField = ref(false)
|
||||
const showBccField = ref(false)
|
||||
const working = ref(false)
|
||||
|
||||
const validSenderAddresses = computed(() => {
|
||||
return [authStore.authUser.username]
|
||||
})
|
||||
|
||||
const close = () => {
|
||||
router.push({
|
||||
name: 'MailboxView',
|
||||
@@ -168,11 +210,27 @@ const initForm = () => {
|
||||
form.value = {
|
||||
sender: authStore.authUser.username,
|
||||
}
|
||||
console.log(props.originalEmail)
|
||||
if (props.originalEmail) {
|
||||
form.value.to = props.originalEmail.from_address.address
|
||||
form.value.to = props.originalEmail.reply_to
|
||||
? props.originalEmail.reply_to
|
||||
: props.originalEmail.from_address.address
|
||||
if (props.replyAll) {
|
||||
let addresses = props.originalEmail.to
|
||||
.filter((rcpt) => rcpt.address !== authStore.authUser.username)
|
||||
.map((rcpt) => rcpt.fulladdress)
|
||||
if (props.originalEmail.cc && props.originalEmail.cc.length) {
|
||||
addresses = addresses.concat(
|
||||
props.originalEmail.cc.map((rcpt) => rcpt.fulladdress)
|
||||
)
|
||||
}
|
||||
form.value.cc = addresses
|
||||
showCcField.value = true
|
||||
}
|
||||
form.value.subject = props.originalEmail.subject
|
||||
form.value.body = props.originalEmail.body
|
||||
if (props.originalEmail.message_id) {
|
||||
form.value.in_reply_to = props.originalEmail.message_id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +241,25 @@ const submit = async () => {
|
||||
}
|
||||
working.value = true
|
||||
const body = { ...form.value }
|
||||
body.to = [body.to]
|
||||
if (typeof form.value.to !== 'string') {
|
||||
body.to = [form.value.to.emails[0].address]
|
||||
} else {
|
||||
body.to = [form.value.to]
|
||||
}
|
||||
if (body.cc?.length) {
|
||||
const cc = []
|
||||
for (const rcpt of body.cc) {
|
||||
cc.push(typeof rcpt === 'string' ? rcpt : rcpt.emails[0].address)
|
||||
}
|
||||
body.cc = cc
|
||||
}
|
||||
if (body.bcc?.length) {
|
||||
const bcc = []
|
||||
for (const rcpt of body.bcc) {
|
||||
bcc.push(typeof rcpt === 'string' ? rcpt : rcpt.emails[0].address)
|
||||
}
|
||||
body.bcc = bcc
|
||||
}
|
||||
try {
|
||||
await api.sendEmail(body)
|
||||
router.push({ name: 'MailboxView' })
|
||||
@@ -195,6 +271,28 @@ const submit = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const openAttachmentsDialog = () => {
|
||||
showAttachmentsDialog.value = true
|
||||
}
|
||||
|
||||
const closeAttachmentDialog = async () => {
|
||||
showAttachmentsDialog.value = false
|
||||
const resp = await api.getUploadedAttachments(route.query.uid)
|
||||
attachmentCount.value = resp.data.length
|
||||
}
|
||||
|
||||
const lookForContacts = debounce(async (search) => {
|
||||
if (search) {
|
||||
const params = { search }
|
||||
const resp = await contactsApi.getContacts(params)
|
||||
if (resp.data.length) {
|
||||
contacts.value = resp.data
|
||||
}
|
||||
} else {
|
||||
contacts.value = []
|
||||
}
|
||||
}, 500)
|
||||
|
||||
watch(
|
||||
() => props.originalEmail,
|
||||
() => {
|
||||
@@ -202,4 +300,19 @@ watch(
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
if (!route.query.uid) {
|
||||
api.createComposeSession().then((resp) => {
|
||||
const query = { ...route.query, uid: resp.data.uid }
|
||||
router.push({ name: route.name, query })
|
||||
})
|
||||
} else {
|
||||
api.getUploadedAttachments(route.query.uid).then((resp) => {
|
||||
attachmentCount.value = resp.data.length
|
||||
})
|
||||
}
|
||||
|
||||
api.getAllowedSenders().then((resp) => {
|
||||
allowedSenders.value = resp.data
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<template>
|
||||
<v-card min-width="300">
|
||||
<v-list>
|
||||
<v-list-item
|
||||
:subtitle="model.name ? model.address : ''"
|
||||
:title="model.name || model.address"
|
||||
>
|
||||
<template #append>
|
||||
<v-btn
|
||||
v-if="!model.contact_id"
|
||||
color="secondary"
|
||||
icon="mdi-card-account-mail-outline"
|
||||
variant="text"
|
||||
:loading="working"
|
||||
:title="$gettext('Add to contacts')"
|
||||
@click="addContact"
|
||||
></v-btn>
|
||||
<v-btn
|
||||
v-else
|
||||
icon="mdi-pencil"
|
||||
variant="text"
|
||||
:loading="working"
|
||||
:title="$gettext('Update contact')"
|
||||
@click="redirectToContacts"
|
||||
></v-btn>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useGettext } from 'vue3-gettext'
|
||||
import { useBusStore } from '@/stores'
|
||||
import contactsApi from '@/api/contacts'
|
||||
|
||||
const emit = defineEmits(['contact-added'])
|
||||
const model = defineModel()
|
||||
|
||||
const router = useRouter()
|
||||
const { $gettext } = useGettext()
|
||||
const { displayNotification } = useBusStore()
|
||||
|
||||
const working = ref(false)
|
||||
|
||||
const addContact = async () => {
|
||||
const body = {
|
||||
emails: [{ address: model.value.address, type: 'other' }],
|
||||
}
|
||||
if (model.value.name) {
|
||||
body.display_name = model.value.name
|
||||
}
|
||||
working.value = true
|
||||
let resp
|
||||
try {
|
||||
resp = await contactsApi.createContact(body)
|
||||
} finally {
|
||||
working.value = false
|
||||
}
|
||||
emit('contact-added', resp.data)
|
||||
displayNotification({ msg: $gettext('Contact added to address book') })
|
||||
}
|
||||
|
||||
const redirectToContacts = () => {
|
||||
router.push({ name: 'ContactList' })
|
||||
}
|
||||
</script>
|
||||
@@ -11,13 +11,16 @@
|
||||
<v-text-field
|
||||
v-model="search"
|
||||
prepend-inner-icon="mdi-magnify"
|
||||
:placeholder="$gettext('Search')"
|
||||
:placeholder="$gettext('Search in messages')"
|
||||
variant="outlined"
|
||||
single-line
|
||||
flat
|
||||
hide-details
|
||||
density="compact"
|
||||
class="flex-grow-0 w-33 mr-4"
|
||||
clearable
|
||||
@click:clear="fetchEmails"
|
||||
@keyup.enter="submitSearch"
|
||||
></v-text-field>
|
||||
<v-btn
|
||||
class="ml-2"
|
||||
@@ -75,6 +78,12 @@
|
||||
prepend-icon="mdi-star-outline"
|
||||
@click="() => flagSelection('unflagged')"
|
||||
/>
|
||||
<v-list-item
|
||||
v-if="$route.params.mailbox !== 'Trash'"
|
||||
:title="$gettext('Empty mailbox')"
|
||||
prepend-icon="mdi-trash-can"
|
||||
@click="emptyMailbox"
|
||||
/>
|
||||
</v-list>
|
||||
</v-menu>
|
||||
</v-btn>
|
||||
@@ -104,44 +113,58 @@
|
||||
<v-skeleton-loader v-if="loading" type="card@2"></v-skeleton-loader>
|
||||
<template v-else>
|
||||
<div class="emails position-absolute top-0 bottom-0 w-100 overflow-y-auto">
|
||||
<v-card
|
||||
v-for="email in emails.results"
|
||||
:key="email.imapid"
|
||||
density="compact"
|
||||
class="mb-2 mx-1"
|
||||
>
|
||||
<v-card-text
|
||||
class="d-flex align-center"
|
||||
:class="{ 'font-weight-bold': email.style === 'unseen' }"
|
||||
<template v-if="emails.results?.length">
|
||||
<v-card
|
||||
v-for="email in emails.results"
|
||||
:key="email.imapid"
|
||||
density="compact"
|
||||
class="mb-2 mx-1"
|
||||
>
|
||||
<v-checkbox v-model="selection" :value="email.imapid" hide-details />
|
||||
<v-btn
|
||||
:icon="email.flagged ? 'mdiu-star' : 'mdi-star-outline'"
|
||||
variant="flat"
|
||||
/>
|
||||
<div class="ml-4 clickable" @click="openEmail(email.imapid)">
|
||||
<div>{{ email.subject }}</div>
|
||||
<div class="mt-1 text-grey">
|
||||
<span
|
||||
v-if="email.from_address.name"
|
||||
:title="email.from_address.address"
|
||||
>{{ email.from_address.name }}</span
|
||||
>
|
||||
<span v-else>{{ email.from_address.address }}</span>
|
||||
<v-card-text
|
||||
class="d-flex align-center"
|
||||
:class="{ 'font-weight-bold': email.style === 'unseen' }"
|
||||
>
|
||||
<v-checkbox
|
||||
v-model="selection"
|
||||
:value="email.imapid"
|
||||
hide-details
|
||||
/>
|
||||
<v-btn
|
||||
:icon="email.flagged ? 'mdi-star' : 'mdi-star-outline'"
|
||||
variant="flat"
|
||||
@click="toggleFollowState(email)"
|
||||
/>
|
||||
<div class="ml-4 clickable" @click="openEmail(email.imapid)">
|
||||
<div>{{ email.subject }}</div>
|
||||
<div class="mt-1 text-grey">
|
||||
<span
|
||||
v-if="email.from_address.name"
|
||||
:title="email.from_address.address"
|
||||
>{{ email.from_address.name }}</span
|
||||
>
|
||||
<span v-else>{{ email.from_address.address }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<v-spacer />
|
||||
<div class="text-right">
|
||||
<div>{{ email.date }}</div>
|
||||
<div class="mt-1">
|
||||
<v-icon v-if="email.answered" icon="mdi-reply-outline" />
|
||||
<v-icon v-if="email.forwarded" icon="mdi-share-outline" />
|
||||
<v-icon v-if="email.attachments" icon="mdi-paperclip" />
|
||||
<span class="text-grey">{{ $filesize(email.size) }}</span>
|
||||
<v-spacer />
|
||||
<div class="text-right">
|
||||
<div>{{ email.date }}</div>
|
||||
<div class="mt-1">
|
||||
<v-icon v-if="email.answered" icon="mdi-reply-outline" />
|
||||
<v-icon v-if="email.forwarded" icon="mdi-share-outline" />
|
||||
<v-icon v-if="email.attachments" icon="mdi-paperclip" />
|
||||
<span class="text-grey">{{ $filesize(email.size) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</template>
|
||||
<v-alert
|
||||
v-else
|
||||
class="mt-4"
|
||||
type="info"
|
||||
:text="$gettext('No message yet in this mailbox')"
|
||||
variant="tonal"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
@@ -184,7 +207,7 @@ const fetchEmails = () => {
|
||||
emails.value = {}
|
||||
loading.value = true
|
||||
api
|
||||
.getMailboxEmails(props.mailbox, { page: page.value })
|
||||
.getMailboxEmails(props.mailbox, { page: page.value, search: search.value })
|
||||
.then((resp) => {
|
||||
emails.value = resp.data
|
||||
loading.value = false
|
||||
@@ -194,6 +217,12 @@ const fetchEmails = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const submitSearch = () => {
|
||||
if (search.value) {
|
||||
fetchEmails()
|
||||
}
|
||||
}
|
||||
|
||||
const toggleAllSelection = (value) => {
|
||||
if (!value) {
|
||||
selection.value = []
|
||||
@@ -251,6 +280,20 @@ const flagSelection = (status) => {
|
||||
})
|
||||
}
|
||||
|
||||
const emptyMailbox = () => {
|
||||
loading.value = true
|
||||
api.emptyUserMailbox(route.query.mailbox).then(() => {
|
||||
emails.value = {}
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
const toggleFollowState = async (email) => {
|
||||
const flag = email.flagged ? 'unflagged' : 'flagged'
|
||||
await api.flagSelection(route.query.mailbox, [email.imapid], flag)
|
||||
email.flagged = flag === 'flagged'
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.mailbox,
|
||||
() => {
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
<template>
|
||||
<v-card :title="title">
|
||||
<v-card-text>
|
||||
<v-form ref="formRef">
|
||||
<v-text-field
|
||||
v-model="form.name"
|
||||
:label="$gettext('Name')"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
:rules="[rules.required]"
|
||||
/>
|
||||
<div class="mb-2 rounded-lg">
|
||||
<h4>{{ $gettext('Parent mailbox') }}</h4>
|
||||
<MailboxList
|
||||
v-model="form.parent_mailbox"
|
||||
:active-mailbox="props.parent"
|
||||
:mailboxes="props.userMailboxes"
|
||||
light-mode
|
||||
compact
|
||||
:unseen-counters="false"
|
||||
allow-unselect
|
||||
/>
|
||||
</div>
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
<v-btn
|
||||
:text="$gettext('Close')"
|
||||
variant="flat"
|
||||
:loading="loading"
|
||||
@click="close"
|
||||
/>
|
||||
<v-btn
|
||||
:text="submitLabel"
|
||||
variant="tonal"
|
||||
color="primary"
|
||||
:loading="loading"
|
||||
@click="submit"
|
||||
/>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useGettext } from 'vue3-gettext'
|
||||
import { useBusStore } from '@/stores'
|
||||
import MailboxList from '@/components/webmail/MailboxList.vue'
|
||||
import api from '@/api/webmail'
|
||||
import rules from '@/plugins/rules'
|
||||
|
||||
const props = defineProps({
|
||||
userMailboxes: Array,
|
||||
mailbox: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
hdelimiter: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
})
|
||||
const emit = defineEmits(['close', 'mailboxRenamed'])
|
||||
|
||||
const { $gettext } = useGettext()
|
||||
const { displayNotification } = useBusStore()
|
||||
|
||||
const form = ref({})
|
||||
const formRef = ref()
|
||||
const loading = ref(false)
|
||||
|
||||
const title = computed(() => {
|
||||
return !props.mailbox
|
||||
? $gettext('Create new mailbox')
|
||||
: $gettext('Edit mailbox')
|
||||
})
|
||||
const submitLabel = computed(() => {
|
||||
return !props.mailbox ? $gettext('Create') : $gettext('Update')
|
||||
})
|
||||
|
||||
const close = () => {
|
||||
form.value = {}
|
||||
emit('close')
|
||||
}
|
||||
|
||||
const submit = async () => {
|
||||
const { valid } = await formRef.value.validate()
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const body = { ...form.value }
|
||||
if (props.mailbox) {
|
||||
body.oldname = props.mailbox
|
||||
await api.renameUserMailbox(body)
|
||||
displayNotification({ msg: $gettext('Mailbox renamed') })
|
||||
emit(
|
||||
'mailboxRenamed',
|
||||
`${body.parent_mailbox}${props.hdelimiter}${body.name}`
|
||||
)
|
||||
} else {
|
||||
await api.createUserMailbox(body)
|
||||
displayNotification({ msg: $gettext('Mailbox created') })
|
||||
}
|
||||
close()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.mailbox,
|
||||
(value) => {
|
||||
if (value) {
|
||||
const parts = props.mailbox.split(props.hdelimiter)
|
||||
form.value.name = parts.slice(-1)[0]
|
||||
form.value.parent_mailbox = parts.slice(0, -1).join(props.hdelimiter)
|
||||
} else {
|
||||
form.value = {}
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
@@ -3,17 +3,18 @@
|
||||
<div
|
||||
v-for="mailbox in props.mailboxes"
|
||||
:key="mailbox.name"
|
||||
class="py-1 pl-3 text-body-2"
|
||||
class="pl-3 text-body-2"
|
||||
:class="{ 'py-1': !props.compact }"
|
||||
>
|
||||
<div
|
||||
:class="getBackgroundColorClass(mailbox)"
|
||||
class="d-flex mailbox pa-1 align-center"
|
||||
@click="$emit('mailboxSelected', mailbox)"
|
||||
@click="updateSelection(mailbox.name)"
|
||||
@mouseover="setHover(mailbox, true)"
|
||||
@mouseleave="setHover(mailbox, false)"
|
||||
>
|
||||
<v-icon :icon="iconByMailboxType[mailbox.type]" class="mr-4" />
|
||||
<template v-if="mailbox.unseen > 0">
|
||||
<template v-if="props.unseenCounters && mailbox.unseen > 0">
|
||||
<span class="font-weight-bold">
|
||||
{{ getMailboxLabel(mailbox) }} ({{ mailbox.unseen }})
|
||||
</span>
|
||||
@@ -33,9 +34,11 @@
|
||||
</div>
|
||||
<MailboxList
|
||||
v-if="getMailboxState(mailbox) && mailbox.sub && mailbox.sub.length"
|
||||
v-model="model"
|
||||
:mailboxes="mailbox.sub"
|
||||
class="mt-1"
|
||||
@mailbox-selected="(mailbox) => $emit('mailboxSelected', mailbox)"
|
||||
:light-mode="props.lightMode"
|
||||
:compact="props.compact"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -43,18 +46,32 @@
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import api from '@/api/webmail'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const props = defineProps({
|
||||
mailboxes: {
|
||||
type: Array,
|
||||
default: null,
|
||||
},
|
||||
lightMode: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
compact: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
unseenCounters: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
allowUnselect: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
})
|
||||
const emit = defineEmits(['mailboxSelected'])
|
||||
const model = defineModel()
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const iconByMailboxType = {
|
||||
inbox: 'mdi-inbox',
|
||||
@@ -77,10 +94,15 @@ function setHover(mailbox, value) {
|
||||
}
|
||||
|
||||
function getBackgroundColorClass(mailbox) {
|
||||
if (route.query.mailbox === mailbox.name) {
|
||||
return 'bg-primary-lighten-1'
|
||||
if (model.value === mailbox.name) {
|
||||
return `bg-primary-lighten-1`
|
||||
}
|
||||
return hoverStates.value[mailbox.name] ? 'bg-primary-lighten-1' : 'bg-primary'
|
||||
if (!props.lightMode) {
|
||||
return hoverStates.value[mailbox.name]
|
||||
? `bg-primary-lighten-1`
|
||||
: `bg-primary`
|
||||
}
|
||||
return hoverStates.value[mailbox.name] ? 'bg-primary' : `bg-white`
|
||||
}
|
||||
|
||||
function getMailboxState(mailbox) {
|
||||
@@ -94,10 +116,18 @@ function toggleMailbox(mailbox) {
|
||||
mailboxStates.value[mailbox.name] = !mailboxStates.value[mailbox.name]
|
||||
if (mailboxStates.value[mailbox.name] && !mailbox.sub.length) {
|
||||
api.getUserMailboxes(mailbox.name).then((resp) => {
|
||||
mailbox.sub = resp.data
|
||||
mailbox.sub = resp.data.mailboxes
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function updateSelection(value) {
|
||||
if (props.allowUnselect && value === model.value) {
|
||||
emit('update:modelValue', null)
|
||||
} else {
|
||||
emit('update:modelValue', value)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@@ -8,65 +8,205 @@
|
||||
color="primary"
|
||||
app
|
||||
>
|
||||
<div class="d-flex align-center">
|
||||
<v-img
|
||||
src="@/assets/Modoboa_RVB-BLANC-SANS.png"
|
||||
max-width="190"
|
||||
class="logo"
|
||||
/>
|
||||
<v-btn
|
||||
:icon="rail ? 'mdi-chevron-right' : 'mdi-chevron-left'"
|
||||
variant="text"
|
||||
@click.stop="rail = !rail"
|
||||
>
|
||||
</v-btn>
|
||||
</div>
|
||||
<template #prepend>
|
||||
<div class="d-flex align-center">
|
||||
<v-img
|
||||
src="@/assets/Modoboa_RVB-BLANC-SANS.png"
|
||||
max-width="190"
|
||||
class="logo"
|
||||
/>
|
||||
<v-btn
|
||||
:icon="rail ? 'mdi-chevron-right' : 'mdi-chevron-left'"
|
||||
variant="text"
|
||||
@click.stop="rail = !rail"
|
||||
>
|
||||
</v-btn>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-center mb-4">
|
||||
<v-btn
|
||||
:text="$gettext('Compose')"
|
||||
color="secondary"
|
||||
variant="flat"
|
||||
prepend-icon="mdi-pencil"
|
||||
@click="openComposeForm"
|
||||
/>
|
||||
</div>
|
||||
<div class="d-flex justify-center mb-4">
|
||||
<v-btn
|
||||
:text="$gettext('Compose')"
|
||||
color="secondary"
|
||||
variant="flat"
|
||||
prepend-icon="mdi-pencil"
|
||||
@click="openComposeForm"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<MailboxList
|
||||
v-model="selectedMailbox"
|
||||
:mailboxes="userMailboxes"
|
||||
class="mr-2"
|
||||
@mailbox-selected="openMailbox"
|
||||
@update:model-value="openMailbox"
|
||||
/>
|
||||
<template #append>
|
||||
<div class="border-t-sm d-flex align-center bg-grey">
|
||||
<v-btn class="ml-2" variant="text" icon size="small">
|
||||
<v-icon icon="mdi-cog" />
|
||||
<v-menu activator="parent">
|
||||
<v-list density="compact">
|
||||
<v-list-item
|
||||
:title="$gettext('Create a new mailbox')"
|
||||
prepend-icon="mdi-plus"
|
||||
@click="openMailboxForm"
|
||||
/>
|
||||
<v-list-item
|
||||
:title="$gettext('Edit this mailbox')"
|
||||
prepend-icon="mdi-pencil"
|
||||
:disabled="readOnlyMailbox"
|
||||
@click="editMailbox"
|
||||
/>
|
||||
<v-list-item
|
||||
:title="$gettext('Delete this mailbox')"
|
||||
prepend-icon="mdi-trash-can"
|
||||
:disabled="readOnlyMailbox"
|
||||
@click="deleteMailbox"
|
||||
/>
|
||||
<v-list-item
|
||||
:title="$gettext('Compress this mailbox')"
|
||||
prepend-icon="mdi-folder-zip-outline"
|
||||
@click="compressMailbox"
|
||||
/>
|
||||
</v-list>
|
||||
</v-menu>
|
||||
</v-btn>
|
||||
|
||||
<v-progress-linear
|
||||
v-if="mailboxQuota"
|
||||
:color="quotaColor"
|
||||
:model-value="mailboxQuota.usage"
|
||||
:title="mailboxQuotaTitle"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</v-navigation-drawer>
|
||||
</template>
|
||||
</ConnectedLayout>
|
||||
<v-dialog v-model="showMailboxForm" max-width="800">
|
||||
<MailboxForm
|
||||
:user-mailboxes="userMailboxes"
|
||||
:mailbox="editedMailbox"
|
||||
:hdelimiter="hdelimiter"
|
||||
@mailbox-renamed="navigateToMailbox"
|
||||
@close="closeMailboxForm()"
|
||||
/>
|
||||
</v-dialog>
|
||||
<ConfirmDialog ref="confirm" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useGettext } from 'vue3-gettext'
|
||||
import { useBusStore } from '@/stores'
|
||||
import ConfirmDialog from '@/components/tools/ConfirmDialog.vue'
|
||||
import ConnectedLayout from '@/layouts/connected/ConnectedLayout.vue'
|
||||
import MailboxForm from '@/components/webmail/MailboxForm.vue'
|
||||
import MailboxList from '@/components/webmail/MailboxList.vue'
|
||||
import api from '@/api/webmail'
|
||||
|
||||
const { $gettext } = useGettext()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const { displayNotification } = useBusStore()
|
||||
|
||||
const confirm = ref()
|
||||
const drawer = ref(true)
|
||||
const rail = ref(false)
|
||||
const editedMailbox = ref(null)
|
||||
const hdelimiter = ref(null)
|
||||
const mailboxQuota = ref(null)
|
||||
const selectedMailbox = ref(route.query.mailbox || 'INBOX')
|
||||
const showMailboxForm = ref(false)
|
||||
const userMailboxes = ref([])
|
||||
|
||||
const readOnlyMailbox = computed(() => {
|
||||
const mailboxes = ['INBOX']
|
||||
return mailboxes.includes(route.query.mailbox || 'INBOX')
|
||||
})
|
||||
|
||||
const quotaColor = computed(() => {
|
||||
if (mailboxQuota.value.usage < 50) {
|
||||
return 'info'
|
||||
}
|
||||
if (mailboxQuota.value.usage < 80) {
|
||||
return 'warning'
|
||||
}
|
||||
return 'error'
|
||||
})
|
||||
|
||||
const mailboxQuotaTitle = computed(() => {
|
||||
return `${mailboxQuota.value.current} / ${mailboxQuota.value.limit} (${mailboxQuota.value.usage}%)`
|
||||
})
|
||||
|
||||
function openMailbox(mailbox) {
|
||||
console.log(mailbox)
|
||||
router.push({
|
||||
name: 'MailboxView',
|
||||
query: { mailbox: mailbox.name },
|
||||
query: { mailbox },
|
||||
})
|
||||
api.getUserMailboxQuota(mailbox).then((resp) => {
|
||||
mailboxQuota.value = resp.data
|
||||
})
|
||||
}
|
||||
|
||||
api.getUserMailboxes().then((resp) => {
|
||||
userMailboxes.value = resp.data
|
||||
userMailboxes.value = resp.data.mailboxes
|
||||
hdelimiter.value = resp.data.hdelimiter
|
||||
})
|
||||
|
||||
const openComposeForm = () => {
|
||||
router.push({ name: 'ComposeEmailView' })
|
||||
}
|
||||
|
||||
const closeMailboxForm = () => {
|
||||
showMailboxForm.value = false
|
||||
editedMailbox.value = null
|
||||
api.getUserMailboxes().then((resp) => {
|
||||
userMailboxes.value = resp.data.mailboxes
|
||||
})
|
||||
}
|
||||
|
||||
const openMailboxForm = () => {
|
||||
showMailboxForm.value = true
|
||||
}
|
||||
|
||||
const editMailbox = () => {
|
||||
editedMailbox.value = selectedMailbox.value
|
||||
showMailboxForm.value = true
|
||||
}
|
||||
|
||||
const navigateToMailbox = (mailbox) => {
|
||||
selectedMailbox.value = mailbox
|
||||
router.push({
|
||||
name: 'MailboxView',
|
||||
query: { mailbox },
|
||||
})
|
||||
}
|
||||
|
||||
const compressMailbox = async () => {
|
||||
await api.compressUserMailbox({ name: selectedMailbox.value })
|
||||
displayNotification({ msg: $gettext('Mailbox compressed') })
|
||||
}
|
||||
|
||||
const deleteMailbox = async () => {
|
||||
const confirmed = await confirm.value.open(
|
||||
$gettext('Warning'),
|
||||
$gettext('Delete this mailbox?'),
|
||||
{
|
||||
color: 'warning',
|
||||
agreeLabel: $gettext('Yes'),
|
||||
cancelLabel: $gettext('No'),
|
||||
}
|
||||
)
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
await api.deleteUserMailbox({ name: selectedMailbox.value })
|
||||
displayNotification({ msg: $gettext('Mailbox deleted') })
|
||||
navigateToMailbox('INBOX')
|
||||
}
|
||||
|
||||
api.getUserMailboxQuota(route.query.mailbox || 'INBOX').then((resp) => {
|
||||
mailboxQuota.value = resp.data
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -355,6 +355,14 @@ const routes = [
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'forward',
|
||||
name: 'ForwardEmailView',
|
||||
component: () => import('@/views/webmail/ForwardEmailView.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
color="primary"
|
||||
variant="tonal"
|
||||
prepend-icon="mdi-reply"
|
||||
@click="replyToEmail"
|
||||
@click="() => replyToEmail()"
|
||||
>
|
||||
{{ $gettext('Reply') }}
|
||||
<template #append>
|
||||
@@ -15,8 +15,14 @@
|
||||
<v-icon icon="mdi-chevron-down" />
|
||||
<v-menu activator="parent">
|
||||
<v-list>
|
||||
<v-list-item :title="$gettext('Reply all')" />
|
||||
<v-list-item :title="$gettext('Forward')" />
|
||||
<v-list-item
|
||||
:title="$gettext('Reply all')"
|
||||
@click="() => replyToEmail(true)"
|
||||
/>
|
||||
<v-list-item
|
||||
:title="$gettext('Forward')"
|
||||
@click="forwardEmail"
|
||||
/>
|
||||
</v-list>
|
||||
</v-menu>
|
||||
</v-btn>
|
||||
@@ -80,16 +86,46 @@
|
||||
<div v-if="email" ref="headers" class="bg-white pa-4">
|
||||
<h2>{{ email.subject }}</h2>
|
||||
<div class="d-flex mt-2">
|
||||
<h3 v-if="email.from_address.fulladdress">
|
||||
{{ email.from_address.fulladdress }}
|
||||
</h3>
|
||||
<h3 v-else>{{ email.from_address.address }}</h3>
|
||||
<v-menu key="sender" open-on-hover>
|
||||
<template #activator="{ props }">
|
||||
<h3 v-bind="props">
|
||||
<template v-if="email.from_address.name">
|
||||
{{ email.from_address.name }}
|
||||
<span class="text-grey text-body-2">
|
||||
<{{ email.from_address.address }}>
|
||||
</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ email.from_address.address }}
|
||||
</template>
|
||||
</h3>
|
||||
</template>
|
||||
<ContactCard
|
||||
v-model="email.from_address"
|
||||
@contact-added="
|
||||
(contact) => (email.from_address.contact_id = contact.id)
|
||||
"
|
||||
/>
|
||||
</v-menu>
|
||||
<v-spacer />
|
||||
<span>{{ email.date }}</span>
|
||||
<span class="text-grey">{{ email.date }}</span>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<div class="mt-2 text-grey">
|
||||
{{ $gettext('To') }}
|
||||
{{ recipients }}
|
||||
<v-menu
|
||||
v-for="(rcpt, index) in recipients"
|
||||
:key="`rcpt-${index}`"
|
||||
open-on-hover
|
||||
>
|
||||
<template #activator="{ props }">
|
||||
<span v-if="index > 0">, </span>
|
||||
<span v-bind="props">{{ rcpt.name || rcpt.address }}</span>
|
||||
</template>
|
||||
<ContactCard
|
||||
:model-value="rcpt"
|
||||
@contact-added="(contact) => storeContactId(rcpt, contact)"
|
||||
/>
|
||||
</v-menu>
|
||||
</div>
|
||||
<div v-if="email.attachments.length" class="mt-2">
|
||||
<v-icon icon="mdi-paperclip" />
|
||||
@@ -131,6 +167,7 @@ import { useRoute, useRouter } from 'vue-router'
|
||||
import { useGettext } from 'vue3-gettext'
|
||||
import { useBusStore } from '@/stores'
|
||||
import api from '@/api/webmail'
|
||||
import ContactCard from '@/components/webmail/ContactCard.vue'
|
||||
|
||||
const { $gettext } = useGettext()
|
||||
const { displayNotification } = useBusStore()
|
||||
@@ -149,9 +186,11 @@ const recipients = computed(() => {
|
||||
if (!email.value) {
|
||||
return ''
|
||||
}
|
||||
return email.value.to
|
||||
.map((rcpt) => (rcpt.name ? rcpt.name : rcpt.address))
|
||||
.join(', ')
|
||||
let result = email.value.to
|
||||
if (email.value.cc && email.value.cc.length) {
|
||||
result = result.concat(email.value.cc)
|
||||
}
|
||||
return result
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
@@ -268,8 +307,33 @@ const openEmailSourceDialog = async () => {
|
||||
showEmailSource.value = true
|
||||
}
|
||||
|
||||
const replyToEmail = () => {
|
||||
router.push({ name: 'ReplyEmailView', query: route.query })
|
||||
const storeContactId = (address, contact) => {
|
||||
console.log(address, contact)
|
||||
for (const rcpt of email.value.to) {
|
||||
if (rcpt.address === address.address) {
|
||||
rcpt.contact_id = contact.id
|
||||
return
|
||||
}
|
||||
}
|
||||
if (!email.value.cc) return
|
||||
for (const rcpt of email.value.cc) {
|
||||
if (rcpt.address === address.address) {
|
||||
rcpt.contact_id = contact.id
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const replyToEmail = (all) => {
|
||||
const query = { ...route.query }
|
||||
if (all) {
|
||||
query.all = all
|
||||
}
|
||||
router.push({ name: 'ReplyEmailView', query })
|
||||
}
|
||||
|
||||
const forwardEmail = () => {
|
||||
router.push({ name: 'ForwardEmailView', query: route.query })
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<ComposeEmailForm :original-email="email" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import ComposeEmailForm from '@/components/webmail/ComposeEmailForm'
|
||||
import api from '@/api/webmail'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const email = ref()
|
||||
|
||||
api
|
||||
.getEmailContent(route.query.mailbox, route.query.mailid, {
|
||||
context: 'forward',
|
||||
})
|
||||
.then((resp) => {
|
||||
email.value = resp.data
|
||||
})
|
||||
</script>
|
||||
@@ -1,5 +1,9 @@
|
||||
<template>
|
||||
<ComposeEmailForm :original-email="email" />
|
||||
<ComposeEmailForm
|
||||
:original-email="email"
|
||||
:reply-all="route.query.all === 'true'"
|
||||
@on-toggle-html-mode="getEmailContent"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -12,11 +16,17 @@ const route = useRoute()
|
||||
|
||||
const email = ref()
|
||||
|
||||
api
|
||||
.getEmailContent(route.query.mailbox, route.query.mailid, {
|
||||
context: 'reply',
|
||||
})
|
||||
.then((resp) => {
|
||||
email.value = resp.data
|
||||
})
|
||||
const getEmailContent = (html) => {
|
||||
email.value = ''
|
||||
api
|
||||
.getEmailContent(route.query.mailbox, route.query.mailid, {
|
||||
context: 'reply',
|
||||
dformat: html ? 'html' : 'plain',
|
||||
})
|
||||
.then((resp) => {
|
||||
email.value = resp.data
|
||||
})
|
||||
}
|
||||
|
||||
getEmailContent()
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user