templates: Make stilistic changes in dashboard

- Remove a table with redundant info; it was displaying server's stats,
  which was already in another table
- Add last update info at the top of the page
- Make page more robust by checking if ogLive images are available.

Before this patch, page shows a traceback if the ogLive list are not available.
master
Javier Hernandez 2024-01-03 11:29:24 +01:00 committed by OpenGnSys Support Team
parent 1497e500cb
commit b4856c9b27
2 changed files with 17 additions and 51 deletions

View File

@ -4,6 +4,7 @@
{% block content %}
<p class="text-left">Last update: {{ now }}</p>
<div class="row">
<div class="card col-12">
<table class="table">
@ -82,48 +83,6 @@
<div class="tab-pane {% if loop.first %}show active{% endif %}" id="{{ id }}" role="tabpanel">
<div class="row">
<div class="col-{{ colsize }}">
<ul class="list-group list-group-horizontal">
<li class="list-group-item w-50">
{{ _('Date') }}
</li>
<li class="list-group-item w-50">
<p class="card-text">{{ time_dict['now'] }}</p>
</li>
</ul>
<ul class="list-group list-group-horizontal">
<li class="list-group-item w-50">
{{ _('Uptime') }}
</li>
<li class="list-group-item w-50">
<p class="card-text">{{ time_dict['boot'] }}</p>
</li>
</ul>
<ul class="list-group list-group-horizontal">
<li class="list-group-item w-50">
{{ _('ogServer uptime') }}
</li>
<li class="list-group-item w-50">
<p class="card-text">{{ time_dict['start'] }}</p>
</li>
</ul>
<ul class="list-group list-group-horizontal">
<li class="list-group-item w-50">
{{ _('Connected clients (ogClient)') }}
</li>
<li class="list-group-item w-50">
<p class="card-text">{{ server.clients | length }}</p>
</li>
</ul>
<ul class="list-group list-group-horizontal">
<li class="list-group-item w-50">
{{ _('Number of images') }}
</li>
<li class="list-group-item w-50">
<p class="card-text">{{ images | length }}</p>
</li>
</ul>
</div>
<!-- disk stats -->
<div class="col-{{ colsize }}">
@ -263,14 +222,20 @@
{{ _('ogLive images') }}
</div>
<ul class="list-group">
{% for oglive in oglive_list['oglive'] %}
<li class="list-group-item">
{{ oglive['directory'] }}
{% if loop.index0 == oglive_list['default'] %}
({{ _('default') }})
{% endif %}
</li>
{% endfor %}
{% if oglive_list %}
{% for oglive in oglive_list['oglive'] %}
<li class="list-group-item">
{{ oglive['directory'] }}
{% if loop.index0 == oglive_list['default'] %}
({{ _('default') }})
{% endif %}
</li>
{% endfor %}
{% else %}
<li class="list-group-item">
No ogLive images available
</li>
{% endif %}
</ul>
</div>
</div>

View File

@ -380,7 +380,8 @@ def index():
server_id = i['server'].id
dashboard_servers[server_id]['clients'] = i['json']['clients']
return render_template('dashboard.html', servers=dashboard_servers, colsize="6")
now = timestamp.strftime('%Y-%m-%d %H:%M:%S')
return render_template('dashboard.html', servers=dashboard_servers, now=now, colsize="6")
@app.route('/login', methods=['GET', 'POST'])
def login():