diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-08-05 20:28:51 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-08-05 20:28:51 +0200 |
commit | 70c79646aed56344e2e21f3b738443c135c8211d (patch) | |
tree | e1256b4c6c8ea0340d0a9b5287362c590cba4191 /web/pw-server | |
parent | 6e75cac7cca1dc46f83e9eb7a7624cfdbe09ab3b (diff) | |
download | planetwars.dev-70c79646aed56344e2e21f3b738443c135c8211d.tar.xz planetwars.dev-70c79646aed56344e2e21f3b738443c135c8211d.zip |
show recent matches on bots page
Diffstat (limited to 'web/pw-server')
-rw-r--r-- | web/pw-server/src/lib/components/matches/MatchList.svelte | 4 | ||||
-rw-r--r-- | web/pw-server/src/routes/bots/[bot_name].svelte | 24 |
2 files changed, 23 insertions, 5 deletions
diff --git a/web/pw-server/src/lib/components/matches/MatchList.svelte b/web/pw-server/src/lib/components/matches/MatchList.svelte index aea59c2..01a0b82 100644 --- a/web/pw-server/src/lib/components/matches/MatchList.svelte +++ b/web/pw-server/src/lib/components/matches/MatchList.svelte @@ -43,10 +43,12 @@ </table> <style lang="scss"> + .matches-table { + width: 100%; + } .matches-table td, .matches-table th { padding: 8px 16px; - // width: 100%; } .header-timestamp { diff --git a/web/pw-server/src/routes/bots/[bot_name].svelte b/web/pw-server/src/routes/bots/[bot_name].svelte index 33a522f..48aef21 100644 --- a/web/pw-server/src/routes/bots/[bot_name].svelte +++ b/web/pw-server/src/routes/bots/[bot_name].svelte @@ -10,8 +10,17 @@ }, }); - if (res.ok) { + const matches_res = await fetch(`/api/matches?bot=${params["bot_name"]}`, { + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${token}`, + }, + }); + + + if (res.ok && matches_res.ok) { const { bot, owner, versions } = await res.json(); + const matches = await matches_res.json(); // sort most recent first versions.sort((a: string, b: string) => dayjs(a["created_at"]).isAfter(b["created_at"]) ? -1 : 1 @@ -21,6 +30,7 @@ bot, owner, versions, + matches, }, }; } @@ -34,12 +44,13 @@ <script lang="ts"> import dayjs from "dayjs"; - import { currentUser } from "$lib/stores/current_user"; + import MatchList from "$lib/components/matches/MatchList.svelte"; export let bot: object; export let owner: object; export let versions: object[]; + export let matches: object[]; // function last_updated() { // versions.sort() @@ -92,7 +103,12 @@ </div> {/if} - <div class="versions"> + <div class="matches"> + <h3>Recent matches</h3> + <MatchList {matches} /> + </div> + + <!-- <div class="versions"> <h4>Versions</h4> <ul class="version-list"> {#each versions as version} @@ -104,7 +120,7 @@ {#if versions.length == 0} This bot does not have any versions yet. {/if} - </div> + </div> --> </div> <style lang="scss"> |