aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorKaran Jayachandra <karan.jayachandra@nxp.com>2024-10-15 12:07:42 +0200
committerKaran Jayachandra <karan.jayachandra@nxp.com>2024-10-15 12:07:42 +0200
commit600b6afff3066d5fc9c4eca659f969322e670a77 (patch)
tree1bccadf85e486520d747bd1144ae98c7d0ad969b /templates
parentccdf8fcb51a47b79d5a1c0042699b0d60c3c304c (diff)
Cleaned up the code significantly
Diffstat (limited to 'templates')
-rw-r--r--templates/courts.j25
-rw-r--r--templates/games.j219
-rw-r--r--templates/index.j2115
-rw-r--r--templates/player.j27
-rw-r--r--templates/players.j24
5 files changed, 88 insertions, 62 deletions
diff --git a/templates/courts.j2 b/templates/courts.j2
index 4e3cb3a..5dc64f9 100644
--- a/templates/courts.j2
+++ b/templates/courts.j2
@@ -2,7 +2,10 @@
<div class="grid">
{% for key, value in courts.items() %}
<div class="cell">
- <button class={% if value %} "button is-success" {% else %} "button is-danger" {% endif %} hx-post="{{ "/court-toggle/" ~ key}}" hx-trigger="click" hx-swap="outerHTML">{{ key }}</button>
+ <button class={% if value %} "button is-success" {% else %} "button is-danger" {% endif %}
+ hx-post="{{ "/court-toggle/" ~ key}}"
+ hx-trigger="click"
+ hx-swap="outerHTML">{{ key }}</button>
</div>
{% endfor %}
</div>
diff --git a/templates/games.j2 b/templates/games.j2
index b070b16..55cabf4 100644
--- a/templates/games.j2
+++ b/templates/games.j2
@@ -1,17 +1,20 @@
<table class="table is-bordered is-striped is-narrow is-hoverable is-fullwidth" id="games">
<thead>
+ <th colspan="5" align="center"> {{ title }} </th>
+</thead>
+<thead>
<th> Court </th>
- <th colspan="2"> Team 1 </th>
- <th colspan="2"> Team 2 </th>
+ <th colspan="2" align="center"> Team 1 </th>
+ <th colspan="2" align="center"> Team 2 </th>
</thead>
<tbody>
-{% for game in games %}
+{% for _, game in games.items() %}
<tr>
- <th>{{ game.court.number }}</th>
- <td>{{ game.team1.player1.name }}</th>
- <td>{{ game.team1.player2.name }}</th>
- <td>{{ game.team2.player1.name }}</th>
- <td>{{ game.team2.player2.name }}</th>
+ <th>{{ game.court }}</th>
+ <td>{{ game.team1.player1 }}</th>
+ <td>{{ game.team1.player2 }}</th>
+ <td>{{ game.team2.player1 }}</th>
+ <td>{{ game.team2.player2 }}</th>
</tr>
{% endfor %}
</tbody>
diff --git a/templates/index.j2 b/templates/index.j2
index cfd32b5..3a2118b 100644
--- a/templates/index.j2
+++ b/templates/index.j2
@@ -1,52 +1,67 @@
<!doctype html>
<html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>🏸Match Up!</title>
- <link rel="icon" type="image/x-icon" href="/images/favicon.ico">
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.2/css/bulma.min.css">
- <script src="https://unpkg.com/htmx.org@2.0.0/dist/htmx.min.js"></script>
- <style>
- button {
- width: 100%;
- }
- td {
- text-align:center;
- width:20%;
- }
- </style>
- </head>
- <body>
- <section class="hero">
- <div class="hero-body">
- <p class="title">🏸The Smashing Fellows </p>
- </div>
- </section>
- <section class="section">
- <p class="title">Games</p>
- <div class="columns">
- <div class="column"></div>
- <div class="column"><button class="button is-success" hx-post="/random-games" hx-trigger="click" hx-target="#games">Random Games</button></div>
- <div class="column"><button class="button is-success" hx-post="/skilled-games" hx-trigger="click" hx-target="#games">Skilled Games</button></div>
- <div class="column"></div>
- <div class="column"><button class="button is-danger" hx-post="/clear-games" hx-trigger="click" hx-target="#games">Clear</button></div>
- <div class="column"></div>
- </div>
- <div hx-get="/game-list" hx-swap="outerHTML" hx-trigger="revealed"></div>
- </section>
- <section class="section">
- <h2 class="title">Courts</h2>
- <div hx-get="/court-list" hx-swap="outerHTML" hx-trigger="revealed"></div>
- </section>
- <section class="section">
- <h2 class="title">Players</h2>
- <div hx-get="/player-list" hx-swap="outerHTML" hx-trigger="revealed"></div>
- </section>
- <footer class="footer">
- <div class="content has-text-centered">
- Made by <a href="https://karanjayachandra.com/">K. Jayachandra</a> using <a href="https://flask.palletsprojects.com">Flask</a>, <a href="https://htmx.org/">HTMX</a> and <a href="https://bulma.io">Bulma</a>
- </div>
- </footer>
- </body>
-</html> \ No newline at end of file
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>🏸Match Up!</title>
+ <link rel="icon" type="image/x-icon" href="/images/favicon.ico">
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.2/css/bulma.min.css">
+ <script src="https://unpkg.com/htmx.org@2.0.0/dist/htmx.min.js"></script>
+ <style>
+ button, input, .select, .select select {
+ width: 100%;
+ }
+ td {
+ width: 20%;
+ }
+ </style>
+ </head>
+ <body>
+ <section class="hero">
+ <div class="hero-body">
+ <p class="title">🏸The Smashing Fellows </p>
+ </div>
+ </section>
+ <section class="section">
+ <p class="title">Games</p>
+ <div class="columns">
+ <div class="column">
+ <div class="select">
+ <select name="type">
+ <option>10 Levels</option>
+ <option>8 Levels</option>
+ <option>6 Levels</option>
+ <option>4 Levels</option>
+ <option>2 Levels</option>
+ <option>0 Levels</option>
+ </select>
+ </div>
+ </div>
+ <div class="column">
+ <button class="button is-success" hx-post="/propose" hx-trigger="click" hx-target="#games" hx-include="[name='type']">Propose</button>
+ </div>
+ <div class="column"></div>
+ <div class="column">
+ <button class="button is-success" hx-post="/confirm" hx-trigger="click" hx-target="#games">Confirm</button>
+ </div>
+ <div class="column">
+ <button class="button is-danger" hx-post="/clear" hx-trigger="click" hx-target="#games">Clear</button>
+ </div>
+ </div>
+ <div hx-post="/clear" hx-swap="outerHTML" hx-trigger="revealed"></div>
+ </section>
+ <section class="section">
+ <h2 class="title">Courts</h2>
+ <div hx-get="/courts" hx-swap="outerHTML" hx-trigger="revealed"></div>
+ </section>
+ <section class="section">
+ <h2 class="title">Players</h2>
+ <div hx-get="/players" hx-swap="outerHTML" hx-trigger="revealed"></div>
+ </section>
+ <footer class="footer">
+ <div class="content has-text-centered">
+ Made by <a href="https://karanjayachandra.com/">K. Jayachandra</a> using <a href="https://flask.palletsprojects.com">Flask</a>, <a href="https://htmx.org/">HTMX</a> and <a href="https://bulma.io">Bulma</a>
+ </div>
+ </footer>
+ </body>
+</html>
diff --git a/templates/player.j2 b/templates/player.j2
index 5b70df6..68bea2a 100644
--- a/templates/player.j2
+++ b/templates/player.j2
@@ -1 +1,6 @@
-<button class={% if player.status %} "button is-success" {% else %} "button is-danger" {% endif %} hx-post="{{ "/player-toggle/" ~ player.name}}" hx-trigger="click" hx-swap="outerHTML">{{ player.name }}</button> \ No newline at end of file
+<button class={% if status %} "button is-success" {% else %} "button is-danger" {% endif %}
+ hx-post="{{ "/player-toggle/" ~ id}}"
+ hx-trigger="click"
+ hx-swap="outerHTML">
+ {{ name }}
+</button> \ No newline at end of file
diff --git a/templates/players.j2 b/templates/players.j2
index 6179dbb..7a13672 100644
--- a/templates/players.j2
+++ b/templates/players.j2
@@ -1,8 +1,8 @@
<div class="fixed-grid has-5-cols">
<div class="grid">
-{% for player in players %}
+{% for id, player in players.items() %}
<div class="cell">
- <button class={% if player.status %} "button is-success" {% else %} "button is-danger" {% endif %} hx-post="{{ "/player-toggle/" ~ player.name}}" hx-trigger="click" hx-swap="outerHTML">{{ player.name }}</button>
+ <button class={% if player.status %} "button is-success" {% else %} "button is-danger" {% endif %} hx-post="{{ "/player-toggle/" ~ id}}" hx-trigger="click" hx-swap="outerHTML">{{ player.name }}</button>
</div>
{% endfor %}
</div> \ No newline at end of file