mirror of
https://github.com/DarkflameUniverse/NexusDashboard.git
synced 2024-11-22 05:27:25 +00:00
apeed up about page loading
add some neat info
This commit is contained in:
parent
37af644078
commit
f643f428ea
18
app/main.py
18
app/main.py
@ -4,6 +4,9 @@ from flask_user import current_user, login_required
|
|||||||
from app.models import Account, CharacterInfo, ActivityLog
|
from app.models import Account, CharacterInfo, ActivityLog
|
||||||
from app.schemas import AccountSchema, CharacterInfoSchema
|
from app.schemas import AccountSchema, CharacterInfoSchema
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import time
|
||||||
|
|
||||||
main_blueprint = Blueprint('main', __name__)
|
main_blueprint = Blueprint('main', __name__)
|
||||||
|
|
||||||
account_schema = AccountSchema()
|
account_schema = AccountSchema()
|
||||||
@ -30,10 +33,14 @@ def about():
|
|||||||
"""About Page"""
|
"""About Page"""
|
||||||
mods = Account.query.filter(Account.gm_level > 0).order_by(Account.gm_level.desc()).all()
|
mods = Account.query.filter(Account.gm_level > 0).order_by(Account.gm_level.desc()).all()
|
||||||
online = 0
|
online = 0
|
||||||
chars = CharacterInfo.query.all()
|
users = []
|
||||||
|
zones = {}
|
||||||
|
twodaysago = time.mktime((datetime.datetime.now() - datetime.timedelta(days=2)).timetuple())
|
||||||
|
chars = CharacterInfo.query.filter(CharacterInfo.last_login >= twodaysago).all()
|
||||||
|
|
||||||
for char in chars:
|
for char in chars:
|
||||||
last_log = ActivityLog.query.with_entities(
|
last_log = ActivityLog.query.with_entities(
|
||||||
ActivityLog.activity
|
ActivityLog.activity, ActivityLog.map_id
|
||||||
).filter(
|
).filter(
|
||||||
ActivityLog.character_id == char.id
|
ActivityLog.character_id == char.id
|
||||||
).order_by(ActivityLog.id.desc()).first()
|
).order_by(ActivityLog.id.desc()).first()
|
||||||
@ -41,8 +48,13 @@ def about():
|
|||||||
if last_log:
|
if last_log:
|
||||||
if last_log[0] == 0:
|
if last_log[0] == 0:
|
||||||
online += 1
|
online += 1
|
||||||
|
if current_user.gm_level >= 8: users.append([char.name, last_log[1]])
|
||||||
|
if str(last_log[1]) not in zones:
|
||||||
|
zones[str(last_log[1])] = 1
|
||||||
|
else:
|
||||||
|
zones[str(last_log[1])] += 1
|
||||||
|
|
||||||
return render_template('main/about.html.j2', mods=mods, online=online)
|
return render_template('main/about.html.j2', mods=mods, online=online, users=users, zones=zones)
|
||||||
|
|
||||||
|
|
||||||
@main_blueprint.route('/favicon.ico')
|
@main_blueprint.route('/favicon.ico')
|
||||||
|
@ -4,9 +4,47 @@
|
|||||||
|
|
||||||
{% block content_before %}
|
{% block content_before %}
|
||||||
Online Players: {{ online }}
|
Online Players: {{ online }}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
{# show general zone info to everyone #}
|
||||||
|
{% if zones %}
|
||||||
|
<div class='card mx-auto mt-5 shadow-sm bg-dark border-primary'>
|
||||||
|
<div class="card-body">
|
||||||
|
{% for zone, players in zones.items() %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col text-right">
|
||||||
|
{{ zone|get_zone_name }}
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
{{ players }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# only show this info to high level admina #}
|
||||||
|
{% if current_user.gm_level >= 8 and users|length > 0 %}
|
||||||
|
<div class='card mx-auto mt-5 shadow-sm bg-dark border-primary'>
|
||||||
|
<div class="card-body">
|
||||||
|
{% for user in users %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col text-right">
|
||||||
|
{{ user[0] }}
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
{{ user[1]|get_zone_name }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class='card mx-auto mt-5 shadow-sm bg-dark border-primary'>
|
<div class='card mx-auto mt-5 shadow-sm bg-dark border-primary'>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4 class="text-center">Staff</h4>
|
<h4 class="text-center">Staff</h4>
|
||||||
|
Loading…
Reference in New Issue
Block a user