From cab5c3b7ec92116b507fb8186656847d04a7610b Mon Sep 17 00:00:00 2001 From: Stef Date: Fri, 5 Sep 2025 08:25:51 +0200 Subject: [PATCH] More chart experimentation. Managed to make a chart of ping history display --- app.py | 14 ++++++++-- mem/templates/chart.html | 55 +++++++++++++++++++++------------------- 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/app.py b/app.py index b3a827f..aaf20c2 100644 --- a/app.py +++ b/app.py @@ -7,6 +7,7 @@ from flask_migrate import upgrade, stamp from pathlib import Path from models import service, log from typing import Any, Optional, cast +import json # Init and upgrade with app.app_context(): @@ -34,12 +35,21 @@ with app.app_context(): @app.route("/") def homepage(): - return render_template("home.html", services=services) + return render_template("home.html") @app.route("/chart") def chart(): - return render_template("chart.html") + with app.app_context(): + logs = [] + s = db.session.query(service).first() + if s: + logs: list[log] = s.logs.limit(60).all() + return render_template( + "chart.html", + dates=[item.dateCreated.isoformat() for item in logs], + values=json.dumps([item.ping for item in logs]), + ) @app.route("/api/status") diff --git a/mem/templates/chart.html b/mem/templates/chart.html index 44aacfa..97812f0 100644 --- a/mem/templates/chart.html +++ b/mem/templates/chart.html @@ -1,45 +1,48 @@ - + - - Chart - - + + + Simple Line Chart + + + -
- -
+ - + + + - - \ No newline at end of file