1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
from dash.html import Div, H4, Thead, Tbody, Tr, Td, Th
from match_up.model import Player, Game
from dash_bootstrap_components import (
Row,
Col,
Container,
Input,
Select,
Table,
NavbarSimple,
)
class GameLayout:
def __init__(self, game_list: list[Game]):
table_header = [Thead(Tr([Th("Court"), Th("Team 1"), Th("Team 2")]))]
table_body = [
Tbody(
[
Tr(
[
Td(children=game.court_number),
Td(children=game.team_1.__str__()),
Td(children=game.team_2.__str__()),
]
)
for game in game_list
]
)
]
self._layout = Div(
[
H4(children="Game List", style={"textAlign": "center"}),
Table(table_header + table_body, bordered=True),
]
)
def get(self):
return self._layout
class PlayerLayout:
def __init__(self, player_list: list[Player]):
table_header = [Thead(Tr([Th("Player Name")]))]
table_body = [
Tbody(
[
Tr(
[
Td(
children=player.first_name + " " + player.last_name,
style={"color": ("green" if player.status else "red")},
)
]
)
for player in player_list
]
)
]
self._layout = Div(
[
H4(children="Player List", style={"textAlign": "center"}),
Table(table_header + table_body, bordered=True),
]
)
def get(self):
return self._layout
class MainLayout:
def __init__(self, player_list: list[Player], game_list: list[Game]):
self._player_layout = PlayerLayout(player_list)
self._game_layout = GameLayout(game_list)
def refresh(): ...
def get(self):
full_layout = Div(
[
NavbarSimple(brand="Match Up!"),
Container(
[
Row(
[
Col([self._game_layout.get()], width=9),
Col([self._player_layout.get()], width=3),
],
style={"margin": "15px"},
)
]
),
]
)
# full_layout = Div([Div(children="Hello World")])
return full_layout
|