1
+ #!/usr/bin/env python3
2
+
3
+ from enddevices import add_end_device , show_list
4
+ from nicegui import ui
5
+ from router import Router
6
+
7
+ from ieee_2030_5 .utils import xml_to_dataclass
8
+
9
+ router = Router ()
10
+
11
+ from session import backend_session , endpoint
12
+
13
+
14
+ @router .add ('/' )
15
+ async def show_one ():
16
+ ui .label ('Content One' ).classes ('text-2xl' )
17
+
18
+ @router .add ('/end-devices' )
19
+ async def show_end_devices ():
20
+ # resp = requests.get("https://127.0.0.1:7443/admin/enddevices",
21
+ # cert=('/home/os2004/tls/certs/admin.pem', '/home/os2004/tls/private/admin.pem'),
22
+ # verify="/home/os2004/tls/certs/ca.pem")
23
+ resp = backend_session .get (endpoint ("enddevices" ))
24
+ enddevices = xml_to_dataclass (resp .text )
25
+ show_list (enddevices )
26
+
27
+ @router .add ('/end-devices/add' )
28
+ async def add_enddevice ():
29
+ # resp = requests.get("https://127.0.0.1:7443/admin/enddevices",
30
+ # cert=('/home/os2004/tls/certs/admin.pem', '/home/os2004/tls/private/admin.pem'),
31
+ # verify="/home/os2004/tls/certs/ca.pem")
32
+ #enddevices = xml_to_dataclass(resp.text)
33
+ #show_list(enddevices)
34
+ add_end_device ()
35
+
36
+
37
+
38
+
39
+ @router .add ('/two' )
40
+ async def show_two ():
41
+ ui .label ('Content Two' ).classes ('text-2xl' )
42
+
43
+
44
+ @router .add ('/three' )
45
+ async def show_three ():
46
+ ui .label ('Content Three' ).classes ('text-2xl' )
47
+
48
+
49
+ @ui .page ('/' ) # normal index page (eg. the entry point of the app)
50
+ @ui .page ('/{_:path}' ) # all other pages will be handled by the router but must be registered to also show the SPA index page
51
+ async def main ():
52
+
53
+ with ui .header (elevated = True ).style ('background-color: #3874c8' ).classes ('items-center justify-between' ):
54
+ ui .label ('HEADER' )
55
+
56
+ with ui .left_drawer (top_corner = True , bottom_corner = True ).style ('background-color: #d7e3f4' ):
57
+ with ui .column ():
58
+ ui .button ("End Devices" , on_click = lambda : router .open (show_end_devices )).classes ('w-64' )
59
+ ui .button ("Add End Device" , on_click = lambda : router .open (add_enddevice )).classes ('w-64' )
60
+ ui .button ('One' , on_click = lambda : router .open (show_one )).classes ('w-64' )
61
+ ui .button ('Two' , on_click = lambda : router .open (show_two )).classes ('w-64' )
62
+ ui .button ('Three' , on_click = lambda : router .open (show_three )).classes ('w-64' )
63
+
64
+ with ui .footer ().style ('background-color: #3874c8' ):
65
+ ui .label ('FOOTER' )
66
+
67
+
68
+
69
+
70
+ # this places the content which should be displayed
71
+ router .frame ().classes ('w-full p-4 bg-gray-100' )
72
+
73
+ ui .run ()
0 commit comments