From 46935b946ce9c703200297f49a85fd91fcef2998 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 18 Oct 2020 14:27:42 +0200 Subject: [PATCH 1/7] use sudo in auto deploy --- app/auto-deploy.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/auto-deploy.sh b/app/auto-deploy.sh index c270e5f..7401092 100755 --- a/app/auto-deploy.sh +++ b/app/auto-deploy.sh @@ -7,7 +7,7 @@ set -eux trap "exit" INT TERM ERR trap "kill 0" EXIT -./main.py & +sudo ./main.py & SERVER_PID=$! while true; do @@ -19,11 +19,12 @@ while true; do git stash git pull --rebase git stash pop - + kill $SERVER_PID || true - ./main.py & + sudo ./main.py & SERVER_PID=$! fi sleep 5 + sudo -v done From 4d75c03bd516f5699f90973a6e01f97b539e9a20 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 18 Oct 2020 14:29:54 +0200 Subject: [PATCH 2/7] autodeploy --- app/auto-deploy.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/auto-deploy.sh b/app/auto-deploy.sh index 7401092..aed8a98 100755 --- a/app/auto-deploy.sh +++ b/app/auto-deploy.sh @@ -7,7 +7,9 @@ set -eux trap "exit" INT TERM ERR trap "kill 0" EXIT -sudo ./main.py & +export GOOGLE_APPLICATION_CREDENTIALS="~/key" + +./main.py & SERVER_PID=$! while true; do @@ -20,11 +22,12 @@ while true; do git pull --rebase git stash pop + pip install -r requirements.txt + kill $SERVER_PID || true - sudo ./main.py & + ./main.py & SERVER_PID=$! fi sleep 5 - sudo -v done From 529c8046af43fb2d44b21aa7d38c507470aa1c31 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 18 Oct 2020 14:39:58 +0200 Subject: [PATCH 3/7] auto-deploy --- app/auto-deploy.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/auto-deploy.sh b/app/auto-deploy.sh index aed8a98..935edc5 100755 --- a/app/auto-deploy.sh +++ b/app/auto-deploy.sh @@ -7,10 +7,11 @@ set -eux trap "exit" INT TERM ERR trap "kill 0" EXIT +sudo -v + export GOOGLE_APPLICATION_CREDENTIALS="~/key" -./main.py & -SERVER_PID=$! +SERVER_PID=-1 while true; do git fetch @@ -22,12 +23,11 @@ while true; do git pull --rebase git stash pop - pip install -r requirements.txt - kill $SERVER_PID || true - ./main.py & + sudo -H -E bash -c './main.py &' SERVER_PID=$! fi sleep 5 + sudo -v done From ebfbf75f4182f9236c55b5a7bf45c9a2cefefb3d Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 18 Oct 2020 14:47:20 +0200 Subject: [PATCH 4/7] autodeploy --- app/auto-deploy.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/auto-deploy.sh b/app/auto-deploy.sh index 935edc5..3aac83a 100755 --- a/app/auto-deploy.sh +++ b/app/auto-deploy.sh @@ -9,9 +9,9 @@ trap "kill 0" EXIT sudo -v -export GOOGLE_APPLICATION_CREDENTIALS="~/key" +export GOOGLE_APPLICATION_CREDENTIALS="/home/ubuntu/key" -SERVER_PID=-1 +sudo -H -E bash -c './main.py &' while true; do git fetch @@ -23,7 +23,7 @@ while true; do git pull --rebase git stash pop - kill $SERVER_PID || true + sudo killall python3 # lol sudo -H -E bash -c './main.py &' SERVER_PID=$! fi From 0f24a6218269f976ab2675252a510eb893840578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20K=C3=B6nig?= Date: Sun, 18 Oct 2020 15:00:35 +0200 Subject: [PATCH 5/7] Product --- app/main.py | 66 +++++++++++++++++++++----------- {data => app/static}/galaxy.png | Bin app/static/navigation.js | 6 +++ app/templates/navigation.html | 40 +++++++++++++++++-- app/templates/phone.html | 31 +++++++++++++++ 5 files changed, 117 insertions(+), 26 deletions(-) rename {data => app/static}/galaxy.png (100%) create mode 100644 app/templates/phone.html diff --git a/app/main.py b/app/main.py index 5865698..d118626 100755 --- a/app/main.py +++ b/app/main.py @@ -96,6 +96,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('/') @@ -109,27 +130,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: @@ -160,21 +161,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') diff --git a/data/galaxy.png b/app/static/galaxy.png similarity index 100% rename from data/galaxy.png rename to app/static/galaxy.png diff --git a/app/static/navigation.js b/app/static/navigation.js index 57ab087..8884560 100644 --- a/app/static/navigation.js +++ b/app/static/navigation.js @@ -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); }); @@ -50,3 +51,8 @@ function rotateDirection(deg) { } } +function gotonavigator(redirect) { + console.log("Go To Navigator"); + document.getElementById("overlay").style.display = "block"; + location.href = redirect; +} diff --git a/app/templates/navigation.html b/app/templates/navigation.html index fe395ff..a2ba625 100644 --- a/app/templates/navigation.html +++ b/app/templates/navigation.html @@ -25,6 +25,23 @@ + + + -
+
@@ -172,8 +189,25 @@ {{ svg|safe }}
-
{{ user_y }}
-
{{ user_x }}
+ + +
+
+
+ + +

Beste Route wird berechnet ...

+ + + + + + + + +
+
diff --git a/app/templates/phone.html b/app/templates/phone.html new file mode 100644 index 0000000..cb0cf4e --- /dev/null +++ b/app/templates/phone.html @@ -0,0 +1,31 @@ + + + + + + +
+ +
+
+ + + + \ No newline at end of file From 5dbeedc7eade4a5e306339bfd73cc96d29f72cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20K=C3=B6nig?= Date: Sun, 18 Oct 2020 15:06:46 +0200 Subject: [PATCH 6/7] stuff --- app/templates/navigation.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/navigation.html b/app/templates/navigation.html index 829ef57..4fd5821 100644 --- a/app/templates/navigation.html +++ b/app/templates/navigation.html @@ -193,7 +193,7 @@

{{ item_name }}

+ 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%">
From d1faecf200211fc85726271ee458efe86e13e8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20K=C3=B6nig?= Date: Sun, 18 Oct 2020 15:09:25 +0200 Subject: [PATCH 7/7] stuff --- app/templates/navigation.html | 37 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/app/templates/navigation.html b/app/templates/navigation.html index 4fd5821..e5d532e 100644 --- a/app/templates/navigation.html +++ b/app/templates/navigation.html @@ -15,6 +15,27 @@ + + + + +
-