diff --git a/app.py b/app.py index 9914dba..ae096dd 100644 --- a/app.py +++ b/app.py @@ -912,6 +912,70 @@ def delete_word(category, word): return redirect( f"/categories/edit/{category}" ) + +def parse_cron_jobs(cron_jobs): + + schedules = {} + + for name, cron in cron_jobs.items(): + + schedules[name] = { + "cron": cron, + "minute": "", + "hour": "", + "interval": "", + "days": [] + } + + if ( + not cron + or "Linux" in cron + ): + continue + + try: + + minute, hour, day, month, weekday = ( + cron.split() + ) + + schedules[name]["minute"] = minute + + if hour.startswith("*/"): + + schedules[name]["interval"] = ( + hour.replace( + "*/", + "" + ) + ) + + else: + + schedules[name]["hour"] = hour + + if "-" in weekday: + + start, end = weekday.split("-") + + schedules[name]["days"] = list( + range( + int(start), + int(end) + 1 + ) + ) + + else: + + schedules[name]["days"] = [ + int(weekday) + ] + + except Exception: + + pass + + return schedules @app.route("/maintenance") def maintenance(): @@ -922,11 +986,17 @@ def maintenance(): "" ) cron_jobs = get_cron_jobs() + + schedules = parse_cron_jobs( + cron_jobs + ) + print(schedules) return render_template( "maintenance.html", year=year, week=week, cron_jobs=cron_jobs, + schedules=schedules, message=message ) @app.route("/log") diff --git a/static/style.css b/static/style.css index 002b30a..6a4df72 100644 --- a/static/style.css +++ b/static/style.css @@ -445,4 +445,19 @@ text-decoration: underline; .automation-table .action-column { text-align: right; width: 180px; +} +.weekday-selector { + display: flex; + flex-wrap: wrap; + gap: 12px; +} + +.weekday-selector label { + font-weight: normal; +} + +.schedule-block { + margin-top: 20px; + padding-top: 15px; + border-top: 1px solid #ddd; } \ No newline at end of file diff --git a/templates/maintenance.html b/templates/maintenance.html index 8cdc943..54c02a6 100644 --- a/templates/maintenance.html +++ b/templates/maintenance.html @@ -93,7 +93,55 @@
balance.py ausführen
+