-
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
167 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<template> | ||
<div class="mail-preview"> | ||
<!-- headers --> | ||
<mail-preview-attributes :mail="mail"/> | ||
|
||
<!-- HTML preview --> | ||
<iframe | ||
v-if="mail.html" | ||
class="mail-preview-html" | ||
:style="{height: `${iframeHeight}px`}" | ||
:srcdoc="mail.html" | ||
@load="setIframeHeight" | ||
ref="iframe" | ||
></iframe> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import {ref} from "vue"; | ||
import MailPreviewAttributes from "./MailPreviewAttributes.vue"; | ||
defineProps({ | ||
mail: { | ||
type: Object, | ||
}, | ||
}) | ||
const iframe = ref(null); | ||
const iframeHeight = ref(600); | ||
const setIframeHeight = () => { | ||
iframeHeight.value = (iframe.value?.contentWindow?.document?.body?.clientHeight || 580) + 20; | ||
} | ||
</script> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<template> | ||
<div class="mail-preview-attributes"> | ||
<table> | ||
<tr v-if="mail.from"> | ||
<td class="font-semibold">From</td> | ||
<td>{{ mail.from }}</td> | ||
</tr> | ||
<tr v-if="mail.to"> | ||
<td class="font-semibold">To</td> | ||
<td>{{ mail.to }}</td> | ||
</tr> | ||
<tr v-if="mail.id"> | ||
<td class="font-semibold">Message ID</td> | ||
<td>{{ mail.id }}</td> | ||
</tr> | ||
<tr v-if="mail.subject"> | ||
<td class="font-semibold">Subject</td> | ||
<td>{{ mail.subject }}</td> | ||
</tr> | ||
<tr v-if="mail.attachments && mail.attachments.length > 0"> | ||
<td class="font-semibold">Attachments</td> | ||
<td> | ||
<div v-for="(attachment, index) in mail.attachments" :key="`mail-${mail.id}-attachment-${index}`" | ||
class="mail-attachment-button" | ||
> | ||
<div class="flex items-center"> | ||
<PaperClipIcon class="h-4 w-4 text-gray-500 dark:text-gray-400 mr-1"/> | ||
<span>{{ attachment.filename }} <span class="opacity-60">({{ attachment.size_formatted }})</span></span> | ||
</div> | ||
<div> | ||
<a href="#" @click.prevent="downloadAttachment(attachment)" | ||
class="text-blue-600 hover:text-blue-700 dark:text-blue-500 dark:hover:text-blue-400" | ||
>Download</a> | ||
</div> | ||
</div> | ||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { PaperClipIcon } from '@heroicons/vue/24/outline'; | ||
defineProps(['mail']); | ||
const downloadAttachment = (attachment) => { | ||
// Decode the base64 encoded string | ||
const decodedContent = atob(attachment.content); | ||
// Convert decoded base64 string to a Uint8Array | ||
const byteNumbers = new Array(decodedContent.length); | ||
for (let i = 0; i < decodedContent.length; i++) { | ||
byteNumbers[i] = decodedContent.charCodeAt(i); | ||
} | ||
const byteArray = new Uint8Array(byteNumbers); | ||
const blob = new Blob([byteArray], { type: attachment.content_type || 'application/octet-stream' }); | ||
const blobUrl = URL.createObjectURL(blob); | ||
const downloadLink = document.createElement('a'); | ||
downloadLink.href = blobUrl; | ||
downloadLink.download = attachment.filename; | ||
downloadLink.click(); | ||
// Clean up the temporary URL after the download | ||
URL.revokeObjectURL(blobUrl); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<template> | ||
<div class="mail-preview"> | ||
<!-- headers --> | ||
<mail-preview-attributes :mail="mail"/> | ||
|
||
<!-- Text preview --> | ||
<pre | ||
v-if="mail.text" | ||
class="mail-preview-text" | ||
v-text="mail.text" | ||
></pre> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import {ref} from "vue"; | ||
import MailPreviewAttributes from "./MailPreviewAttributes.vue"; | ||
defineProps({ | ||
mail: { | ||
type: Object, | ||
}, | ||
}) | ||
const iframe = ref(null); | ||
const iframeHeight = ref(600); | ||
const setIframeHeight = () => { | ||
iframeHeight.value = (iframe.value?.contentWindow?.document?.body?.clientHeight || 580) + 20; | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters