commit 20d7fe39bd24ae2ed3e0a7fb3f75f1d433ed36d8 Author: Daniel Maas Date: Mon Oct 5 18:38:53 2026 +0200 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..726bb60 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +# Python +__pycache__/ +*.py[cod] + +# Virtual environments +.venv/ +venv/ +env/ + +# Environments / secrets +.env + +# Tool caches +.mypy_cache/ +.ruff_cache/ +.pytest_cache/ + +# Flet +.flet/ +build/ + +# IDE +.idea/ +.vscode/ + +# macOS +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c0929a6 --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +# Dansboard app + +## Run the app + +### uv + +Run as a desktop app: + +```bash +uv run flet run +``` + +Run as a web app: + +```bash +uv run flet run --web +``` + +For more details on running the app, refer to the [Getting Started Guide](https://flet.dev/docs/). + +## Build the app + +### Android + +```bash +flet build apk -v +``` + +For more details on building and signing `.apk` or `.aab`, refer to the [Android Packaging Guide](https://flet.dev/docs/publish/android/). + +### iOS + +```bash +flet build ipa -v +``` + +For more details on building and signing `.ipa`, refer to the [iOS Packaging Guide](https://flet.dev/docs/publish/ios/). + +### macOS + +```bash +flet build macos -v +``` + +For more details on building macOS package, refer to the [macOS Packaging Guide](https://flet.dev/docs/publish/macos/). + +### Linux + +```bash +flet build linux -v +``` + +For more details on building Linux package, refer to the [Linux Packaging Guide](https://flet.dev/docs/publish/linux/). + +### Windows + +```bash +flet build windows -v +``` + +For more details on building Windows package, refer to the [Windows Packaging Guide](https://flet.dev/docs/publish/windows/). + +### Web + +```bash +flet build web -v +``` + +For more details on building Web app, refer to the [Web Packaging Guide](https://flet.dev/docs/publish/web/). diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..337b2a8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,43 @@ +[project] +name = "dansboard" +version = "0.1.0" +description = "" +readme = "README.md" +requires-python = ">=3.10" +authors = [ + { name = "Flet developer", email = "you@example.com" } +] +dependencies = [ + "flet>=1.0.3" +] + +[dependency-groups] +dev = [ + "flet-cli>=1.0.3", + "flet-desktop>=1.0.3", + "flet-web>=1.0.3", + # Integration testing with `flet test` / pytest. The `test` extra brings in + # pytest, pytest-asyncio and the screenshot-comparison dependencies. + "flet[test]>=1.0.3", +] + +[tool.pytest.ini_options] +asyncio_mode = "auto" +testpaths = ["tests"] +pythonpath = ["src"] + +[tool.flet] +org = "com.mycompany" +product = "dansboard" +company = "Flet" +copyright = "Copyright (C) 2023-2026 by Flet" + +# src/assets/icon.png is the icon for every platform. Keep it transparent and +# filling the whole canvas: web, Windows and Linux show it as-is, and Flet +# shrinks it to the margin iOS, macOS and Android each mask away. This colour +# is what sits behind it where transparency cannot survive - the iOS icon, the +# macOS tile and the Android background layer. Defaults to white. +# icon_background = "#ffffff" + +[tool.flet.app] +path = "src" diff --git a/src/assets/icon.png b/src/assets/icon.png new file mode 100644 index 0000000..98687e6 Binary files /dev/null and b/src/assets/icon.png differ diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..77bd453 --- /dev/null +++ b/src/main.py @@ -0,0 +1,97 @@ +import flet as ft +import requests + +# Liste deiner Docker-Dienste auf dem Pi +SERVICES = [ + { + "name": "Portainer", + "url": "https://192.168.2.33:9443", + "icon": ft.Icons.DIRECTIONS_BOAT, + "desc": "Container Management" + }, + { + "name": "NGINX", + "url": "http://192.168.2.33:81", + "icon": ft.Icons.ASSISTANT_DIRECTION, + "desc": "Proxy Manager" + }, + { + "name": "Jellyfin", + "url": "https://jellyfin.dansbude.org/", + "icon": ft.Icons.MOVIE, + "desc": "Media Server" + }, + { + "name": "Gitea", + "url": "https://gitea.dansbude.org/", + "icon": ft.Icons.CODE, + "desc": "Git source control" + }, +] + +def check_status(url): + """Prüft, ob der Dienst antwortet und gibt Fehler im Terminal aus.""" + try: + # User-Agent simuliert einen echten Browser, Timeout auf 3.0s erhöht + headers = {'User-Agent': 'Mozilla/5.0'} + response = requests.get(url, timeout=3.0, verify=False, headers=headers) + + # 200 (OK), 302 (Redirect) oder 401 (Unauthorized/Login nötig) heissen alle: Portainer LÄUFT! + if response.status_code < 500: + return ft.Colors.GREEN_400 + else: + print(f"[STATUS] {url} antwortete mit Status Code: {response.status_code}") + return ft.Colors.ORANGE_400 + + except Exception as e: + # Das zeigt dir im Terminal EXAKT, warum der Check fehlschlägt: + print(f"[FEHLER] {url} -> {type(e).__name__}: {e}") + return ft.Colors.RED_400 + +def main(page: ft.Page): + page.title = "Dansboard" + page.theme_mode = ft.ThemeMode.DARK + page.padding = 30 + page.scroll = ft.ScrollMode.AUTO + + # Header + header = ft.Text("Dansboard", size=32, weight=ft.FontWeight.BOLD) + + cards = [] + + for service in SERVICES: + # Status-Farbe abfragen + status_color = check_status(service["url"]) + + # Kachel für jeden Dienst bauen + card = ft.Container( + content=ft.Column([ + ft.Row([ + ft.Icon(service["icon"], size=30, color=ft.Colors.BLUE_400), + ft.Container( + width=12, height=12, + bgcolor=status_color, + border_radius=6, + tooltip="Online" if status_color == ft.Colors.GREEN_400 else "Offline" + ) + ]), + ft.Text(service["name"], size=18, weight=ft.FontWeight.BOLD), + ft.Text(service["desc"], size=12, color=ft.Colors.GREY_400), + ]), + padding=20, + bgcolor=ft.Colors.SURFACE_CONTAINER_HIGHEST, + border_radius=12, + width=200, + height=130, + ink=True, + url=service["url"], # Öffnet Link im neuen Tab + ) + cards.append(card) + + # Raster mit allen Kacheln + grid = ft.Row(controls=cards, wrap=True, spacing=20) + + page.add(header, ft.Divider(height=20, color=ft.Colors.TRANSPARENT), grid) + +# Als Webserver auf Port 8550 starten +ft.run(main) diff --git a/tests/test_main.py b/tests/test_main.py new file mode 100644 index 0000000..858e8fe --- /dev/null +++ b/tests/test_main.py @@ -0,0 +1,22 @@ +import flet.testing as ftt + + +async def test_increment(flet_app: ftt.FletTestApp): + """Counter sample: tap the FAB and assert the counter goes 0 -> 1. + + The `flet_app` fixture is provided automatically by the flet pytest plugin. + Run with `flet test` (or `uv run pytest`) from the project directory. + """ + tester = flet_app.tester + + await tester.pump_and_settle() + + # Initial state + assert (await tester.find_by_text("0")).count == 1 + + # Tap the increment button (found by its key) and let the UI settle + await tester.tap(await tester.find_by_key("increment")) + await tester.pump_and_settle() + + # New state + assert (await tester.find_by_text("1")).count == 1