Dieser Commit ist enthalten in:
Ursprung
3108d9bf20
Commit
9a16c4b560
@ -22,7 +22,6 @@
|
||||
"@astrojs/tailwind": "^5.0.4",
|
||||
"@astropub/icons": "^0.2.0",
|
||||
"@types/color": "^3.0.6",
|
||||
"@types/crypto-js": "^4.2.1",
|
||||
"@types/node": "^20.10.5",
|
||||
"@typescript-eslint/eslint-plugin": "^6.15.0",
|
||||
"@typescript-eslint/parser": "^6.15.0",
|
||||
@ -52,7 +51,6 @@
|
||||
"chartjs-adapter-dayjs-4": "^1.0.4",
|
||||
"chartjs-adapter-moment": "^1.0.1",
|
||||
"color": "^4.2.3",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dayjs": "^1.11.10",
|
||||
"easymde": "^2.18.0",
|
||||
"flowbite": "^1.8.1",
|
||||
|
@ -38,9 +38,6 @@ dependencies:
|
||||
color:
|
||||
specifier: ^4.2.3
|
||||
version: 4.2.3
|
||||
crypto-js:
|
||||
specifier: ^4.2.0
|
||||
version: 4.2.0
|
||||
dayjs:
|
||||
specifier: ^1.11.10
|
||||
version: 1.11.10
|
||||
@ -85,9 +82,6 @@ devDependencies:
|
||||
'@types/color':
|
||||
specifier: ^3.0.6
|
||||
version: 3.0.6
|
||||
'@types/crypto-js':
|
||||
specifier: ^4.2.1
|
||||
version: 4.2.1
|
||||
'@types/node':
|
||||
specifier: ^20.10.5
|
||||
version: 20.10.5
|
||||
@ -1083,10 +1077,6 @@ packages:
|
||||
'@types/color-convert': 2.0.3
|
||||
dev: true
|
||||
|
||||
/@types/crypto-js@4.2.1:
|
||||
resolution: {integrity: sha512-FSPGd9+OcSok3RsM0UZ/9fcvMOXJ1ENE/ZbLfOPlBWj7BgXtEAM8VYfTtT760GiLbQIMoVozwVuisjvsVwqYWw==}
|
||||
dev: true
|
||||
|
||||
/@types/debug@4.1.12:
|
||||
resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==}
|
||||
dependencies:
|
||||
@ -1975,10 +1965,6 @@ packages:
|
||||
shebang-command: 2.0.0
|
||||
which: 2.0.2
|
||||
|
||||
/crypto-js@4.2.0:
|
||||
resolution: {integrity: sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==}
|
||||
dev: false
|
||||
|
||||
/css-declaration-sorter@7.1.1(postcss@8.4.32):
|
||||
resolution: {integrity: sha512-dZ3bVTEEc1vxr3Bek9vGwfB5Z6ESPULhcRvO472mfjVnj8jRcTnKO8/JTczlvxM10Myb+wBM++1MtdO76eWcaQ==}
|
||||
engines: {node: ^14 || ^16 || >=18}
|
||||
|
@ -19,9 +19,10 @@
|
||||
|
||||
<script lang="ts">
|
||||
import {t} from "astro-i18n"
|
||||
import {dataRepo, schemRepo} from "@repo/repo";
|
||||
import SchematicList from "./dashboard/SchematicList.svelte";
|
||||
import UserInfo from "./dashboard/UserInfo.svelte";
|
||||
import {dataRepo} from "@repo/data.ts";
|
||||
import {schemRepo} from "@repo/schem.ts";
|
||||
|
||||
let userFetch = getUser();
|
||||
let schematicFetch = getSchematics();
|
||||
|
@ -18,8 +18,8 @@
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
import {statsRepo} from "@repo/repo.ts";
|
||||
import {t} from "astro-i18n";
|
||||
import {statsRepo} from "@repo/stats.ts";
|
||||
|
||||
export let gamemode: string;
|
||||
|
||||
|
@ -18,9 +18,9 @@
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
import {statsRepo} from "@repo/repo.ts";
|
||||
import FightStatsChart from "./FightStatsChart.svelte";
|
||||
import {t} from "astro-i18n";
|
||||
import {statsRepo} from "@repo/stats.ts";
|
||||
|
||||
let request = getStats();
|
||||
|
||||
|
@ -28,7 +28,8 @@
|
||||
let error: string = "";
|
||||
|
||||
async function login() {
|
||||
let {tokenStore, authRepo} = await import("./repo/repo.ts");
|
||||
let {tokenStore} = await import("./repo/repo.ts");
|
||||
let {authRepo} = await import("./repo/auth.ts");
|
||||
if (username === "" || pw === "") {
|
||||
pw = "";
|
||||
error = t("login.error");
|
||||
|
@ -20,11 +20,11 @@
|
||||
<script lang="ts">
|
||||
import {ArrowLeftSolid} from "flowbite-svelte-icons";
|
||||
import {Button, Card, Navbar, NavBrand, Spinner} from "flowbite-svelte";
|
||||
import {pageRepo} from "@repo/repo.ts";
|
||||
import {mapToMap, nameRegex} from "../util.ts";
|
||||
import TypeAheadSearch from "../components/TypeAheadSearch.svelte";
|
||||
import {branches} from "@stores/stores.ts";
|
||||
import Editor from "./edit/Editor.svelte";
|
||||
import {pageRepo} from "@repo/page.ts";
|
||||
|
||||
$: pagesFuture = $pageRepo.listPages(selectedBranch);
|
||||
|
||||
|
@ -22,8 +22,8 @@
|
||||
import EventEdit from "./event/EventEdit.svelte";
|
||||
import {ArrowLeftSolid} from "flowbite-svelte-icons";
|
||||
import FightList from "./event/FightList.svelte";
|
||||
import {eventRepo} from "@repo/repo.ts";
|
||||
import TeamList from "./event/TeamList.svelte";
|
||||
import {eventRepo} from "@repo/event.ts";
|
||||
|
||||
export let params: { id: number };
|
||||
|
||||
|
@ -20,8 +20,8 @@
|
||||
<script lang="ts">
|
||||
import {Navbar, NavBrand, Spinner, TabItem, Tabs} from "flowbite-svelte";
|
||||
import {ArrowLeftSolid} from "flowbite-svelte-icons";
|
||||
import {eventRepo} from "@repo/repo.ts";
|
||||
import GroupGenerator from "./generate/GroupGenerator.svelte";
|
||||
import {eventRepo} from "@repo/event.ts";
|
||||
|
||||
export let params: { id: number };
|
||||
|
||||
|
@ -23,7 +23,8 @@
|
||||
import {PlusSolid} from "flowbite-svelte-icons";
|
||||
import EventCard from "./home/EventCard.svelte";
|
||||
import CreateEventModal from "./home/CreateEventModal.svelte";
|
||||
import {eventRepo, tokenStore} from "@repo/repo.ts";
|
||||
import {eventRepo} from "@repo/event.ts";
|
||||
import {tokenStore} from "@repo/repo.ts";
|
||||
|
||||
let events = $eventRepo.listEvents()
|
||||
let showAdd = false
|
||||
|
@ -21,8 +21,8 @@
|
||||
import {Button, Card, Checkbox, Input, Label, Navbar, NavBrand, Radio, Spinner} from "flowbite-svelte";
|
||||
import {ArrowLeftSolid} from "flowbite-svelte-icons";
|
||||
import {players} from "@stores/stores.ts";
|
||||
import {permsRepo} from "@repo/repo.ts";
|
||||
import {capitalize} from "../util.ts";
|
||||
import {permsRepo} from "@repo/perms.ts";
|
||||
|
||||
let search = "";
|
||||
$: lowerCaseSearch = search.toLowerCase();
|
||||
|
@ -21,12 +21,12 @@
|
||||
import {Spinner, Toolbar, ToolbarButton, ToolbarGroup} from "flowbite-svelte";
|
||||
import {json} from "@codemirror/lang-json";
|
||||
import CodeMirror from "svelte-codemirror-editor";
|
||||
import {pageRepo} from "@repo/repo.ts";
|
||||
import {base64ToBytes} from "../../util.ts";
|
||||
import type {Page} from "@type/page.ts";
|
||||
import {materialDark} from '@ddietr/codemirror-themes/material-dark.js'
|
||||
import {createEventDispatcher} from "svelte";
|
||||
import MDEMarkdownEditor from "./MDEMarkdownEditor.svelte";
|
||||
import {pageRepo} from "@repo/page.ts";
|
||||
|
||||
export let pageId: number;
|
||||
export let branch: string;
|
||||
|
@ -23,8 +23,7 @@
|
||||
import {schemTypes} from "@stores/stores.ts";
|
||||
import dayjs from "dayjs";
|
||||
import utc from "dayjs/plugin/utc"
|
||||
import type {UpdateEvent} from "@repo/event.ts";
|
||||
import {eventRepo} from "@repo/repo.ts";
|
||||
import {eventRepo, type UpdateEvent} from "@repo/event.ts";
|
||||
import ErrorModal from "../../components/ErrorModal.svelte";
|
||||
import {replace} from "svelte-spa-router";
|
||||
import {CheckCircleOutline} from "flowbite-svelte-icons";
|
||||
|
@ -23,8 +23,8 @@
|
||||
import type {EventFight, ExtendedEvent} from "@type/event.ts";
|
||||
import FightEditModal from "./modals/FightEditModal.svelte";
|
||||
import {createEventDispatcher} from "svelte";
|
||||
import {fightRepo} from "@repo/repo.ts";
|
||||
import {isWide} from "@stores/stores.ts";
|
||||
import {fightRepo} from "@repo/fight.ts";
|
||||
|
||||
export let fight: EventFight;
|
||||
export let data: ExtendedEvent;
|
||||
|
@ -36,10 +36,9 @@
|
||||
} from "flowbite-svelte-icons";
|
||||
import FightCard from "./FightCard.svelte";
|
||||
import CreateFightModal from "./modals/CreateFightModal.svelte";
|
||||
import {fightRepo} from "@repo/repo.ts";
|
||||
import {groups, players} from "@stores/stores.ts";
|
||||
import TypeAheadSearch from "../../components/TypeAheadSearch.svelte";
|
||||
import type {UpdateFight} from "@repo/fight.ts";
|
||||
import {fightRepo, type UpdateFight} from "@repo/fight.ts";
|
||||
import dayjs from "dayjs";
|
||||
import duration from "dayjs/plugin/duration"
|
||||
dayjs.extend(duration)
|
||||
|
@ -21,10 +21,10 @@
|
||||
import {Button, Modal} from "flowbite-svelte";
|
||||
import type {ExtendedEvent} from "@type/event.ts";
|
||||
import FightEditPart from "../../../components/FightEditPart.svelte";
|
||||
import {fightRepo} from "@repo/repo.ts";
|
||||
import ErrorModal from "../../../components/ErrorModal.svelte";
|
||||
import {createEventDispatcher} from "svelte";
|
||||
import dayjs from "dayjs";
|
||||
import {fightRepo} from "@repo/fight.ts";
|
||||
|
||||
let dispatch = createEventDispatcher();
|
||||
|
||||
|
@ -21,8 +21,7 @@
|
||||
import {Button, Modal} from "flowbite-svelte";
|
||||
import type {EventFight, ExtendedEvent} from "@type/event.ts";
|
||||
import FightEditPart from "../../../components/FightEditPart.svelte";
|
||||
import type {UpdateFight} from "@repo/fight.ts";
|
||||
import {fightRepo} from "@repo/repo.ts";
|
||||
import {fightRepo, type UpdateFight} from "@repo/fight.ts";
|
||||
import ErrorModal from "../../../components/ErrorModal.svelte";
|
||||
import {createEventDispatcher} from "svelte";
|
||||
import dayjs from "dayjs";
|
||||
|
@ -25,9 +25,9 @@
|
||||
import {Button, Input, Label, Modal, Range, Select} from "flowbite-svelte";
|
||||
import {gamemodes, maps} from "@stores/stores.ts";
|
||||
import {PlusSolid} from "flowbite-svelte-icons";
|
||||
import {fightRepo} from "@repo/repo.ts";
|
||||
import {replace} from "svelte-spa-router";
|
||||
import dayjs from "dayjs";
|
||||
import {fightRepo} from "@repo/fight.ts";
|
||||
|
||||
export let data: ExtendedEvent;
|
||||
$: teams = new Map<number, Team>(data.teams.map(team => [team.id, team]));
|
||||
|
@ -21,8 +21,8 @@
|
||||
import {Button, Input, Label, Modal} from "flowbite-svelte";
|
||||
import {createEventDispatcher} from "svelte";
|
||||
import ErrorModal from "../../components/ErrorModal.svelte";
|
||||
import {eventRepo} from "@repo/repo.ts";
|
||||
import dayjs from "dayjs";
|
||||
import {eventRepo} from "@repo/event.ts";
|
||||
|
||||
export let open = false;
|
||||
const dispatch = createEventDispatcher();
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
<script lang="ts">
|
||||
import {createEventDispatcher} from "svelte";
|
||||
import {schemRepo} from "@repo/repo";
|
||||
import {Modal, Spinner} from "flowbite-svelte";
|
||||
import SchematicInfoModal from "./SchematicInfoModal.svelte";
|
||||
import type {Player} from "@type/data.ts";
|
||||
import {schemRepo} from "@repo/schem.ts";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
|
@ -23,9 +23,9 @@
|
||||
import {Modal} from "flowbite-svelte";
|
||||
import type {SchematicInfo} from "@type/schem.ts";
|
||||
import {createEventDispatcher} from "svelte";
|
||||
import {schemRepo} from "@repo/repo";
|
||||
import type {Player} from "@type/data.ts";
|
||||
import dayjs from "dayjs";
|
||||
import {schemRepo} from "@repo/schem.ts";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
<script lang="ts">
|
||||
import type {Player} from "@type/data.ts";
|
||||
import {statsRepo} from "@repo/repo.ts";
|
||||
import {astroI18n, t} from "astro-i18n"
|
||||
import {statsRepo} from "@repo/stats.ts";
|
||||
|
||||
export let user: Player;
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
<script lang="ts">
|
||||
import {Modal} from "flowbite-svelte";
|
||||
import {schemRepo} from "@repo/repo.ts";
|
||||
import {createEventDispatcher} from "svelte";
|
||||
import {schemRepo} from "@repo/schem.ts";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
|
@ -20,9 +20,10 @@
|
||||
<script lang="ts">
|
||||
import {t} from "astro-i18n";
|
||||
import type {Player} from "@type/data.ts";
|
||||
import {authRepo, tokenStore} from "@repo/repo.ts";
|
||||
import {l} from "@utils/util.ts";
|
||||
import Statistics from "./Statistics.svelte";
|
||||
import {authRepo} from "@repo/auth.ts";
|
||||
import {tokenStore} from "@repo/repo.ts";
|
||||
|
||||
export let user: Player;
|
||||
|
||||
|
@ -17,7 +17,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {fetchWithToken} from "./repo.ts";
|
||||
import {fetchWithToken, tokenStore} from "./repo.ts";
|
||||
import {derived} from "svelte/store";
|
||||
|
||||
export class AuthRepo {
|
||||
constructor(private token: string) {
|
||||
@ -38,4 +39,6 @@ export class AuthRepo {
|
||||
method: "POST"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const authRepo = derived(tokenStore, ($token) => new AuthRepo($token));
|
@ -19,7 +19,8 @@
|
||||
|
||||
import type {Player, Server} from "@type/data.ts";
|
||||
import {PlayerSchema, ServerSchema} from "@type/data.ts";
|
||||
import {fetchWithToken} from "./repo.ts";
|
||||
import {fetchWithToken, tokenStore} from "./repo.ts";
|
||||
import {derived} from "svelte/store";
|
||||
|
||||
export class DataRepo {
|
||||
constructor(private token: string) {}
|
||||
@ -31,4 +32,6 @@ export class DataRepo {
|
||||
public async getMe(): Promise<Player> {
|
||||
return await fetchWithToken(this.token, "/data/me").then(value => value.json()).then(PlayerSchema.parse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const dataRepo = derived(tokenStore, ($token) => new DataRepo($token));
|
@ -18,10 +18,11 @@
|
||||
*/
|
||||
|
||||
import type {ExtendedEvent, ShortEvent, SWEvent} from "@type/event";
|
||||
import {fetchWithToken} from "./repo";
|
||||
import {fetchWithToken, tokenStore} from "./repo";
|
||||
import {ExtendedEventSchema, ShortEventSchema, SWEventSchema} from "@type/event.js";
|
||||
import {z} from "zod";
|
||||
import type {Dayjs} from "dayjs";
|
||||
import {derived} from "svelte/store";
|
||||
|
||||
export interface CreateEvent {
|
||||
name: string
|
||||
@ -95,3 +96,5 @@ export class EventRepo {
|
||||
return res.ok;
|
||||
}
|
||||
}
|
||||
|
||||
export const eventRepo = derived(tokenStore, ($token) => new EventRepo($token));
|
||||
|
@ -18,10 +18,11 @@
|
||||
*/
|
||||
|
||||
import type {EventFight} from "@type/event.js";
|
||||
import {fetchWithToken} from "./repo";
|
||||
import {fetchWithToken, tokenStore} from "./repo";
|
||||
import {z} from "zod";
|
||||
import {EventFightSchema} from "@type/event.js";
|
||||
import type {Dayjs} from "dayjs";
|
||||
import {derived} from "svelte/store";
|
||||
|
||||
export interface CreateFight {
|
||||
spielmodus: string
|
||||
@ -86,12 +87,14 @@ export class FightRepo {
|
||||
}
|
||||
|
||||
public async deleteFight(fightId: number): Promise<void> {
|
||||
let res = await fetchWithToken(this.token, `/fights/${fightId}`, {
|
||||
const res = await fetchWithToken(this.token, `/fights/${fightId}`, {
|
||||
method: "DELETE"
|
||||
})
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error("Could not delete fight: " + res.statusText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const fightRepo = derived(tokenStore, ($token) => new FightRepo($token));
|
||||
|
@ -18,10 +18,11 @@
|
||||
*/
|
||||
|
||||
import type {Page, PageList} from "@type/page.ts";
|
||||
import {fetchWithToken} from "./repo.ts";
|
||||
import {fetchWithToken, tokenStore} from "./repo.ts";
|
||||
import {PageListSchema, PageSchema} from "@type/page.ts";
|
||||
import {bytesToBase64} from "../admin/util.ts";
|
||||
import {z} from "zod";
|
||||
import {derived} from "svelte/store";
|
||||
|
||||
export class PageRepo {
|
||||
constructor(private token: string) {}
|
||||
@ -74,4 +75,6 @@ export class PageRepo {
|
||||
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})});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const pageRepo = derived(tokenStore, ($token) => new PageRepo($token));
|
@ -18,8 +18,9 @@
|
||||
*/
|
||||
|
||||
import type {Perms, UserPerms} from "@type/perms.js";
|
||||
import {fetchWithToken} from "./repo";
|
||||
import {fetchWithToken, tokenStore} from "./repo";
|
||||
import {PermsSchema, UserPermsSchema} from "@type/perms.js";
|
||||
import {derived} from "svelte/store";
|
||||
|
||||
export class PermsRepo {
|
||||
constructor(private token: string) {}
|
||||
@ -68,3 +69,5 @@ export class PermsRepo {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const permsRepo = derived(tokenStore, ($token) => new PermsRepo($token));
|
||||
|
@ -17,38 +17,16 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {derived, writable} from "svelte/store";
|
||||
import {EventRepo} from "./event";
|
||||
import {FightRepo} from "./fight";
|
||||
import {PermsRepo} from "./perms";
|
||||
import {PageRepo} from "./page";
|
||||
import {DataRepo} from "./data";
|
||||
import {SchematicRepo} from "./schem";
|
||||
import {StatsRepo} from "./stats";
|
||||
import {AuthRepo} from "./auth";
|
||||
import {writable} from "svelte/store";
|
||||
|
||||
import { AES, enc } from "crypto-js";
|
||||
export const fetchWithToken = (token: string, url: string, params: RequestInit = {}) =>
|
||||
fetch(`${import.meta.env.PUBLIC_API_SERVER}${url}`, {...params, headers: {...(token !== "" ? {"Authorization": "Bearer " + (token)}:{}), "Content-Type": "application/json", ...params.headers}})
|
||||
.then(value => {
|
||||
if (value.status === 401) {
|
||||
tokenStore.set("");
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
||||
export const apiUrl = import.meta.env.PUBLIC_API_SERVER;
|
||||
const secret = import.meta.env.PUBLIC_SECRET;
|
||||
|
||||
function encryptToken(token: string): string {
|
||||
return AES.encrypt(token, secret).toString();
|
||||
}
|
||||
|
||||
function decryptToken(token: string): string {
|
||||
return AES.decrypt(token, secret).toString(enc.Utf8);
|
||||
}
|
||||
|
||||
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") ?? ""));
|
||||
tokenStore.subscribe((value) => localStorage.setItem("sw-session", encryptToken(value)));
|
||||
|
||||
export const eventRepo = derived(tokenStore, ($token) => new EventRepo($token));
|
||||
export const fightRepo = derived(tokenStore, ($token) => new FightRepo($token));
|
||||
export const permsRepo = derived(tokenStore, ($token) => new PermsRepo($token));
|
||||
export const pageRepo = derived(tokenStore, ($token) => new PageRepo($token));
|
||||
export const dataRepo = derived(tokenStore, ($token) => new DataRepo($token));
|
||||
export const schemRepo = derived(tokenStore, ($token) => new SchematicRepo($token));
|
||||
export const statsRepo = derived(tokenStore, ($token) => new StatsRepo($token));
|
||||
export const authRepo = derived(tokenStore, ($token) => new AuthRepo($token));
|
||||
export const tokenStore = writable((localStorage.getItem("sw-session") ?? ""));
|
||||
tokenStore.subscribe((value) => localStorage.setItem("sw-session", value));
|
||||
|
@ -17,9 +17,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {fetchWithToken} from "./repo.ts";
|
||||
import {fetchWithToken, tokenStore} from "./repo.ts";
|
||||
import type {SchematicCode, SchematicInfo, SchematicList} from "@type/schem.ts";
|
||||
import {SchematicCodeSchema, SchematicInfoSchema, SchematicListSchema} from "@type/schem.ts";
|
||||
import {derived} from "svelte/store";
|
||||
|
||||
export class SchematicRepo {
|
||||
constructor(private token: string) {}
|
||||
@ -49,4 +50,6 @@ export class SchematicRepo {
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const schemRepo = derived(tokenStore, ($token) => new SchematicRepo($token));
|
@ -18,8 +18,9 @@
|
||||
*/
|
||||
|
||||
import type {FightStats, Ranking, UserStats} from "@type/stats.ts";
|
||||
import {fetchWithToken} from "./repo.ts";
|
||||
import {fetchWithToken, tokenStore} from "./repo.ts";
|
||||
import {FightStatsSchema, RankingSchema, UserStatsSchema} from "@type/stats.ts";
|
||||
import {derived} from "svelte/store";
|
||||
|
||||
export class StatsRepo {
|
||||
|
||||
@ -36,4 +37,6 @@ export class StatsRepo {
|
||||
public async getUserStats(id: number): Promise<UserStats> {
|
||||
return await fetchWithToken(this.token, `/stats/user/${id}`).then(value => value.json()).then(UserStatsSchema.parse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const statsRepo = derived(tokenStore, ($token) => new StatsRepo($token));
|
@ -23,8 +23,10 @@ import {cached, cachedFamily} from "./cached";
|
||||
import type {Team} from "@type/team.ts";
|
||||
import {TeamSchema} from "@type/team";
|
||||
import {derived, get, writable} from "svelte/store";
|
||||
import {dataRepo, fetchWithToken, pageRepo, tokenStore} from "@repo/repo.ts";
|
||||
import {z} from "zod";
|
||||
import {fetchWithToken, tokenStore} from "@repo/repo.ts";
|
||||
import {pageRepo} from "@repo/page.ts";
|
||||
import {dataRepo} from "@repo/data.ts";
|
||||
|
||||
export const schemTypes = cached<SchematicType[]>([], () =>
|
||||
fetchWithToken(get(tokenStore), "/data/schematicTypes")
|
||||
|
@ -88,12 +88,12 @@ const ogImage = await getImage({
|
||||
)}
|
||||
<Content />
|
||||
<script>
|
||||
import type {ExtendedEvent} from "@types/event";
|
||||
import FightTable from "@components/FightTable.svelte";
|
||||
// @ts-expect-error Import Schenanigans
|
||||
import {get} from "svelte/store";
|
||||
import {eventRepo} from "@repo/repo";
|
||||
import GroupTable from "@components/GroupTable.svelte";
|
||||
import {eventRepo} from "../../components/repo/event";
|
||||
import type {ExtendedEvent} from "@type/event";
|
||||
const eventMounts: Map<string, ((ev: ExtendedEvent) => void)[]> = new Map();
|
||||
|
||||
class FightTableElement extends HTMLElement {
|
||||
|
@ -5,10 +5,9 @@ import {t} from "astro-i18n";
|
||||
---
|
||||
|
||||
<PageLayout title={t("dashboard.page")}>
|
||||
<script>
|
||||
import {AES} from "crypto-js";
|
||||
<script is:inline>
|
||||
import {l} from "../util/util";
|
||||
if (AES.decrypt(localStorage.getItem("sw-session") ?? "", import.meta.env.PUBLIC_SECRET)?.toString() === "") {
|
||||
if ((localStorage.getItem("sw-session") ?? "") === "") {
|
||||
window.location.href = l("/login");
|
||||
}
|
||||
</script>
|
||||
|
@ -7,11 +7,10 @@ import localBau from "@images/2023-10-08_20.43.43.png";
|
||||
---
|
||||
|
||||
<NavbarLayout title={t("login.page")}>
|
||||
<script>
|
||||
<script is:inline>
|
||||
import {l} from "../util/util";
|
||||
import {AES} from "crypto-js";
|
||||
|
||||
if (AES.decrypt(localStorage.getItem("sw-session") ?? "", import.meta.env.PUBLIC_SECRET)?.toString() !== "") {
|
||||
if ((localStorage.getItem("sw-session") ?? "") !== "") {
|
||||
window.location.href = l("/dashboard");
|
||||
}
|
||||
</script>
|
||||
|
@ -1,8 +1,3 @@
|
||||
setup:
|
||||
- "echo 'PUBLIC_API_SERVER=https://steamwar.de/eventplanner-api/
|
||||
PUBLIC_SECRET=mae6eeheeT4Quain' > .env"
|
||||
|
||||
build:
|
||||
- "pnpm run ci"
|
||||
|
||||
artifacts:
|
||||
- "echo 'PUBLIC_API_SERVER=https://steamwar.de/eventplanner-api/"
|
||||
- "pnpm run ci"
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren