From ccfe86729e3a454e3fdf529abd7063ceb8fa859f Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Sun, 24 Jul 2022 16:45:29 +0200 Subject: add bot detail page --- .../src/lib/components/Leaderboard.svelte | 14 ++- .../src/lib/components/navbar/UserControls.svelte | 4 +- web/pw-server/src/routes/bots/[bot_id].svelte | 74 ----------- web/pw-server/src/routes/bots/[bot_name].svelte | 139 +++++++++++++++++++++ web/pw-server/src/routes/users/[user_name].svelte | 25 ++-- 5 files changed, 160 insertions(+), 96 deletions(-) delete mode 100644 web/pw-server/src/routes/bots/[bot_id].svelte create mode 100644 web/pw-server/src/routes/bots/[bot_name].svelte (limited to 'web/pw-server') diff --git a/web/pw-server/src/lib/components/Leaderboard.svelte b/web/pw-server/src/lib/components/Leaderboard.svelte index 8582198..d29d5d6 100644 --- a/web/pw-server/src/lib/components/Leaderboard.svelte +++ b/web/pw-server/src/lib/components/Leaderboard.svelte @@ -41,11 +41,17 @@ {formatRating(entry)} - {entry["bot"]["name"]} + + {entry["bot"]["name"]} + {#if entry["author"]} - - {entry["author"]["username"]} + + {entry["author"]["username"]} {/if} @@ -71,7 +77,7 @@ color: #333; } - .leaderboard-author a{ + .leaderboard-href { text-decoration: none; color: black; } diff --git a/web/pw-server/src/lib/components/navbar/UserControls.svelte b/web/pw-server/src/lib/components/navbar/UserControls.svelte index a9bd87b..5646982 100644 --- a/web/pw-server/src/lib/components/navbar/UserControls.svelte +++ b/web/pw-server/src/lib/components/navbar/UserControls.svelte @@ -36,8 +36,8 @@
{#if $currentUser} - - {$currentUser["username"]} + + {$currentUser["username"]}
Sign out
{:else} diff --git a/web/pw-server/src/routes/bots/[bot_id].svelte b/web/pw-server/src/routes/bots/[bot_id].svelte deleted file mode 100644 index 3eece10..0000000 --- a/web/pw-server/src/routes/bots/[bot_id].svelte +++ /dev/null @@ -1,74 +0,0 @@ - - - - -
- {bot["name"]} -
- -
Upload code
-
- - -
- - diff --git a/web/pw-server/src/routes/bots/[bot_name].svelte b/web/pw-server/src/routes/bots/[bot_name].svelte new file mode 100644 index 0000000..9e9f016 --- /dev/null +++ b/web/pw-server/src/routes/bots/[bot_name].svelte @@ -0,0 +1,139 @@ + + + + + + +
+
+

{bot["name"]}

+ {#if owner} + + {owner["username"]} + + {/if} +
+ + {#if $currentUser && $currentUser["user_id"] === bot["owner_id"]} +
+ + Publish a new version by pushing a docker container to + registry.planetwars.dev/{bot["name"]}:latest, or using the web editor. +
+ {/if} + +
+

Versions

+
    + {#each versions as version} +
  • + {dayjs(version["created_at"]).format("YYYY-MM-DD HH:mm")} +
  • + {/each} +
+
+
+ + diff --git a/web/pw-server/src/routes/users/[user_name].svelte b/web/pw-server/src/routes/users/[user_name].svelte index fab3a96..a1801f4 100644 --- a/web/pw-server/src/routes/users/[user_name].svelte +++ b/web/pw-server/src/routes/users/[user_name].svelte @@ -1,12 +1,4 @@