diff --git a/frontend/src/views/Settings.vue b/frontend/src/views/Settings.vue index 56598ab..e46e43d 100644 --- a/frontend/src/views/Settings.vue +++ b/frontend/src/views/Settings.vue @@ -354,6 +354,22 @@ +
+ +
+

+ + Set custom headers +

+ + + +
@@ -396,7 +412,24 @@ export default Vue.extend({ this.form.smtp.splice(i, 1); }, + showSMTPHeaders(i) { + const s = this.form.smtp[i]; + s.showHeaders = true; + this.form.smtp.splice(i, 1, s); + }, + onSubmit() { + const form = { ...this.form }; + + // De-serialize custom e-mail headers. + for (let i = 0; i < form.smtp.length; i += 1) { + if (form.smtp[i].strEmailHeaders && form.smtp[i].strEmailHeaders !== '[]') { + form.smtp[i].email_headers = JSON.parse(form.smtp[i].strEmailHeaders); + } else { + form.smtp[i].email_headers = []; + } + } + this.isLoading = true; this.$api.updateSettings(this.form).then((data) => { if (data.needsRestart) { @@ -425,8 +458,14 @@ export default Vue.extend({ getSettings() { this.$api.getSettings().then((data) => { - this.form = data; - this.formCopy = JSON.stringify(data); + const d = data; + // Serialize the `email_headers` array map to display on the form. + for (let i = 0; i < d.smtp.length; i += 1) { + d.smtp[i].strEmailHeaders = JSON.stringify(d.smtp[i].email_headers, null, 4); + } + + this.form = d; + this.formCopy = JSON.stringify(d); this.isLoading = false; }); },