1
Fork 0
mirror of https://github.com/Steffo99/estus.git synced 2024-11-22 07:34:19 +00:00

Aggiunta la dashboard

This commit is contained in:
Steffo 2017-02-02 08:46:15 +01:00
parent 01f6674da4
commit 02c8fa8c79
4 changed files with 72 additions and 14 deletions

View file

@ -96,7 +96,15 @@ def page_login():
@app.route('/dashboard') @app.route('/dashboard')
def page_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']) @app.route('/ente_add', methods=['GET', 'POST'])
def page_ente_add(): def page_ente_add():
@ -104,7 +112,7 @@ def page_ente_add():
return redirect(url_for('page_login')) return redirect(url_for('page_login'))
if request.method == 'GET': if request.method == 'GET':
css = url_for("static", filename="style.css") 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: else:
nuovoent = Ente(request.form['nomeente'], request.form['nomebreveente']) nuovoent = Ente(request.form['nomeente'], request.form['nomebreveente'])
db.session.add(nuovoent) db.session.add(nuovoent)

View 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>

View file

@ -5,6 +5,7 @@
<link rel="stylesheet" href="{{css}}"> <link rel="stylesheet" href="{{css}}">
</head> </head>
<body> <body>
{% include 'nav.html.j2' %}
<div class="container"> <div class="container">
<h1> <h1>
Login Login

View file

@ -1,8 +1,13 @@
<nav class="navbar navbar-inverse navbar-fixed-top"> <nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid"> <div class="container-fluid">
<div class="navbar-header"> <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> </div>
{% if user %}
<ul class="nav navbar-nav"> <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 "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 "serv" %}active{% endif %}"><a href="/serv_list">Servizi</a></li>
@ -14,5 +19,6 @@
</p> </p>
<a href="/login" class="btn btn-danger navbar-btn btn-right">Logout</a> <a href="/login" class="btn btn-danger navbar-btn btn-right">Logout</a>
</ul> </ul>
{% endif %}
</div> </div>
</nav> </nav>