From 7450ecdabb3f1be9a6ce4e3d16e47e448698efa0 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 5 Nov 2023 22:27:20 +0100 Subject: [PATCH] Updates and more --- package.json | 2 + src/components/Dashboard.svelte | 227 ++++++++++++++++++ src/components/Login.svelte | 67 ++++++ src/components/PlayerCount.svelte | 3 +- src/components/SchematicInfo.svelte | 65 +++++ src/components/ServerStatus.svelte | 2 +- src/components/admin/App.svelte | 2 +- .../admin/components/FightEditPart.svelte | 4 +- src/components/admin/pages/Edit.svelte | 4 +- src/components/admin/pages/Event.svelte | 2 +- src/components/admin/pages/Generate.svelte | 2 +- src/components/admin/pages/Home.svelte | 2 +- src/components/admin/pages/Login.svelte | 2 +- src/components/admin/pages/Perms.svelte | 4 +- src/components/admin/pages/edit/Editor.svelte | 4 +- .../admin/pages/event/EventEdit.svelte | 8 +- .../admin/pages/event/FightCard.svelte | 6 +- .../admin/pages/event/FightList.svelte | 8 +- .../admin/pages/event/TeamList.svelte | 2 +- .../event/modals/CreateFightModal.svelte | 6 +- .../pages/event/modals/FightEditModal.svelte | 8 +- .../pages/generate/GroupGenerator.svelte | 8 +- .../admin/pages/generate/TeamChip.svelte | 2 +- .../admin/pages/home/CreateEventModal.svelte | 4 +- .../admin/pages/home/EventCard.svelte | 2 +- src/components/admin/types/data.ts | 16 -- src/components/admin/util.ts | 6 +- src/components/repo/data.ts | 11 + src/components/{admin => }/repo/event.ts | 0 src/components/{admin => }/repo/fight.ts | 0 src/components/{admin => }/repo/page.ts | 2 +- src/components/{admin => }/repo/perms.ts | 0 src/components/{admin => }/repo/repo.ts | 19 +- src/components/{admin => }/stores/cached.ts | 0 src/components/stores/server.ts | 4 - src/components/{admin => }/stores/stores.ts | 10 +- src/components/types/data.ts | 34 +++ src/components/{admin => }/types/event.ts | 0 src/components/{admin => }/types/page.ts | 0 src/components/{admin => }/types/perms.ts | 0 src/components/types/schem.ts | 35 +++ src/components/{admin => }/types/team.ts | 0 src/env.d.ts | 6 +- src/i18n/pages/login/en.json | 15 ++ src/pages/dashboard.astro | 24 ++ src/pages/event/[...slug].astro | 3 - src/pages/index.astro | 2 +- src/pages/login.astro | 43 +--- 48 files changed, 565 insertions(+), 111 deletions(-) create mode 100644 src/components/Dashboard.svelte create mode 100644 src/components/Login.svelte create mode 100644 src/components/SchematicInfo.svelte delete mode 100644 src/components/admin/types/data.ts create mode 100644 src/components/repo/data.ts rename src/components/{admin => }/repo/event.ts (100%) rename src/components/{admin => }/repo/fight.ts (100%) rename src/components/{admin => }/repo/page.ts (98%) rename src/components/{admin => }/repo/perms.ts (100%) rename src/components/{admin => }/repo/repo.ts (50%) rename src/components/{admin => }/stores/cached.ts (100%) delete mode 100644 src/components/stores/server.ts rename src/components/{admin => }/stores/stores.ts (81%) create mode 100644 src/components/types/data.ts rename src/components/{admin => }/types/event.ts (100%) rename src/components/{admin => }/types/page.ts (100%) rename src/components/{admin => }/types/perms.ts (100%) create mode 100644 src/components/types/schem.ts rename src/components/{admin => }/types/team.ts (100%) create mode 100644 src/i18n/pages/login/en.json create mode 100644 src/pages/dashboard.astro delete mode 100644 src/pages/event/[...slug].astro diff --git a/package.json b/package.json index 58113d9..e3caeb8 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@astrojs/tailwind": "^5.0.2", "@astropub/icons": "^0.2.0", "@types/color": "^3.0.5", + "@types/crypto-js": "^4.1.3", "@types/node": "^20.8.10", "cssnano": "^6.0.1", "esbuild": "^0.19.5", @@ -34,6 +35,7 @@ "astro": "^3.4.3", "astro-i18n": "^2.1.18", "color": "^4.2.3", + "crypto-js": "^4.2.0", "flowbite": "^1.8.1", "flowbite-svelte": "^0.44.19", "flowbite-svelte-icons": "^0.4.5", diff --git a/src/components/Dashboard.svelte b/src/components/Dashboard.svelte new file mode 100644 index 0000000..4e1ab37 --- /dev/null +++ b/src/components/Dashboard.svelte @@ -0,0 +1,227 @@ + + +{#await userFetch} +

loading...

