Skip to content

Commit

Permalink
Merge branch 'master' of github.com:NikolasE/hackdaysBW_TeamAwesome
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolas Engelhard committed Oct 18, 2020
2 parents d08b247 + d1faecf commit 5b2714c
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 31 deletions.
14 changes: 9 additions & 5 deletions app/auto-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ set -eux
trap "exit" INT TERM ERR
trap "kill 0" EXIT

./main.py &
SERVER_PID=$!
sudo -v

export GOOGLE_APPLICATION_CREDENTIALS="/home/ubuntu/key"

sudo -H -E bash -c './main.py &'

while true; do
git fetch
Expand All @@ -19,11 +22,12 @@ while true; do
git stash
git pull --rebase
git stash pop
kill $SERVER_PID || true
./main.py &

sudo killall python3 # lol
sudo -H -E bash -c './main.py &'
SERVER_PID=$!
fi

sleep 5
sudo -v
done
66 changes: 43 additions & 23 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,27 @@ class UserData:
0: UserData([]),
}

pizzas = [
{'id': "0116393", 'price': '1.44', 'text': 'Wagner Steinofen', 'url': '/static/wagner.jpeg'},
{'id': '0007873', 'price': '1.93', 'text': 'kinder bueno', 'url': '/static/kinder_bueno.jpeg'},
{'id': '0000305', 'price': '1.92', 'text': 'kinder Country', 'url': '/static/kinder_country.jpeg'},
{'id': '0119704', 'price': '1.32', 'text': 'Bellona', 'url': '/static/bellona.jpeg'},
{'id': '0001847', 'price': '2.22', 'text': 'kinder Überraschung', 'url': '/static/kinder_suprise.jpeg'},
{'id': '0003376', 'price': '1.73', 'text': 'Balisto', 'url': '/static/balisto.jpeg'},
{'id': '0136673', 'price': '3.21', 'text': 'Koelln Muesli', 'url': '/static/koelln.jpeg'},
{'id': '0003430', 'price': '0.58', 'text': 'Jodsalz', 'url': '/static/jodsalz.jpeg'},
{'id': '0047627', 'price': '1.56', 'text': 'Pickup', 'url': '/static/pickup.jpeg'},
{'id': '0001375', 'price': '1.95', 'text': 'Pizza Linsencurry', 'url': '/static/pizza2.jpg'},
{'id': '0034957', 'price': '1.87', 'text': 'Calabrese Style', 'url': '/static/pizza3.jpg'},
{'id': '0057475', 'price': '2.57', 'text': 'La Mia Grande', 'url': '/static/pizza4.jpg'},
{'id': '0098066', 'price': '2.12', 'text': 'Pizza Vegetale', 'url': '/static/pizza5.jpg'},
{'id': '0122344', 'price': '1.98', 'text': 'Papa tonis', 'url': '/static/pizza1.jpg'},
{'id': '0410170', 'price': '0.79', 'text': 'Hefe', 'url': '/static/hefe.jpg'},
{'id': '0212833', 'price': '7.43', 'text': 'Formil activ', 'url': '/static/formil.png'},
{'id': '0826492', 'price': '2.46', 'text': 'Fleischwurst', 'url': '/static/fleischwurst.png'},
{'id': '0926460', 'price': '1.23', 'text': 'Vollmilch', 'url': '/static/milch.png'},
{'id': '0173628', 'price': '2.50', 'text': 'Tomaten', 'url': '/static/tomaten.jpg'}
]

### STATIC FLASK PART ###
@app.route('/')
Expand All @@ -108,27 +129,7 @@ def main():

