Show lease information in the IP page
This commit is contained in:
parent
7577e83915
commit
86641dcca5
3 changed files with 41 additions and 0 deletions
21
main.py
21
main.py
|
@ -438,12 +438,33 @@ def ip(last_byte):
|
|||
return redirect(url_for('ips'))
|
||||
else:
|
||||
ipmap = load_ips()
|
||||
leases = load_leases()
|
||||
lease = None
|
||||
try:
|
||||
if last_byte in leases:
|
||||
lease = leases[last_byte]
|
||||
today = time.localtime().tm_wday
|
||||
expiry_t = time.localtime(int(lease[0]))
|
||||
expiry_day = expiry_t.tm_wday
|
||||
expiry_hour = time.strftime("%I:%M %p", expiry_t)
|
||||
if today == expiry_day:
|
||||
lease[0] = "las " + expiry_hour
|
||||
elif (today + 1) % 7 == expiry_day:
|
||||
lease[0] = "ma\N{LATIN SMALL LETTER N WITH TILDE}ana a las " + expiry_hour
|
||||
else:
|
||||
lease[0] = time.strftime("%B %d, ", expiry_t) + expiry_hour
|
||||
except ValueError:
|
||||
pass
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
addr = "{}.{}".format(ipmap["prefix"], last_byte)
|
||||
return render_template(
|
||||
"ip.html",
|
||||
addr=addr,
|
||||
valid_colors=valid_colors,
|
||||
meta=ipmap[last_byte],
|
||||
lease=lease,
|
||||
)
|
||||
|
||||
@app.route("/logout")
|
||||
|
|
|
@ -111,6 +111,11 @@ span.leased {
|
|||
font-size: x-small;
|
||||
}
|
||||
|
||||
div.lease {
|
||||
color: #66bb6a;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
div.ips-cell.dhcp-pool {
|
||||
background-color: #bed;
|
||||
}
|
||||
|
|
|
@ -99,10 +99,25 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if lease %}
|
||||
<div class="form-group">
|
||||
<div class="col-xs-12">
|
||||
<div class="lease">
|
||||
<i class="fa fa-circle"></i>
|
||||
Otorgado a {{ lease[1] }}
|
||||
{% if lease[3] != "*" %} ({{ lease[3] }}) {% endif %}<br>
|
||||
<i class="fa fa-circle" style="visibility: hidden;"></i>
|
||||
hasta {{ lease[0] }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if create_error %}
|
||||
<center>
|
||||
<p>Error: {{ errormsg }}</p>
|
||||
|
|
Loading…
Reference in a new issue