2021-03-11 05:43:45 +01:00
|
|
|
import $ from "jquery";
|
|
|
|
|
2021-02-28 00:39:51 +01:00
|
|
|
import * as channel from "../channel";
|
|
|
|
|
2020-07-02 01:45:54 +02:00
|
|
|
$(() => {
|
2019-03-26 17:17:02 +01:00
|
|
|
// This code will be executed when the user visits /emails in
|
|
|
|
// development mode and email_log.html is rendered.
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#toggle").on("change", () => {
|
2020-07-15 01:29:15 +02:00
|
|
|
if ($(".email-text").css("display") === "none") {
|
2019-03-26 17:17:02 +01:00
|
|
|
$(".email-text").each(function () {
|
|
|
|
$(this).css("display", "block");
|
|
|
|
});
|
|
|
|
$(".email-html").each(function () {
|
|
|
|
$(this).css("display", "none");
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$(".email-text").each(function () {
|
|
|
|
$(this).css("display", "none");
|
|
|
|
});
|
|
|
|
$(".email-html").each(function () {
|
|
|
|
$(this).css("display", "block");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2020-07-15 01:29:15 +02:00
|
|
|
$("input[type=radio][name=forward]").on("change", function () {
|
2019-03-26 17:17:02 +01:00
|
|
|
if ($(this).val() === "enabled") {
|
|
|
|
$("#forward_address_sections").show();
|
|
|
|
} else {
|
|
|
|
$("#forward_address_sections").hide();
|
|
|
|
}
|
|
|
|
});
|
2020-07-02 01:45:54 +02:00
|
|
|
$("#save_smptp_details").on("click", () => {
|
2020-07-15 00:34:28 +02:00
|
|
|
const address =
|
|
|
|
$("input[name=forward]:checked").val() === "enabled" ? $("#address").val() : "";
|
2020-07-15 01:29:15 +02:00
|
|
|
const csrf_token = $('input[name="csrfmiddlewaretoken"]').attr("value");
|
2019-11-02 00:06:25 +01:00
|
|
|
const data = {forward_address: address, csrfmiddlewaretoken: csrf_token};
|
2019-03-26 17:17:02 +01:00
|
|
|
|
|
|
|
channel.post({
|
|
|
|
url: "/emails/",
|
2020-07-20 22:18:43 +02:00
|
|
|
data,
|
|
|
|
success() {
|
2019-03-26 17:17:02 +01:00
|
|
|
$("#smtp_form_status").show();
|
2020-07-02 01:45:54 +02:00
|
|
|
setTimeout(() => {
|
2019-03-26 17:17:02 +01:00
|
|
|
$("#smtp_form_status").hide();
|
|
|
|
}, 3000);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|