mirror of
https://github.com/Steffo99/estus.git
synced 2024-11-21 23:24:18 +00:00
Aggiunta la dashboard
This commit is contained in:
parent
01f6674da4
commit
02c8fa8c79
4 changed files with 72 additions and 14 deletions
12
server.py
12
server.py
|
@ -96,7 +96,15 @@ def page_login():
|
|||
|
||||
@app.route('/dashboard')
|
||||
def page_dashboard():
|
||||
return "Buongiornissimo {}".format(session['username'])
|
||||
enti = Ente.query.all()
|
||||
conteggioservizi = dict()
|
||||
for ente in enti:
|
||||
conteggioservizi[ente.nomeente] = Servizio.query.join(Ente).filter_by(eid=ente.eid).count()
|
||||
conteggioutenti = dict()
|
||||
for ente in enti:
|
||||
conteggioutenti[ente.nomeente] = Impiegato.query.join(Servizio).join(Ente).filter_by(eid=ente.eid).count()
|
||||
css = url_for("static", filename="style.css")
|
||||
return render_template("dashboard.html.j2", css=css, type="main", user=session["username"], conteggioutenti=conteggioutenti, conteggioservizi=conteggioservizi)
|
||||
|
||||
@app.route('/ente_add', methods=['GET', 'POST'])
|
||||
def page_ente_add():
|
||||
|
@ -104,7 +112,7 @@ def page_ente_add():
|
|||
return redirect(url_for('page_login'))
|
||||
if request.method == 'GET':
|
||||
css = url_for("static", filename="style.css")
|
||||
return render_template("ente/add.html.j2", css=css, type="ente")
|
||||
return render_template("ente/add.html.j2", css=css, type="ente", user=session["username"])
|
||||
else:
|
||||
nuovoent = Ente(request.form['nomeente'], request.form['nomebreveente'])
|
||||
db.session.add(nuovoent)
|
||||
|
|
43
templates/dashboard.html.j2
Normal file
43
templates/dashboard.html.j2
Normal file
|
@ -0,0 +1,43 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Elenco enti - Inventario</title>
|
||||
<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="{{css}}">
|
||||
</head>
|
||||
<body>
|
||||
{% include 'nav.html.j2' %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<h2>
|
||||
Servizi per ente
|
||||
</h2>
|
||||
<ul class="list-group">
|
||||
{% for ente in conteggioservizi %}
|
||||
<li class="list-group-item">
|
||||
{{ente}}
|
||||
<span class="badge">{{conteggioservizi[ente]}}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<h2>
|
||||
Utenti per ente
|
||||
</h2>
|
||||
<ul class="list-group">
|
||||
{% for ente in conteggioutenti %}
|
||||
<li class="list-group-item">
|
||||
{{ente}}
|
||||
<span class="badge">{{conteggioutenti[ente]}}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
Destra
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -5,6 +5,7 @@
|
|||
<link rel="stylesheet" href="{{css}}">
|
||||
</head>
|
||||
<body>
|
||||
{% include 'nav.html.j2' %}
|
||||
<div class="container">
|
||||
<h1>
|
||||
Login
|
||||
|
|
|
@ -1,18 +1,24 @@
|
|||
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand {% if type is equalto "main" %}active{% endif %}" href="/dashboard">Inventario</a>
|
||||
{% if user %}
|
||||
<a class="navbar-brand" href="/dashboard">Inventario</a>
|
||||
{% else %}
|
||||
<a class="navbar-brand active" href="/login">Inventario</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="{% if type is equalto "ente" %}active{% endif %}"><a href="/ente_list">Enti</a></li>
|
||||
<li class="{% if type is equalto "serv" %}active{% endif %}"><a href="/serv_list">Servizi</a></li>
|
||||
<li class="{% if type is equalto "imp" %}active{% endif %}"><a href="/imp_list">Impiegati</a></li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<p class="navbar-text">
|
||||
{{user}}
|
||||
</p>
|
||||
<a href="/login" class="btn btn-danger navbar-btn btn-right">Logout</a>
|
||||
</ul>
|
||||
{% if user %}
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="{% if type is equalto "ente" %}active{% endif %}"><a href="/ente_list">Enti</a></li>
|
||||
<li class="{% if type is equalto "serv" %}active{% endif %}"><a href="/serv_list">Servizi</a></li>
|
||||
<li class="{% if type is equalto "imp" %}active{% endif %}"><a href="/imp_list">Impiegati</a></li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<p class="navbar-text">
|
||||
{{user}}
|
||||
</p>
|
||||
<a href="/login" class="btn btn-danger navbar-btn btn-right">Logout</a>
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
</nav>
|
||||
|
|
Loading…
Reference in a new issue