minor fixes

This commit is contained in:
Felix
2020-03-12 20:03:52 +01:00
parent 77379f5520
commit d3f71692a0
10 changed files with 130 additions and 42 deletions

View File

@@ -9,42 +9,24 @@ import json
import logging
import os
import datetime
import base64
class S(BaseHTTPRequestHandler):
def do_OPTIONS(self):
self.send_response(200, "ok")
# TODO remove in production
self.send_header('Access-Control-Allow-Origin', '*')
# TODO remove in production
self.send_header('Access-Control-Allow-Methods', 'GET, OPTIONS')
# TODO remove in production
self.send_header("Access-Control-Allow-Headers", "X-Requested-With")
# TODO remove in production
self.send_header("Access-Control-Allow-Headers", "Content-Type")
self.end_headers()
def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'application/json')
self.end_headers()
with open('schedule.json', 'r') as file:
with open('data/schedule.json', 'r') as file:
schedule_string = json.load(file)
self.wfile.write(json.dumps(schedule_string).encode('utf-8'))
def do_POST(self):
self.send_response(200, "ok")
# TODO remove in production
self.send_header('Access-Control-Allow-Origin', '*')
# TODO remove in production
self.send_header('Access-Control-Allow-Methods', 'GET, OPTIONS')
# TODO remove in production
self.send_header("Access-Control-Allow-Headers", "X-Requested-With")
# TODO remove in production
self.send_header("Access-Control-Allow-Headers", "Content-Type")
self.end_headers()
content_length = int(self.headers['Content-Length'])
request_raw = self.rfile.read(content_length)
request_content = json.loads(request_raw)
@@ -52,8 +34,9 @@ class S(BaseHTTPRequestHandler):
pw = request_content['pw']
caption = request_content['caption']
heading = request_content['heading']
image = request_content['image']
if pw != '123':
if pw != 'kurswerk':
self.send_response(401)
self.send_header('Content-Type', 'text/html')
self.end_headers()
@@ -65,13 +48,16 @@ class S(BaseHTTPRequestHandler):
schedule_and_caption['heading'] = heading
now = datetime.datetime.now()
try:
os.rename('schedule.json', 'schedule_{}.json'.format(now.strftime("%Y%m%d")))
os.rename('data/schedule.json', 'data/schedule_{}.json'.format(now.strftime("%Y%m%d")))
except Exception:
logging.info('Backup exists, did not backup..')
pass
with open('schedule.json', 'w') as file:
with open('data/schedule.json', 'w') as file:
json.dump(schedule_and_caption, file)
with open('data/schedule.jpg', 'wb') as f:
f.write(base64.b64decode(image))
self.send_response(200)
self.send_header('Content-Type', 'text/html')
self.end_headers()
@@ -96,4 +82,4 @@ if __name__ == '__main__':
if len(argv) == 2:
run(port=int(argv[1]))
else:
run()
run()

58
backend/nginx.conf Normal file
View File

