Some Code Cleanup
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
Chaoscaot 2023-12-25 21:54:40 +01:00
Ursprung a2687083e0
Commit 3108d9bf20
61 geänderte Dateien mit 305 neuen und 247 gelöschten Zeilen

Datei anzeigen

@ -5,6 +5,8 @@ import configureI18n from "./astro-i18n.adapter";
import sitemap from "@astrojs/sitemap"; import sitemap from "@astrojs/sitemap";
import robotsTxt from "astro-robots-txt"; import robotsTxt from "astro-robots-txt";
import {resolve} from "node:url";
import path from "node:path";
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({
@ -30,5 +32,19 @@ export default defineConfig({
disallow: ["/admin", "/login", "/dashboard", "/de", "/_astro"] disallow: ["/admin", "/login", "/dashboard", "/de", "/_astro"]
}] }]
})], })],
vite: {} vite: {
resolve: {
alias: {
"@components": path.resolve("./src/components"),
"@pages": path.resolve("./src/pages"),
"@styles": path.resolve("./src/styles"),
"@utils": path.resolve("./src/util"),
"@type": path.resolve("./src/components/types"),
"@images": path.resolve("./src/images"),
"@layouts": path.resolve("./src/layouts"),
"@repo": path.resolve("./src/components/repo"),
"@stores": path.resolve("./src/components/stores"),
}
}
}
}); });

Datei anzeigen

@ -19,7 +19,7 @@
<script lang="ts"> <script lang="ts">
import {t} from "astro-i18n" import {t} from "astro-i18n"
import {dataRepo, schemRepo} from "./repo/repo"; import {dataRepo, schemRepo} from "@repo/repo";
import SchematicList from "./dashboard/SchematicList.svelte"; import SchematicList from "./dashboard/SchematicList.svelte";
import UserInfo from "./dashboard/UserInfo.svelte"; import UserInfo from "./dashboard/UserInfo.svelte";

Datei anzeigen

@ -18,7 +18,7 @@
--> -->
<script lang="ts"> <script lang="ts">
import {statsRepo} from "./repo/repo.ts"; import {statsRepo} from "@repo/repo.ts";
import {t} from "astro-i18n"; import {t} from "astro-i18n";
export let gamemode: string; export let gamemode: string;

Datei anzeigen

@ -18,7 +18,7 @@
--> -->
<script lang="ts"> <script lang="ts">
import {statsRepo} from "./repo/repo.ts"; import {statsRepo} from "@repo/repo.ts";
import FightStatsChart from "./FightStatsChart.svelte"; import FightStatsChart from "./FightStatsChart.svelte";
import {t} from "astro-i18n"; import {t} from "astro-i18n";

Datei anzeigen

@ -30,7 +30,7 @@
Legend, Legend,
Title Title
} from "chart.js" } from "chart.js"
import type {FightStats} from "./types/stats.ts" import type {FightStats} from "@type/stats.ts"
import 'chartjs-adapter-dayjs-4' import 'chartjs-adapter-dayjs-4'
export let data: FightStats; export let data: FightStats;

Datei anzeigen

@ -20,31 +20,46 @@
<script lang="ts"> <script lang="ts">
import {window} from "./util.ts"; import {window} from "./util.ts";
import {astroI18n, t} from "astro-i18n"; import {astroI18n, t} from "astro-i18n";
import type {ExtendedEvent} from "./types/event.ts"; import type {EventFight, ExtendedEvent} from "@type/event";
export let event: ExtendedEvent; export let event: ExtendedEvent;
export let group: string; export let group: string;
export let rows: number = 1; export let rows: number = 1;
function getWinner(fight: EventFight) {
switch (fight.ergebnis) {
case 1:
return fight.blueTeam.kuerzel;
case 2:
return fight.redTeam.kuerzel;
case 3:
return t("announcements.table.draw");
default:
return t("announcements.table.notPlayed");
}
}
</script> </script>
<div> <div>
<table> <table>
<tr class="font-bold border-b"> <tr class="font-bold border-b">
{#each Array(rows) as _} {#each Array(rows) as i (i)}
<td>{t("announcements.table.time")}</td> <td>{t("announcements.table.time")}</td>
<td>{t("announcements.table.blue")}</td> <td>{t("announcements.table.blue")}</td>
<td>{t("announcements.table.red")}</td> <td>{t("announcements.table.red")}</td>
<td>{t("announcements.table.winner")}</td>
{/each} {/each}
</tr> </tr>
{#each window(event.fights.filter(f => f.group === group), rows) as fights} {#each window(event.fights.filter(f => f.group === group), rows) as fights}
<tr> <tr>
{#each fights as fight} {#each fights as fight (fight.id)}
<td>{Intl.DateTimeFormat(astroI18n.locale, { <td>{Intl.DateTimeFormat(astroI18n.locale, {
hour: "numeric", hour: "numeric",
minute: "numeric", minute: "numeric",
}).format(new Date(fight.start))}</td> }).format(new Date(fight.start))}</td>
<td class:font-bold={fight.ergebnis === 1} class:italic={fight.ergebnis === 3}>{fight.blueTeam.kuerzel}</td> <td class:font-bold={fight.ergebnis === 1} class:italic={fight.ergebnis === 3}>{fight.blueTeam.kuerzel}</td>
<td class:font-bold={fight.ergebnis === 2} class:italic={fight.ergebnis === 3}>{fight.redTeam.kuerzel}</td> <td class:font-bold={fight.ergebnis === 2} class:italic={fight.ergebnis === 3}>{fight.redTeam.kuerzel}</td>
<td>{getWinner(fight)}</td>
{/each} {/each}
</tr> </tr>
{/each} {/each}
@ -56,6 +71,6 @@
@apply w-full; @apply w-full;
} }
div { div {
@apply p-3 bg-gray-200 dark:bg-gray-800 rounded-2xl w-3/4 mx-auto; @apply p-3 bg-gray-200 dark:bg-neutral-800 rounded-2xl w-3/4 mx-auto;
} }
</style> </style>

Datei anzeigen

@ -20,7 +20,7 @@
<script lang="ts"> <script lang="ts">
import {window} from "./util.ts"; import {window} from "./util.ts";
import {t} from "astro-i18n"; import {t} from "astro-i18n";
import type {ExtendedEvent} from "./types/event.ts"; import type {ExtendedEvent} from "@type/event.ts";
export let event: ExtendedEvent; export let event: ExtendedEvent;
export let group: string; export let group: string;
@ -70,6 +70,6 @@
@apply w-full; @apply w-full;
} }
div { div {
@apply p-3 bg-gray-200 dark:bg-gray-800 rounded-2xl w-3/4 mx-auto; @apply p-3 bg-gray-200 dark:bg-neutral-800 rounded-2xl w-3/4 mx-auto;
} }
</style> </style>

Datei anzeigen

