Added time to unlock display

master
Jared 8 years ago
parent b726139474
commit 0f499d3ae9

@ -35,7 +35,14 @@ def help():
@app.route('/status')
@requires_auth
def status():
return render_template('status.html')
locked = False
t = 0
with open('locked_till.txt', 'rb') as f:
txt = f.read()
t = float(txt)
locked = time.time() < t
timestring = time.strftime('%Y-%m-%d %H:%M:%S %Z', time.localtime(t))
return render_template('status.html', locked=locked, timestring=timestring)
@app.route('/lock-fridge/<duration>')
@requires_auth
@ -49,7 +56,7 @@ def lock_fridge(duration):
def unlock_fridge():
with open('locked_till.txt', 'wb') as f:
f.write('0')
return '{"success":true}'
return redirect(url_for('status'))
@app.route('/open/<what>')
@requires_auth

@ -139,6 +139,6 @@ function lock_fridge() {
if (isNaN(period))
return;
$.getJSON('http://130.237.3.207/lock-fridge/' + period, function(data) {
location.reload()
});
}

@ -242,6 +242,14 @@ p {
color: #013A3A;
}
.locked_till {
color: #f48158;
font-size: 10pt;
padding: 0;
text-align: center;
width: 100%;
}
ul.mail-list {
padding-left: 50pt;
}

@ -26,8 +26,9 @@
<a href="/open/tools"><div class="big-button">Open tools</div></a>
<br>
<div class="disable-lock">
<a href="#"><div class="big-button" onclick="lock_fridge()">Lock</div></a>
<a href="{% if locked %}/unlock-fridge{% else %}#{% endif %}" {% if locked %}class="locked"{% endif %}><div class="big-button" {% if not locked %}onclick="lock_fridge()"{% endif %}>{% if locked %}Unlock{% else %}Lock{% endif %}</div></a>
<input type="text" name="period" placeholder="Duration (h)" id="period" class="duration-input">
{% if locked %}<p class="locked_till">The fridge will be locked until {{ timestring }}</p>{% endif %}
</div>
</div>
<div class="shadow" onclick="overlay_out()"></div>

Loading…
Cancel
Save