From 28807cd014d01e9ca420a650504eabbebfc379f9 Mon Sep 17 00:00:00 2001 From: kristof de spiegeleer Date: Wed, 11 Sep 2024 22:19:48 +0300 Subject: [PATCH] ... --- lib/webcomponents/timeline/controller.py | 21 + lib/webcomponents/timeline/model_db.py | 3 + lib/webcomponents/timeline/model_view.py | 65 +++ lib/webcomponents/timeline/render.py | 16 + .../timeline/templates/timeline_white.html | 73 +++ .../pages/pages/projects/timeline_white.html | 435 ++++++++++++++++++ poc/server.py | 2 + 7 files changed, 615 insertions(+) create mode 100644 lib/webcomponents/timeline/controller.py create mode 100644 lib/webcomponents/timeline/model_db.py create mode 100644 lib/webcomponents/timeline/model_view.py create mode 100644 lib/webcomponents/timeline/render.py create mode 100644 lib/webcomponents/timeline/templates/timeline_white.html create mode 100644 poc/out/pages/pages/projects/timeline_white.html diff --git a/lib/webcomponents/timeline/controller.py b/lib/webcomponents/timeline/controller.py new file mode 100644 index 0000000..8291788 --- /dev/null +++ b/lib/webcomponents/timeline/controller.py @@ -0,0 +1,21 @@ +from fastapi import APIRouter, HTTPException, Request +from fastapi.responses import HTMLResponse +from jinja2 import TemplateNotFound +from webcomponents.timeline_white.web import render as render_timeline + +router_timeline = APIRouter() + + +@router_timeline.get('/timeline/{id:int}', response_class=HTMLResponse) +async def timeline_example(request: Request, id: int): + # deps = request.app.deps + try: + return render_timeline() + except TemplateNotFound: + raise HTTPException( + status_code=404, detail=f'Template not found: {template_path}' + ) from None + except Exception as e: + raise HTTPException( + status_code=500, detail=f'An unexpected error occurred: {str(e)}' + ) from None diff --git a/lib/webcomponents/timeline/model_db.py b/lib/webcomponents/timeline/model_db.py new file mode 100644 index 0000000..b14c0f2 --- /dev/null +++ b/lib/webcomponents/timeline/model_db.py @@ -0,0 +1,3 @@ +# TODO: calls the openrpc backend + +# TODO: converts the data as comesback from backend to the model_view diff --git a/lib/webcomponents/timeline/model_view.py b/lib/webcomponents/timeline/model_view.py new file mode 100644 index 0000000..9e33828 --- /dev/null +++ b/lib/webcomponents/timeline/model_view.py @@ -0,0 +1,65 @@ +class TimelineEvent: + def __init__( + self, + icon, + icon_color_from, + icon_color_to, + title, + date, + time, + description, + tags, + ): + self.icon = icon + self.icon_color_from = icon_color_from + self.icon_color_to = icon_color_to + self.title = title + self.date = date + self.time = time + self.description = description + self.tags = tags + + +class Timeline: + def __init__(self, example=False): + if example: + self.events = self.example().events + + def example(): + events: list[TimelineEvent] = [ + TimelineEvent( + icon='ni-bell-55', + icon_color_from='green-600', + icon_color_to='lime-400', + title='$2400, Design changes', + date='22 DEC', + time='7:20 PM', + description='People care about how you see the world, how you think, what motivates you, what you’re struggling with or afraid of.', + tags=['design'], + ), + TimelineEvent( + icon='ni-html5', + icon_color_from='red-600', + icon_color_to='rose-400', + title='New order #1832412', + date='21 DEC', + time='11 PM', + description='People care about how you see the world, how you think, what motivates you, what you’re struggling with or afraid of.', + tags=['order', '#1832412'], + ), + TimelineEvent( + icon='ni-cart', + icon_color_from='blue-600', + icon_color_to='cyan-400', + title='Server payments for April', + date='21 DEC', + time='9:34 PM', + description='People care about how you see the world, how you think, what motivates you, what you’re struggling with or afraid of.', + tags=['server', 'payments'], + ), + # Add more events as needed + ] + + timeline = Timeline() + timeline.events = events + return timeline diff --git a/lib/webcomponents/timeline/render.py b/lib/webcomponents/timeline/render.py new file mode 100644 index 0000000..1b88166 --- /dev/null +++ b/lib/webcomponents/timeline/render.py @@ -0,0 +1,16 @@ +from jinja2 import Environment, FileSystemLoader +from webcomponents.timeline_white.model import TimeLine + + +def render(timeline_id: int) -> str: + # Create an agenda instance + timeline = TimeLine(example=True) # timeline_id=timeline_id + + # Set up Jinja2 environment and load the template + env = Environment(loader=FileSystemLoader(searchpath='./templates')) + template = env.get_template('timeline.html') + + # Render the template with the agenda data + output = template.render(timeline=timeline) + + return output diff --git a/lib/webcomponents/timeline/templates/timeline_white.html b/lib/webcomponents/timeline/templates/timeline_white.html new file mode 100644 index 0000000..83db5f6 --- /dev/null +++ b/lib/webcomponents/timeline/templates/timeline_white.html @@ -0,0 +1,73 @@ + + + + + + Timeline + + + +
+
+
+
+
+
Timeline with dotted line
+
+
+
+ {% for event in timeline.events %} +
+ + + +
+
+ {{ event.title }} +
+