@ -18,14 +18,14 @@
--> -->
<script lang="ts"> <script lang="ts">
import {l} from "../util/util.ts"; import {l} from "@utils/util.ts";
import {t} from "astro-i18n"; import {t} from "astro-i18n";
import {get} from "svelte/store"; import {get} from "svelte/store";
let username = ""; let username: string = "";
let pw = ""; let pw: string = "";
let error = ""; let error: string = "";
async function login() { async function login() {
let {tokenStore, authRepo} = await import("./repo/repo.ts"); let {tokenStore, authRepo} = await import("./repo/repo.ts");

Datei anzeigen

@ -1,5 +1,5 @@
--- ---
import {CollectionEntry} from "astro:content" import {CollectionEntry} from "astro:content";
import {l} from "../util/util"; import {l} from "../util/util";
import {astroI18n} from "astro-i18n"; import {astroI18n} from "astro-i18n";
import {Image} from "astro:assets"; import {Image} from "astro:assets";
@ -7,7 +7,7 @@ import TagComponent from "./TagComponent.astro";
import P from "./P.astro"; import P from "./P.astro";
interface Props { interface Props {
post: CollectionEntry<'announcements'> post: CollectionEntry<"announcements">
} }
const { post } = Astro.props as Props; const { post } = Astro.props as Props;
@ -30,7 +30,7 @@ const { post } = Astro.props as Props;
<P>{post.data.description}</P> <P>{post.data.description}</P>
<div class="mt-1"> <div class="mt-1">
{post.data.tags.map((tag) => ( {post.data.tags.map((tag) => (
<TagComponent tag={tag} /> <TagComponent tag={tag} />
))} ))}
</div> </div>
</div> </div>

Datei anzeigen

@ -22,7 +22,7 @@
import wrap from "svelte-spa-router/wrap"; import wrap from "svelte-spa-router/wrap";
import Router, {replace} from "svelte-spa-router"; import Router, {replace} from "svelte-spa-router";
import {get} from "svelte/store"; import {get} from "svelte/store";
import {tokenStore} from "../repo/repo"; import {tokenStore} from "@repo/repo";
const routes: RouteDefinition = { const routes: RouteDefinition = {
'/': wrap({asyncComponent: () => import('./pages/Home.svelte'), conditions: detail => get(tokenStore) != ""}), '/': wrap({asyncComponent: () => import('./pages/Home.svelte'), conditions: detail => get(tokenStore) != ""}),

Datei anzeigen

@ -20,8 +20,8 @@
<script lang="ts"> <script lang="ts">
import {Input, Label, Select} from "flowbite-svelte"; import {Input, Label, Select} from "flowbite-svelte";
import TypeAheadSearch from "./TypeAheadSearch.svelte"; import TypeAheadSearch from "./TypeAheadSearch.svelte";
import {gamemodes, groups, maps, players} from "../../stores/stores"; import {gamemodes, groups, maps, players} from "@stores/stores.ts";
import type {Team} from '../../types/team.js'; import type {Team} from "@type/team.ts";
export let teams: Team[] = []; export let teams: Team[] = [];
export let blueTeam: string; export let blueTeam: string;
@ -29,8 +29,8 @@
export let start = ""; export let start = "";
export let gamemode = ""; export let gamemode = "";
export let map = ""; export let map = "";
export let kampfleiter = ""; export let kampfleiter: string | undefined = "";
export let group = ""; export let group: string | null = "";
export let groupSearch = ""; export let groupSearch = "";
$: selectPlayers = $players.map(player => { $: selectPlayers = $players.map(player => {

Datei anzeigen

@ -18,7 +18,7 @@
--> -->
<script lang="ts"> <script lang="ts">
import {Button, Dropdown, DropdownItem, Search} from 'flowbite-svelte' import {Button, Dropdown, Search} from 'flowbite-svelte'
export let selected: string | null = null export let selected: string | null = null
export let items: {name: string, value: string}[] = [] export let items: {name: string, value: string}[] = []

Datei anzeigen

@ -19,11 +19,11 @@
<script lang="ts"> <script lang="ts">
import {ArrowLeftSolid} from "flowbite-svelte-icons"; import {ArrowLeftSolid} from "flowbite-svelte-icons";
import {Button, Card, Input, Label, Navbar, NavBrand, NavHamburger, NavUl, Spinner} from "flowbite-svelte"; import {Button, Card, Navbar, NavBrand, Spinner} from "flowbite-svelte";
import {pageRepo} from "../../repo/repo"; import {pageRepo} from "@repo/repo.ts";
import {mapToMap, nameRegex} from "../util.ts"; import {mapToMap, nameRegex} from "../util.ts";
import TypeAheadSearch from "../components/TypeAheadSearch.svelte"; import TypeAheadSearch from "../components/TypeAheadSearch.svelte";
import {branches} from "../../stores/stores.ts"; import {branches} from "@stores/stores.ts";
import Editor from "./edit/Editor.svelte"; import Editor from "./edit/Editor.svelte";
$: pagesFuture = $pageRepo.listPages(selectedBranch); $: pagesFuture = $pageRepo.listPages(selectedBranch);

Datei anzeigen

@ -18,11 +18,11 @@
--> -->
<script lang="ts"> <script lang="ts">
import {Avatar, Navbar, NavBrand, Spinner, TabItem, Tabs} from "flowbite-svelte"; import {Navbar, NavBrand, Spinner, TabItem, Tabs} from "flowbite-svelte";
import EventEdit from "./event/EventEdit.svelte"; import EventEdit from "./event/EventEdit.svelte";
import {ArrowLeftSolid} from "flowbite-svelte-icons"; import {ArrowLeftSolid} from "flowbite-svelte-icons";
import FightList from "./event/FightList.svelte"; import FightList from "./event/FightList.svelte";
import {eventRepo} from "../../repo/repo"; import {eventRepo} from "@repo/repo.ts";
import TeamList from "./event/TeamList.svelte"; import TeamList from "./event/TeamList.svelte";
export let params: { id: number }; export let params: { id: number };

Datei anzeigen

@ -18,15 +18,12 @@
--> -->
<script lang="ts"> <script lang="ts">
import {Avatar, Navbar, NavBrand, Spinner, TabItem, Tabs} from "flowbite-svelte"; import {Navbar, NavBrand, Spinner, TabItem, Tabs} from "flowbite-svelte";
import EventEdit from "./event/EventEdit.svelte";
import {ArrowLeftSolid} from "flowbite-svelte-icons"; import {ArrowLeftSolid} from "flowbite-svelte-icons";
import FightList from "./event/FightList.svelte"; import {eventRepo} from "@repo/repo.ts";
import {eventRepo} from "../../repo/repo";
import TeamList from "./event/TeamList.svelte";
import GroupGenerator from "./generate/GroupGenerator.svelte"; import GroupGenerator from "./generate/GroupGenerator.svelte";
export let params: { id: number } = {}; export let params: { id: number };
let id = params.id; let id = params.id;
let event = $eventRepo.getEvent(id.toString()); let event = $eventRepo.getEvent(id.toString());

Datei anzeigen

@ -18,13 +18,12 @@
--> -->
<script lang="ts"> <script lang="ts">
import {Button, Modal, Navbar, NavBrand, NavHamburger, NavLi, NavUl, Spinner} from "flowbite-svelte"; import {Button, Modal, Navbar, NavBrand, NavHamburger, NavLi, NavUl, Spinner} from "flowbite-svelte";
import {replace} from "svelte-spa-router"; import {replace} from "svelte-spa-router";
import {PlusSolid} from "flowbite-svelte-icons"; import {PlusSolid} from "flowbite-svelte-icons";
import EventCard from "./home/EventCard.svelte"; import EventCard from "./home/EventCard.svelte";
import CreateEventModal from "./home/CreateEventModal.svelte"; import CreateEventModal from "./home/CreateEventModal.svelte";
import {eventRepo, tokenStore} from "../../repo/repo"; import {eventRepo, tokenStore} from "@repo/repo.ts";
let events = $eventRepo.listEvents() let events = $eventRepo.listEvents()
let showAdd = false let showAdd = false

Datei anzeigen

@ -21,8 +21,8 @@
import {Button, Input, Label, Spinner, Toast} from "flowbite-svelte"; import {Button, Input, Label, Spinner, Toast} from "flowbite-svelte";
import {fly} from "svelte/transition"; import {fly} from "svelte/transition";
import {replace} from "svelte-spa-router"; import {replace} from "svelte-spa-router";
import {EyeOutline, EyeSlashOutline, EyeSolid} from "flowbite-svelte-icons"; import {EyeOutline, EyeSlashOutline} from "flowbite-svelte-icons";
import {fetchWithToken, tokenStore} from "../../repo/repo"; import {fetchWithToken, tokenStore} from "@repo/repo.ts";
let show = false; let show = false;
let loading = false; let loading = false;

Datei anzeigen

@ -20,10 +20,9 @@
<script lang="ts"> <script lang="ts">
import {Button, Card, Checkbox, Input, Label, Navbar, NavBrand, Radio, Spinner} from "flowbite-svelte"; import {Button, Card, Checkbox, Input, Label, Navbar, NavBrand, Radio, Spinner} from "flowbite-svelte";
import {ArrowLeftSolid} from "flowbite-svelte-icons"; import {ArrowLeftSolid} from "flowbite-svelte-icons";
import {players} from "../../stores/stores.ts"; import {players} from "@stores/stores.ts";
import {permsRepo} from "../../repo/repo.ts"; import {permsRepo} from "@repo/repo.ts";
import {capitalize} from "../util.ts"; import {capitalize} from "../util.ts";
import type {Player} from "../../types/data.ts";
let search = ""; let search = "";
$: lowerCaseSearch = search.toLowerCase(); $: lowerCaseSearch = search.toLowerCase();

Datei anzeigen

@ -18,12 +18,12 @@
--> -->
<script lang="ts"> <script lang="ts">
import {Spinner, Toolbar, ToolbarButton, ToolbarGroup, Tooltip} from "flowbite-svelte"; import {Spinner, Toolbar, ToolbarButton, ToolbarGroup} from "flowbite-svelte";
import {json} from "@codemirror/lang-json"; import {json} from "@codemirror/lang-json";
import CodeMirror from "svelte-codemirror-editor"; import CodeMirror from "svelte-codemirror-editor";
import {pageRepo} from "../../../repo/repo.ts"; import {pageRepo} from "@repo/repo.ts";
import {base64ToBytes} from "../../util.ts"; import {base64ToBytes} from "../../util.ts";
import type {Page} from "../../../types/page.ts"; import type {Page} from "@type/page.ts";
import {materialDark} from '@ddietr/codemirror-themes/material-dark.js' import {materialDark} from '@ddietr/codemirror-themes/material-dark.js'
import {createEventDispatcher} from "svelte"; import {createEventDispatcher} from "svelte";
import MDEMarkdownEditor from "./MDEMarkdownEditor.svelte"; import MDEMarkdownEditor from "./MDEMarkdownEditor.svelte";

Datei anzeigen

@ -18,13 +18,13 @@
--> -->
<script lang="ts"> <script lang="ts">
import type {ExtendedEvent} from "../../../types/event.js"; import type {ExtendedEvent} from "@type/event.ts";
import {Button, Heading, Input, Label, Modal, Range, Select, Toast, Toggle} from "flowbite-svelte"; import {Button, Input, Label, Modal, Range, Select, Toast, Toggle} from "flowbite-svelte";
import {schemTypes} from "../../../stores/stores"; import {schemTypes} from "@stores/stores.ts";
import dayjs from "dayjs"; import dayjs from "dayjs";
import utc from "dayjs/plugin/utc" import utc from "dayjs/plugin/utc"
import type {UpdateEvent} from "../../../repo/event.js"; import type {UpdateEvent} from "@repo/event.ts";
import {eventRepo} from "../../../repo/repo"; import {eventRepo} from "@repo/repo.ts";
import ErrorModal from "../../components/ErrorModal.svelte"; import ErrorModal from "../../components/ErrorModal.svelte";
import {replace} from "svelte-spa-router"; import {replace} from "svelte-spa-router";
import {CheckCircleOutline} from "flowbite-svelte-icons"; import {CheckCircleOutline} from "flowbite-svelte-icons";
@ -43,7 +43,7 @@
let spectateSystem = event.spectateSystem; let spectateSystem = event.spectateSystem;
let errorOpen = false; let errorOpen = false;
let error: Error = undefined; let error: any = undefined;
let deleteOpen = false; let deleteOpen = false;
$: deadlineDate = dayjs(deadline); $: deadlineDate = dayjs(deadline);

Datei anzeigen

@ -18,13 +18,13 @@
--> -->
<script lang="ts"> <script lang="ts">
import {EditOutline, InboxSolid, TrashBinOutline} from "flowbite-svelte-icons"; import {EditOutline, TrashBinOutline} from "flowbite-svelte-icons";
import {Button, Checkbox, Modal, Toolbar, ToolbarButton} from "flowbite-svelte"; import {Button, Modal, Toolbar, ToolbarButton} from "flowbite-svelte";
import type {EventFight, ExtendedEvent} from "../../../types/event.js"; import type {EventFight, ExtendedEvent} from "@type/event.ts";
import FightEditModal from "./modals/FightEditModal.svelte"; import FightEditModal from "./modals/FightEditModal.svelte";
import {createEventDispatcher, onMount} from "svelte"; import {createEventDispatcher} from "svelte";
import {fightRepo} from "../../../repo/repo"; import {fightRepo} from "@repo/repo.ts";
import {isWide} from "../../../stores/stores"; import {isWide} from "@stores/stores.ts";
export let fight: EventFight; export let fight: EventFight;
export let data: ExtendedEvent; export let data: ExtendedEvent;

Datei anzeigen

@ -18,7 +18,7 @@
--> -->
<script lang="ts"> <script lang="ts">
import type {EventFight, ExtendedEvent} from "../../../types/event.js"; import type {EventFight, ExtendedEvent} from "@type/event.ts";
import { import {
Button, Button,
Checkbox, Input, Label, Checkbox, Input, Label,
@ -36,12 +36,12 @@
} from "flowbite-svelte-icons"; } from "flowbite-svelte-icons";
import FightCard from "./FightCard.svelte"; import FightCard from "./FightCard.svelte";
import CreateFightModal from "./modals/CreateFightModal.svelte"; import CreateFightModal from "./modals/CreateFightModal.svelte";
import {fightRepo} from "../../../repo/repo"; import {fightRepo} from "@repo/repo.ts";
import {groups, players} from "../../../stores/stores"; import {groups, players} from "@stores/stores.ts";
import TypeAheadSearch from "../../components/TypeAheadSearch.svelte"; import TypeAheadSearch from "../../components/TypeAheadSearch.svelte";
import type {UpdateFight} from "../../../repo/fight.js"; import type {UpdateFight} from "@repo/fight.ts";
import dayjs from "dayjs"; import dayjs from "dayjs";
import * as duration from "dayjs/plugin/duration" import duration from "dayjs/plugin/duration"
dayjs.extend(duration) dayjs.extend(duration)
export let data: ExtendedEvent; export let data: ExtendedEvent;

Datei anzeigen

@ -18,8 +18,8 @@
--> -->
<script lang="ts"> <script lang="ts">
import {Avatar, Button, Modal} from "flowbite-svelte"; import {Avatar} from "flowbite-svelte";
import type {ExtendedEvent} from "../../../types/event.js"; import type {ExtendedEvent} from "@type/event.ts";
export let data: ExtendedEvent; export let data: ExtendedEvent;
</script> </script>

Datei anzeigen

@ -19,10 +19,9 @@
<script lang="ts"> <script lang="ts">
import {Button, Modal} from "flowbite-svelte"; import {Button, Modal} from "flowbite-svelte";
import type {ExtendedEvent} from "../../../../types/event.js"; import type {ExtendedEvent} from "@type/event.ts";
import FightEditPart from "../../../components/FightEditPart.svelte"; import FightEditPart from "../../../components/FightEditPart.svelte";
import {fightRepo} from "../../../../repo/repo"; import {fightRepo} from "@repo/repo.ts";
import type {CreateFight} from "../../../../repo/fight.ts";
import ErrorModal from "../../../components/ErrorModal.svelte"; import ErrorModal from "../../../components/ErrorModal.svelte";
import {createEventDispatcher} from "svelte"; import {createEventDispatcher} from "svelte";
import dayjs from "dayjs"; import dayjs from "dayjs";
@ -40,12 +39,12 @@
let gamemode: string = ""; let gamemode: string = "";
let map: string = ""; let map: string = "";
let kampfleiter: string | null = null; let kampfleiter: string | undefined = undefined;
let group: string | null = null; let group: string | null = null;
let groupSearch = ""; let groupSearch = "";
let errorOpen = false; let errorOpen = false;
let error: Error | null = null; let error: any = undefined;
$: canCreate = blueTeam !== "" && redTeam !== "" && start !== "" && gamemode !== "" && map !== ""; $: canCreate = blueTeam !== "" && redTeam !== "" && start !== "" && gamemode !== "" && map !== "";

Datei anzeigen

@ -18,11 +18,11 @@
--> -->
<script lang="ts"> <script lang="ts">
import {Button, Input, Label, Modal, Select} from "flowbite-svelte"; import {Button, Modal} from "flowbite-svelte";
import type {EventFight, ExtendedEvent} from "../../../../types/event.js"; import type {EventFight, ExtendedEvent} from "@type/event.ts";
import FightEditPart from "../../../components/FightEditPart.svelte"; import FightEditPart from "../../../components/FightEditPart.svelte";
import type {UpdateFight} from "../../../../repo/fight.js"; import type {UpdateFight} from "@repo/fight.ts";
import {fightRepo} from "../../../../repo/repo"; import {fightRepo} from "@repo/repo.ts";
import ErrorModal from "../../../components/ErrorModal.svelte"; import ErrorModal from "../../../components/ErrorModal.svelte";
import {createEventDispatcher} from "svelte"; import {createEventDispatcher} from "svelte";
import dayjs from "dayjs"; import dayjs from "dayjs";
@ -37,14 +37,14 @@
let redTeam = fight.redTeam.id.toString(); let redTeam = fight.redTeam.id.toString();
let blueTeam = fight.blueTeam.id.toString(); let blueTeam = fight.blueTeam.id.toString();
let start = dayjs(fight.start).utc(true).toISOString().slice(0, -1); let start = dayjs(fight.start).utc(true).toISOString().slice(0, -1);
let kampfleiter = fight.kampfleiter.id.toString(); let kampfleiter = fight.kampfleiter?.id.toString();
let gamemode = fight.spielmodus let gamemode = fight.spielmodus
let map = fight.map; let map = fight.map;
let group = fight.group; let group = fight.group;
let groupSearch = fight.group ?? ""; let groupSearch = fight.group ?? "";
let errorOpen = false; let errorOpen = false;
let error = undefined; let error: any = undefined;
let dispatch = createEventDispatcher(); let dispatch = createEventDispatcher();
function save() { function save() {

Datei anzeigen

@ -36,7 +36,7 @@
} }
</script> </script>
<div class="w-56 bg-gray-800 p-4 rounded" class:border={dragover} class:m-px={!dragover} on:drop={handleDrop} on:dragover={handleDragOver} on:dragleave={() => dragover = false}> <div class="w-56 bg-gray-800 p-4 rounded" class:border={dragover} class:m-px={!dragover} on:drop={handleDrop} on:dragover={handleDragOver} on:dragleave={() => dragover = false} role="none">
<slot></slot> <slot></slot>
</div> </div>

Datei anzeigen

@ -18,14 +18,14 @@
--> -->
<script lang="ts"> <script lang="ts">
import type {ExtendedEvent} from "../../../types/event.js"; import type {ExtendedEvent} from "@type/event.ts";
import TeamChip from "./TeamChip.svelte"; import TeamChip from "./TeamChip.svelte";
import type {Team} from "../../../types/team.js"; import type {Team} from "@type/team.ts";
import DragAcceptor from "./DragAcceptor.svelte"; import DragAcceptor from "./DragAcceptor.svelte";
import {Button, Input, Label, Modal, Range, Select} from "flowbite-svelte"; import {Button, Input, Label, Modal, Range, Select} from "flowbite-svelte";
import {gamemodes, maps} from "../../../stores/stores"; import {gamemodes, maps} from "@stores/stores.ts";
import {PlusSolid} from "flowbite-svelte-icons"; import {PlusSolid} from "flowbite-svelte-icons";
import {fightRepo} from "../../../repo/repo"; import {fightRepo} from "@repo/repo.ts";
import {replace} from "svelte-spa-router"; import {replace} from "svelte-spa-router";
import dayjs from "dayjs"; import dayjs from "dayjs";

Datei anzeigen

@ -18,7 +18,7 @@
--> -->
<script lang="ts"> <script lang="ts">
import type {Team} from "../../../types/team.js"; import type {Team} from "@type/team.ts";
import {brightness, colorFromTeam, lighten} from "../../util"; import {brightness, colorFromTeam, lighten} from "../../util";
export let team: Team; export let team: Team;
@ -30,7 +30,8 @@
style:background-color={hover ? lighten(colorFromTeam(team)) : colorFromTeam(team)} class:text-black={brightness(colorFromTeam(team))} draggable="true" style:background-color={hover ? lighten(colorFromTeam(team)) : colorFromTeam(team)} class:text-black={brightness(colorFromTeam(team))} draggable="true"
on:dragstart on:dragstart
on:mouseenter={() => hover = true} on:mouseenter={() => hover = true}
on:mouseleave={() => hover = false}> on:mouseleave={() => hover = false}
role="figure">
<span>{team.name}</span> <span>{team.name}</span>
</div> </div>

Datei anzeigen

@ -21,14 +21,14 @@
import {Button, Input, Label, Modal} from "flowbite-svelte"; import {Button, Input, Label, Modal} from "flowbite-svelte";
import {createEventDispatcher} from "svelte"; import {createEventDispatcher} from "svelte";
import ErrorModal from "../../components/ErrorModal.svelte"; import ErrorModal from "../../components/ErrorModal.svelte";
import {eventRepo} from "../../../repo/repo"; import {eventRepo} from "@repo/repo.ts";
import dayjs from "dayjs"; import dayjs from "dayjs";
export let open = false; export let open = false;
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
let errorOpen = false; let errorOpen = false;
let error = undefined; let error: any = undefined;
let eventName = ""; let eventName = "";
let start = ""; let start = "";
@ -47,7 +47,7 @@
}) })
dispatch("create"); dispatch("create");
open = false; open = false;
} catch (e) { } catch (e: any) {
error = e; error = e;
errorOpen = true; errorOpen = true;
open = false; open = false;

Datei anzeigen

@ -20,7 +20,7 @@
<script lang="ts"> <script lang="ts">
import {Card} from "flowbite-svelte"; import {Card} from "flowbite-svelte";
import {link} from 'svelte-spa-router' import {link} from 'svelte-spa-router'
import type {ShortEvent} from "../../../types/event.js"; import type {ShortEvent} from "@type/event.ts";
export let event: ShortEvent; export let event: ShortEvent;

Datei anzeigen

@ -18,8 +18,8 @@
*/ */
import Color from "color"; import Color from "color";
import type {Team} from "../types/team.js"; import type {Team} from "@type/team.js";
import type {ListPage, PageList} from "../types/page.ts"; import type {ListPage, PageList} from "@type/page.ts";
export const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1); export const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);
@ -28,7 +28,7 @@ export const nameRegex = new RegExp("(?!.*\/).+(?=\\.(md|json))");
export function mapToMap(pages: PageList): Map<string, ListPage[]> { export function mapToMap(pages: PageList): Map<string, ListPage[]> {
const map = new Map(); const map = new Map();
for (const page of pages) { for (const page of pages) {
let folder = page.path.substring(0, page.path.indexOf(nameRegex.exec(page.path)!![0])); const folder = page.path.substring(0, page.path.indexOf(nameRegex.exec(page.path)![0]));
if (!map.has(folder)) { if (!map.has(folder)) {
map.set(folder, []); map.set(folder, []);
} }
@ -39,47 +39,47 @@ export function mapToMap(pages: PageList): Map<string, ListPage[]> {
export function colorFromTeam(team: Team): string { export function colorFromTeam(team: Team): string {
switch (team.color) { switch (team.color) {
case "1": case "1":
return "#0000AA"; return "#0000AA";
case "2": case "2":
return "#00AA00"; return "#00AA00";
case "3": case "3":
return "#00AAAA"; return "#00AAAA";
case "4": case "4":
return "#AA0000"; return "#AA0000";
case "5": case "5":
return "#AA00AA"; return "#AA00AA";
case "6": case "6":
return "#FFAA00"; return "#FFAA00";
case "7": case "7":
return "#AAAAAA"; return "#AAAAAA";
case "8": case "8":
return "#555555"; return "#555555";
case "9": case "9":
return "#5555FF"; return "#5555FF";
case "a": case "a":
return "#55FF55"; return "#55FF55";
case "b": case "b":
return "#55FFFF"; return "#55FFFF";
case "c": case "c":
return "#FF5555"; return "#FF5555";
case "d": case "d":
return "#FF55FF"; return "#FF55FF";
case "e": case "e":
return "#FFFF55"; return "#FFFF55";
case "f": case "f":
return "#FFFFFF"; return "#FFFFFF";
default: default:
return "#000000"; return "#000000";
} }
} }
export function lighten(color: string) { export function lighten(color: string) {
return brightness(color) ? Color(color).lighten(0.2).hex() : Color(color).darken(0.2).hex() return brightness(color) ? Color(color).lighten(0.2).hex() : Color(color).darken(0.2).hex();
} }
export function brightness(color: string) { export function brightness(color: string) {
return Color(color).isLight() return Color(color).isLight();
} }
export function base64ToBytes(base64: string) { export function base64ToBytes(base64: string) {

Datei anzeigen

@ -19,10 +19,10 @@
<script lang="ts"> <script lang="ts">
import {createEventDispatcher} from "svelte"; import {createEventDispatcher} from "svelte";
import {schemRepo} from "../repo/repo"; import {schemRepo} from "@repo/repo";
import {Modal, Spinner} from "flowbite-svelte"; import {Modal, Spinner} from "flowbite-svelte";
import SchematicInfoModal from "./SchematicInfoModal.svelte"; import SchematicInfoModal from "./SchematicInfoModal.svelte";
import type {Player} from "../types/data.ts"; import type {Player} from "@type/data.ts";
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();

Datei anzeigen

@ -21,10 +21,10 @@
import {astroI18n, t} from "astro-i18n"; import {astroI18n, t} from "astro-i18n";
import {CheckSolid, XCircleOutline} from "flowbite-svelte-icons"; import {CheckSolid, XCircleOutline} from "flowbite-svelte-icons";
import {Modal} from "flowbite-svelte"; import {Modal} from "flowbite-svelte";
import type {SchematicInfo} from "../types/schem.ts"; import type {SchematicInfo} from "@type/schem.ts";
import {createEventDispatcher} from "svelte"; import {createEventDispatcher} from "svelte";
import {schemRepo} from "../repo/repo"; import {schemRepo} from "@repo/repo";
import type {Player} from "../types/data.ts"; import type {Player} from "@type/data.ts";
import dayjs from "dayjs"; import dayjs from "dayjs";
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();

Datei anzeigen

@ -28,12 +28,12 @@
InfoCircleOutline InfoCircleOutline
} from "flowbite-svelte-icons"; } from "flowbite-svelte-icons";
import SchematicListTile from "./SchematicListTile.svelte"; import SchematicListTile from "./SchematicListTile.svelte";
import {Breadcrumb, BreadcrumbItem, Pagination, Tooltip} from "flowbite-svelte"; import {Breadcrumb, BreadcrumbItem, Tooltip} from "flowbite-svelte";
import {createEventDispatcher} from "svelte"; import {createEventDispatcher} from "svelte";
import type {SchematicList} from "../types/schem.ts"; import type {SchematicList} from "@type/schem.ts";
import SchematicInfo from "./SchematicInfo.svelte"; import SchematicInfo from "./SchematicInfo.svelte";
import UploadModal from "./UploadModal.svelte"; import UploadModal from "./UploadModal.svelte";
import type {Player} from "../types/data.ts"; import type {Player} from "@type/data.ts";
import SWButton from "../styled/SWButton.svelte"; import SWButton from "../styled/SWButton.svelte";
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();

Datei anzeigen

@ -20,8 +20,8 @@
<script lang="ts"> <script lang="ts">
import {astroI18n, t} from "astro-i18n"; import {astroI18n, t} from "astro-i18n";
import {CheckSolid, FileOutline, FolderOutline, XCircleOutline} from "flowbite-svelte-icons"; import {CheckSolid, FileOutline, FolderOutline, XCircleOutline} from "flowbite-svelte-icons";
import type {Schematic} from "../types/schem.ts"; import type {Schematic} from "@type/schem.ts";
import type {Player} from "../types/data.ts"; import type {Player} from "@type/data.ts";
import dayjs from "dayjs"; import dayjs from "dayjs";
import utc from "dayjs/plugin/utc"; import utc from "dayjs/plugin/utc";

Datei anzeigen

@ -18,8 +18,8 @@
--> -->
<script lang="ts"> <script lang="ts">
import type {Player} from "../types/data.ts"; import type {Player} from "@type/data.ts";
import {statsRepo} from "../repo/repo.ts"; import {statsRepo} from "@repo/repo.ts";
import {astroI18n, t} from "astro-i18n" import {astroI18n, t} from "astro-i18n"
export let user: Player; export let user: Player;

Datei anzeigen

@ -19,7 +19,7 @@
<script lang="ts"> <script lang="ts">
import {Modal} from "flowbite-svelte"; import {Modal} from "flowbite-svelte";
import {schemRepo} from "../repo/repo.ts"; import {schemRepo} from "@repo/repo.ts";
import {createEventDispatcher} from "svelte"; import {createEventDispatcher} from "svelte";
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();

Datei anzeigen

@ -19,9 +19,9 @@
<script lang="ts"> <script lang="ts">
import {t} from "astro-i18n"; import {t} from "astro-i18n";
import type {Player} from "../types/data.ts"; import type {Player} from "@type/data.ts";
import {authRepo, tokenStore} from "../repo/repo.ts"; import {authRepo, tokenStore} from "@repo/repo.ts";
import {l} from "../../util/util.ts"; import {l} from "@utils/util.ts";
import Statistics from "./Statistics.svelte"; import Statistics from "./Statistics.svelte";
export let user: Player; export let user: Player;

Datei anzeigen

@ -17,8 +17,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import type {Player, Server} from "../types/data.ts"; import type {Player, Server} from "@type/data.ts";
import {PlayerSchema, ServerSchema} from "../types/data.ts"; import {PlayerSchema, ServerSchema} from "@type/data.ts";
import {fetchWithToken} from "./repo.ts"; import {fetchWithToken} from "./repo.ts";
export class DataRepo { export class DataRepo {

Datei anzeigen

@ -17,9 +17,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import type {ExtendedEvent, ShortEvent, SWEvent} from "../types/event.js"; import type {ExtendedEvent, ShortEvent, SWEvent} from "@type/event";
import {fetchWithToken} from "./repo"; import {fetchWithToken} from "./repo";
import {ExtendedEventSchema, ShortEventSchema, SWEventSchema} from "../types/event.js"; import {ExtendedEventSchema, ShortEventSchema, SWEventSchema} from "@type/event.js";
import {z} from "zod"; import {z} from "zod";
import type {Dayjs} from "dayjs"; import type {Dayjs} from "dayjs";

Datei anzeigen

@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import type {EventFight} from "../types/event.js"; import type {EventFight} from "@type/event.js";
import {fetchWithToken} from "./repo"; import {fetchWithToken} from "./repo";
import {z} from "zod"; import {z} from "zod";
import {EventFightSchema} from "../types/event.js"; import {EventFightSchema} from "@type/event.js";
import type {Dayjs} from "dayjs"; import type {Dayjs} from "dayjs";
export interface CreateFight { export interface CreateFight {

Datei anzeigen

@ -17,9 +17,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import type {Page, PageList} from "../types/page.ts"; import type {Page, PageList} from "@type/page.ts";
import {fetchWithToken} from "./repo.ts"; import {fetchWithToken} from "./repo.ts";
import {PageListSchema, PageSchema} from "../types/page.ts"; import {PageListSchema, PageSchema} from "@type/page.ts";
import {bytesToBase64} from "../admin/util.ts"; import {bytesToBase64} from "../admin/util.ts";
import {z} from "zod"; import {z} from "zod";
@ -30,13 +30,13 @@ export class PageRepo {
return await fetchWithToken(this.token, `/page?branch=${branch}`) return await fetchWithToken(this.token, `/page?branch=${branch}`)
.then(value => value.json()) .then(value => value.json())
.then(PageListSchema.parse) .then(PageListSchema.parse)
.then(value => value.map(value1 => ({...value1, path: value1.path.replace("src/content/", "")}))) .then(value => value.map(value1 => ({...value1, path: value1.path.replace("src/content/", "")})));
} }
public async getPage(id: number, branch: string = "master"): Promise<Page> { public async getPage(id: number, branch: string = "master"): Promise<Page> {
return await fetchWithToken(this.token, `/page/${id}?branch=${branch}`) return await fetchWithToken(this.token, `/page/${id}?branch=${branch}`)
.then(value => value.json()) .then(value => value.json())
.then(PageSchema.parse) .then(PageSchema.parse);
} }
public async updatePage(id: number, content: string, sha: string, message: string, branch: string = "master"): Promise<void> { public async updatePage(id: number, content: string, sha: string, message: string, branch: string = "master"): Promise<void> {
@ -46,32 +46,32 @@ export class PageRepo {
content: bytesToBase64(new TextEncoder().encode(content)), content: bytesToBase64(new TextEncoder().encode(content)),
sha, message sha, message
}) })
}) });
} }
public async getBranches(): Promise<string[]> { public async getBranches(): Promise<string[]> {
return await fetchWithToken(this.token, "/page/branch") return await fetchWithToken(this.token, "/page/branch")
.then(value => value.json()) .then(value => value.json())
.then(value => z.array(z.string()).parse(value)) .then(value => z.array(z.string()).parse(value));
} }
public async createBranch(branch: string): Promise<void> { public async createBranch(branch: string): Promise<void> {
await fetchWithToken(this.token, `/page/branch`, {method: "POST", body: JSON.stringify({branch})}) await fetchWithToken(this.token, "/page/branch", {method: "POST", body: JSON.stringify({branch})});
} }
public async deleteBranch(branch: string): Promise<void> { public async deleteBranch(branch: string): Promise<void> {
await fetchWithToken(this.token, `/page/branch`, {method: "DELETE", body: JSON.stringify({branch})}) await fetchWithToken(this.token, "/page/branch", {method: "DELETE", body: JSON.stringify({branch})});
} }
public async createFile(path: string, branch: string = "master"): Promise<void> { public async createFile(path: string, branch: string = "master"): Promise<void> {
await fetchWithToken(this.token, `/page?branch=${branch}`, {method: "POST", body: JSON.stringify({path})}) await fetchWithToken(this.token, `/page?branch=${branch}`, {method: "POST", body: JSON.stringify({path})});
} }
public async merge(branch: string, message: string): Promise<void> { public async merge(branch: string, message: string): Promise<void> {
await fetchWithToken(this.token, `/page/branch/merge`, {method: "POST", body: JSON.stringify({branch, message})}) await fetchWithToken(this.token, "/page/branch/merge", {method: "POST", body: JSON.stringify({branch, message})});
} }
public async deletePage(id: number, message: string, sha: string, branch: string = "master"): Promise<void> { public async deletePage(id: number, message: string, sha: string, branch: string = "master"): Promise<void> {
await fetchWithToken(this.token, `/page/${id}?branch=${branch}`, {method: "DELETE", body: JSON.stringify({message, sha})}) await fetchWithToken(this.token, `/page/${id}?branch=${branch}`, {method: "DELETE", body: JSON.stringify({message, sha})});
} }
} }

Datei anzeigen

@ -17,9 +17,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import type {Perms, UserPerms} from "../types/perms.js"; import type {Perms, UserPerms} from "@type/perms.js";
import {fetchWithToken} from "./repo"; import {fetchWithToken} from "./repo";
import {PermsSchema, UserPermsSchema} from "../types/perms.js"; import {PermsSchema, UserPermsSchema} from "@type/perms.js";
export class PermsRepo { export class PermsRepo {
constructor(private token: string) {} constructor(private token: string) {}

Datei anzeigen

@ -18,18 +18,16 @@
*/ */
import {derived, writable} from "svelte/store"; import {derived, writable} from "svelte/store";
import {EventRepo} from "./event.js"; import {EventRepo} from "./event";
import {FightRepo} from "./fight.js"; import {FightRepo} from "./fight";
import {PermsRepo} from "./perms.js"; import {PermsRepo} from "./perms";
import {PageRepo} from "./page.ts"; import {PageRepo} from "./page";
import {DataRepo} from "./data.ts"; import {DataRepo} from "./data";
import {SchematicRepo} from "./schem";
import {StatsRepo} from "./stats";
import {AuthRepo} from "./auth";
import { AES, enc, format } from "crypto-js"; import { AES, enc } from "crypto-js";
import {SchematicRepo} from "./schem.ts";
import {StatsRepo} from "./stats.ts";
import {AuthRepo} from "./auth.ts";
export { EventRepo } from "./event.js"
export const apiUrl = import.meta.env.PUBLIC_API_SERVER; export const apiUrl = import.meta.env.PUBLIC_API_SERVER;
const secret = import.meta.env.PUBLIC_SECRET; const secret = import.meta.env.PUBLIC_SECRET;
@ -43,14 +41,14 @@ function decryptToken(token: string): string {
} }
export const fetchWithToken = (token: string, url: string, params: RequestInit = {}) => fetch(`${apiUrl}${url}`, {...params, headers: {...(token !== "" ? {"Authorization": "Bearer " + (token)}:{}), "Content-Type": "application/json", ...params.headers}}); export const fetchWithToken = (token: string, url: string, params: RequestInit = {}) => fetch(`${apiUrl}${url}`, {...params, headers: {...(token !== "" ? {"Authorization": "Bearer " + (token)}:{}), "Content-Type": "application/json", ...params.headers}});
export const tokenStore = writable(decryptToken(localStorage.getItem("sw-session") ?? "")) export const tokenStore = writable(decryptToken(localStorage.getItem("sw-session") ?? ""));
tokenStore.subscribe((value) => localStorage.setItem("sw-session", encryptToken(value))) tokenStore.subscribe((value) => localStorage.setItem("sw-session", encryptToken(value)));
export const eventRepo = derived(tokenStore, ($token) => new EventRepo($token)) export const eventRepo = derived(tokenStore, ($token) => new EventRepo($token));
export const fightRepo = derived(tokenStore, ($token) => new FightRepo($token)) export const fightRepo = derived(tokenStore, ($token) => new FightRepo($token));
export const permsRepo = derived(tokenStore, ($token) => new PermsRepo($token)) export const permsRepo = derived(tokenStore, ($token) => new PermsRepo($token));
export const pageRepo = derived(tokenStore, ($token) => new PageRepo($token)) export const pageRepo = derived(tokenStore, ($token) => new PageRepo($token));
export const dataRepo = derived(tokenStore, ($token) => new DataRepo($token)) export const dataRepo = derived(tokenStore, ($token) => new DataRepo($token));
export const schemRepo = derived(tokenStore, ($token) => new SchematicRepo($token)) export const schemRepo = derived(tokenStore, ($token) => new SchematicRepo($token));
export const statsRepo = derived(tokenStore, ($token) => new StatsRepo($token)) export const statsRepo = derived(tokenStore, ($token) => new StatsRepo($token));
export const authRepo = derived(tokenStore, ($token) => new AuthRepo($token)) export const authRepo = derived(tokenStore, ($token) => new AuthRepo($token));

Datei anzeigen

@ -18,8 +18,8 @@
*/ */
import {fetchWithToken} from "./repo.ts"; import {fetchWithToken} from "./repo.ts";
import type {SchematicCode, SchematicInfo, SchematicList} from "../types/schem.ts"; import type {SchematicCode, SchematicInfo, SchematicList} from "@type/schem.ts";
import {SchematicCodeSchema, SchematicInfoSchema, SchematicListSchema} from "../types/schem.ts"; import {SchematicCodeSchema, SchematicInfoSchema, SchematicListSchema} from "@type/schem.ts";
export class SchematicRepo { export class SchematicRepo {
constructor(private token: string) {} constructor(private token: string) {}
@ -41,12 +41,12 @@ export class SchematicRepo {
} }
public async uploadSchematic(name: string, content: string) { public async uploadSchematic(name: string, content: string) {
return await fetchWithToken(this.token, `/schem`, { return await fetchWithToken(this.token, "/schem", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
name, name,
content content
}) })
}) });
} }
} }

