aboutsummaryrefslogtreecommitdiff
path: root/web/pw-server/src/routes/bots
diff options
context:
space:
mode:
Diffstat (limited to 'web/pw-server/src/routes/bots')
-rw-r--r--web/pw-server/src/routes/bots/[bot_id].svelte4
-rw-r--r--web/pw-server/src/routes/bots/index.svelte108
2 files changed, 56 insertions, 56 deletions
diff --git a/web/pw-server/src/routes/bots/[bot_id].svelte b/web/pw-server/src/routes/bots/[bot_id].svelte
index 2556d73..955f1c6 100644
--- a/web/pw-server/src/routes/bots/[bot_id].svelte
+++ b/web/pw-server/src/routes/bots/[bot_id].svelte
@@ -1,6 +1,6 @@
<script lang="ts" context="module">
import { get_session_token } from "$lib/auth";
-import { mount_component } from "svelte/internal";
+ import { mount_component } from "svelte/internal";
export async function load({ page }) {
const token = get_session_token();
@@ -30,7 +30,7 @@ import { mount_component } from "svelte/internal";
<script lang="ts">
import dayjs from "dayjs";
-
+
export let bot: object;
export let bundles: object[];
diff --git a/web/pw-server/src/routes/bots/index.svelte b/web/pw-server/src/routes/bots/index.svelte
index 775652b..9186271 100644
--- a/web/pw-server/src/routes/bots/index.svelte
+++ b/web/pw-server/src/routes/bots/index.svelte
@@ -1,71 +1,71 @@
<script lang="ts" context="module">
- import { get_session_token } from '$lib/auth';
+ import { get_session_token } from "$lib/auth";
- /** @type {import('@sveltejs/kit').Load} */
- export async function load({ params, fetch, session, stuff }) {
- const token = get_session_token();
- const res = await fetch('/api/bots/my_bots', {
- headers: {
- 'Content-Type': 'application/json',
- Authorization: `Bearer ${token}`
- }
- });
+ /** @type {import('@sveltejs/kit').Load} */
+ export async function load({ params, fetch, session, stuff }) {
+ const token = get_session_token();
+ const res = await fetch("/api/bots/my_bots", {
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${token}`,
+ },
+ });
- if (res.ok) {
- return {
- props: {
- bots: await res.json()
- }
- };
- }
+ if (res.ok) {
+ return {
+ props: {
+ bots: await res.json(),
+ },
+ };
+ }
- return {
- status: res.status,
- error: new Error('Could not load bots')
- };
- }
+ return {
+ status: res.status,
+ error: new Error("Could not load bots"),
+ };
+ }
</script>
<script lang="ts">
- import { goto } from '$app/navigation';
+ import { goto } from "$app/navigation";
- export let bots: object[];
- let name: string | undefined;
+ export let bots: object[];
+ let name: string | undefined;
- async function createBot() {
- const token = get_session_token();
- const res = await fetch('/api/bots', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Authorization: `Bearer ${token}`
- },
- body: JSON.stringify({
- name: name
- })
- });
+ async function createBot() {
+ const token = get_session_token();
+ const res = await fetch("/api/bots", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${token}`,
+ },
+ body: JSON.stringify({
+ name: name,
+ }),
+ });
- if (res.ok) {
- let bot = await res.json();
- goto(`/bots/${bot['id']}`);
- } else {
- new Error('creation failed');
- }
- }
+ if (res.ok) {
+ let bot = await res.json();
+ goto(`/bots/${bot["id"]}`);
+ } else {
+ new Error("creation failed");
+ }
+ }
</script>
<form on:submit|preventDefault={createBot}>
- <label for="name">Name</label>
- <input name="name" bind:value={name}/>
- <button type="submit">Create</button>
+ <label for="name">Name</label>
+ <input name="name" bind:value={name} />
+ <button type="submit">Create</button>
</form>
<ul>
- {#each bots as bot}
- <li>
- <a target="_blank" href={`bots/${bot['id']}`}>
- {bot['name']}
- </a>
- </li>
- {/each}
+ {#each bots as bot}
+ <li>
+ <a target="_blank" href={`bots/${bot["id"]}`}>
+ {bot["name"]}
+ </a>
+ </li>
+ {/each}
</ul>