+ {{ event.date }} {{ event.time }} +

+

+ {{ event.description }} +

+ {% for tag in event.tags %} + {{ tag }} + {% endfor %} +
+
+ {% endfor %} +
+
+
+
+
+
+ + diff --git a/poc/out/pages/pages/projects/timeline_white.html b/poc/out/pages/pages/projects/timeline_white.html new file mode 100644 index 0000000..9c6ab6b --- /dev/null +++ b/poc/out/pages/pages/projects/timeline_white.html @@ -0,0 +1,435 @@ + + + + + + + + + + Soft UI Dashboard PRO Tailwind by Creative Tim + + + + + + + + + + + + + + + +
+
+
+
+
+
+ Timeline with dotted line +
+
+
+
+
+ + + + +
+
+ $2400, Design changes +
+

+ 22 DEC 7:20 PM +

+

+ People care about how you see the world, how you think, what motivates you, what you’re struggling with or afraid of. +

+ + design + +
+
+
+ + + + +
+
+ New order #1832412 +
+

+ 21 DEC 11 PM +

+

+ People care about how you see the world, how you think, what motivates you, what you’re struggling with or afraid of. +

+ + order + + + #1832412 + +
+
+
+ + + + +
+
+ Server payments for April +
+

+ 21 DEC 9:34 PM +

+

+ People care about how you see the world, how you think, what motivates you, what you’re struggling with or afraid of. +

+ + server + + + payments + +
+
+
+ + + + +
+
+ New card added for order #4395133 +
+

+ 20 DEC 2:20 AM +

+

+ People care about how you see the world, how you think, what motivates you, what you’re struggling with or afraid of. +

+ + card + + + #4395133 + + + priority + +
+
+
+ + + + +
+
+ Unlock packages for development +
+

+ 18 DEC 4:54 AM +

+

+ People care about how you see the world, how you think, what motivates you, what you’re struggling with or afraid of. +

+ + development + +
+
+
+ + + + +
+
+ New message unread +
+

+ 16 DEC +

+

+ People care about how you see the world, how you think, what motivates you, what you’re struggling with or afraid of. +

+ + message + +
+
+
+ + + + +
+
+ Notifications unread +
+

+ 15 DEC +

+

+ People care about how you see the world, how you think, what motivates you, what you’re struggling with or afraid of. +

+ + notification + +
+
+
+ + + + +
+
+ New request +
+

+ 14 DEC +

+

+ People care about how you see the world, how you think, what motivates you, what you’re struggling with or afraid of. +

+ + request + + + priority + +
+
+
+ + + + +
+
+ Controller issues +
+

+ 13 DEC +

+

+ People care about how you see the world, how you think, what motivates you, what you’re struggling with or afraid of. +

+ + controller + +
+
+
+
+
+
+
+
+ + + +
+ + +
+
+
+
+ Soft UI Configurator +
+

+ See our dashboard options. +

+
+
+ +
+ +
+
+
+ +
+
+ Sidebar Colors +
+
+ +
+ + + + + + + + + + + + +
+
+ +
+
+ Sidenav Type +
+

+ Choose between 2 different sidenav types. +

+
+
+ + +
+

+ You can change the sidenav type just on desktop view. +

+ +
+
+ Navbar Fixed +
+
+
+ +
+
+
+
+ Sidenav Mini +
+
+
+ +
+
+
+
+ Light/Dark +
+
+
+ +
+
+ + Buy Now + + + Free Demo + + + View documentation + +
+ + Star + +
+ Thank you for sharing! +
+ + + Tweet + + + + Share + +
+
+
+
+ + + + + + + diff --git a/poc/server.py b/poc/server.py index 54d9545..8d6feda 100644 --- a/poc/server.py +++ b/poc/server.py @@ -8,6 +8,7 @@ from fastapi.responses import ( from infoserver.dependencies import Dependencies from infoserver.router_login import router_login from infoserver.router_pdf_preso import router_pdf +from infoserver.router_projects import router_projects from infoserver.router_static import router_static from infoserver.router_template import router_template from jwt.exceptions import PyJWTError @@ -50,6 +51,7 @@ app.include_router(router_login) app.include_router(router_pdf) app.include_router(router_static) app.include_router(router_template) +app.include_router(router_projects) deps = Dependencies( DB_PATH, TEMPLATES_DIR, STATIC_DIR, HEROWEB_DIR, COLLECTIONS_DIR, SERVERHOST