This commit is contained in:
Anika 2024-03-04 22:22:58 +01:00
parent ed8fc409f8
commit 43bce4789c
6 changed files with 47 additions and 34 deletions

Binary file not shown.

View File

@ -1,14 +1,18 @@
[ [
{ {
"datetime": "05.04.2025 06:33", "datetime": "05.03.2024 21:16",
"message": "Test" "message": "lkjasdf"
}, },
{ {
"datetime": "05.04.2025 06:57", "datetime": "05.03.2024 21:16",
"message": "EEh" "message": "lkjasdf"
}, },
{ {
"datetime": "04.03.2024 18:40", "datetime": "05.03.2024 20:20",
"message": "PREVIOUS" "message": "gestern"
},
{
"datetime": "04.03.2024 23:22",
"message": "nachher"
} }
] ]

View File

@ -1,22 +1,10 @@
[ [
{ {
"datetime": "11.02.2024 22:58", "datetime": "04.03.2024 18:44",
"message": "Nice" "message": "j\u00f6lasdf"
}, },
{ {
"datetime": "12.02.2024 15:03", "datetime": "04.03.2024 18:44",
"message": "Lololol" "message": "lkjasdf"
},
{
"datetime": "22.02.2024 11:14",
"message": "Seitenschneider an Leon"
},
{
"datetime": "04.03.2024 13:02",
"message": "hkjaflksaflksafl kisafjdbsafdo\u00f6ijar\u00f6oirpijwfeij"
},
{
"datetime": "04.03.2024 18:02",
"message": "hdhdh"
} }
] ]

View File

@ -8,9 +8,14 @@
"log alarms"; "log alarms";
} }
div.datetime {
display: inline-block;
}
div.log { div.log {
grid-area: log; grid-area: log;
margin-bottom: 1cm; margin-bottom: 1cm;
margin-right: 2cm;
} }
div.alarms { div.alarms {
@ -22,6 +27,7 @@ div.savedLogs {
border-radius: 20px; border-radius: 20px;
border-width: 5px; border-width: 5px;
grid-area: savedLogs; grid-area: savedLogs;
margin-right: 2cm;
} }
div.savedAlarms { div.savedAlarms {

View File

@ -28,7 +28,7 @@
<input type="text" name="logMessage" <input type="text" name="logMessage"
class="form-control" class="form-control"
value="{{ request.form['logMessage'] }}"></input> value="{{ request.form['logMessage'] }}"></input>
<input type="submit" id="saveLog" value="Speichern"/> <input type="submit" id="saveLog" value="Speichern" style="margin-top: 3mm;"/>
</div> </div>
</form> </form>
</div> </div>
@ -36,15 +36,24 @@
<form method="post" action="/setAlarm"> <form method="post" action="/setAlarm">
<div class="form-group"> <div class="form-group">
<label for="time">Time</label> <div class="datetime" style="padding-left: 3mm;">
<input type="datetime-local" name="datetime" <label for="time">Datum</label>
class="form-control" <input type="date" name="date"
value="{{ request.form['datetime'] }}"></input> class="form-control"
<label for="alarmMessage">alarmMessage</label> value="{{ request.form['date'] }}" style="width: 150px;"></input>
<input type="text" name="alarmMessage" </div>
class="form-control" <div class="datetime">
value="{{ request.form['alarmMessage'] }}"></input> <label for="time">Uhrzeit</label>
<input type="submit" id="saveAlarm" value="Speichern"/> <input type="time" name="time" class="form-control"
value="{{ request.form['time'] }}" style="width: 80px;"></input>
</div>
<div style="padding: 3mm;">
<label for="alarmMessage">alarmMessage</label>
<input type="text" name="alarmMessage"
class="form-control"
value="{{ request.form['alarmMessage'] }}" required></input>
</div>
<input type="submit" id="saveAlarm" value="Speichern" style="padding-left: 3mm; margin-left: 3mm;"/>
</div> </div>
</form> </form>
</div> </div>

10
test.py
View File

@ -33,9 +33,15 @@ def index():
@app.route('/setAlarm', methods=('GET', 'POST')) @app.route('/setAlarm', methods=('GET', 'POST'))
def setAlarm(): def setAlarm():
if request.method == 'POST': if request.method == 'POST':
time = datetime.fromisoformat(request.form['datetime']).strftime("%d.%m.%Y %H:%M") print(request.form['date']+' '+request.form['time'])
if request.form['date'] !="" and request.form['time']!="":
time = datetime.strptime(request.form['date']+' '+request.form['time'], "%Y-%m-%d %H:%M")
elif request.form['date'] == "":
time = datetime.combine(datetime.today(),datetime.strptime(request.form['time'], "%H:%M").time())
if time<datetime.now():
time = time + timedelta(days=1)
content = request.form['alarmMessage'] content = request.form['alarmMessage']
activeAlarms.append({'datetime':time,'message':content}) activeAlarms.append({'datetime':datetime.strftime(time,"%d.%m.%Y %H:%M"),'message':content})
allAlarms = activeAlarms+previousAlarms allAlarms = activeAlarms+previousAlarms
with open('alarms.json', 'w') as f: with open('alarms.json', 'w') as f: