aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-10-28 07:46:12 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-10-28 07:46:12 +0200
commit60e9f900bd9776c0101f85c81b8e640fa32c7c2e (patch)
tree9239e3b2c0411a8db8f5e5aec7c6a63199a0e904
parent5369212cf456d1f08035edf3eb5bfa1865e831c9 (diff)
downloadplanetwars.dev-60e9f900bd9776c0101f85c81b8e640fa32c7c2e.tar.xz
planetwars.dev-60e9f900bd9776c0101f85c81b8e640fa32c7c2e.zip
show matches that had errors on bot page
-rw-r--r--web/pw-server/src/routes/bots/[bot_name]/index.svelte54
1 files changed, 28 insertions, 26 deletions
diff --git a/web/pw-server/src/routes/bots/[bot_name]/index.svelte b/web/pw-server/src/routes/bots/[bot_name]/index.svelte
index 6e93834..37d9da9 100644
--- a/web/pw-server/src/routes/bots/[bot_name]/index.svelte
+++ b/web/pw-server/src/routes/bots/[bot_name]/index.svelte
@@ -6,10 +6,11 @@
try {
const bot_name = params["bot_name"];
- const [botData, botStats, matchesPage] = await Promise.all([
+ const [botData, botStats, matchesPage, errorMatchesPage] = await Promise.all([
apiClient.get(`/api/bots/${bot_name}`),
apiClient.get(`/api/bots/${bot_name}/stats`),
apiClient.get("/api/matches", { bot: params["bot_name"], count: "20" }),
+ apiClient.get("/api/matches", { bot: params["bot_name"], count: "10", had_errors: true }),
]);
const { bot, owner, versions } = botData;
@@ -23,6 +24,7 @@
versions,
botStats,
matches: matchesPage["matches"],
+ errorMatches: errorMatchesPage["matches"],
},
};
} catch (error) {
@@ -44,31 +46,7 @@
export let owner: object;
export let versions: object[];
export let matches: object[];
- export let botStats: object;
- // function last_updated() {
- // versions.sort()
- // }
-
- // let files;
-
- // async function submitCode() {
- // console.log("click");
- // const token = get_session_token();
-
- // const formData = new FormData();
- // formData.append("File", files[0]);
-
- // const res = await fetch(`/api/bots/${bot["id"]}/upload`, {
- // method: "POST",
- // headers: {
- // // the content type header will be set by the browser
- // Authorization: `Bearer ${token}`,
- // },
- // body: formData,
- // });
-
- // console.log(res.statusText);
- // }
+ export let errorMatches: object[];
</script>
<!--
@@ -113,6 +91,20 @@
This bot does not have any versions yet.
{/if}
</div>
+
+ <div class="matches">
+ <h3>Matches with errors</h3>
+ <MatchList matches={errorMatches} />
+ {#if errorMatches.length > 0}
+ <div class="btn-container">
+ <LinkButton href={`/matches?bot=${bot["name"]}&had_errors=true`}>View all</LinkButton>
+ </div>
+ {:else}
+ <div class="table-placeholder">
+ Nothing here yet
+ </div>
+ {/if}
+ </div>
{/if}
<div class="matches">
@@ -122,6 +114,10 @@
<div class="btn-container">
<LinkButton href={`/matches?bot=${bot["name"]}`}>All matches</LinkButton>
</div>
+ {:else}
+ <div class="table-placeholder">
+ No matches played yet
+ </div>
{/if}
</div>
</div>
@@ -131,6 +127,7 @@
width: 800px;
max-width: 80%;
margin: 50px auto;
+ padding-bottom: 24px;
}
.header {
@@ -160,6 +157,11 @@
text-align: center;
}
+ .table-placeholder {
+ padding: 12px;
+ text-align: center;
+ }
+
.versions {
margin: 30px 0;
}