Datei anzeigen

@ -17,9 +17,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import type {FightStats, Ranking, UserStats} from "../types/stats.ts"; import type {FightStats, Ranking, UserStats} from "@type/stats.ts";
import {fetchWithToken} from "./repo.ts"; import {fetchWithToken} from "./repo.ts";
import {FightStatsSchema, RankingSchema, UserStatsSchema} from "../types/stats.ts"; import {FightStatsSchema, RankingSchema, UserStatsSchema} from "@type/stats.ts";
export class StatsRepo { export class StatsRepo {
@ -30,7 +30,7 @@ export class StatsRepo {
} }
public async getFightStats(): Promise<FightStats> { public async getFightStats(): Promise<FightStats> {
return await fetchWithToken(this.token, `/stats/fights`).then(value => value.json()).then(FightStatsSchema.parse); return await fetchWithToken(this.token, "/stats/fights").then(value => value.json()).then(FightStatsSchema.parse);
} }
public async getUserStats(id: number): Promise<UserStats> { public async getUserStats(id: number): Promise<UserStats> {

Datei anzeigen

@ -33,7 +33,7 @@ export function cached<T>(normal: T, init: () => Promise<T>): Cached<T> {
init().then(data => { init().then(data => {
store.set(data); store.set(data);
}); });
} };
return { return {
...readonly(store), ...readonly(store),
@ -52,7 +52,7 @@ export function cachedFamily<T, K>(normal: K, init: (arg0: T) => Promise<K>): (a
const stores: Map<T, Cached<K>> = new Map(); const stores: Map<T, Cached<K>> = new Map();
return (arg: T) => { return (arg: T) => {
if(stores.has(arg)) { if(stores.has(arg)) {
return stores.get(arg)!!; return stores.get(arg)!;
} else { } else {
const store = writable<K>(normal); const store = writable<K>(normal);
let first = true; let first = true;
@ -61,7 +61,7 @@ export function cachedFamily<T, K>(normal: K, init: (arg0: T) => Promise<K>): (a
init(arg).then(data => { init(arg).then(data => {
store.set(data); store.set(data);
}); });
} };
const cachedStore = { const cachedStore = {
...readonly(store), ...readonly(store),
@ -78,5 +78,5 @@ export function cachedFamily<T, K>(normal: K, init: (arg0: T) => Promise<K>): (a
stores.set(arg, cachedStore); stores.set(arg, cachedStore);
return cachedStore; return cachedStore;
} }
} };
} }

Datei anzeigen

@ -17,28 +17,28 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import type {Player, SchematicType} from "../types/data.js"; import type {Player, SchematicType} from "@type/data";
import {PlayerSchema} from "../types/data.js"; import {PlayerSchema} from "@type/data.ts";
import {cached, cachedFamily} from "./cached.js"; import {cached, cachedFamily} from "./cached";
import type {Team} from "../types/team.js"; import type {Team} from "@type/team.ts";
import {TeamSchema} from "../types/team.js"; import {TeamSchema} from "@type/team";
import {derived, get, writable} from "svelte/store"; import {derived, get, writable} from "svelte/store";
import {dataRepo, fetchWithToken, pageRepo, tokenStore} from "../repo/repo"; import {dataRepo, fetchWithToken, pageRepo, tokenStore} from "@repo/repo.ts";
import {z} from "zod"; import {z} from "zod";
export const schemTypes = cached<SchematicType[]>([], () => export const schemTypes = cached<SchematicType[]>([], () =>
fetchWithToken(get(tokenStore), `/data/schematicTypes`) fetchWithToken(get(tokenStore), "/data/schematicTypes")
.then(res => res.json())) .then(res => res.json()));
export const players = cached<Player[]>([], async () => { export const players = cached<Player[]>([], async () => {
const res = await fetchWithToken(get(tokenStore), `/data/users`); const res = await fetchWithToken(get(tokenStore), "/data/users");
return z.array(PlayerSchema).parse(await res.json()); return z.array(PlayerSchema).parse(await res.json());
}) });
export const gamemodes = cached<string[]>([], async () => { export const gamemodes = cached<string[]>([], async () => {
const res = await fetchWithToken(get(tokenStore), `/data/gamemodes`); const res = await fetchWithToken(get(tokenStore), "/data/gamemodes");
return z.array(z.string()).parse(await res.json()); return z.array(z.string()).parse(await res.json());
}) });
export const maps = cachedFamily<string, string[]>([], async (gamemode) => { export const maps = cachedFamily<string, string[]>([], async (gamemode) => {
if (get(gamemodes).every(value => value !== gamemode)) return []; if (get(gamemodes).every(value => value !== gamemode)) return [];
@ -49,22 +49,22 @@ export const maps = cachedFamily<string, string[]>([], async (gamemode) => {
} else { } else {
return res.json(); return res.json();
} }
}) });
export const groups = cached<string[]>([], async () => { export const groups = cached<string[]>([], async () => {
const res = await fetchWithToken(get(tokenStore), `/data/groups`); const res = await fetchWithToken(get(tokenStore), "/data/groups");
return z.array(z.string()).parse(await res.json()); return z.array(z.string()).parse(await res.json());
}) });
export const teams = cached<Team[]>([], async () => { export const teams = cached<Team[]>([], async () => {
const res = await fetchWithToken(get(tokenStore), `/team`); const res = await fetchWithToken(get(tokenStore), "/team");
return z.array(TeamSchema).parse(await res.json()); return z.array(TeamSchema).parse(await res.json());
}) });
export const branches = cached<string[]>([], async () => { export const branches = cached<string[]>([], async () => {
const res = await get(pageRepo).getBranches(); const res = await get(pageRepo).getBranches();
return z.array(z.string()).parse(res); return z.array(z.string()).parse(res);
}) });
export const server = derived(dataRepo, $dataRepo => $dataRepo.getServer()); export const server = derived(dataRepo, $dataRepo => $dataRepo.getServer());

Datei anzeigen

@ -22,7 +22,7 @@ import {z} from "zod";
export const SchematicTypeSchema = z.object({ export const SchematicTypeSchema = z.object({
name: z.string(), name: z.string(),
db: z.string(), db: z.string(),
}) });
export type SchematicType = z.infer<typeof SchematicTypeSchema>; export type SchematicType = z.infer<typeof SchematicTypeSchema>;
@ -32,7 +32,7 @@ export const PlayerSchema = z.object({
uuid: z.string(), uuid: z.string(),
prefix: z.string(), prefix: z.string(),
perms: z.array(z.string()), perms: z.array(z.string()),
}) });
export type Player = z.infer<typeof PlayerSchema>; export type Player = z.infer<typeof PlayerSchema>;
@ -48,6 +48,6 @@ export const ServerSchema = z.object({
protocol: z.number() protocol: z.number()
}), }),
favicon: z.string().optional() favicon: z.string().optional()
}) });
export type Server = z.infer<typeof ServerSchema>; export type Server = z.infer<typeof ServerSchema>;