total_price=0
# IDs correspond to the ones in `product_locations`
pizzas = [
{'id': "0116393",'price': '1.44', 'text': 'Wagner Steinofen', 'url': '/static/wagner.jpeg'},
{'id': '0007873', 'price': '1.93', 'text': 'kinder bueno', 'url': '/static/kinder_bueno.jpeg'},
{'id': '0000305', 'price': '1.92', 'text': 'kinder Country', 'url': '/static/kinder_country.jpeg'},
{'id': '0119704', 'price': '1.32', 'text': 'Bellona', 'url': '/static/bellona.jpeg'},
{'id': '0001847', 'price': '2.22', 'text': 'kinder Überraschung', 'url': '/static/kinder_suprise.jpeg'},
{'id': '0003376', 'price': '1.73', 'text': 'Balisto', 'url': '/static/balisto.jpeg'},
{'id': '0136673', 'price': '3.21', 'text': 'Koelln Muesli', 'url': '/static/koelln.jpeg'},
{'id': '0003430', 'price': '0.58', 'text': 'Jodsalz', 'url': '/static/jodsalz.jpeg'},
{'id': '0047627', 'price': '1.56', 'text': 'Pickup', 'url': '/static/pickup.jpeg'},
{'id': '0001375', 'price': '1.95', 'text': 'Pizza Linsencurry', 'url': '/static/pizza2.jpg'},
{'id': '0034957', 'price': '1.87', 'text': 'Calabrese Style', 'url': '/static/pizza3.jpg'},
{'id': '0057475', 'price': '2.57', 'text': 'La Mia Grande', 'url': '/static/pizza4.jpg'},
{'id': '0098066', 'price': '2.12', 'text': 'Pizza Vegetale', 'url': '/static/pizza5.jpg'},
{'id': '0122344', 'price': '1.98', 'text': 'Papa tonis', 'url': '/static/pizza1.jpg'},
{'id': '0410170', 'price': '0.79', 'text': 'Hefe', 'url': '/static/hefe.jpg'},
{'id': '0212833', 'price': '7.43', 'text': 'Formil activ', 'url': '/static/formil.png'},
{'id': '0826492', 'price': '2.46', 'text': 'Fleischwurst', 'url': '/static/fleischwurst.png'},
{'id': '0926460', 'price': '1.23', 'text': 'Vollmilch', 'url': '/static/milch.png'},
{'id': '0173628', 'price': '2.50', 'text': 'Tomaten', 'url': '/static/tomaten.jpg'}
]


for counter, item in enumerate(pizzas):
if item['id'] in user_datas[user_id].einkaufszettel:
Expand Down Expand Up @@ -159,21 +160,40 @@ def _get_path_for_einkaufszettel(user_location):
def navigation():

user_location = request.args.get('user_location')
item_id = request.args.get('item_id')
if user_location is not None:
user_location = eval(user_location)
else:
user_location = (850, 60) # y,x

#remove item from shopping list if there ist one
if item_id is not None:
if item_id in user_datas[user_id].einkaufszettel:
user_datas[user_id].einkaufszettel.remove(item_id)

coin_list = [(440, 25), (210, 320)]

path_list, item_list = _get_path_for_einkaufszettel(user_location)
item_locations = [product_locations[id] for id in item_list if id not in ["_user", "_kasse"]]
print(item_locations)

print(item_list)
#GET DETAILS
for item in pizzas:
if item['id'] == item_list[1]:
item_name = item['text']
item_path = item['url']
item_price = item['price']

if len(item_locations) > 0:
redirect = '/navigation?user_location={}&item_id={}'.format(item_locations[0],item_list[1])
else:
redirect = '/'
item_name = "Finished"
item_path = ""
item_price = ""

svg = build_map(coin_list, user_location, item_locations, path_list)
return render_template('navigation.html', svg=svg, user_x = user_location[0], user_y= user_location[1])
return render_template('navigation.html', item_name = item_name, item_path=item_path, item_price=item_price, redirect=redirect, svg=svg, user_x = user_location[0], user_y= user_location[1])


@app.route('/startseite')
Expand Down
File renamed without changes
6 changes: 6 additions & 0 deletions app/static/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var socket = io.connect('https://localhost:8000/', { secure: true });
console.log("[+] Connected");

