1
Fork 0
mirror of https://github.com/Steffo99/estus.git synced 2024-11-25 17:14:19 +00:00
estus/templates/dispositivo/show.htm

175 lines
8.7 KiB
HTML
Raw Normal View History

2017-09-12 10:50:28 +00:00
{% extends "base.htm" %}
2017-09-13 06:41:07 +00:00
{% block title %}Modifica dispositivo • estus{% endblock %}
2017-09-12 10:50:28 +00:00
{% 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>"
}
2017-09-12 10:50:28 +00:00
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");
}
}
}
2017-09-18 13:38:49 +00:00
function calchostname() {
var comune = prompt("Inserisci le due lettere corrispondenti al comune in cui verrà collocato il dispositivo. (Es: VG)");
if(comune === null) return;
2017-09-19 08:29:57 +00:00
var anno = $("#form-ordine").find(":selected").text().substring(2,4);
if(anno === "") anno = prompt("Inserisci l'anno d'acquisto del dispositivo. (Es: 17)");
if(anno === null) return;
2017-09-19 08:29:57 +00:00
var servizio = prompt("Inserisci le tre lettere corrispondenti al servizio di destinazione del dispositivo. (Es. SCU)");
if(servizio === null) return;
2017-09-18 13:38:49 +00:00
var inv = $("#form-ced").val();
if(inv === "") inv = prompt("Inserisci il numero dell'inventario del dispositivo. (Es: 0351)");
if(inv === null) return;
2017-09-18 13:38:49 +00:00
var proprietario = prompt("Inserisci la lettera corrispondente al proprietario del dispositivo. (Es: U)");
if(proprietario === null) return;
2017-09-19 08:29:57 +00:00
$("#form-hostname").val(comune + anno + servizio + inv.padStart(4, "0") + proprietario);
2017-09-18 13:38:49 +00:00
}
2017-09-18 14:15:44 +00:00
{% if dispositivo %}
window.onload = function () {
{% for accesso in accessi %}
adduser();
2017-09-19 15:36:44 +00:00
$("#utente{{ loop.index - 1 }} option").prop("selected", false);
$("#utente{{ loop.index - 1 }} option[value={{ accesso.iid }}]").prop("selected", true);
2017-09-18 14:15:44 +00:00
{% endfor %}
2017-09-19 06:42:52 +00:00
};
2017-09-18 14:15:44 +00:00
{% endif %}
2017-09-12 10:50:28 +00:00
</script>
{% endblock %}
{% block content %}
2017-09-20 10:01:07 +00:00
<div class="page-header">
<h1>
{% if action == "add" %}
Crea dispositivo
{% elif action == "show" %}
Modifica dispositivo
{% elif action == "clone" %}
Clona dispositivo
{% endif %}
</h1>
</div>
<div class="alert alert-info">
Sapevi che puoi fare doppio click sui campi con <b>[...]</b> per attivare il completamento automatico?
</div>
2017-09-22 06:29:20 +00:00
<form class="form-horizontal" method="post">
2017-09-12 10:50:28 +00:00
<div class="form-group">
2017-09-18 14:15:44 +00:00
<label class="col-xs-2" for="form-tipo">Tipo dispositivo</label>
2017-09-12 10:50:28 +00:00
<div class="col-xs-10">
2017-09-20 10:31:54 +00:00
<input type="text" class="form-control" placeholder="Tipo dispositivo [...]" name="tipo" list="form-tipo" {% if dispositivo %}value="{{ dispositivo.tipo }}"{% endif %}>
2017-09-21 06:38:48 +00:00
<datalist id="form-tipo">
2017-09-12 10:50:28 +00:00
{% for opzione in opzioni %}
2017-09-21 06:38:48 +00:00
<option value="{{ opzione.tipo }}">{{ opzione.tipo }}</option>
2017-09-12 10:50:28 +00:00
{% endfor %}
</datalist>
2017-09-12 10:50:28 +00:00
</div>
2017-09-18 14:07:04 +00:00
</div>
2017-09-19 08:29:57 +00:00
<div class="form-group">
<label class="col-xs-2" for="form-ordine">Ordine di appartenenza</label>
<div class="col-xs-10">
<select id="form-ordine" class="form-control" name="ordine">
<option value=""></option>
{% for ordine in ordini %}
<option value="{{ ordine.oid }}" {% if dispositivo and ordine.oid == dispositivo.oid %}selected{% endif %}>{{ ordine.data }} {{ ordine.fornitore }} #{{ ordine.numero_ordine }}</option>
2017-09-19 08:29:57 +00:00
{% endfor %}
</select>
</div>
</div>
2017-09-18 14:07:04 +00:00
<div class="form-group">
2017-09-19 06:42:52 +00:00
<label class="col-xs-2" for="form-so">Sistema operativo</label>
2017-09-18 14:07:04 +00:00
<div class="col-xs-10">
2017-09-20 10:31:54 +00:00
<input type="text" class="form-control" placeholder="Sistema operativo [...]" name="so" list="form-so" {% if dispositivo %}value="{{ dispositivo.so }}"{% endif %}>
<datalist id="form-so">
2017-09-18 14:07:04 +00:00
{% for sistema in sistemi %}
2017-09-21 06:38:48 +00:00
<option value="{{ sistema.so }}">{{ sistema.so }}</option>
2017-09-18 14:07:04 +00:00
{% endfor %}
</datalist>
2017-09-18 14:07:04 +00:00
</div>
2017-09-12 10:50:28 +00:00
</div>
<div class="form-group">
<label class="col-xs-2" for="form-utente">Utenti</label>
<div class="col-xs-10" id="users-column">
2017-09-18 08:18:31 +00:00
<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>
2017-09-12 10:50:28 +00:00
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-marca">Marca</label>
<div class="col-xs-10">
2017-09-18 14:15:44 +00:00
<input id="form-marca" class="form-control" type="text" placeholder="Marca" name="marca" {% if dispositivo %}value="{{ dispositivo.marca }}"{% endif %}>
2017-09-12 10:50:28 +00:00
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-modello">Modello</label>
<div class="col-xs-10">
2017-09-18 14:15:44 +00:00
<input id="form-modello" class="form-control" type="text" placeholder="Modello" name="modello" {% if dispositivo %}value="{{ dispositivo.modello }}"{% endif %}>
2017-09-12 10:50:28 +00:00
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-ced">Inventario CED</label>
<div class="col-xs-10">
2017-09-18 14:15:44 +00:00
<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 %}>
2017-09-12 10:50:28 +00:00
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-ente">Inventario ente</label>
<div class="col-xs-10">
2017-09-18 14:15:44 +00:00
<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 %}>
2017-09-12 10:50:28 +00:00
</div>
</div>
<div class="form-group">
<label class="col-xs-2" for="form-seriale">Numero Seriale</label>
<div class="col-xs-10">
2017-09-20 10:08:48 +00:00
<input id="form-seriale" class="form-control" type="text" placeholder="Seriale" name="seriale" {% if dispositivo and dispositivo.seriale %}value="{{ dispositivo.seriale }}"{% elif request.args.get("scanned_barcode") %}value="{{ request.args.get('scanned_barcode') }}"{% endif %}>
2017-09-12 10:50:28 +00:00
</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 %}
2017-09-22 06:37:36 +00:00
<option value="{{ rete.nid }}" {% if (dispositivo and rete.nid == dispositivo.nid) or (action == "add" and rete.network_ip == "0.0.0.0") %}selected{% endif %}>{{ rete.nome }} - {{ rete.network_ip }}/{{ rete.subnet }}</option>
2017-09-12 10:50:28 +00:00
{% endfor %}
</select>
</div>
</div>
<div class="form-group">
2017-09-18 13:38:49 +00:00
<label class="col-xs-2" for="form-ip">IP</label>
2017-09-12 10:50:28 +00:00
<div class="col-xs-10">
2017-09-18 14:15:44 +00:00
<input id="form-ip" class="form-control" type="text" placeholder="Indirizzo IP" name="ip" {% if dispositivo %}value="{{ dispositivo.ip }}"{% endif %}>
2017-09-12 10:50:28 +00:00
</div>
</div>
<div class="form-group">
2017-09-18 13:38:49 +00:00
<label class="col-xs-2" for="form-ip">Hostname</label>
<div class="col-xs-8">
2017-09-20 10:08:48 +00:00
<input id="form-hostname" class="form-control" type="text" placeholder="Hostname" name="hostname" {% if dispositivo and dispositivo.hostname %}value="{{ dispositivo.hostname }}"{% endif %}>
2017-09-18 13:38:49 +00:00
</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">
2017-09-18 13:38:49 +00:00
<input class="form-control btn btn-primary" type="submit">
</div>
</div>
2017-09-12 10:50:28 +00:00
</form>
{% endblock %}