Datei anzeigen

@ -26,7 +26,7 @@ export const ShortEventSchema = z.object({
name: z.string(), name: z.string(),
start: z.number(), start: z.number(),
end: z.number(), end: z.number(),
}) });
export type ShortEvent = z.infer<typeof ShortEventSchema>; export type ShortEvent = z.infer<typeof ShortEventSchema>;
@ -36,7 +36,7 @@ export const SWEventSchema = ShortEventSchema.extend({
schemType: z.string().nullable(), schemType: z.string().nullable(),
publicSchemsOnly: z.boolean(), publicSchemsOnly: z.boolean(),
spectateSystem: z.boolean(), spectateSystem: z.boolean(),
}) });
export type SWEvent = z.infer<typeof SWEventSchema>; export type SWEvent = z.infer<typeof SWEventSchema>;
@ -50,7 +50,7 @@ export const EventFightSchema = z.object({
start: z.number(), start: z.number(),
ergebnis: z.number(), ergebnis: z.number(),
group: z.string().nullable(), group: z.string().nullable(),
}) });
export type EventFight = z.infer<typeof EventFightSchema>; export type EventFight = z.infer<typeof EventFightSchema>;
@ -58,6 +58,6 @@ export const ExtendedEventSchema = z.object({
event: SWEventSchema, event: SWEventSchema,
teams: z.array(TeamSchema), teams: z.array(TeamSchema),
fights: z.array(EventFightSchema), fights: z.array(EventFightSchema),
}) });
export type ExtendedEvent = z.infer<typeof ExtendedEventSchema>; export type ExtendedEvent = z.infer<typeof ExtendedEventSchema>;

