-
-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #269 from opcodesio/mail-previews
Feature / mail previews straight from the log viewer
- Loading branch information
Showing
11 changed files
with
340 additions
and
17 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,85 @@ | ||
<template> | ||
<div class="mail-preview"> | ||
<!-- headers --> | ||
<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> | ||
|
||
<!-- 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 { PaperClipIcon } from '@heroicons/vue/24/outline'; | ||
import {computed, ref} from "vue"; | ||
const props = defineProps({ | ||
mail: { | ||
type: Object, | ||
}, | ||
}) | ||
const iframe = ref(null); | ||
const iframeHeight = ref(600); | ||
const setIframeHeight = () => { | ||
iframeHeight.value = (iframe.value?.contentWindow?.document?.body?.clientHeight || 580) + 20; | ||
} | ||
const downloadAttachment = (attachment) => { | ||
const blob = new Blob([attachment.content], { 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,33 @@ | ||
<template> | ||
<div> | ||
<div class="tabs-container" v-if="tabs && tabs.length > 1"> | ||
<div class="border-b border-gray-200 dark:border-gray-800"> | ||
<nav class="-mb-px flex space-x-6" aria-label="Tabs"> | ||
<a v-for="tab in tabs" :key="tab.name" href="#" @click.prevent="currentTab = tab" | ||
:class="[isCurrent(tab) ? 'border-brand-500 dark:border-brand-400 text-brand-600 dark:text-brand-500' : 'border-transparent text-gray-500 dark:text-gray-400 hover:border-gray-300 hover:text-gray-700 dark:hover:text-gray-200', 'whitespace-nowrap border-b-2 py-2 px-1 text-sm font-medium focus:outline-brand-500']" | ||
:aria-current="isCurrent(tab) ? 'page' : undefined">{{ tab.name }}</a> | ||
</nav> | ||
</div> | ||
</div> | ||
|
||
<slot></slot> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import {provide, ref} from "vue"; | ||
const props = defineProps({ | ||
tabs: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}) | ||
const currentTab = ref(props.tabs[0]); | ||
provide('currentTab', currentTab); | ||
const isCurrent = (tab) => { | ||
return currentTab.value && currentTab.value.value === tab.value; | ||
} | ||
</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,22 @@ | ||
<template> | ||
<div v-if="isSelected"> | ||
<slot></slot> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import {computed, inject} from "vue"; | ||
const props = defineProps({ | ||
tabValue: { | ||
type: String, | ||
required: true, | ||
}, | ||
}) | ||
const currentTab = inject('currentTab'); | ||
const isSelected = computed(() => { | ||
return currentTab.value && currentTab.value.value === props.tabValue; | ||
}) | ||
</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
Oops, something went wrong.