Corrected unauthorized side navigation change regarding the placement of the "Global Search" feature.

Removed the statistics and recent activity / history data display from the dashboard view.
This commit is contained in:
Matt Scott 2023-03-10 16:23:33 -05:00
parent e7fc082b60
commit 26f3f79388
3 changed files with 14 additions and 203 deletions

View File

@ -36,7 +36,7 @@ class ZoneTabs:
"""
tabs = {
'forward': TabInfo("", None),
'forward': TabInfo("", None),
'reverse_ipv4': TabInfo("in-addr.arpa", '%.in-addr.arpa'),
'reverse_ipv6': TabInfo("ip6.arpa", '%.ip6.arpa'),
}
@ -55,7 +55,7 @@ def before_request():
# Check site is in maintenance mode
maintenance = Setting().get('maintenance')
if maintenance and current_user.is_authenticated and current_user.role.name not in [
'Administrator', 'Operator'
'Administrator', 'Operator'
]:
return render_template('maintenance.html')
@ -83,13 +83,14 @@ def domains_custom(tab_id):
.outerjoin(Account, Domain.account_id == Account.id) \
.outerjoin(AccountUser, Account.id == AccountUser.account_id) \
.filter(
db.or_(
DomainUser.user_id == current_user.id,
AccountUser.user_id == current_user.id
))
db.or_(
DomainUser.user_id == current_user.id,
AccountUser.user_id == current_user.id
))
template = current_app.jinja_env.get_template("dashboard_domain.html")
render = template.make_module(vars={"current_user": current_user, "allow_user_view_history": Setting().get('allow_user_view_history')})
render = template.make_module(
vars={"current_user": current_user, "allow_user_view_history": Setting().get('allow_user_view_history')})
columns = [
Domain.name, Domain.dnssec, Domain.type, Domain.serial, Domain.master,
@ -184,64 +185,9 @@ def dashboard():
if BG_DOMAIN_UPDATE and current_user.role.name not in ['Administrator', 'Operator']:
show_bg_domain_button = False
# Stats for dashboard
domain_count = 0
history_number = 0
history = []
user_num = User.query.count()
if current_user.role.name in ['Administrator', 'Operator']:
domain_count = Domain.query.count()
history_number = History.query.count()
history = History.query.order_by(History.created_on.desc()).limit(4).all()
elif Setting().get('allow_user_view_history'):
allowed_domain_id_subquery = db.session.query(Domain.id) \
.outerjoin(DomainUser, Domain.id == DomainUser.domain_id) \
.outerjoin(Account, Domain.account_id == Account.id) \
.outerjoin(AccountUser, Account.id == AccountUser.account_id) \
.filter(db.or_(
DomainUser.user_id == current_user.id,
AccountUser.user_id == current_user.id
)) \
.subquery()
history = db.session.query(History) \
.with_hint(History, "FORCE INDEX (ix_history_created_on)", 'mysql') \
.order_by(History.created_on.desc()) \
.filter(History.domain_id.in_(allowed_domain_id_subquery)) \
.limit(4) \
.all()
history_number = db.session.query(History) \
.filter(History.domain_id.in_(allowed_domain_id_subquery)) \
.count()
domain_count = db.session.query(Domain) \
.outerjoin(DomainUser, Domain.id == DomainUser.domain_id) \
.outerjoin(Account, Domain.account_id == Account.id) \
.outerjoin(AccountUser, Account.id == AccountUser.account_id) \
.filter(
db.or_(
DomainUser.user_id == current_user.id,
AccountUser.user_id == current_user.id
)).count()
from .admin import convert_histories, DetailedHistory
detailedHistories = convert_histories(history)
server = Server(server_id='localhost')
statistics = server.get_statistic()
if statistics:
uptime = list([
uptime for uptime in statistics if uptime['name'] == 'uptime'
])[0]['value']
else:
uptime = 0
# Add custom boxes to render_template
return render_template('dashboard.html',
zone_tabs=ZoneTabs,
domain_count=domain_count,
user_num=user_num,
history_number=history_number,
uptime=uptime,
histories=detailedHistories,
show_bg_domain_button=show_bg_domain_button,
pdns_version=Setting().get('pdns_version'))

View File

@ -85,12 +85,6 @@
<p>Dashboard</p>
</a>
</li>
<li class="{{ 'nav-item active' if active_page == 'admin_global_search' else 'nav-item' }}">
<a href="{{ url_for('admin.global_search') }}" class="nav-link">
<i class="nav-icon fa-solid fa-search"></i>
<p>Global Search</p>
</a>
</li>
{% if SETTING.get('allow_user_create_domain') or current_user.role.name in ['Administrator', 'Operator'] %}
<li class="{{ 'nav-item active' if active_page == 'nav-item new_domain' else 'nav-item' }}">
<a href="{{ url_for('domain.add') }}" class="nav-link">
@ -109,6 +103,12 @@
{% endif %}
{% if current_user.role.name in ['Administrator', 'Operator'] %}
<li class="nav-header">Administration</li>
<li class="{{ 'nav-item active' if active_page == 'admin_global_search' else 'nav-item' }}">
<a href="{{ url_for('admin.global_search') }}" class="nav-link">
<i class="nav-icon fa-solid fa-search"></i>
<p>Global Search</p>
</a>
</li>
<li class="{{ 'nav-item active' if active_page == 'server_statistics' else 'nav-item' }}">
<a href="{{ url_for('admin.server_statistics') }}" class="nav-link">
<i class="nav-icon fa-solid fa-chart-simple"></i>

View File

@ -21,144 +21,9 @@
</div>
{% endblock %}
{% import 'applied_change_macro.html' as applied_change_macro %}
{% block content %}
<section class="content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card card-outline card-secondary shadow">
<div class="card-header">
<h3 class="card-title">Statistics</h3>
</div>
<!-- /.card-header -->
<div class="card-body">
<div class="row">
<div class="col-6 col-sm-3">
<div class="small-box bg-info">
<div class="inner">
<h3>{{ domain_count }}</h3>
<p>{% if domain_count > 1 %}Domains{% else %}Domain{% endif %}</p>
</div>
<div class="icon">
<i class="fa-solid fa-book"></i>
</div>
</div>
</div>
<div class="col-6 col-sm-3">
<a href="{{ url_for('admin.history') }}">
<div class="small-box bg-green">
<div class="inner">
<h3>{{ history_number }}</h3>
<p>{% if history_number > 1 %}Histories{% else %}
History{% endif %}</p>
</div>
<div class="icon">
<i class="fa-solid fa-calendar"></i>
</div>
</div>
</a>
</div>
{% if current_user.role.name in ['Administrator', 'Operator'] %}
<div class="col-6 col-sm-3">
<a href="{{ url_for('admin.manage_user') }}">
<div class="small-box bg-green">
<div class="inner">
<h3>{{ user_num }}</h3>
<p>{% if user_num > 1 %}Users{% else %}User{% endif %}</p>
</div>
<div class="icon">
<i class="fa-solid fa-users"></i>
</div>
</div>
</a>
</div>
<div class="col-6 col-sm-3">
<a href="{{ url_for('admin.server_statistics') }}">
<div class="small-box bg-green">
<div class="inner">
<h3><span
style="font-size: 18px">{{ uptime|display_second_to_time }}</span>
</h3>
<p>Uptime</p>
</div>
<div class="icon">
<i class="fa-solid fa-clock"></i>
</div>
</div>
</a>
</div>
{% endif %}
</div>
<!-- /.row -->
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
{% if current_user.role.name in ['Administrator', 'Operator'] or SETTING.get('allow_user_view_history') %}
<div class="row">
<div class="col-12">
<div class="card card-outline card-secondary shadow">
<div class="card-header">
<h3 class="card-title">Recent Activity</h3>
</div>
<!-- /.card-header -->
<div class="card-body table-responsive records p-0">
<table class="table table-striped table-hover table-sm records">
<thead>
<tr>
<th>Log Message</th>
<th>Timestamp</th>
<th>User</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for history in histories %}
<tr class="odd">
<td>{{ history.history.msg }}</td>
<td>{{ history.history.created_on | format_datetime_local }}</td>
<td>{{ history.history.created_by }}</td>
<td>
<div id="history-info-div-{{ loop.index0 }}" style="display: none;">
{{ history.detailed_msg | safe }}
{% if history.change_set %}
<div class="content">
<div id="change_index_definition"></div>
{% call applied_change_macro.applied_change_template(history.change_set) %}
{% endcall %}
</div>
{% endif %}
</div>
<button type="button" class="btn btn-sm btn-primary history-info-button"
title="View Additional Information"
{% if history.detailed_msg == "" and history.change_set is none %}
style="visibility: hidden;"
{% endif %} value="{{ loop.index0 }}">
<i class="fa-solid fa-info-circle"></i>
</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
{% endif %}
<div class="row">
<div class="col-12">
<div class="card card-outline card-primary shadow">