mirror of
https://github.com/simple-login/app.git
synced 2024-09-29 21:21:29 +02:00
improve dashboard page
This commit is contained in:
parent
5b8bc68da1
commit
d929cea771
@ -9,7 +9,7 @@
|
|||||||
{% block default_content %}
|
{% block default_content %}
|
||||||
<div class="page-header row">
|
<div class="page-header row">
|
||||||
<h3 class="page-title col">
|
<h3 class="page-title col">
|
||||||
Alias Activity {{ alias }}
|
{{ alias }}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -22,11 +22,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Activity</th>
|
<th>Activity</th>
|
||||||
<th>Website Email</th>
|
<th>Website Email</th>
|
||||||
|
<th></th>
|
||||||
<th>
|
|
||||||
Forward/Reply
|
|
||||||
</th>
|
|
||||||
|
|
||||||
<th>Alias</th>
|
<th>Alias</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -35,66 +35,39 @@
|
|||||||
<table class="table table-hover table-outline table-vcenter text-nowrap card-table">
|
<table class="table table-hover table-outline table-vcenter text-nowrap card-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Email</th>
|
<th>Alias</th>
|
||||||
<th>
|
<th>Activity <i class="fe fe-help-circle" data-toggle="tooltip" title="Stats on this alias"></i>
|
||||||
Used On
|
|
||||||
<i class="fe fe-help-circle" data-toggle="tooltip"
|
|
||||||
title="List of app/website that has received this email"></i>
|
|
||||||
</th>
|
</th>
|
||||||
<th>Actions</th>
|
<th>Email Forwarding <i class="fe fe-help-circle" data-toggle="tooltip" title="Block/unblock an alias"></i>
|
||||||
<th>
|
|
||||||
Email Forwarding
|
|
||||||
</th>
|
</th>
|
||||||
<th>Delete</th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for gen_email in gen_emails %}
|
{% for alias_info in aliases %}
|
||||||
|
{% set gen_email = alias_info.gen_email %}
|
||||||
|
|
||||||
<tr {% if gen_email.id == highlight_gen_email_id %} class="highlight-row" {% endif %}>
|
<tr {% if gen_email.id == highlight_gen_email_id %} class="highlight-row" {% endif %}>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<div>
|
<div>
|
||||||
<a href="mailto: {{ gen_email.email }}">{{ gen_email.email }}</a>
|
<a href="mailto: {{ gen_email.email }}">{{ gen_email.email }}</a>
|
||||||
|
{% if gen_email.enabled %}
|
||||||
|
<span class="icon clipboard" data-clipboard-text="{{ gen_email.email }}">
|
||||||
|
<i class="dropdown-icon fe fe-clipboard"></i>
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
Created {{ gen_email.created_at | dt }}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
{% for client_user in gen_email.client_users %}
|
<div>{{ alias_info.nb_forward }} forwarded</div>
|
||||||
{{ client_user.client.name }} <br>
|
<div>{{ alias_info.nb_blocked }} blocked</div>
|
||||||
{% endfor %}
|
<div>{{ alias_info.nb_reply }} reply</div>
|
||||||
</td>
|
|
||||||
|
|
||||||
<td>
|
|
||||||
<div class="btn-group">
|
|
||||||
{% if gen_email.enabled %}
|
|
||||||
<button class="clipboard btn btn-secondary btn-sm"
|
|
||||||
data-toggle="tooltip"
|
|
||||||
title="Copy the alias to clipboard"
|
|
||||||
data-clipboard-text="{{ gen_email.email }}">
|
|
||||||
Copy
|
|
||||||
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if gen_email.enabled %}
|
|
||||||
<form method="post">
|
|
||||||
<input type="hidden" name="form-name" value="trigger-email">
|
|
||||||
<input type="hidden" name="gen-email-id" value="{{ gen_email.id }}">
|
|
||||||
|
|
||||||
|
|
||||||
<button class="btn btn-secondary btn-sm"
|
|
||||||
data-toggle="tooltip"
|
|
||||||
title="Send a test email to the alias."
|
|
||||||
{% if loop.index ==1 %}
|
|
||||||
data-intro="By triggering the test email,
|
|
||||||
SimpleLogin server will send an email to this alias
|
|
||||||
and this email should arrive to your personal email inbox 🚀"
|
|
||||||
{% endif %}
|
|
||||||
>Trigger Test Email
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
@ -126,13 +99,37 @@
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
<div class="item-action dropdown">
|
||||||
|
<a href="javascript:void(0)" data-toggle="dropdown" class="icon"><i class="fe fe-more-vertical"></i></a>
|
||||||
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
|
<a href="{{ url_for('dashboard.alias_log', alias=gen_email.email) }}"
|
||||||
|
class="dropdown-item">
|
||||||
|
<i class="dropdown-icon fe fe-activity"></i>
|
||||||
|
Activity
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{% if gen_email.enabled %}
|
||||||
<form method="post">
|
<form method="post">
|
||||||
|
<a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fe fe-send"></i>
|
||||||
|
<input type="hidden" name="form-name" value="trigger-email">
|
||||||
|
<input type="hidden" name="gen-email-id"
|
||||||
|
value="{{ gen_email.id }}">
|
||||||
|
<span class="trigger-email"> Send email to alias </span>
|
||||||
|
</a>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
<a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fe fe-trash"></i>
|
||||||
<input type="hidden" name="form-name" value="delete-email">
|
<input type="hidden" name="form-name" value="delete-email">
|
||||||
<input type="hidden" name="gen-email-id" value="{{ gen_email.id }}">
|
<input type="hidden" name="gen-email-id" value="{{ gen_email.id }}">
|
||||||
<span class="icon delete-email">
|
<span class="delete-email"> Delete </span>
|
||||||
<i class="fe fe-trash"></i>
|
</a>
|
||||||
</span>
|
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@ -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) {
|
$(".custom-switch-input").change(function (e) {
|
||||||
var message = "";
|
var message = "";
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from flask import render_template, request, redirect, url_for, flash, session
|
from flask import render_template, request, redirect, url_for, flash, session
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
from sqlalchemy.orm import joinedload
|
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.dashboard.base import dashboard_bp
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.log import LOG
|
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"])
|
@dashboard_bp.route("/", methods=["GET", "POST"])
|
||||||
@ -97,6 +107,43 @@ def index():
|
|||||||
return render_template(
|
return render_template(
|
||||||
"dashboard/index.html",
|
"dashboard/index.html",
|
||||||
client_users=client_users,
|
client_users=client_users,
|
||||||
|
aliases=get_alias_info(current_user.id),
|
||||||
gen_emails=gen_emails,
|
gen_emails=gen_emails,
|
||||||
highlight_gen_email_id=highlight_gen_email_id,
|
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())
|
||||||
|
Loading…
Reference in New Issue
Block a user