mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-10-03 07:46:18 +00:00
Added Jinja template for subject #837
This commit is contained in:
@@ -88,7 +88,7 @@ watch(livePreview, () => {
|
||||
</div>
|
||||
<div class="col-6" v-if="livePreview">
|
||||
<PeerShareWithEmailBodyPreview
|
||||
:body="email.Body"
|
||||
:email="email"
|
||||
:selectedPeer="selectedPeer"
|
||||
>
|
||||
</PeerShareWithEmailBodyPreview>
|
||||
|
@@ -2,26 +2,28 @@
|
||||
|
||||
import {fetchPost} from "@/utilities/fetch.js";
|
||||
import {ref, watch} from "vue";
|
||||
import LocaleText from "@/components/text/localeText.vue";
|
||||
|
||||
const props = defineProps(['body', 'selectedPeer'])
|
||||
const props = defineProps(['email', 'selectedPeer'])
|
||||
const preview = ref("")
|
||||
const error = ref(false)
|
||||
const errorMsg = ref("")
|
||||
|
||||
|
||||
const getPreview = async () => {
|
||||
if (props.body){
|
||||
if (props.email){
|
||||
error.value = false;
|
||||
preview.value = ("")
|
||||
await fetchPost('/api/email/previewBody', {
|
||||
Body: props.body,
|
||||
|
||||
await fetchPost('/api/email/preview', {
|
||||
Subject: props.email.Subject,
|
||||
Body: props.email.Body,
|
||||
ConfigurationName: props.selectedPeer.configuration.Name,
|
||||
Peer: props.selectedPeer.id
|
||||
}, (res) => {
|
||||
|
||||
if (res.status){
|
||||
preview.value = res.data;
|
||||
}else{
|
||||
preview.value = ("")
|
||||
errorMsg.value = res.message
|
||||
}
|
||||
error.value = !res.status
|
||||
@@ -32,7 +34,7 @@ const getPreview = async () => {
|
||||
await getPreview();
|
||||
let timeout = undefined
|
||||
watch(() => {
|
||||
return props.body
|
||||
return props.email
|
||||
}, async () => {
|
||||
if (timeout === undefined){
|
||||
timeout = setTimeout(async () => {
|
||||
@@ -44,21 +46,27 @@ watch(() => {
|
||||
await getPreview();
|
||||
}, 500)
|
||||
}
|
||||
}, {
|
||||
deep: true
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="card rounded-0 border-start-0 border-bottom-0 bg-body-secondary" style="height: 400px; overflow: scroll">
|
||||
<div class="card-body">
|
||||
<div class="alert alert-danger rounded-3" v-if="error && body">
|
||||
<div class="alert alert-danger rounded-3" v-if="error && email.Body">
|
||||
<i class="bi bi-exclamation-triangle-fill me-2"></i>
|
||||
<span class="font-monospace">
|
||||
{{errorMsg}}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="body"
|
||||
:class="{'opacity-50': error}"
|
||||
:innerText="preview"></div>
|
||||
<div>
|
||||
<div v-if="preview">
|
||||
<strong><LocaleText t="Subject"></LocaleText>: </strong>{{ preview.Subject }}
|
||||
</div>
|
||||
<hr>
|
||||
<div :class="{'opacity-50': error}" v-bind:innerText="preview.Body"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
Reference in New Issue
Block a user