mirror of
https://github.com/Steffo99/estus.git
synced 2024-11-21 23:24:18 +00:00
Add Network modify page + stability improvement
This commit is contained in:
parent
f7a97156ea
commit
6570989902
5 changed files with 52 additions and 17 deletions
24
server.py
24
server.py
|
@ -582,6 +582,11 @@ def page_net_add():
|
|||
if request.method == 'GET':
|
||||
return render_template("net/add.htm", type="net", user=session["username"])
|
||||
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"],
|
||||
primary_dns=request.form["primary_dns"], secondary_dns=request.form["secondary_dns"])
|
||||
db.session.add(nuovonet)
|
||||
|
@ -626,6 +631,25 @@ def page_net_details(nid):
|
|||
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')
|
||||
def page_user_list():
|
||||
"""Pagina di elenco degli utenti che possono connettersi al sito.
|
||||
|
|
|
@ -88,9 +88,7 @@
|
|||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<a href="/disp_show/{{ disp.did }}">
|
||||
<button type="button" class="btn btn-primary">
|
||||
<a href="/disp_show/{{ disp.did }}" class="btn btn-primary">
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Modifica
|
||||
</button>
|
||||
</a>
|
||||
{% endblock %}
|
|
@ -40,14 +40,10 @@
|
|||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<a href="/net_show/{{ net.nid }}">
|
||||
<button type="button" class="btn btn-primary">
|
||||
<a href="/net_show/{{ net.nid }}" class="btn btn-primary">
|
||||
<span class="glyphicon glyphicon-pencil"></span> Modifica
|
||||
</button>
|
||||
</a>
|
||||
<a href="/net_del/{{ net.nid }}">
|
||||
<button type="button" class="btn btn-danger">
|
||||
<a href="/net_del/{{ net.nid }}" class="btn btn-danger">
|
||||
<span class="glyphicon glyphicon-remove"></span> Elimina
|
||||
</button>
|
||||
</a>
|
||||
{% endblock %}
|
|
@ -14,16 +14,18 @@
|
|||
<th>Nome Rete</th>
|
||||
<th>IP</th>
|
||||
<th>Ispeziona</th>
|
||||
<th>Modifica</th>
|
||||
<th>Elimina</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
{% for rete in reti %}
|
||||
<tr>
|
||||
<td>{{ rete.nome }}</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>{% if reti|length > 2 %}<a href="/net_del/{{ rete.nid }}"><span class="glyphicon glyphicon-remove"></span></a>{% endif %}</td>
|
||||
{% endfor %}
|
||||
<td><a href="/net_show/{{ rete.nid }}"><span class="glyphicon glyphicon-pencil"></span></a></td>
|
||||
<td>{% if reti|length > 1 %}<a href="/net_del/{{ rete.nid }}"><span class="glyphicon glyphicon-remove"></span></a>{% endif %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
|
15
templates/net/show.htm
Normal file
15
templates/net/show.htm
Normal 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 %}
|
Loading…
Reference in a new issue