Refactor template(s) for multiserver-display

* all virtual servers are now included in one single outputfile
* navbar for navigation between virtual servers
This commit is contained in:
Thor77 2016-11-22 22:59:57 +01:00
parent 4f77b2b6f3
commit 9a686f7a2f
2 changed files with 47 additions and 29 deletions

View File

@ -0,0 +1,35 @@
<html>
<head>
<title>{{ title }}</title>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css" integrity="sha256-7KczUWqIa/6KaIKtNfG18eilVQR4vJ4S9SSiDAplUwc=" crossorigin="anonymous">
<style type="text/css">
body {
padding-top: 50px;
}
</style>
</head>
<body>
<div class="container-fluid">
<nav class="navbar navbar-default navbar-fixed-top"><div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">{{ title }}</a>
</div>
<ul class="nav navbar-nav">
{% for sid, _ in servers %}
<li><a href="#sid{{ sid }}">Server {{ sid }}</a></li>
{% endfor %}
</ul>
{% if debug %}
<p class="navbar-text navbar-right" style="color: red; padding-right: 10px;">debug mode</p>
{% endif %}
</div></nav>
{% for server in servers %}
<h1 class="page-header" onclick="window.location = '#sid{{ server.sid }}'" id="sid{{ server.sid }}">Server {{ server.sid }}</h2>
{% include 'stats.jinja2' %}
{% endfor %}
<small>Generated by <a href="https://github.com/Thor77/TeamspeakStats">TeamspeakStats</a> at {{ creation_time|frmttime }}</small>
</div>
</body>
</html>

View File

@ -1,30 +1,17 @@
<html> {% set clients = server.clients %}
<head> {% for headline, clients in [
<title>{{ title }}</title> ('Onlinetime', clients.onlinetime),
<meta charset="utf-8"> ('Kicks', clients.kicks),
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> ('Passive kicks', clients.pkicks),
<link rel="stylesheet" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css" integrity="sha256-7KczUWqIa/6KaIKtNfG18eilVQR4vJ4S9SSiDAplUwc=" crossorigin="anonymous"> ('Bans', clients.bans),
<style type="text/css"> ('Passive bans', clients.pbans)
h1, p { ] %}
text-align: center; {% if clients|length > 0 %}
} {% set headline_id = [server.sid, headline|lower|replace(' ', '_')]|join('.') %}
</style>
</head>
<body>
<div class="container-fluid">
{% if debug %}
<div class="alert alert-danger" role="alert" style="text-align: center;">
<b>DEBUG</b>
</div>
{% endif %}
<h1 class="page-header">{{ title }}</h1>
{% for headline, list in objs %}
{% if list|length > 0 %}
{% set headline_id = headline|lower|replace(' ', '_') %}
<h2 onclick="window.location = '#{{ headline_id }}'">{{ headline }}</h2> <h2 onclick="window.location = '#{{ headline_id }}'">{{ headline }}</h2>
<ul class="list-group" id="{{ headline_id }}"> <ul class="list-group" id="{{ headline_id }}">
{% for client, value in list %} {% for client, value in clients %}
{% set id = headline_id + "." + client.nick %} {% set id = [headline_id, client.nick|striptags]|join('.') %}
<li id="{{ id }}" onclick="window.location = '#{{ id }}'" class="list-group-item{{ ' list-group-item-success' if client.connected else loop.cycle('" style="background-color: #eee;', '') }}"> <li id="{{ id }}" onclick="window.location = '#{{ id }}'" class="list-group-item{{ ' list-group-item-success' if client.connected else loop.cycle('" style="background-color: #eee;', '') }}">
<span {% if not client.connected %}class="hint--right" data-hint="{{ client.last_seen|frmttime }}"{% endif %}>{{ client.nick }}{{ " (" + client.identifier + ")" if debug }}</span> <span {% if not client.connected %}class="hint--right" data-hint="{{ client.last_seen|frmttime }}"{% endif %}>{{ client.nick }}{{ " (" + client.identifier + ")" if debug }}</span>
<span class="badge">{{ value }}</span> <span class="badge">{{ value }}</span>
@ -33,7 +20,3 @@
</ul> </ul>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<small>Generated by <a href="https://github.com/Thor77/TeamspeakStats">TeamspeakStats</a> at {{ creation_time|frmttime }}</small>
</div>
</body>
</html>