1
Fork 0
mirror of https://github.com/Steffo99/estus.git synced 2024-11-25 00:54:18 +00:00

Aggiunto elenco dispositivi (da finire)

This commit is contained in:
Lorenzo 2017-02-02 15:44:26 +01:00
parent 8df4826745
commit 0f929f58af
6 changed files with 258 additions and 4 deletions

View file

@ -78,8 +78,7 @@ class Dispositivo(db.Model):
inv_ente = db.Column(db.String(8))
fornitore = db.Column(db.String(64))
def __init__(self, did, tipo, marca, modello, inv_ced, inv_ente, fornitore):
self.did = did
def __init__(self, tipo, marca, modello, inv_ced, inv_ente, fornitore
self.tipo = tipo
self.marca = marca
self.modello = modello

View file

@ -79,8 +79,7 @@ class Dispositivo(db.Model):
inv_ente = db.Column(db.String(8))
fornitore = db.Column(db.String(64))
def __init__(self, did, tipo, marca, modello, inv_ced, inv_ente, fornitore):
self.did = did
def __init__(self, tipo, marca, modello, inv_ced, inv_ente, fornitore):
self.tipo = tipo
self.marca = marca
self.modello = modello
@ -313,3 +312,67 @@ def page_imp_show(iid):
imp.passwd = request.form["passwd"]
db.session.commit()
return redirect(url_for('page_imp_list'))
@app.route('/disp_add', methods=['GET', 'POST'])
def page_disp_add():
if 'username' not in session:
return redirect(url_for('page_login'))
if request.method == 'GET':
opzioni=["Centralino", "Dispositivo generico di rete", "Marcatempo", "PC", "Portatile", "POS", "Router", "Server", "Stampante di rete", "Switch", "Telefono IP", "Monitor", "Scanner", "Stampante locale"]
impiegati = Impiegato.query.all()
css = url_for("static", filename="style.css")
return render_template("dispositivo/add.html.j2", css=css, impiegati=impiegati,opzioni=opzioni, type="dev", user=session["username"])
else:
nuovodisp = Dispositivo(request.form['tipo'], request.form['marca'], request.form['modello'], request.form['inv_ced'], request.form['inv_ente'], request.form['fornitore'])
db.session.add(nuovodisp)
db.session.commit()
return redirect(url_for('page_disp_list'))
@app.route('/disp_del/<int:did>')
def page_disp_del(did):
if 'username' not in session:
return redirect(url_for('page_login'))
disp = Dispositivo.query.get(did)
db.session.delete(disp)
db.session.commit()
return redirect(url_for('page_disp_list'))
@app.route('/disp_list')
def page_disp_list():
if 'username' not in session:
return redirect(url_for('page_login'))
dispositivi = Dispositivo.query.all()
css = url_for("static", filename="style.css")
return render_template("dispositivo/list.html.j2", css=css, dispositivi=dispositivi, type="disp", user=session["username"])
@app.route('/disp_list/<int:did>')
def page_disp_list_plus(did):
if 'username' not in session:
return redirect(url_for('page_login'))
dispositivi = Dispositivo.query.all()
css = url_for("static", filename="style.css")
return render_template("dispositivo/list.html.j2", css=css, impiegati=impiegati, user=session["username"])
@app.route('/disp_show/<int:did>', methods=['GET', 'POST'])
def page_disp_show(did):
if 'username' not in session:
return redirect(url_for('page_login'))
if request.method == "GET":
opzioni = ["Centralino", "Dispositivo generico di rete", "Marcatempo", "PC", "Portatile", "POS", "Router", "Server", "Stampante di rete", "Switch", "Telefono IP", "Monitor", "Scanner", "Stampante locale"]
dev = Dispositivo.query.get(did)
css = url_for("static", filename="style.css")
return render_template("dispositivo/show.html.j2", css=css, dispositivo=dev, tipi=opzioni, user=session["username"])
else:
dev = Dispositivo.query.get(did)
dev.tipo = request.form["tipo"]
dev.marca = request.form["marca"]
dev.modello = request.form["modello"]
dev.inv_ced = request.form["inv_ced"]
dev.inv_ente = request.form["inv_ente"]
dev.fornitore = request.form["fornitore"]
db.session.commit()
return redirect(url_for('page_disp_list'))
@app.route('/details_host')
def page_details_host():
return "Non implementato"

View file

@ -0,0 +1,73 @@
<html>
<head>
<title>Aggiunta dispositivo - 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">
<h1>
Aggiunta nuovo dispositivo
</h1>
<form class="form-horizontal" action="/disp_add" method="post">
<div class="form-group">
<label class="col-xs-2" for="">Tipo dispositivo</label>
<div class="col-xs-10">
<select id="form-tipo" class="form-control" name="tipo">
{% for opzione in opzioni %}
<option value="{{opzione}}">{{opzione}}</option>
{% endfor %}
</select>
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-utente">Utenti</label>
<div class="col-xs-10">
<select id="form-utente" multiple class="form-control" name="utente">
{% for impiegato in impiegati %}
<option value="{{impiegato.iid}}">{{impiegato.nomeimpiegato}} - {{impiegato.username}}</option>
{% endfor %}
</select>
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-marca">Marca</label>
<div class="col-xs-10">
<input id="form-marca" class="form-control" type="text" placeholder="Marca" name="marca">
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-modello">Modello</label>
<div class="col-xs-10">
<input id="form-modello" class="form-control" type="text" placeholder="Modello" name="modello">
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-ced">Inventario CED</label>
<div class="col-xs-10">
<input id="form-ced" class="form-control" type="text" placeholder="Inventario CED" name="inv_ced">
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-ente">Inventario ente</label>
<div class="col-xs-10">
<input id="form-ente" class="form-control" type="text" placeholder="Inventario ente" name="inv_ente">
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-fornitore">Fornitore</label>
<div class="col-xs-10">
<input id="form-fornitore" class="form-control" type="text" placeholder="Fornitore" name="fornitore">
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-control"></label>
<div class="col-xs-10">
<input class="form-control btn btn-primary" type="submit">
</div>
</div>
</form>
</div>
</body>
</html>

View file

View file

@ -0,0 +1,46 @@
<html>
<head>
<title>Elenco dispositivi - 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">
<h1>
Dispositivi esistenti
</h1>
<table class="table table-hover">
<thead>
<tr>
<th>Tipo dispositivo</th>
<th>Utenti</th>
<th>Inventario CED</th>
<th>Inventario ente</th>
<th>Marca</th>
<th>Modello</th>
<th>Fornitore</th>
<th>Ispeziona</th>
<th>Modifica</th>
<th>Elimina</th>
</tr>
</thead>
{% for dispositivo in dispositivi %}
<tr>
<td>{{ dispositivo.tipo }}</td>
<td> ITS A FEATURE </td>
<td>{{ dispositivo.inv_ced }}</td>
<td>{{ dispositivo.inv_ente }}</td>
<td>{{ dispositivo.marca }}</td>
<td>{{ dispositivo.modello }}</td>
<td>{{ dispositivo.fornitore }}</td>
<td><a href="/details_host/{{ dispositivo.did }}"><span class="glyphicon glyphicon-list-alt"></span></a></td>
<td><a href="/disp_show/{{ dispositivo.did }}"><span class="glyphicon glyphicon-pencil"></span></a></td>
<td><a href="/disp_del/{{ dispositivo.did }}"><span class="glyphicon glyphicon-remove"></span></a></td>
</tr>
{% endfor %}
</table>
<a class="btn btn-success" href="/disp_add">Aggiungi</a>
</div>
</body>
</html>

View file

@ -0,0 +1,73 @@
<html>
<head>
<title>Modifica servizio - 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">
<h1>
Modifica servizio
</h1>
<form class="form-horizontal" action="/disp_show/{{dispositivo.did}}" method="post">
<div class="form-group">
<label class="col-xs-2" for="">Tipo dispositivo</label>
<div class="col-xs-10">
<select id="form-tipo" class="form-control" name="tipo">
{% for tipo in tipi %}
<option value="{{tipo}}"{% if tipo == dispositivo.tipo %}selected="selected"{% endif %}>{{tipo}}</option>
{% endfor %}
</select>
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-utente">Utenti</label>
<div class="col-xs-10">
<select id="form-utente" multiple class="form-control" name="utente">
{# {% for impiegato in impiegati %}
<option value="{{impiegato.iid}}"{% if i == dispositivo.tipo %}selected="selected"{% endif %}>{{impiegato.nomeimpiegato}} - {{impiegato.username}}</option>
{% endfor %} #}
</select>
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-marca">Marca</label>
<div class="col-xs-10">
<input id="form-marca" class="form-control" type="text" placeholder="Marca" name="marca" value="{{dispositivo.marca}}">
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-modello">Modello</label>
<div class="col-xs-10">
<input id="form-modello" class="form-control" type="text" placeholder="Modello" name="modello" value="{{dispositivo.modello}}">
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-ced">Inventario CED</label>
<div class="col-xs-10">
<input id="form-ced" class="form-control" type="text" placeholder="Inventario CED" name="inv_ced" value="{{dispositivo.inv_ced}}">
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-ente">Inventario ente</label>
<div class="col-xs-10">
<input id="form-ente" class="form-control" type="text" placeholder="Inventario ente" name="inv_ente" value="{{dispositivo.inv_ente}}">
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-fornitore">Fornitore</label>
<div class="col-xs-10">
<input id="form-fornitore" class="form-control" type="text" placeholder="Fornitore" name="fornitore" value="{{dispositivo.fornitore}}">
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-control"></label>
<div class="col-xs-10">
<input class="form-control btn btn-primary" type="submit">
</div>
</div>
</form>
</div>
</body>
</html>