-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Allow toggle between HTML/plain text alternative body if it …
- Loading branch information
Showing
8 changed files
with
458 additions
and
315 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
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
151 changes: 82 additions & 69 deletions
151
Rnwood.Smtp4dev/ClientApp/src/components/messagepartsource.vue
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 |
---|---|---|
@@ -1,90 +1,103 @@ | ||
<template> | ||
<div class="hfillpanel" v-loading="loading"> | ||
<el-alert v-if="error" type="error"> | ||
{{error.message}} | ||
<div class="hfillpanel" v-loading="loading"> | ||
<el-alert v-if="error" type="error"> | ||
{{ error.message }} | ||
|
||
<el-button v-on:click="loadMessage">Retry</el-button> | ||
</el-alert> | ||
<el-button v-on:click="loadMessage">Retry</el-button> | ||
</el-alert> | ||
|
||
<div class="toolbar"><el-button size="small" icon="el-icon-document" @click="download">Open</el-button></div> | ||
<div v-show="source" class="vfillpanel fill"> | ||
<textview :text="source" class="fill"></textview> | ||
</div> | ||
<div class="toolbar"> | ||
<el-button size="small" icon="el-icon-document" @click="viewSource">Open</el-button> | ||
|
||
<el-button size="small" icon="el-icon-download" @click="download" v-show="downloadurl">Download</el-button> | ||
</div> | ||
<div v-show="source" class="vfillpanel fill"> | ||
<textview :text="source" class="fill"></textview> | ||
</div> | ||
</div> | ||
</template> | ||
<script lang="ts"> | ||
import { Component, Prop, Watch } from 'vue-property-decorator' | ||
import Vue from 'vue' | ||
import MessagesController from "../ApiClient/MessagesController"; | ||
import MessageEntitySummary from "../ApiClient/MessageEntitySummary"; | ||
import TextView from "@/components/textview.vue"; | ||
@Component({ | ||
components: { | ||
textview: TextView | ||
} | ||
}) | ||
import {Component, Prop, Watch} from 'vue-property-decorator' | ||
import Vue from 'vue' | ||
import MessagesController from "../ApiClient/MessagesController"; | ||
import MessageEntitySummary from "../ApiClient/MessageEntitySummary"; | ||
import TextView from "@/components/textview.vue"; | ||
@Component({ | ||
components: { | ||
textview: TextView | ||
} | ||
}) | ||
export default class MessagePartSource extends Vue { | ||
constructor() { | ||
super(); | ||
} | ||
constructor() { | ||
super(); | ||
} | ||
@Prop() | ||
messageEntitySummary: MessageEntitySummary | null = null; | ||
@Prop() | ||
messageEntitySummary: MessageEntitySummary | null = null; | ||
source: string | null = null; | ||
sourceurl: string | null = null; | ||
error: Error | null = null; | ||
loading = false; | ||
source: string | null = null; | ||
sourceurl: string | null = null; | ||
downloadurl: string | null = null; | ||
error: Error | null = null; | ||
loading = false; | ||
@Prop({ default: "source" } ) | ||
type!: "source" | "raw"; | ||
@Prop({default: "source"}) | ||
type!: "source" | "raw"; | ||
@Watch("messageEntitySummary") | ||
async onMessageEntitySummaryChanged(value: MessageEntitySummary, oldValue: MessageEntitySummary) { | ||
@Watch("messageEntitySummary") | ||
async onMessageEntitySummaryChanged(value: MessageEntitySummary, oldValue: MessageEntitySummary) { | ||
await this.loadMessage(); | ||
await this.loadMessage(); | ||
} | ||
} | ||
download() { | ||
if (this.sourceurl) { | ||
window.open(this.sourceurl); | ||
} | ||
} | ||
download() { | ||
if (this.downloadurl) { | ||
window.open(this.downloadurl); | ||
} | ||
} | ||
viewSource() { | ||
if (this.sourceurl) { | ||
window.open(this.sourceurl); | ||
} | ||
} | ||
async loadMessage() { | ||
async loadMessage() { | ||
this.error = null; | ||
this.loading = true; | ||
this.source = null; | ||
this.sourceurl = null; | ||
this.error = null; | ||
this.loading = true; | ||
this.source = null; | ||
this.sourceurl = null; | ||
this.downloadurl = null; | ||
try { | ||
if (this.messageEntitySummary != null) { | ||
if (this.type === "raw") { | ||
this.sourceurl = new MessagesController().getPartSourceRaw_url(this.messageEntitySummary.messageId, this.messageEntitySummary.id); | ||
this.source = await new MessagesController().getPartSourceRaw(this.messageEntitySummary.messageId, this.messageEntitySummary.id); | ||
try { | ||
if (this.messageEntitySummary != null) { | ||
if (this.type === "raw") { | ||
this.sourceurl = new MessagesController().getPartSourceRaw_url(this.messageEntitySummary.messageId, this.messageEntitySummary.id); | ||
this.source = await new MessagesController().getPartSourceRaw(this.messageEntitySummary.messageId, this.messageEntitySummary.id); | ||
} else { | ||
this.sourceurl = new MessagesController().getPartSource_url(this.messageEntitySummary.messageId, this.messageEntitySummary.id); | ||
this.source = await new MessagesController().getPartSource(this.messageEntitySummary.messageId, this.messageEntitySummary.id); | ||
} else { | ||
} | ||
} | ||
} catch (e: any) { | ||
this.error = e; | ||
} finally { | ||
this.loading = false; | ||
} | ||
} | ||
async created() { | ||
this.loadMessage(); | ||
} | ||
this.sourceurl = new MessagesController().getPartSource_url(this.messageEntitySummary.messageId, this.messageEntitySummary.id); | ||
this.downloadurl = new MessagesController().getPartContent_url(this.messageEntitySummary.messageId, this.messageEntitySummary.id); | ||
this.source = await new MessagesController().getPartSource(this.messageEntitySummary.messageId, this.messageEntitySummary.id); | ||
async destroyed() { | ||
} | ||
} | ||
} | ||
} | ||
} catch (e: any) { | ||
this.error = e; | ||
} finally { | ||
this.loading = false; | ||
} | ||
} | ||
async created() { | ||
this.loadMessage(); | ||
} | ||
async destroyed() { | ||
} | ||
} | ||
</script> |
Oops, something went wrong.