Datei anzeigen

@ -29,7 +29,7 @@ export const ListPageSchema = z.object({
export type ListPage = z.infer<typeof ListPageSchema>; export type ListPage = z.infer<typeof ListPageSchema>;
export const PageListSchema = z.array(ListPageSchema) export const PageListSchema = z.array(ListPageSchema);
export type PageList = z.infer<typeof PageListSchema>; export type PageList = z.infer<typeof PageListSchema>;
@ -41,7 +41,7 @@ export const PageSchema = z.object({
content: z.string(), content: z.string(),
size: z.number().gte(0), size: z.number().gte(0),
id: z.number().positive() id: z.number().positive()
}) });
export type Page = z.infer<typeof PageSchema>; export type Page = z.infer<typeof PageSchema>;

Datei anzeigen

@ -23,20 +23,20 @@ export const PrefixSchema = z.object({
name: z.string().startsWith("PREFIX_"), name: z.string().startsWith("PREFIX_"),
colorCode: z.string().length(2).startsWith("§"), colorCode: z.string().length(2).startsWith("§"),
chatPrefix: z.string() chatPrefix: z.string()
}) });
export type Prefix = z.infer<typeof PrefixSchema>; export type Prefix = z.infer<typeof PrefixSchema>;
export const PermsSchema = z.object({ export const PermsSchema = z.object({
perms: z.array(z.string()), perms: z.array(z.string()),
prefixes: z.record(PrefixSchema), prefixes: z.record(PrefixSchema),
}) });
export type Perms = z.infer<typeof PermsSchema>; export type Perms = z.infer<typeof PermsSchema>;
export const UserPermsSchema = z.object({ export const UserPermsSchema = z.object({
prefix: PrefixSchema, prefix: PrefixSchema,
perms: z.array(z.string()), perms: z.array(z.string()),
}) });
export type UserPerms = z.infer<typeof UserPermsSchema>; export type UserPerms = z.infer<typeof UserPermsSchema>;

