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

Remove disp_add page

This commit is contained in:
Steffo 2017-09-18 16:15:44 +02:00 committed by Stefano Pigozzi
parent adc5d0dc15
commit cb05b5963b
3 changed files with 27 additions and 166 deletions

View file

@ -466,7 +466,7 @@ def page_disp_add():
"Windows NT", "Windows Vista", "Windows XP", "Debian", "Altro"] "Windows NT", "Windows Vista", "Windows XP", "Debian", "Altro"]
reti = Rete.query.order_by(Rete.nome).all() reti = Rete.query.order_by(Rete.nome).all()
impiegati = Impiegato.query.order_by(Impiegato.nomeimpiegato).all() impiegati = Impiegato.query.order_by(Impiegato.nomeimpiegato).all()
return render_template("dispositivo/add.htm", impiegati=impiegati, opzioni=opzioni, reti=reti, return render_template("dispositivo/show.htm", action="add", impiegati=impiegati, opzioni=opzioni, reti=reti,
pagetype="dev", user=session.get("username"), serial=serial, sistemi=sistemi) pagetype="dev", user=session.get("username"), serial=serial, sistemi=sistemi)
else: else:
if request.form["inv_ced"]: if request.form["inv_ced"]:

View file

@ -1,143 +0,0 @@
{% extends "base.htm" %}
{% block title %}Aggiungi dispositivo • estus{% endblock %}
{% block extrahead %}
<script>
var users = 0;
function genhtml(n) {
return "<select id=\"utente" + n + "\" class=\"form-control\" name=\"utente" + n + "\">{% for impiegato in impiegati %}<option value=\"{{impiegato.iid}}\">{{impiegato.nomeimpiegato}} - {{impiegato.username}}</option>{% endfor %}</select>"
}
function adduser() {
$("#users-column").append(genhtml(users));
users += 1;
$("#remove-user").removeClass("disabled");
}
function removeuser() {
if (users > 0) {
$("#utente" + (users - 1)).remove();
users -= 1;
if (users === 0) {
$("#remove-user").addClass("disabled");
}
}
}
function calchostname() {
var comune = prompt("Inserisci le due lettere corrispondenti al comune in cui verrà collocato il dispositivo. (Es: VG)");
var anno = prompt("Inserisci le ultime due cifre dell'anno di acquisto di questo dispositivo. (Es: 17)");
var servizio = prompt("Inserisci le tre lettere corrispondenti al servizio a cui è destinato questo PC. (Es: SCU)");
var inv = $("#form-ced").val();
if(inv === "")
{
inv = prompt("Inserisci il numero dell'inventario del dispositivo. (Es: 0351)");
}
var proprietario = prompt("Inserisci la lettera corrispondente al proprietario del dispositivo. (Es: U)");
$("#form-hostname").val(comune + anno + servizio + inv + proprietario);
}
</script>
{% endblock %}
{% block content %}
<h1>
Aggiungi 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="">Sistema Operativo</label>
<div class="col-xs-10">
<select id="form-so" class="form-control" name="so">
{% for sistema in sistemi %}
<option value="{{ sistema }}">{{ sistema }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-utente">Utenti</label>
<div class="col-xs-10" id="users-column">
<p>
<div id="add-user" class="btn btn-success" onclick="adduser()"><span class="glyphicon glyphicon-plus"></span></div>
<div id="remove-user" class="btn btn-danger disabled" onclick="removeuser()"><span class="glyphicon glyphicon-minus"></span></div>
</p>
</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-seriale">Numero Seriale</label>
<div class="col-xs-10">
<input id="form-seriale" class="form-control" type="text" placeholder="Seriale" name="seriale" {% if serial %}value="{{ serial }}"{% endif %}>
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="">Rete</label>
<div class="col-xs-10">
<select id="form-rete" class="form-control" name="rete">
{% for rete in reti %}
<option value="{{ rete.nid }}">{{ rete.nome }} - {{ rete.network_ip }}/{{ rete.subnet }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-ip">Indirizzo IP</label>
<div class="col-xs-10">
<input id="form-ip" class="form-control" type="text" placeholder="IP" name="ip">
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-ip">Hostname</label>
<div class="col-xs-8">
<input id="form-hostname" class="form-control" type="text" placeholder="Hostname" name="hostname">
</div>
<div class="col-xs-2">
<button class="form-control btn btn-info" onclick="calchostname()" type="button">Genera</button>
</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>
{% endblock %}

View file

@ -37,6 +37,7 @@
$("#form-hostname").val(comune + anno + inv + proprietario); $("#form-hostname").val(comune + anno + inv + proprietario);
} }
{% if dispositivo %}
window.onload = function () { window.onload = function () {
{% for accesso in accessi %} {% for accesso in accessi %}
adduser(); adduser();
@ -44,33 +45,36 @@
$("#utente{{ loop.index }} option[value={{ accesso.iid }}]").prop("selected", true); $("#utente{{ loop.index }} option[value={{ accesso.iid }}]").prop("selected", true);
{% endfor %} {% endfor %}
} }
{% endif %}
</script> </script>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<h1> <h1>
{% if action == "show" %} {% if action == "add" %}
Crea dispositivo
{% elif action == "show" %}
Modifica dispositivo Modifica dispositivo
{% elif action == "clone" %} {% elif action == "clone" %}
Clona dispositivo Clona dispositivo
{% endif %} {% endif %}
</h1> </h1>
<form class="form-horizontal" action="/disp_{{ action }}/{{ dispositivo.did }}" method="post"> <form class="form-horizontal" action="/disp_{{ action }}{% if dispositivo %}/{{ dispositivo.did }}{% endif %}" method="post">
<div class="form-group"> <div class="form-group">
<label class="col-xs-2" for="">Tipo dispositivo</label> <label class="col-xs-2" for="form-tipo">Tipo dispositivo</label>
<div class="col-xs-10"> <div class="col-xs-10">
<select id="form-tipo" class="form-control" name="tipo"> <select id="form-tipo" class="form-control" name="tipo">
{% for opzione in opzioni %} {% for opzione in opzioni %}
<option value="{{ opzione }}" {% if opzione == dispositivo.tipo %}selected{% endif %}>{{ opzione }}</option> <option value="{{ opzione }}" {% if dispositivo and opzione == dispositivo.tipo %}selected{% endif %}>{{ opzione }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-xs-2" for="">Sistema Operativo</label> <label class="col-xs-2" for="form-so">Sistema Operativo</label>
<div class="col-xs-10"> <div class="col-xs-10">
<select id="form-so" class="form-control" name="so"> <select id="form-so" class="form-control" name="so">
{% for sistema in sistemi %} {% for sistema in sistemi %}
<option value="{{ sistema }}" {% if sistema == dispositivo.so %}selected{% endif %}>{{ sistema }}</option> <option value="{{ sistema }}" {% if dispositivo and sistema == dispositivo.so %}selected{% endif %}>{{ sistema }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@ -87,37 +91,37 @@
<div class="form-group"> <div class="form-group">
<label class="col-xs-2" for="form-marca">Marca</label> <label class="col-xs-2" for="form-marca">Marca</label>
<div class="col-xs-10"> <div class="col-xs-10">
<input id="form-marca" class="form-control" type="text" placeholder="Marca" name="marca" value="{{ dispositivo.marca }}"> <input id="form-marca" class="form-control" type="text" placeholder="Marca" name="marca" {% if dispositivo %}value="{{ dispositivo.marca }}"{% endif %}>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-xs-2" for="form-modello">Modello</label> <label class="col-xs-2" for="form-modello">Modello</label>
<div class="col-xs-10"> <div class="col-xs-10">
<input id="form-modello" class="form-control" type="text" placeholder="Modello" name="modello" value="{{ dispositivo.modello }}"> <input id="form-modello" class="form-control" type="text" placeholder="Modello" name="modello" {% if dispositivo %}value="{{ dispositivo.modello }}"{% endif %}>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-xs-2" for="form-ced">Inventario CED</label> <label class="col-xs-2" for="form-ced">Inventario CED</label>
<div class="col-xs-10"> <div class="col-xs-10">
<input id="form-ced" class="form-control" type="text" placeholder="Inventario CED" name="inv_ced" {% if dispositivo.inv_ced %}value="{{ dispositivo.inv_ced }}"{% endif %}> <input id="form-ced" class="form-control" type="text" placeholder="Inventario CED" name="inv_ced" {% if dispositivo and dispositivo.inv_ced %}value="{{ dispositivo.inv_ced }}"{% endif %}>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-xs-2" for="form-ente">Inventario ente</label> <label class="col-xs-2" for="form-ente">Inventario ente</label>
<div class="col-xs-10"> <div class="col-xs-10">
<input id="form-ente" class="form-control" type="text" placeholder="Inventario ente" name="inv_ente" {% if dispositivo.inv_ente %}value="{{ dispositivo.inv_ente }}"{% endif %}> <input id="form-ente" class="form-control" type="text" placeholder="Inventario ente" name="inv_ente" {% if dispositivo and dispositivo.inv_ente %}value="{{ dispositivo.inv_ente }}"{% endif %}>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-xs-2" for="form-fornitore">Fornitore</label> <label class="col-xs-2" for="form-fornitore">Fornitore</label>
<div class="col-xs-10"> <div class="col-xs-10">
<input id="form-fornitore" class="form-control" type="text" placeholder="Fornitore" name="fornitore" value="{{ dispositivo.fornitore }}"> <input id="form-fornitore" class="form-control" type="text" placeholder="Fornitore" name="fornitore" {% if dispositivo %}value="{{ dispositivo.fornitore }}"{% endif %}>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-xs-2" for="form-seriale">Numero Seriale</label> <label class="col-xs-2" for="form-seriale">Numero Seriale</label>
<div class="col-xs-10"> <div class="col-xs-10">
<input id="form-seriale" class="form-control" type="text" placeholder="Seriale" name="seriale" value="{{ dispositivo.seriale }}"> <input id="form-seriale" class="form-control" type="text" placeholder="Seriale" name="seriale" {% if dispositivo %}value="{{ dispositivo.seriale }}"{% endif %}>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -125,7 +129,7 @@
<div class="col-xs-10"> <div class="col-xs-10">
<select id="form-rete" class="form-control" name="rete"> <select id="form-rete" class="form-control" name="rete">
{% for rete in reti %} {% for rete in reti %}
<option value="{{ rete.nid }}" {% if rete.nid == dispositivo.nid %}selected{% endif %}>{{ rete.nome }} - {{ rete.network_ip }}/{{ rete.subnet }}</option> <option value="{{ rete.nid }}" {% if dispositivo and rete.nid == dispositivo.nid %}selected{% endif %}>{{ rete.nome }} - {{ rete.network_ip }}/{{ rete.subnet }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@ -133,13 +137,13 @@
<div class="form-group"> <div class="form-group">
<label class="col-xs-2" for="form-ip">IP</label> <label class="col-xs-2" for="form-ip">IP</label>
<div class="col-xs-10"> <div class="col-xs-10">
<input id="form-ip" class="form-control" type="text" placeholder="Indirizzo IP" name="ip" value="{{ dispositivo.ip }}"> <input id="form-ip" class="form-control" type="text" placeholder="Indirizzo IP" name="ip" {% if dispositivo %}value="{{ dispositivo.ip }}"{% endif %}>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-xs-2" for="form-ip">Hostname</label> <label class="col-xs-2" for="form-ip">Hostname</label>
<div class="col-xs-8"> <div class="col-xs-8">
<input id="form-hostname" class="form-control" type="text" placeholder="Hostname" name="hostname"> <input id="form-hostname" class="form-control" type="text" placeholder="Hostname" name="hostname" {% if dispositivo %}value="{{ dispositivo.hostname }}"{% endif %}>
</div> </div>
<div class="col-xs-2"> <div class="col-xs-2">
<button class="form-control btn btn-info" onclick="calchostname()" type="button">Genera</button> <button class="form-control btn btn-info" onclick="calchostname()" type="button">Genera</button>