Skip to content

Commit

Permalink
v0.2.1 adding remaining info to swapping.html
Browse files Browse the repository at this point in the history
  • Loading branch information
fjfricke committed Sep 10, 2018
1 parent 236add5 commit 6b374fa
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 10 deletions.
14 changes: 14 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions RPi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class GPIO:

def output(a,b):
pass
17 changes: 13 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
bar.drinks[3].create_version(shortname='single', ingredients=[bar.ingredients[5], bar.ingredients[6]], proportions=[30,70], glassize=200)
bar.save_config('config')
'''

'''BARTENDER2 SECTION END'''

bar = reload_config('config')
Expand Down Expand Up @@ -349,19 +349,27 @@ def submitDeleteVersion():

@app.route("/swapping")
def swapView(toast=""):
if request.method == 'GET':
toast = request.args.get('toast')
return render_template('/swapping.html', toast=toast, ingredients=bar.ingredients)

@app.route("/tools/swap", methods=['POST'])
@app.route("/tools/swap", methods=['GET','POST'])
def swapAction():
try:
iding = request.form.get('iding')
iding = "";
if request.method == 'POST':
iding = request.form.get('iding')
else:
iding = request.args.get('iding')

if iding == "":
raise Exception()

iding = int(iding)

bar.ingredients[iding].swapBottle()
bar.save_config('config')
return redirect(url_for('swapView', toast='Bottle refilled.'))
return swapView('Bottle refilled.')
except:
return swapView('Something went wrong..')
Expand Down Expand Up @@ -414,6 +422,7 @@ def startChrome():
driver.get("http://127.0.0.1:5000")

if __name__ == "__main__":
t = Thread(target=startChrome
t = Thread(target=startChrome)
t.start()
app.run(debug=False)
#app.run(host='192.168.0.77', port=5000, debug=False)
3 changes: 2 additions & 1 deletion bar.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import time
import sys
import RPi.GPIO as GPIO
#import RPi.GPIO as GPIO
from RPi import GPIO
import json
from threading import Thread
import traceback
Expand Down
Binary file added config/config.obj
Binary file not shown.
Binary file added static/pictures/munichmule.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/pictures/wodkacola.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 44 additions & 5 deletions templates/swapping.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

{% block content %}

<div class="container" id="detailView">
<div class="container">
<div class="row">
<div class="col s12">
<div class="col s12">{#
<div class="row">
<h3 class="header">Swap bottle</h3>
<form action="/tools/swap" enctype="multipart/form-data" method="post">
Expand All @@ -25,18 +25,57 @@ <h3 class="header">Swap bottle</h3>

</div>
</div>

#}
</div>

<div class="row">
<div class="col s12">
<h3 class="header">Swap bottle</h3>
</div>
<div class="collection">
{% for ingredient in ingredients %}
<a href="#modal{{ loop.index }}" class="collection-item black-text modal-trigger">
<span class="badge">
<div class="progress">
<div id="makeprogress" class="determinate black" style="width: {{ ingredient.remaining / ingredient.bottlesize * 100 }}%"></div>
</div>
</span>
<span class="badge">
{{ ingredient.remaining|round|int }} ml of {{ ingredient.bottlesize|round|int }} ml left
</span>

{{ ingredient.name }}
</a>
{% endfor %}
</div>
</div>
</div>

<!-- Modal Structure -->
{% for ingredient in ingredients %}
<div id="modal{{ loop.index }}" class="modal">
<div class="modal-content">
<h4>Swap {{ ingredient.name }}</h4>
<p>Do you want to swap {{ ingredient.name }}?</p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-close waves-effect waves-green btn-flat">Dismiss</a>
<a href="tools/swap?iding={{ loop.index-1 }}" class="modal-close waves-effect waves-green btn-flat">Swap bottle</a>
</div>
</div>
{% endfor %}

{% endblock content%}

{% block scripts%}
<script>

$(document).ready(function(){
var toast = '{{toast}}';
if (toast) M.toast({html: toast});
$('.modal').modal();
let toast = '{{toast}}';
if (toast){
if(toast != "None") M.toast({html: toast});
}
$('select').formSelect();
});

Expand Down

0 comments on commit 6b374fa

Please sign in to comment.