Datei anzeigen

@ -30,7 +30,7 @@ export const SchematicSchema = z.object({
rank: z.number(), rank: z.number(),
replaceColor: z.boolean(), replaceColor: z.boolean(),
allowReplay: z.boolean() allowReplay: z.boolean()
}) });
export type Schematic = z.infer<typeof SchematicSchema> export type Schematic = z.infer<typeof SchematicSchema>
@ -41,7 +41,7 @@ export const SchematicListSchema = z.object({
})), })),
schematics: z.array(SchematicSchema), schematics: z.array(SchematicSchema),
players: z.record(z.string(), PlayerSchema) players: z.record(z.string(), PlayerSchema)
}) });
export type SchematicList = z.infer<typeof SchematicListSchema> export type SchematicList = z.infer<typeof SchematicListSchema>
@ -49,7 +49,7 @@ export const SchematicInfoSchema = z.object({
members: z.array(PlayerSchema), members: z.array(PlayerSchema),
path: z.string(), path: z.string(),
schem: SchematicSchema schem: SchematicSchema
}) });
export type SchematicInfo = z.infer<typeof SchematicInfoSchema> export type SchematicInfo = z.infer<typeof SchematicInfoSchema>
@ -57,6 +57,6 @@ export const SchematicCodeSchema = z.object({
id: z.number().gte(0), id: z.number().gte(0),
code: z.string(), code: z.string(),
expires: z.number().positive() expires: z.number().positive()
}) });
export type SchematicCode = z.infer<typeof SchematicCodeSchema> export type SchematicCode = z.infer<typeof SchematicCodeSchema>

