diff --git a/app/dashboard/templates/dashboard/alias_log.html b/app/dashboard/templates/dashboard/alias_log.html index 923962f4..6ef8ae0f 100644 --- a/app/dashboard/templates/dashboard/alias_log.html +++ b/app/dashboard/templates/dashboard/alias_log.html @@ -9,7 +9,7 @@ {% block default_content %} @@ -22,11 +22,7 @@ Activity Website Email - - - Forward/Reply - - + Alias diff --git a/app/dashboard/templates/dashboard/index.html b/app/dashboard/templates/dashboard/index.html index 47aaf4f5..10d9413b 100644 --- a/app/dashboard/templates/dashboard/index.html +++ b/app/dashboard/templates/dashboard/index.html @@ -35,66 +35,39 @@ - - + - - - + + - {% for gen_email in gen_emails %} + {% for alias_info in aliases %} + {% set gen_email = alias_info.gen_email %} + + - - @@ -246,6 +243,18 @@ }); }); + $(".trigger-email").on("click", function (e) { + notie.confirm({ + text: "SimpleLogin server will send an email to this alias and it should arrive to your inbox, please confirm", + cancelCallback: () => { + // nothing to do + }, + submitCallback: () => { + $(this).closest("form").submit(); + } + }); + }); + $(".custom-switch-input").change(function (e) { var message = ""; diff --git a/app/dashboard/views/index.py b/app/dashboard/views/index.py index fdc82a13..a2275083 100644 --- a/app/dashboard/views/index.py +++ b/app/dashboard/views/index.py @@ -1,3 +1,5 @@ +from dataclasses import dataclass + from flask import render_template, request, redirect, url_for, flash, session from flask_login import login_required, current_user from sqlalchemy.orm import joinedload @@ -7,7 +9,15 @@ from app.config import HIGHLIGHT_GEN_EMAIL_ID from app.dashboard.base import dashboard_bp from app.extensions import db from app.log import LOG -from app.models import GenEmail, ClientUser +from app.models import GenEmail, ClientUser, ForwardEmail, ForwardEmailLog + + +@dataclass +class AliasInfo: + gen_email: GenEmail + nb_forward: int + nb_blocked: int + nb_reply: int @dashboard_bp.route("/", methods=["GET", "POST"]) @@ -97,6 +107,43 @@ def index(): return render_template( "dashboard/index.html", client_users=client_users, + aliases=get_alias_info(current_user.id), gen_emails=gen_emails, highlight_gen_email_id=highlight_gen_email_id, ) + + +def get_alias_info(user_id) -> [AliasInfo]: + aliases = {} # dict of alias and AliasInfo + q = db.session.query(GenEmail, ForwardEmail, ForwardEmailLog).filter( + GenEmail.user_id == user_id, + GenEmail.id == ForwardEmail.gen_email_id, + ForwardEmail.id == ForwardEmailLog.forward_id, + ) + + for ge, fe, fel in q: + if ge.email not in aliases: + aliases[ge.email] = AliasInfo( + gen_email=ge, nb_blocked=0, nb_forward=0, nb_reply=0 + ) + + alias_info = aliases[ge.email] + if fel.is_reply: + alias_info.nb_reply += 1 + elif fel.blocked: + alias_info.nb_blocked += 1 + else: + alias_info.nb_forward += 1 + + # also add alias that has no forward email or log + q = ( + db.session.query(GenEmail) + .filter(GenEmail.email.notin_(aliases.keys())) + .filter(GenEmail.user_id == user_id) + ) + for ge in q: + aliases[ge.email] = AliasInfo( + gen_email=ge, nb_blocked=0, nb_forward=0, nb_reply=0 + ) + + return list(aliases.values())
Email - Used On - + AliasActivity   Actions - Email Forwarding + Email Forwarding Delete
- {{ gen_email.email }} + {{ gen_email.email }}     + {% if gen_email.enabled %} + + + + {% endif %} +
+
+ Created {{ gen_email.created_at | dt }}
- {% for client_user in gen_email.client_users %} - {{ client_user.client.name }}
- {% endfor %} -
-
- {% if gen_email.enabled %} - - {% endif %} - - {% if gen_email.enabled %} -
- - - - - -
- {% endif %} - -
+
{{ alias_info.nb_forward }} forwarded
+
{{ alias_info.nb_blocked }} blocked
+
{{ alias_info.nb_reply }} reply
@@ -126,13 +99,37 @@ -
- - - - - -
+