Automatic services added to dashboard

This commit is contained in:
2025-04-15 10:13:07 +02:00
parent 0a05885801
commit a1e95bd148
4 changed files with 31 additions and 22 deletions

View File

@@ -3,7 +3,13 @@
{%block title%}Dashboard{%endblock%} {%block title%}Dashboard{%endblock%}
{%block content%} {%block content%}
<div class="grid-container"> <div class="grid-container">
{% for service in services%}
<div class="container-xxl">
name: {{service["name"]}} <br>
url: {{service["url"]}}
</div>
{% endfor %}
<div class="container-xxl"> <div class="container-xxl">
Item 1 Item 1
</div> </div>
@@ -22,5 +28,5 @@
<div class="container-xxl"> <div class="container-xxl">
Item 6 Item 6
</div> </div>
</div> </div>
{%endblock%} {%endblock%}

View File

@@ -1,5 +1,6 @@
from flask import Blueprint, render_template from flask import Blueprint, render_template
from flask_login import login_required # type: ignore from flask_login import login_required # type: ignore
from application.dash.models import Service
dash_blueprint = Blueprint("dash", __name__, template_folder="templates") 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"]) @dash_blueprint.route("/", methods=["GET", "POST"])
@login_required @login_required
def index(): def index():
return render_template("dashboard.html") services = Service.query.all() # type: ignore
return render_template("dashboard.html", services=services)

View File

@@ -12,13 +12,14 @@ new_strikers = [
""" """
new_user = User(username="admin", password=generate_password_hash("admin")) new_user = User(username="admin", password=generate_password_hash("admin"))
new_services = Service(name="test123", url="http://google.com")
with app.app_context(): with app.app_context():
# Remove all existing # Remove all existing
# Service.query.delete() Service.query.delete()
User.query.delete() User.query.delete()
db.session.commit() db.session.commit()
# Then add new # Then add new
# db.session.add_all(new_strikers) db.session.add(new_services)
db.session.add(new_user) db.session.add(new_user)
db.session.commit() db.session.commit()