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

Add Network modify page + stability improvement

This commit is contained in:
Lorenzo 2017-09-13 11:36:20 +02:00 committed by Stefano
parent f7a97156ea
commit 6570989902
5 changed files with 52 additions and 17 deletions

View file

@ -582,6 +582,11 @@ def page_net_add():
if request.method == 'GET': if request.method == 'GET':
return render_template("net/add.htm", type="net", user=session["username"]) return render_template("net/add.htm", type="net", user=session["username"])
else: else:
try:
int(request.form["subnet"])
except ValueError:
return render_template("error.htm", error="Il campo Subnet deve contenere il numero di bit della subnet. "
"(8, 16, 24...)")
nuovonet = Rete(nome=request.form["nome"], network_ip=request.form["network_ip"], subnet=request.form["subnet"], nuovonet = Rete(nome=request.form["nome"], network_ip=request.form["network_ip"], subnet=request.form["subnet"],
primary_dns=request.form["primary_dns"], secondary_dns=request.form["secondary_dns"]) primary_dns=request.form["primary_dns"], secondary_dns=request.form["secondary_dns"])
db.session.add(nuovonet) db.session.add(nuovonet)
@ -626,6 +631,25 @@ def page_net_details(nid):
user=session["username"]) user=session["username"])
@app.route('/net_show/<int:nid>', methods=['GET', 'POST'])
def page_net_show(nid):
if 'username' not in session:
return abort(403)
if request.method == 'GET':
net = Rete.query.filter_by(nid=nid).first_or_404()
return render_template("net/show.htm", net=net, type="net", user=session["username"])
else:
net = Rete.query.filter_by(nid=nid).first_or_404()
net.nome = request.form['nome']
net.network_ip = request.form['network_ip']
net.subnet = request.form['subnet']
net.primary_dns = request.form['primary_dns']
net.secondary_dns = request.form['secondary_dns']
db.session.commit()
return redirect(url_for('page_net_list'))
@app.route('/user_list') @app.route('/user_list')
def page_user_list(): def page_user_list():
"""Pagina di elenco degli utenti che possono connettersi al sito. """Pagina di elenco degli utenti che possono connettersi al sito.

View file

@ -88,9 +88,7 @@
</div> </div>
</li> </li>
</ul> </ul>
<a href="/disp_show/{{ disp.did }}"> <a href="/disp_show/{{ disp.did }}" class="btn btn-primary">
<button type="button" class="btn btn-primary"> <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Modifica
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Modifica
</button>
</a> </a>
{% endblock %} {% endblock %}

View file

@ -40,14 +40,10 @@
</div> </div>
</li> </li>
</ul> </ul>
<a href="/net_show/{{ net.nid }}"> <a href="/net_show/{{ net.nid }}" class="btn btn-primary">
<button type="button" class="btn btn-primary"> <span class="glyphicon glyphicon-pencil"></span> Modifica
<span class="glyphicon glyphicon-pencil"></span> Modifica
</button>
</a> </a>
<a href="/net_del/{{ net.nid }}"> <a href="/net_del/{{ net.nid }}" class="btn btn-danger">
<button type="button" class="btn btn-danger"> <span class="glyphicon glyphicon-remove"></span> Elimina
<span class="glyphicon glyphicon-remove"></span> Elimina
</button>
</a> </a>
{% endblock %} {% endblock %}

View file

@ -14,16 +14,18 @@
<th>Nome Rete</th> <th>Nome Rete</th>
<th>IP</th> <th>IP</th>
<th>Ispeziona</th> <th>Ispeziona</th>
<th>Modifica</th>
<th>Elimina</th> <th>Elimina</th>
</tr> </tr>
</thead> </thead>
<tr> {% for rete in reti %}
{% for rete in reti %} <tr>
<td>{{ rete.nome }}</td> <td>{{ rete.nome }}</td>
<td>{{ rete.network_ip }}/{{ rete.subnet }}</td> <td>{{ rete.network_ip }}/{{ rete.subnet }}</td>
<td><a href="/net_details/{{ rete.nid }}"><span class="glyphicon glyphicon-list-alt"></span></a></td> <td><a href="/net_details/{{ rete.nid }}"><span class="glyphicon glyphicon-list-alt"></span></a></td>
<td>{% if reti|length > 2 %}<a href="/net_del/{{ rete.nid }}"><span class="glyphicon glyphicon-remove"></span></a>{% endif %}</td> <td><a href="/net_show/{{ rete.nid }}"><span class="glyphicon glyphicon-pencil"></span></a></td>
{% endfor %} <td>{% if reti|length > 1 %}<a href="/net_del/{{ rete.nid }}"><span class="glyphicon glyphicon-remove"></span></a>{% endif %}</td>
</tr> </tr>
{% endfor %}
</table> </table>
{% endblock %} {% endblock %}

15
templates/net/show.htm Normal file
View file

@ -0,0 +1,15 @@
{% extends "base.htm" %}
{% block title %}Aggiungi rete • estus{% endblock %}
{% block content %}
<h1>
Aggiungi nuova rete
</h1>
<form class="form-inline" action="/net_show/{{ net.nid }}" method="post">
<input class="form-control" type="text" placeholder="Nome rete" name="nome" value="{{ net.nome }}">
<input class="form-control" type="text" placeholder="Network IP" name="network_ip" value="{{ net.network_ip }}">
<input class="form-control" type="text" placeholder="Subnet mask" name="subnet" value="{{ net.subnet }}">
<input class="form-control" type="text" placeholder="DNS primario" name="primary_dns" value="{{ net.primary_dns }}">
<input class="form-control" type="text" placeholder="DNS secondario" name="secondary_dns" value="{{ net.secondary_dns }}">
<input class="btn btn-primary" type="submit">
</form>
{% endblock %}