window.addEventListener("load", function() {
document.getElementById("overlay").style.display = "none";
rotateDirection(0);
window.scrollTo(0,document.body.scrollHeight);
});
Expand Down Expand Up @@ -50,3 +51,8 @@ function rotateDirection(deg) {
}
}

function gotonavigator(redirect) {
console.log("Go To Navigator");
document.getElementById("overlay").style.display = "block";
location.href = redirect;
}
45 changes: 42 additions & 3 deletions app/templates/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,27 @@
</head>

<body>
<div class="swatch-300" id="overlay"
style="display: none; position: fixed; bottom: 0; right: 0; display: block; z-index: 2; background-color: rgba(245, 245, 245, 0.7); width:100%; height:100%">
<div class="text-center">

<span style="position: relative; top: 15rem;">
<h1>Beste Route wird berechnet ...</h1>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="margin: auto; display: block;" width="200px" height="200px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
<circle cx="50" cy="50" r="32" stroke-width="8" stroke="#015aa2" stroke-dasharray="50.26548245743669 50.26548245743669" fill="none" stroke-linecap="round">
<animateTransform attributeName="transform" type="rotate" dur="1s" repeatCount="indefinite" keyTimes="0;1" values="0 50 50;360 50 50"></animateTransform>
</circle>
<circle cx="50" cy="50" r="23" stroke-width="8" stroke="#fff200" stroke-dasharray="36.12831551628262 36.12831551628262" stroke-dashoffset="36.12831551628262" fill="none" stroke-linecap="round">
<animateTransform attributeName="transform" type="rotate" dur="1s" repeatCount="indefinite" keyTimes="0;1" values="0 50 50;-360 50 50"></animateTransform>
</circle>
</svg>
</span>
</div>
</div>




<nav class="navbar sticky-top navbar-light">
<a class="navbar-brand" href="/">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-arrow-left" fill="currentColor"
Expand All @@ -25,6 +46,23 @@
</a>

</nav>

<nav class="navbar fixed-bottom swatch-200 text-center navbar-right" style="margin-bottom:80px; padding:10px" id="total_price">

<div class="row">
<div class="col-4" style="padding-top: 10px;">
<h4> {{ item_name }} </h4>
{{ item_price }} €
</div>
<div class="col-4 text-center" style="padding-top:10px;">
<img src="{{ item_path }}" width="100px">
</div>
<div class="col-4 text-center" style="padding-top:10px;">
<a class="btn btn-lg btn-primary" href="{{ redirect }}" onclick="gotonavigator()">Found</br>Buy</a>
</div>
</div>
</nav>

<nav class="navbar fixed-bottom navbar-dark bg-primary">

<a class="navbar-brand" href="/">
Expand All @@ -49,7 +87,7 @@
</a>
</nav>

<div class="container-fluid">
<div class="container-fluid" style="padding-bottom: 150px">
<div>
<svg id="svg-object" viewBox="0 0 460 1000" xmlns="http://www.w3.org/2000/svg">
<rect width="500" height="1000" style="fill:white;stroke-width:3;stroke:rgb(0,0,0)" />
Expand Down Expand Up @@ -172,9 +210,10 @@
{{ svg|safe }}
</svg>
</div>
<div id="user_x">{{ user_y }}</div>
<div id="user_y">{{ user_x }}</div>
<div style="display:none" id="user_x">{{ user_y }}</div>
<div style="display:none" id="user_y">{{ user_x }}</div>
</div>

</body>

</html>
31 changes: 31 additions & 0 deletions app/templates/phone.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<html>

<style>
.center {
margin: auto;
width: 360px;
border: 3px solid black;
background-color: black;
padding: 30px;
padding-bottom: 40px;
border-radius: 40px;
}
.dot {
height: 50px;
width: 50px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
}
</style>

<body>

<div class="center">
<iframe src="https://woistdiehefe.latai.de/" width = "360" height="740" title="W3Schools Free Online Web Tutorials"></iframe>
<center><div class="dot"></div></center>
</div>

</body>

</html>

0 comments on commit 5b2714c

Please sign in to comment.