Split domain detail into Info and DNS page

This commit is contained in:
Son NK 2019-12-30 17:52:08 +01:00
parent 632484ee5c
commit 4b6717d8dd
5 changed files with 87 additions and 12 deletions

View File

@ -0,0 +1,35 @@
{% extends 'default.html' %}
{% set active_page = "custom_domain" %}
{% block default_content %}
<div class="row">
<div class="col-lg-3 order-lg-1 mb-4">
<div class="list-group list-group-transparent mb-0">
<a href="{{ url_for('dashboard.domain_detail', custom_domain_id=custom_domain.id) }}"
class="list-group-item list-group-item-action {{ 'active' if domain_detail_page == 'info' }}">
<span class="icon mr-3"><i class="fe fe-flag"></i></span>Info
</a>
<a href="{{ url_for('dashboard.domain_detail_dns', custom_domain_id=custom_domain.id) }}"
class="list-group-item list-group-item-action {{ 'active' if domain_detail_page == 'dns' }}">
<span class="icon mr-3"><i class="fe fe-cloud"></i></span>DNS
</a>
</div>
</div>
<div class="col-lg-9">
<div class="card">
<div class="card-body">
<div class="text-wrap p-lg-6">
{% block domain_detail_content %}
{% endblock %}
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -1,14 +1,13 @@
{% extends 'default.html' %}
{% set active_page = "custom_domain" %}
{% extends 'dashboard/domain_detail/base.html' %}
{% set domain_detail_page = "dns" %}
{% block title %}
{{ custom_domain.domain }}
{{ custom_domain.domain }} DNS
{% endblock %}
{% block head %}
{% endblock %}
{% block default_content %}
{% block domain_detail_content %}
<div class="bg-white p-4" style="max-width: 60rem; margin: auto">
<h1 class="h3"> {{ custom_domain.domain }} </h1>
<div class="">Please follow the steps below to set up your domain.</div>

View File

@ -0,0 +1,23 @@
{% extends 'dashboard/domain_detail/base.html' %}
{% set domain_detail_page = "info" %}
{% block title %}
{{ custom_domain.domain }} Info
{% endblock %}
{% block domain_detail_content %}
<h1 class="h3"> {{ custom_domain.domain }}
{% if custom_domain.verified %}
<span class="cursor" data-toggle="tooltip" data-original-title="DNS Setup OK"></span>
{% else %}
<span class="cursor" data-toggle="tooltip" data-original-title="DNS Setup Needed">🚫 </span>
{% endif %}
</h1>
<div class="small-text">Created {{ custom_domain.created_at | dt }}</div>
{{ nb_alias }} aliases
{% endblock %}

View File

@ -40,7 +40,7 @@ def custom_domain():
return redirect(
url_for(
"dashboard.domain_detail", custom_domain_id=new_custom_domain.id
"dashboard.domain_detail_dns", custom_domain_id=new_custom_domain.id
)
)

View File

@ -10,12 +10,12 @@ from app.dns_utils import (
get_txt_record,
)
from app.extensions import db
from app.models import CustomDomain
from app.models import CustomDomain, GenEmail
@dashboard_bp.route("/domains/<int:custom_domain_id>", methods=["GET", "POST"])
@dashboard_bp.route("/domains/<int:custom_domain_id>/dns", methods=["GET", "POST"])
@login_required
def domain_detail(custom_domain_id):
def domain_detail_dns(custom_domain_id):
# only premium user can see custom domain
if not current_user.is_premium():
flash("Only premium user can add custom domains", "warning")
@ -91,7 +91,7 @@ def domain_detail(custom_domain_id):
name = custom_domain.domain
CustomDomain.delete(custom_domain_id)
db.session.commit()
flash(f"Domain {name} has been deleted successfully", "success")
flash(f"Domain {name} has been deleted", "success")
return redirect(url_for("dashboard.custom_domain"))
@ -103,4 +103,22 @@ def domain_detail(custom_domain_id):
dkim_record = f"v=DKIM1; k=rsa; p={DKIM_DNS_VALUE}"
return render_template("dashboard/domain_detail.html", **locals())
return render_template("dashboard/domain_detail/dns.html", **locals())
@dashboard_bp.route("/domains/<int:custom_domain_id>/info", methods=["GET", "POST"])
@login_required
def domain_detail(custom_domain_id):
# only premium user can see custom domain
if not current_user.is_premium():
flash("Only premium user can add custom domains", "warning")
return redirect(url_for("dashboard.index"))
custom_domain = CustomDomain.get(custom_domain_id)
if not custom_domain or custom_domain.user_id != current_user.id:
flash("You cannot see this page", "warning")
return redirect(url_for("dashboard.index"))
nb_alias = GenEmail.filter_by(custom_domain_id=custom_domain.id).count()
return render_template("dashboard/domain_detail/info.html", **locals())