diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html index cc8609d..b57e6fa 100644 --- a/app/templates/dashboard.html +++ b/app/templates/dashboard.html @@ -31,8 +31,8 @@
-

###

-

Domains

+

{{ domains|length }}

+

{% if domains|length > 1 %}Domains{% else %}Domain{% endif %}

@@ -43,8 +43,8 @@
-

###

-

Users

+

{{ users|length }}

+

{% if users|length > 1 %}Users{% else %}User{% endif %}

@@ -57,8 +57,8 @@
-

###

-

Histories

+

{{ history_number }}

+

{% if history_number > 1 %}Histories{% else %}History{% endif %}

@@ -69,7 +69,7 @@
-

2W 2D 14h 13m

+

{{ uptime|display_second_to_time }}

Uptime

diff --git a/app/views.py b/app/views.py index bee83ff..a297059 100644 --- a/app/views.py +++ b/app/views.py @@ -135,7 +135,17 @@ def dashboard(): else: domains = User(id=current_user.id).get_domain() - return render_template('dashboard.html', domains=domains) + # stats for dashboard + domains = Domain.query.all() + users = User.query.all() + history_number = History.query.count() + server = Server(server_id='localhost') + statistics = server.get_statistic() + if statistics: + uptime = filter(lambda uptime: uptime['name'] == 'uptime', statistics)[0]['value'] + else: + uptime = 0 + return render_template('dashboard.html', domains=domains, users=users, history_number=history_number, uptime=uptime) @app.route('/domain/', methods=['GET', 'POST'])