This commit is contained in:
2024-11-24 22:57:21 +01:00
parent bbf13cf203
commit 72933a46d1
48 changed files with 752 additions and 450 deletions

View File

@@ -27,8 +27,12 @@
const dispatch = createEventDispatcher();
export let schematicId: number;
export let user: Player;
interface Props {
schematicId: number;
user: Player;
}
let { schematicId, user }: Props = $props();
let schemInfo = getSchematicInfo(schematicId);
@@ -46,6 +50,8 @@
{:catch e}
<SWModal title="Error" open on:close={() => dispatch("reset")}>
<p>{e.message}</p>
<button class="btn !ml-auto" slot="footer" on:click={() => dispatch("reset")}>Close</button>
{#snippet footer()}
<button class="btn !ml-auto" onclick={() => dispatch("reset")}>Close</button>
{/snippet}
</SWModal>
{/await}

View File

@@ -28,8 +28,12 @@
const dispatch = createEventDispatcher();
export let info: SchematicInfo;
export let user: Player;
interface Props {
info: SchematicInfo;
user: Player;
}
let { info, user }: Props = $props();
</script>
<SWModal title={info.schem.name} open on:close={() => dispatch("reset")}>
@@ -63,5 +67,7 @@
{#if info.members.length !== 0}
<p class="!mt-0">{t("dashboard.schematic.info.members", {members: info.members.map(value => value.name).join(", ")})}</p>
{/if}
<button slot="footer" class="btn ml-auto" on:click={() => dispatch("reset")}>{t("dashboard.schematic.info.btn.close")}</button>
{#snippet footer()}
<button class="btn ml-auto" onclick={() => dispatch("reset")}>{t("dashboard.schematic.info.btn.close")}</button>
{/snippet}
</SWModal>

View File

@@ -18,6 +18,8 @@
-->
<script lang="ts">
import { preventDefault } from 'svelte/legacy';
import {t} from "astro-i18n";
import {
ChevronDoubleRightOutline,
@@ -37,10 +39,14 @@
const dispatch = createEventDispatcher();
export let schematics: SchematicList;
export let user: Player;
interface Props {
schematics: SchematicList;
user: Player;
}
let infoModalId: number | null = null;
let { schematics, user }: Props = $props();
let infoModalId: number | null = $state(null);
function schemListClick(isDir: boolean, id: number) {
if (isDir) {
@@ -50,26 +56,30 @@
}
}
let page = 0;
$: maxPage = Math.ceil(schematics.schematics.length / 15);
$: pagedSchematics = schematics.schematics.slice(page * 15, (page + 1) * 15);
let page = $state(0);
let maxPage = $derived(Math.ceil(schematics.schematics.length / 15));
let pagedSchematics = $derived(schematics.schematics.slice(page * 15, (page + 1) * 15));
</script>
<div class="flex justify-between">
<Breadcrumb navClass="py-4">
<BreadcrumbItem home>
<svelte:fragment slot="icon">
<HomeOutline class="w-6 h-6 mx-2 dark:text-white" />
</svelte:fragment>
<span on:click={() => dispatch("reset")} class="hover:underline hover:cursor-pointer text-2xl">{t("dashboard.schematic.home")}</span>
{#snippet icon()}
<HomeOutline class="w-6 h-6 mx-2 dark:text-white" />
{/snippet}
<span onclick={() => dispatch("reset")} class="hover:underline hover:cursor-pointer text-2xl">{t("dashboard.schematic.home")}</span>
</BreadcrumbItem>
{#each schematics.breadcrumbs as bread (bread.id)}
<BreadcrumbItem>
<svelte:fragment slot="icon">
<ChevronDoubleRightOutline class="w-4 h-4 mx-2 dark:text-white" />
</svelte:fragment>
<span on:click={() => {
{#snippet icon()}
<ChevronDoubleRightOutline class="w-4 h-4 mx-2 dark:text-white" />
{/snippet}
<span onclick={() => {
page = 0;
dispatch("to", {id: bread.id});
}} class="hover:underline hover:cursor-pointer text-2xl">{bread.name}</span>
@@ -99,7 +109,7 @@
</th>
</tr>
{#if schematics.breadcrumbs.length !== 0}
<tr on:click|preventDefault={() => {
<tr onclick={preventDefault(() => {
if (schematics.breadcrumbs.length === 1) {
page = 0;
dispatch("reset")
@@ -107,7 +117,7 @@
page = 0;
dispatch("to", {id: schematics.breadcrumbs[schematics.breadcrumbs.length - 2].id})
}
}}>
})}>
<th>
<FolderOutline />
</th>

View File

@@ -18,6 +18,9 @@
-->
<script lang="ts">
import { createBubbler, preventDefault } from 'svelte/legacy';
const bubble = createBubbler();
import {astroI18n, t} from "astro-i18n";
import {CheckSolid, FileOutline, FolderOutline, XCircleOutline} from "flowbite-svelte-icons";
import type {Schematic} from "@type/schem.ts";
@@ -27,11 +30,15 @@
dayjs.extend(utc);
export let schem: Schematic;
export let players: Record<number, Player>;
interface Props {
schem: Schematic;
players: Record<number, Player>;
}
let { schem, players }: Props = $props();
</script>
<tr on:click|preventDefault>
<tr onclick={preventDefault(bubble('click'))}>
<th>
{#if schem.type == null}
<FolderOutline />

View File

@@ -22,7 +22,11 @@
import {astroI18n, t} from "astro-i18n"
import {statsRepo} from "@repo/stats.ts";
export let user: Player;
interface Props {
user: Player;
}
let { user }: Props = $props();
let request = getRequest();

View File

@@ -25,7 +25,11 @@
const dispatch = createEventDispatcher();
export let open = false;
interface Props {
open?: boolean;
}
let { open = $bindable(false) }: Props = $props();
async function upload() {
if (uploadFile == null) {
@@ -53,15 +57,17 @@
dispatch("reset")
}
let uploadFile: FileList | null = null;
let uploadFile: FileList | null = $state(null);
</script>
<SWModal title={t("dashboard.schematic.title")} bind:open>
<form>
<input type="file" bind:files={uploadFile} />
</form>
<svelte:fragment slot="footer">
<button class="btn !ml-auto" on:click={upload}>{t("dashboard.schematic.upload")}</button>
<button class="btn btn-gray" on:click={() => open = false}>{t("dashboard.schematic.cancel")}</button>
</svelte:fragment>
{#snippet footer()}
<button class="btn !ml-auto" onclick={upload}>{t("dashboard.schematic.upload")}</button>
<button class="btn btn-gray" onclick={() => open = false}>{t("dashboard.schematic.cancel")}</button>
{/snippet}
</SWModal>

View File

@@ -24,11 +24,13 @@
import Statistics from "./Statistics.svelte";
import {authRepo} from "@repo/auth.ts";
import {tokenStore} from "@repo/repo.ts";
import SWModal from "@components/styled/SWModal.svelte";
import SWButton from "@components/styled/SWButton.svelte";
import Card from "@components/Card.svelte";
export let user: Player;
interface Props {
user: Player;
}
let { user }: Props = $props();
async function logout() {
await $authRepo.logout()
@@ -46,7 +48,7 @@
</figure>
</Card>
<div class="flex flex-wrap">
<button class="btn mt-2" on:click={logout}>{t("dashboard.buttons.logout")}</button>
<button class="btn mt-2" onclick={logout}>{t("dashboard.buttons.logout")}</button>
{#if user.perms.includes("MODERATION")}
<a class="btn w-fit mt-2" href="/admin" data-astro-reload>{t("dashboard.buttons.admin")}</a>
{/if}