aboutsummaryrefslogtreecommitdiff
path: root/web/pw-server
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-09-10 18:57:38 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-09-10 18:57:38 +0200
commit9e574f08eee8e15cb7f1e8240463ace0d529dbdf (patch)
tree8ab1433c3b19edc57e21498f59b6203aeb5291f2 /web/pw-server
parent3058028edc7ab794e496e12075fa79a4133cd42c (diff)
downloadplanetwars.dev-9e574f08eee8e15cb7f1e8240463ace0d529dbdf.tar.xz
planetwars.dev-9e574f08eee8e15cb7f1e8240463ace0d529dbdf.zip
show bot versions on bot page
Diffstat (limited to 'web/pw-server')
-rw-r--r--web/pw-server/src/routes/bots/[bot_name].svelte43
-rw-r--r--web/pw-server/src/routes/code/[bundle_id].svelte35
2 files changed, 64 insertions, 14 deletions
diff --git a/web/pw-server/src/routes/bots/[bot_name].svelte b/web/pw-server/src/routes/bots/[bot_name].svelte
index 5fe4cc7..58e89ad 100644
--- a/web/pw-server/src/routes/bots/[bot_name].svelte
+++ b/web/pw-server/src/routes/bots/[bot_name].svelte
@@ -91,6 +91,25 @@
Publish a new version by pushing a docker container to
<code>registry.planetwars.dev/{bot["name"]}:latest</code>, or using the web editor.
</div>
+
+ <div class="versions">
+ <h3>Versions</h3>
+ <ul class="version-list">
+ {#each versions.slice(0, 10) as version}
+ <li class="bot-version">
+ {dayjs(version["created_at"]).format("YYYY-MM-DD HH:mm")}
+ {#if version["container_digest"]}
+ <span class="container-digest">{version["container_digest"]}</span>
+ {:else}
+ <a href={`/code/${version["id"]}`}>view code</a>
+ {/if}
+ </li>
+ {/each}
+ </ul>
+ {#if versions.length == 0}
+ This bot does not have any versions yet.
+ {/if}
+ </div>
{/if}
<div class="matches">
@@ -102,20 +121,6 @@
</div>
{/if}
</div>
-
- <!-- <div class="versions">
- <h4>Versions</h4>
- <ul class="version-list">
- {#each versions as version}
- <li>
- {dayjs(version["created_at"]).format("YYYY-MM-DD HH:mm")}
- </li>
- {/each}
- </ul>
- {#if versions.length == 0}
- This bot does not have any versions yet.
- {/if}
- </div> -->
</div>
<style lang="scss">
@@ -155,4 +160,14 @@
.versions {
margin: 30px 0;
}
+
+ .version-list {
+ padding: 0;
+ }
+
+ .bot-version {
+ display: flex;
+ justify-content: space-between;
+ padding: 4px 24px;
+ }
</style>
diff --git a/web/pw-server/src/routes/code/[bundle_id].svelte b/web/pw-server/src/routes/code/[bundle_id].svelte
new file mode 100644
index 0000000..1775ba5
--- /dev/null
+++ b/web/pw-server/src/routes/code/[bundle_id].svelte
@@ -0,0 +1,35 @@
+<script lang="ts" context="module">
+ import { ApiClient } from "$lib/api_client";
+
+ export async function load({ params, fetch }) {
+ const apiClient = new ApiClient(fetch);
+
+ try {
+ const code = await apiClient.getText(`/api/code/${params["bundle_id"]}`);
+ return {
+ props: {
+ code,
+ },
+ };
+ } catch (error) {
+ return {
+ status: error.status,
+ error: error,
+ };
+ }
+ }
+</script>
+
+<script lang="ts">
+ export let code;
+</script>
+
+<pre class="bot-code">
+ {code}
+</pre>
+
+<style lang="scss">
+ .bot-code {
+ margin: 24px 12px;
+ }
+</style>