+{:then user} +
+
+ +
+ + {#if user.perms.includes("MODERATION")} + Admin Panel + {/if} +
+
+
+

Hello, {user.name}

+

Rang: {t("home.prefix." + user.prefix)}

+

Permissions:

+
    + {#each user.perms as permission} +
  • {permission}
  • + {/each} +
+
+
+
+
+ {#await schematicFetch} +

Loading...

+ {:then schematics} +
+ + + + + + schematicFetch = getSchematics()} class="hover:underline hover:cursor-pointer text-2xl">Schematics + + {#each schematics.breadcrumbs as bread} + + + + + schematicFetch = getSchematic(bread.id)} class="hover:underline hover:cursor-pointer text-2xl">{bread.name} + + {/each} + +
+ +
+
+ + + + + + + + + + + + {#if schematics.breadcrumbs.length !== 0} + { + if (schematics.breadcrumbs.length === 1) { + schematicFetch = getSchematics() + } else { + schematicFetch = getSchematic(schematics.breadcrumbs[schematics.breadcrumbs.length - 2].id) + } + }}> + + + + + + + + + {/if} + {#each schematics.schematics as schem} + + + + + + + + + + {/each} + +
TypeName + + + Replace Color + + + + + Allow Replay + +
+ + ../
+ {#if schem.type == null} + + {:else} + + {/if} + + {schem.name}{#if schem.type == null}/{/if} + + {#if schem.replaceColor} + + {:else} + + {/if} + + {#if schem.allowReplay} + + {:else} + + {/if} +
+ {:catch error} +

error: {error.message}

+ {/await} +
+{:catch error} +

error: {error.message}

+{/await} + + +
+ +
+ + + + +
+ +{#if infoModalId !== null} + infoModalId = null} /> +{/if} + + + diff --git a/src/components/Login.svelte b/src/components/Login.svelte new file mode 100644 index 0000000..49939c3 --- /dev/null +++ b/src/components/Login.svelte @@ -0,0 +1,67 @@ + + +
+

{t("login.title")}

+
+ + + + +
+

+ {t("login.generateToken")}

+ + {#if error} +

{error}

+ {/if} + +
+ + \ No newline at end of file diff --git a/src/components/PlayerCount.svelte b/src/components/PlayerCount.svelte index 63708d4..118e47e 100644 --- a/src/components/PlayerCount.svelte +++ b/src/components/PlayerCount.svelte @@ -1,11 +1,10 @@ {#await $server} {:then data} {data.players.online} {:catch error} - Error {/await} \ No newline at end of file diff --git a/src/components/SchematicInfo.svelte b/src/components/SchematicInfo.svelte new file mode 100644 index 0000000..5f32155 --- /dev/null +++ b/src/components/SchematicInfo.svelte @@ -0,0 +1,65 @@ + + +{#await schemInfo} + + + +{:then info} + +

Path: {info.path}

+

+ Replace Color: + {#if info.schem.replaceColor} + + {:else} + + {/if} +

+

+ Allow Replay: {#if info.schem.allowReplay} + + {:else} + + {/if} +

+

Type: {info.schem.type ?? "Directory"}

+

Updated: {new Intl.DateTimeFormat(astroI18n.locale, { + hour: "2-digit", + minute: "2-digit", + second: "2-digit", + day: "2-digit", + month: "2-digit", + year: "numeric" + }).format(moment(info.schem.lastUpdate).utc(false).toDate())}

+

Item: {info.schem.item ?? (info.schem.type == null ? "CHEST" : "CAULDRON_ITEM")}

+ {#if info.members.length !== 0} +

Member: {info.members.join(", ")}

+ {/if} + +
+{:catch e} + +

{e.message}

+ +
+{/await} \ No newline at end of file diff --git a/src/components/ServerStatus.svelte b/src/components/ServerStatus.svelte index 6d9f511..76e87c0 100644 --- a/src/components/ServerStatus.svelte +++ b/src/components/ServerStatus.svelte @@ -1,6 +1,6 @@ diff --git a/src/components/admin/pages/event/modals/CreateFightModal.svelte b/src/components/admin/pages/event/modals/CreateFightModal.svelte index 15e81a5..ad395b3 100644 --- a/src/components/admin/pages/event/modals/CreateFightModal.svelte +++ b/src/components/admin/pages/event/modals/CreateFightModal.svelte @@ -1,9 +1,9 @@ + + + + \ No newline at end of file diff --git a/src/pages/event/[...slug].astro b/src/pages/event/[...slug].astro deleted file mode 100644 index 853d812..0000000 --- a/src/pages/event/[...slug].astro +++ /dev/null @@ -1,3 +0,0 @@ ---- - ---- diff --git a/src/pages/index.astro b/src/pages/index.astro index 3a74545..0e60cd1 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -4,7 +4,7 @@ import NavbarLayout from "../layouts/NavbarLayout.astro"; import { Image } from "astro:assets"; import localBau from "../images/2023-10-08_20.43.43.png"; import {CaretRight, Archive, Rocket, Bell} from "@astropub/icons" -import {astroI18n, t} from "astro-i18n"; +import {t} from "astro-i18n"; import {l} from "../util/util" import PlayerCount from "../components/PlayerCount.svelte"; diff --git a/src/pages/login.astro b/src/pages/login.astro index 09809b8..1f6dd5e 100644 --- a/src/pages/login.astro +++ b/src/pages/login.astro @@ -2,41 +2,22 @@ import NavbarLayout from "../layouts/NavbarLayout.astro"; import localBau from "../images/2023-10-08_20.43.43.png"; import {Image} from "astro:assets"; - +import {l} from "../util/util"; +import Login from "../components/Login.svelte"; --- + Bau
-
-

Login

-
- - - - -
- -
+
- -
- - \ No newline at end of file + \ No newline at end of file