From a1e95bd148759cd638f29c8ae9daee81d480cd41 Mon Sep 17 00:00:00 2001 From: Stef Date: Tue, 15 Apr 2025 10:13:07 +0200 Subject: [PATCH] Automatic services added to dashboard --- application/dash/templates/dash.html | 0 application/dash/templates/dashboard.html | 44 +++++++++++++---------- application/dash/views.py | 4 ++- seed.py | 5 +-- 4 files changed, 31 insertions(+), 22 deletions(-) delete mode 100644 application/dash/templates/dash.html diff --git a/application/dash/templates/dash.html b/application/dash/templates/dash.html deleted file mode 100644 index e69de29..0000000 diff --git a/application/dash/templates/dashboard.html b/application/dash/templates/dashboard.html index ce86b46..ea51429 100644 --- a/application/dash/templates/dashboard.html +++ b/application/dash/templates/dashboard.html @@ -3,24 +3,30 @@ {%block title%}Dashboard{%endblock%} {%block content%} -
-
- Item 1 -
-
- Item 2 -
-
- Item 3 -
-
- Item 4 -
-
- Item 5 -
-
- Item 6 -
+
+ {% for service in services%} +
+ name: {{service["name"]}}
+ url: {{service["url"]}}
+ {% endfor %} +
+ Item 1 +
+
+ Item 2 +
+
+ Item 3 +
+
+ Item 4 +
+
+ Item 5 +
+
+ Item 6 +
+
{%endblock%} \ No newline at end of file diff --git a/application/dash/views.py b/application/dash/views.py index f6b8878..6f7468b 100644 --- a/application/dash/views.py +++ b/application/dash/views.py @@ -1,5 +1,6 @@ from flask import Blueprint, render_template from flask_login import login_required # type: ignore +from application.dash.models import Service dash_blueprint = Blueprint("dash", __name__, template_folder="templates") @@ -9,4 +10,5 @@ dash_blueprint = Blueprint("dash", __name__, template_folder="templates") @dash_blueprint.route("/", methods=["GET", "POST"]) @login_required def index(): - return render_template("dashboard.html") + services = Service.query.all() # type: ignore + return render_template("dashboard.html", services=services) diff --git a/seed.py b/seed.py index b7dacda..4eee012 100644 --- a/seed.py +++ b/seed.py @@ -12,13 +12,14 @@ new_strikers = [ """ new_user = User(username="admin", password=generate_password_hash("admin")) +new_services = Service(name="test123", url="http://google.com") with app.app_context(): # Remove all existing - # Service.query.delete() + Service.query.delete() User.query.delete() db.session.commit() # Then add new - # db.session.add_all(new_strikers) + db.session.add(new_services) db.session.add(new_user) db.session.commit()