@@ -0,0 +1,58 @@
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
disable_symlinks off;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
upstream backend {
server kurswerkstatt-pan_backend:8080;
}
server {
root /usr/share/nginx/html;
location /api/ {
proxy_read_timeout 300s;
proxy_connect_timeout 75s;
proxy_redirect off;
proxy_http_version 1.1;
proxy_pass http://backend;
proxy_set_header Host $host ;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
try_files $uri $uri/ /index.html;
}
}
include /etc/nginx/conf.d/*.conf;
}

BIN
data/schedule.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

1
data/schedule.json Normal file
View File

@@ -0,0 +1 @@
{"schedule": {"Montag": [{"from": "09:00", "to": "10:00", "title": "Pilates #"}, {}, {}, {"title": ""}, {"from": "", "to": "", "title": ""}, {}], "Dienstag": [{"from": "09:00", "to": "10:00", "title": "Fit f\u00fcr Dich\n(mit Julia)"}, {"from": "10:15", "to": "11:30", "title": "R\u00fcckbildung\n(mit Julia)"}, {}, {}, {}, {}], "Mittwoch": [{"from": "09:00", "to": "10:00", "title": "Babymassage\n(mit Julia)"}, {}, {}, {}, {"from": "17:30", "to": "18:30", "title": "Fit f\u00fcr Dich\n(mit Julia)"}, {}], "Donnerstag": [{"from": "09:00", "to": "10:15", "title": "R\u00fcckbildung \n(mit Julia)"}, {}, {}, {}, {"from": "18:15", "to": "19:45", "title": "Progressive \nMuskelentspannung \n(n. Jacobsen) \""}, {}], "Freitag": [{"from": "09:00", "to": "10:30", "title": "Still-\n und Elterntreff *\n(1x im Monat)"}, {}, {}, {}, {}, {}], "Samstag": [{}, {}, {}, {}, {}, {}]}, "caption": "# mit Physiotherapeutin Timea Sobotta\n\" mit Physiotherapeutin Felicitas Sch\u00f6nberger\n* mit Stillberaterin und Kinderkrankenschwester Rhianon Grill\n", "heading": "Stundenplan 2020"}

View File

@@ -0,0 +1 @@
{"schedule": {"Montag": [{"from": "09:00", "to": "10:15", "title": "Hatha Joga"}, {"from": "10:30", "to": "11:45", "title": "Joga f\u00fcr Schwangere"}, {}, {"title": ""}, {"from": "", "to": "", "title": ""}, {}], "Dienstag": [{}, {}, {"from": "15:30", "to": "16:30", "title": "Musikgarten"}, {"from": "18:00", "to": "19:30", "title": "Hatha/Vinjasa Yoga"}, {}, {}], "Mittwoch": [{"from": "09:00", "to": "10:15", "title": "R\u00fcckbildung"}, {"from": "10:30", "to": "11:30", "title": "Fit f\u00fcr Dich"}, {}, {}, {}, {}], "Donnerstag": [{"from": "09:00", "to": "10:00", "title": "Babymassage"}, {"from": "10:00", "to": "11:15", "title": "R\u00fcckbildung"}, {}, {}, {}, {}], "Freitag": [{"from": "09:00", "to": "10:30", "title": "Stilltreff * 2 w\u00f6chentlich"}, {}, {"from": "16:00", "to": "19:00", "title": "Geburtsvorbereitung"}, {}, {}, {}], "Samstag": [{"from": "09:00", "to": "12:00", "title": "Geburtsvorbereitung"}, {}, {}, {}, {}, {}]}, "caption": "* mit Stillberaterin und Kinderkrankenschwester Rhianon Grill\nf\u00fcr mehr Angebote rund um Mama/Baby www.stillberatungimrottal.de", "heading": "Stundenplan 2019"}

View File

@@ -0,0 +1 @@
{"schedule": {"Montag": [{"from": "09:00", "to": "10:15", "title": "Hatha Joga"}, {"from": "10:30", "to": "11:45", "title": "Joga f\u00fcr Schwangere"}, {}, {"title": ""}, {"from": "", "to": "", "title": ""}, {}], "Dienstag": [{}, {}, {"from": "15:30", "to": "16:30", "title": "Musikgarten"}, {"from": "18:00", "to": "19:30", "title": "Hatha/Vinjasa Yoga"}, {}, {}], "Mittwoch": [{"from": "09:00", "to": "10:15", "title": "R\u00fcckbildung"}, {"from": "10:30", "to": "11:30", "title": "Fit f\u00fcr Dich"}, {}, {}, {}, {}], "Donnerstag": [{"from": "09:00", "to": "10:00", "title": "Babymassage"}, {"from": "10:00", "to": "11:15", "title": "R\u00fcckbildung"}, {}, {}, {}, {}], "Freitag": [{"from": "09:00", "to": "10:30", "title": "Stilltreff * 2 w\u00f6chentlich"}, {}, {"from": "16:00", "to": "19:00", "title": "Geburtsvorbereitung"}, {}, {}, {}], "Samstag": [{"from": "09:00", "to": "12:00", "title": "Geburtsvorbereitung"}, {}, {}, {}, {}, {}]}, "caption": "* mit Stillberaterin und Kinderkrankenschwester Rhianon Grill\nf\u00fcr mehr Angebote rund um Mama/Baby www.stillberatungimrottal.de", "heading": "Stundenplan 2019"}

View File

@@ -0,0 +1 @@
{"schedule": {"Montag": [{"from": "09:00", "to": "10:15", "title": "Hatha Yoga"}, {"from": "10:30", "to": "11:45", "title": "Joga f\u00fcr Schwangere"}, {}, {"title": ""}, {"from": "", "to": "", "title": ""}, {}], "Dienstag": [{}, {}, {"from": "15:30", "to": "16:30", "title": "Musikgarten"}, {"from": "18:00", "to": "19:30", "title": "Hatha/Vinjasa Yoga"}, {}, {}], "Mittwoch": [{"from": "09:00", "to": "10:15", "title": "R\u00fcckbildung"}, {"from": "10:30", "to": "11:30", "title": "Fit f\u00fcr Dich"}, {}, {}, {}, {}], "Donnerstag": [{"from": "09:00", "to": "10:00", "title": "Babymassage"}, {"from": "10:00", "to": "11:15", "title": "R\u00fcckbildung"}, {}, {}, {}, {}], "Freitag": [{"from": "09:00", "to": "10:30", "title": "Stilltreff * 2 w\u00f6chentlich"}, {}, {"from": "16:00", "to": "19:00", "title": "Geburtsvorbereitung"}, {}, {}, {}], "Samstag": [{"from": "09:00", "to": "12:00", "title": "Geburtsvorbereitung"}, {}, {}, {}, {}, {}]}, "caption": "* mit Stillberaterin und Kinderkrankenschwester Rhianon Grill\nf\u00fcr mehr Angebote rund um Mama/Baby www.stillberatungimrottal.de", "heading": "Stundenplan 2019"}

View File

@@ -0,0 +1 @@
{"schedule": {"Montag": [{"from": "09:00", "to": "10:00", "title": "Pilates #"}, {}, {}, {"title": ""}, {"from": "", "to": "", "title": ""}, {}], "Dienstag": [{"from": "09:00", "to": "10:00", "title": "Fit f\u00fcr Dich\n(mit Julia)"}, {"from": "10:15", "to": "11:30", "title": "R\u00fcckbildung\n(mit Julia)"}, {}, {}, {}, {}], "Mittwoch": [{"from": "09:00", "to": "10:00", "title": "Babymassage\n(mit Julia)"}, {}, {}, {}, {"from": "17:30", "to": "18:30", "title": "Fit f\u00fcr Dich\n(mit Julia)"}, {}], "Donnerstag": [{"from": "09:00", "to": "10:15", "title": "R\u00fcckbildung \n(mit Julia)"}, {}, {}, {}, {"from": "18:15", "to": "19:45", "title": "Progressive \nMuskelentspannung \n(n. Jacobsen) \""}, {}], "Freitag": [{"from": "09:00", "to": "10:30", "title": "Still-\n und Elterntreff *\n(1x im Monat)"}, {}, {}, {}, {}, {}], "Samstag": [{}, {}, {}, {}, {}, {}]}, "caption": "# mit Physiotherapeutin Timea Sobotta\n\" mit Physiotherapeutin Felicitas Sch\u00f6nberger\n* mit Stillberaterin und Kinderkrankenschwester Rhianon Grill\n", "heading": "Stundenplan 2020"}

View File

@@ -196,7 +196,8 @@
<h4 class="text-center text-uppercase text-secondary mb-3">Stundenplan 2019</h4>
<br>
<div class="Image">
<img class="img-responsive100" src="img/portfolio/Stundenplan.jpg" alt="">
<!-- <img class="img-responsive100" src="img/portfolio/Stundenplan.jpg" alt="Stundenplan 2019"> -->
<img class="img-responsive100" src="data/schedule.jpg" alt="Stundenplan">
</div>
</section>
@@ -496,6 +497,12 @@
<!-- Custom scripts for this template -->
<script src="js/freelancer.min.js"></script>
<script>
$(function(){
$("#schedule-placeholder").load("view-schedule.html");
});
</script>
</body>
</html>

View File

@@ -1,10 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html>
<head>
<!-- development version, includes helpful console warnings -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script><!-- production version, optimized for size and speed -->
<!-- <script src="https://cdn.jsdelivr.net/npm/vue"></script>-->
<!-- development version, includes helpful console warnings -->
<!-- <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> -->
<!-- production version, optimized for size and speed -->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dom-to-image/2.6.0/dom-to-image.js"></script>
<title>Stundenplan Pflege</title>
@@ -12,6 +15,11 @@
#editmode table, th, td {
border: 1px solid black;
}
#edit-heading {
font-size: x-large;
padding-left: 30px;
}
#editmode input {
border: 0;
@@ -34,8 +42,9 @@
}
#readonly-heading {
font-size: x-large;
font-size: xx-large;
padding-left: 30px;
margin-top: 0;
}
#readonly-table {
@@ -97,7 +106,7 @@
<p style="text-align: center"><span style="white-space: pre-line;">{{caption}}</span></p>
</div>
<div id="editmode">
<input type="text"
<input id="edit-heading" type="text"
v-model="heading">
<table id="table"
ref="table"
@@ -121,7 +130,7 @@
v-model="getSchuduleItem(day, slot).to"></p>
<p id="item-title">
<textarea v-model="getSchuduleItem(day, slot).title"></textarea></p>
</div>Eingaben löschen
</div><input type="button" v-on:click="resetScheduleItem(day, slot)" value="Zurücksetzen">
</td>
</tr>
</table><input style="border: 1px solid black"
@@ -145,11 +154,30 @@
amountSlots: 6,
pw: "Passwort",
heading: "Stundenplan 2019",
caption: "* mit Stillberaterin und Kinderkrankenschwester Rhianon Grill\nf\u00fcr mehr Angebote rund um Mama/Baby www.stillberatungimrottal.de",
scheduleData:{"Montag": [{"from": "09:00", "to": "10:15", "title": "Hatha Joga"}, {"from": "10:30", "to": "11:45", "title": "Joga f\u00fcr Schwangere"}, {}, {"title": ""}, {"from": "", "to": "", "title": ""}, {}], "Dienstag": [{}, {}, {"from": "15:30", "to": "16:30", "title": "Musikgarten"}, {"from": "18:00", "to": "19:30", "title": "Hatha/Vinjasa Yoga"}, {}, {}], "Mittwoch": [{"from": "09:00", "to": "10:15", "title": "R\u00fcckbildung"}, {"from": "10:30", "to": "11:30", "title": "Fit f\u00fcr Dich"}, {}, {}, {}, {}], "Donnerstag": [{"from": "09:00", "to": "10:00", "title": "Babymassage"}, {"from": "10:00", "to": "11:15", "title": "R\u00fcckbildung"}, {}, {}, {}, {}], "Freitag": [{"from": "09:00", "to": "10:30", "title": "Stilltreff * 2 w\u00f6chentlich"}, {}, {"from": "16:00", "to": "19:00", "title": "Geburtsvorbereitung"}, {}, {}, {}], "Samstag": [{"from": "09:00", "to": "12:00", "title": "Geburtsvorbereitung"}, {}, {}, {}, {}, {}]}
caption: "* mit Stillberaterin und Kinderkrankenschwester Rhianon Grill\nfür mehr Angebote rund um Mama/Baby www.stillberatungimrottal.de",
scheduleData:{"Montag": [{"from": "09:00", "to": "10:15", "title": "Hatha Joga"}, {"from": "10:30", "to": "11:45", "title": "Joga für Schwangere"}, {}, {"title": ""}, {"from": "", "to": "", "title": ""}, {}], "Dienstag": [{}, {}, {"from": "15:30", "to": "16:30", "title": "Musikgarten"}, {"from": "18:00", "to": "19:30", "title": "Hatha/Vinjasa Yoga"}, {}, {}], "Mittwoch": [{"from": "09:00", "to": "10:15", "title": "Rückbildung"}, {"from": "10:30", "to": "11:30", "title": "Fit für Dich"}, {}, {}, {}, {}], "Donnerstag": [{"from": "09:00", "to": "10:00", "title": "Babymassage"}, {"from": "10:00", "to": "11:15", "title": "Rückbildung"}, {}, {}, {}, {}], "Freitag": [{"from": "09:00", "to": "10:30", "title": "Stilltreff * 2 wöchentlich"}, {}, {"from": "16:00", "to": "19:00", "title": "Geburtsvorbereitung"}, {}, {}, {}], "Samstag": [{"from": "09:00", "to": "12:00", "title": "Geburtsvorbereitung"}, {}, {}, {}, {}, {}]}
}
},
created() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (this.readyState != 4) return;
if (this.status == 200) {
var data = JSON.parse(this.response);
window.app.restoreSettings(data);
}
};
xhr.open("GET", "https://beta.kurswerkstatt-pan.de/api/schedule", true);
xhr.send();
},
methods: {
restoreSettings: function(data) {
this.scheduleData = data.schedule;
this.heading = data.heading;
this.caption = data.caption;
},
getSchuduleItem: function(day, slot) {
return this.scheduleData[day][slot-1];
},
@@ -161,21 +189,25 @@
saveSchedule: function() {
var xhr = new XMLHttpRequest();
// xhr.open("POST", "https://kurswerkstatt-pan.de/api/schedule", true);
xhr.open("POST", "http://localhost:8080", true);
xhr.open("POST", "https://beta.kurswerkstatt-pan.de/api/schedule", true);
xhr.setRequestHeader('Content-Type', 'application/html');
xhr.onload = function(e) {
alert("Gespeichert")
e.target.status === 200 ? alert("Gespeichert") : alert("Fehler: Falsches Passwort?")
}
xhr.onerror = function(e) {
alert("Fehler: \"Datei exportieren\"-Button klicken und Datei Felix schicken")
}
xhr.send(JSON.stringify({
pw: this.pw,
schedule: this.scheduleData,
caption: this.caption,
heading: this.heading
}));
domtoimage.toJpeg(document.getElementById('readonlydiv'), { quality: 0.95 })
.then((scheduleImage) => {
xhr.send(JSON.stringify({
pw: this.pw,
schedule: this.scheduleData,
caption: this.caption,
heading: this.heading,
image: scheduleImage.split(',')[1]
}));
})
},
scheduleToImage: function () {
domtoimage.toJpeg(document.getElementById('readonlydiv'), { quality: 0.95 })