diff --git a/app/dashboard/templates/dashboard/index.html b/app/dashboard/templates/dashboard/index.html index 43437132..b240fd89 100644 --- a/app/dashboard/templates/dashboard/index.html +++ b/app/dashboard/templates/dashboard/index.html @@ -39,7 +39,7 @@ Enable/Disable Email Forwarding - Created At + Delete @@ -104,8 +104,16 @@ - {{ gen_email.created_at | dt }} +
+ + + + + +
+ {% endfor %} @@ -212,10 +220,18 @@ e.clearSelection(); }); - // the modal does not get close when user clicks outside of modal - // necessary for obligatory modal such as the one displayed when user enable/display email forwarding - notie.setOptions({ - overlayClickDismiss: false, + $(".delete-email").on("click", function (e) { + notie.confirm({ + text: "Once an email alias is deleted, people/apps " + + "who used to contact you via this email cannot reach you any more," + + " please confirm", + cancelCallback: () => { + // nothing to do + }, + submitCallback: () => { + $(this).closest("form").submit(); + } + }); }); $(".custom-switch-input").change(function (e) { diff --git a/app/dashboard/views/index.py b/app/dashboard/views/index.py index b2fa08b2..7dfd3611 100644 --- a/app/dashboard/views/index.py +++ b/app/dashboard/views/index.py @@ -66,6 +66,16 @@ SimpleLogin team. ) db.session.commit() + elif request.form.get("form-name") == "delete-email": + gen_email_id = request.form.get("gen-email-id") + gen_email: GenEmail = GenEmail.get(gen_email_id) + + LOG.d("delete gen email %s", gen_email) + email = gen_email.email + GenEmail.delete(gen_email.id) + db.session.commit() + flash(f"Email alias {email} has been deleted", "success") + return redirect(url_for("dashboard.index")) client_users = (