Datei anzeigen

@ -22,7 +22,7 @@ import {z} from "zod";
export const RankingSchema = z.array(z.object({ export const RankingSchema = z.array(z.object({
name: z.string(), name: z.string(),
elo: z.number(), elo: z.number(),
})) }));
export type Ranking = z.infer<typeof RankingSchema>; export type Ranking = z.infer<typeof RankingSchema>;
@ -30,7 +30,7 @@ export const FightStatsSchema = z.array(z.object({
date: z.string(), date: z.string(),
gamemode: z.string(), gamemode: z.string(),
count: z.number(), count: z.number(),
})) }));
export type FightStats = z.infer<typeof FightStatsSchema>; export type FightStats = z.infer<typeof FightStatsSchema>;
@ -40,6 +40,6 @@ export const UserStatsSchema = z.object({
acceptedSchematics: z.number(), acceptedSchematics: z.number(),
fights: z.number(), fights: z.number(),
playtime: z.number() playtime: z.number()
}) });
export type UserStats = z.infer<typeof UserStatsSchema>; export type UserStats = z.infer<typeof UserStatsSchema>;

Datei anzeigen

@ -24,8 +24,6 @@ export const TeamSchema = z.object({
name: z.string(), name: z.string(),
kuerzel: z.string().min(1).max(4), kuerzel: z.string().min(1).max(4),
color: z.string().max(1), color: z.string().max(1),
}) });
export type Team = z.infer<typeof TeamSchema>; export type Team = z.infer<typeof TeamSchema>;

