hook gallery to verwaltung backend

This commit is contained in:
David Rodenkirchen 2024-05-27 17:37:35 +02:00
parent 81e78967c7
commit 86b57600f7
3 changed files with 84 additions and 12 deletions

View File

@ -108,6 +108,7 @@ async def on_session_start(s: rio.Session) -> None:
await s.set_title("EZ GG e.V.") await s.set_title("EZ GG e.V.")
# Create the Rio app # Create the Rio app
database_service = services.DatabaseService()
app = rio.App( app = rio.App(
name='ezgg-website', name='ezgg-website',
pages=[ pages=[
@ -124,7 +125,7 @@ app = rio.App(
rio.Page( rio.Page(
name="Member", name="Member",
page_url='member', page_url='member',
build=lambda: pages.Member(services.DatabaseService()), build=lambda: pages.Member(database_service),
), ),
rio.Page( rio.Page(
name="Constitution", name="Constitution",
@ -139,7 +140,7 @@ app = rio.App(
rio.Page( rio.Page(
name="Pics", name="Pics",
page_url='pics', page_url='pics',
build=pages.Pics, build=lambda: pages.Pics(database_service),
), ),
rio.Page( rio.Page(
name="Imprint", name="Imprint",

View File

@ -1,22 +1,61 @@
from __future__ import annotations from __future__ import annotations
from functools import partial
from typing import * # type: ignore from typing import * # type: ignore
import rio import rio
from from_root import from_root
from .page_builder import build_page from .page_builder import build_page
from .. import components as comps from .. import components as comps, services
class Pics(rio.Component): class Pics(rio.Component):
def build(self) -> rio.Component: def __init__(self, database_service: services.database_service.DatabaseService) -> None:
return build_page(rio.Column( super().__init__()
comps.NewsPost( self._database_service = database_service
header="Galerie", self._active_picture: Optional[rio.URL] = None
article_text="""
""", def build(self) -> rio.Component:
date="" if self._active_picture is None:
grid = rio.Grid(row_spacing=0.4, column_spacing=0.5, margin_right=1)
for i, link in enumerate(self._database_service.get_picture_paths()):
print(i, link)
grid.add(
rio.Button(
rio.Image(
link,
height=12,
width=12
),
shape="rectangle",
style="plain",
on_press=partial(self.on_picture_clicked, link)
),
row=i // 3,
column=i % 3,
)
return build_page(grid)
return rio.Overlay(
rio.Column(
rio.Button(
rio.Image(
self._active_picture,
height="grow",
width="grow"
),
shape="rectangle",
style="plain",
height="grow",
on_press=self.exit_overlay
),
rio.Text("Click to exit", margin_bottom=2)
) )
)) )
async def on_picture_clicked(self, link_to_picture: str) -> None:
self._active_picture = link_to_picture
await self.force_refresh()
async def exit_overlay(self) -> None:
self._active_picture = None
await self.force_refresh()

View File

@ -1,3 +1,4 @@
import rio
from from_root import from_root from from_root import from_root
from ezgg_website.components import MemberInfo from ezgg_website.components import MemberInfo
@ -63,3 +64,34 @@ class DatabaseService:
contact_steam=None contact_steam=None
) )
] ]
def get_picture_paths(self) -> list[rio.URL]:
return [
# BK-LAN 18
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=c345a1b8-0c74-4d8f-8f3d-c747d04c2c12&photo_nr=1"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=c345a1b8-0c74-4d8f-8f3d-c747d04c2c12&photo_nr=2"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=c345a1b8-0c74-4d8f-8f3d-c747d04c2c12&photo_nr=3"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=c345a1b8-0c74-4d8f-8f3d-c747d04c2c12&photo_nr=4"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=c345a1b8-0c74-4d8f-8f3d-c747d04c2c12&photo_nr=5"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=c345a1b8-0c74-4d8f-8f3d-c747d04c2c12&photo_nr=6"),
# BL 46
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=4abbc55b-fc19-445a-9f84-b07c8d4ced12&photo_nr=1"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=4abbc55b-fc19-445a-9f84-b07c8d4ced12&photo_nr=2"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=4abbc55b-fc19-445a-9f84-b07c8d4ced12&photo_nr=3"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=4abbc55b-fc19-445a-9f84-b07c8d4ced12&photo_nr=4"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=4abbc55b-fc19-445a-9f84-b07c8d4ced12&photo_nr=5"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=4abbc55b-fc19-445a-9f84-b07c8d4ced12&photo_nr=6"),
# BL 45
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=d4c862f1-65cd-4051-9525-8be408ef80a8&photo_nr=1"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=d4c862f1-65cd-4051-9525-8be408ef80a8&photo_nr=2"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=d4c862f1-65cd-4051-9525-8be408ef80a8&photo_nr=3"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=d4c862f1-65cd-4051-9525-8be408ef80a8&photo_nr=4"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=d4c862f1-65cd-4051-9525-8be408ef80a8&photo_nr=5"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=d4c862f1-65cd-4051-9525-8be408ef80a8&photo_nr=6"),
# BL 42
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=235bf57f-c65c-4b5f-8029-061775eeec45&photo_nr=1"),
rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=235bf57f-c65c-4b5f-8029-061775eeec45&photo_nr=2")
]