summaryrefslogtreecommitdiff
path: root/src/match_up/view.py
diff options
context:
space:
mode:
authorKaran Jayachandra <karan.jayachandra@nxp.com>2024-04-05 16:55:07 +0200
committerKaran Jayachandra <karan.jayachandra@nxp.com>2024-04-05 16:55:07 +0200
commit9ef7d95c7010351078a929f5144f5098d4142cd0 (patch)
tree57a33fc2bd915c4e9ed727356038537a7c5c719b /src/match_up/view.py
parentf48223b3d93e54cb9ed3f2174e9b6075719128bf (diff)
Added the working version in dash
Diffstat (limited to 'src/match_up/view.py')
-rw-r--r--src/match_up/view.py107
1 files changed, 63 insertions, 44 deletions
diff --git a/src/match_up/view.py b/src/match_up/view.py
index 9da82a9..8fa1c54 100644
--- a/src/match_up/view.py
+++ b/src/match_up/view.py
@@ -1,45 +1,37 @@
-from dash.html import Div, H4
-from match_up.model import Player
-from dash.dash_table import DataTable
-from dash_bootstrap_components import Row, Col, Container, Input, Select
+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 PlayerLayout:
- def __init__(self, player_list: list[Player]):
+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="Player List"),
- DataTable(
- data=[
- {
- "Player": player.first_name + " " + player.last_name,
- "Status": "Active" if player.status else "Inactive",
- }
- for player in player_list
- ],
- columns=[
- {"name": "Player", "id": "Player", "type": "text"},
- ],
- style_data_conditional=[
- {
- "if": {
- "column_id": "Player",
- "filter_query": "{Status} = Active",
- },
- "backgroundColor": "green",
- "color": "white",
- },
- {
- "if": {
- "column_id": "Player",
- "filter_query": "{Status} = Inactive",
- },
- "backgroundColor": "tomato",
- "color": "white",
- "fontWeight": "bold",
- },
- ],
- ),
+ H4(children="Game List", style={"textAlign": "center"}),
+ Table(table_header + table_body, bordered=True),
]
)
@@ -47,30 +39,57 @@ class PlayerLayout:
return self._layout
-class GameLayout:
- def __init__(): ...
+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]):
+ 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(["Total Samples"], width=1),
- Col([self._player_layout.get()], width=10),
+ Col([self._game_layout.get()], width=9),
+ Col([self._player_layout.get()], width=3),
],
style={"margin": "15px"},
)
]
- )
+ ),
]
)
# full_layout = Div([Div(children="Hello World")])