Datei anzeigen

@ -80,5 +80,16 @@
}, },
"elo": { "elo": {
"place": "Platz" "place": "Platz"
},
"announcements": {
"table": {
"time": "Startzeit",
"blue": "Blaues Team",
"red": "Rotes Team",
"winner": "Sieger",
"notPlayed": "Nicht gespielt",
"draw": "Unentschieden",
"points": "Punkte"
}
} }
} }

Datei anzeigen

@ -116,6 +116,9 @@
"time": "Time", "time": "Time",
"blue": "Blue Team", "blue": "Blue Team",
"red": "Red Team", "red": "Red Team",
"winner": "Winner",
"notPlayed": "Not Played",
"draw": "Draw",
"team": "Team", "team": "Team",
"points": "Points" "points": "Points"
} }

Datei anzeigen

@ -1,12 +1,12 @@
--- ---
import {astroI18n, createGetStaticPaths} from "astro-i18n"; import {astroI18n, createGetStaticPaths} from "astro-i18n";
import {getCollection, CollectionEntry} from "astro:content"; import {getCollection, CollectionEntry} from "astro:content";
import PageLayout from "../../layouts/PageLayout.astro"; import PageLayout from "@layouts/PageLayout.astro";
import {TagSolid, CalendarMonthSolid} from "flowbite-svelte-icons"; import {TagSolid, CalendarMonthSolid} from "flowbite-svelte-icons";
import TagComponent from "../../components/TagComponent.astro"; import TagComponent from "@components/TagComponent.astro";
import LanguageWarning from "../../components/LanguageWarning.astro"; import LanguageWarning from "@components/LanguageWarning.astro";
import { SEO } from "astro-seo"; import { SEO } from "astro-seo";
import localBau from "../../images/2022-03-28_13.18.25.png"; import localBau from "@images/2022-03-28_13.18.25.png";
import {getImage, Image} from "astro:assets"; import {getImage, Image} from "astro:assets";
export const getStaticPaths = createGetStaticPaths(async () => { export const getStaticPaths = createGetStaticPaths(async () => {
@ -88,12 +88,12 @@ const ogImage = await getImage({
)} )}
<Content /> <Content />
<script> <script>
import type {ExtendedEvent} from "../../components/types/event"; import type {ExtendedEvent} from "@types/event";
import FightTable from "../../components/FightTable.svelte"; import FightTable from "@components/FightTable.svelte";
// @ts-expect-error Import Schenanigans // @ts-expect-error Import Schenanigans
import {get} from "svelte/store"; import {get} from "svelte/store";
import {eventRepo} from "../../components/repo/repo"; import {eventRepo} from "@repo/repo";
import GroupTable from "../../components/GroupTable.svelte"; import GroupTable from "@components/GroupTable.svelte";
const eventMounts: Map<string, ((ev: ExtendedEvent) => void)[]> = new Map(); const eventMounts: Map<string, ((ev: ExtendedEvent) => void)[]> = new Map();
class FightTableElement extends HTMLElement { class FightTableElement extends HTMLElement {

Datei anzeigen

@ -1,14 +1,14 @@
--- ---
import NavbarLayout from "../layouts/NavbarLayout.astro"; import NavbarLayout from "@layouts/NavbarLayout.astro";
import { Image } from "astro:assets"; import { Image } from "astro:assets";
import localBau from "../images/2023-10-08_20.43.43.png"; import localBau from "@images/2023-10-08_20.43.43.png";
import {CaretRight, Archive, Rocket, Bell} from "@astropub/icons"; import {CaretRight, Archive, Rocket, Bell} from "@astropub/icons";
import {t} from "astro-i18n"; import {t} from "astro-i18n";
import {l} from "../util/util"; import {l} from "@utils/util";
import PlayerCount from "../components/PlayerCount.svelte"; import PlayerCount from "@components/PlayerCount.svelte";
import "../../public/fonts/barlow-condensed/barlow-condensed.css"; import "../../public/fonts/barlow-condensed/barlow-condensed.css";
import type {Player} from "../components/types/data"; import type {Player} from "@components/types/data";
const teamMember = await fetch("http://localhost:1337/data/team").then(value => value.json()); const teamMember = await fetch("http://localhost:1337/data/team").then(value => value.json());

Datei anzeigen

@ -1,9 +1,9 @@
--- ---
import Login from "../components/Login.svelte"; import Login from "@components/Login.svelte";
import NavbarLayout from "../layouts/NavbarLayout.astro"; import NavbarLayout from "@layouts/NavbarLayout.astro";
import {t} from "astro-i18n"; import {t} from "astro-i18n";
import {Image} from "astro:assets"; import {Image} from "astro:assets";
import localBau from "../images/2023-10-08_20.43.43.png"; import localBau from "@images/2023-10-08_20.43.43.png";
--- ---
<NavbarLayout title={t("login.page")}> <NavbarLayout title={t("login.page")}>

Datei anzeigen

@ -1,3 +1,25 @@
{ {
"extends": "astro/tsconfigs/strict" "extends": "astro/tsconfigs/strict",
"compilerOptions": {
"paths": {
"@components/*": ["./src/components/*"],
"@components": ["./src/components"],
"@pages/*": ["./src/pages/*"],
"@pages": ["./src/pages"],
"@styles/*": ["./src/styles/*"],
"@styles": ["./src/styles"],
"@utils/*": ["./src/util/*"],
"@utils": ["./src/util"],
"@type/*": ["./src/components/types/*"],
"@type": ["./src/components/types"],
"@images/*": ["./src/images/*"],
"@images": ["./src/images"],
"@layouts/*": ["./src/layouts/*"],
"@layouts": ["./src/layouts"],
"@repo/*": ["./src/components/repo/*"],
"@repo": ["./src/components/repo"],
"@stores/*": ["./src/components/stores/*"],
"@stores": ["./src/components/stores"],
}
}
} }