move db error handling from per-page to base page
This commit is contained in:
@@ -2,9 +2,9 @@ from __future__ import annotations
|
||||
|
||||
from typing import * # type: ignore
|
||||
|
||||
from rio import Component, event, Spacer, Card, Container, Column, Row, Rectangle, TextStyle, Color, Text
|
||||
from rio import Component, event, Spacer, Card, Container, Column, Row, TextStyle, Color, Text
|
||||
|
||||
from src.ez_lan_manager import ConfigurationService
|
||||
from src.ez_lan_manager import ConfigurationService, DatabaseService
|
||||
from src.ez_lan_manager.components.DesktopNavigation import DesktopNavigation
|
||||
|
||||
class BasePage(Component):
|
||||
@@ -14,6 +14,11 @@ class BasePage(Component):
|
||||
async def on_window_size_change(self):
|
||||
await self.force_refresh()
|
||||
|
||||
@event.on_populate
|
||||
async def check_db_connection(self):
|
||||
if not self.session[DatabaseService].is_connected:
|
||||
self.session.navigate_to("./db-error")
|
||||
|
||||
def build(self) -> Component:
|
||||
if self.content is None:
|
||||
content = Spacer()
|
||||
@@ -63,3 +68,4 @@ class BasePage(Component):
|
||||
align_y=0.5,
|
||||
style=TextStyle(fill=Color.from_hex("FFFFFF"), font_size=0.8)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user