diff --git a/src/lib/components/consts.ts b/src/lib/components/consts.ts new file mode 100644 index 0000000..ec93359 --- /dev/null +++ b/src/lib/components/consts.ts @@ -0,0 +1 @@ +export const apiBaseUrl = 'https://wip.chellaris.net/api'; \ No newline at end of file diff --git a/src/lib/stores/AuthTokenStore.ts b/src/lib/stores/AuthTokenStore.ts new file mode 100644 index 0000000..2459fc1 --- /dev/null +++ b/src/lib/stores/AuthTokenStore.ts @@ -0,0 +1,5 @@ +import { writable, type Writable } from "svelte/store"; + +const AuthTokenStore: Writable = writable(""); + +export default AuthTokenStore; \ No newline at end of file diff --git a/src/lib/stores/admin-page/EmpireStore.ts b/src/lib/stores/admin-page/EmpireStore.ts new file mode 100644 index 0000000..1022b6d --- /dev/null +++ b/src/lib/stores/admin-page/EmpireStore.ts @@ -0,0 +1,5 @@ +import { writable, type Writable } from "svelte/store"; + +const AdminSelectedEmpireStore: Writable<{ [key: number]: number }> = writable({}); + +export default AdminSelectedEmpireStore; \ No newline at end of file diff --git a/src/lib/stores/admin-page/GameDataStore.ts b/src/lib/stores/admin-page/GameDataStore.ts new file mode 100644 index 0000000..9318da2 --- /dev/null +++ b/src/lib/stores/admin-page/GameDataStore.ts @@ -0,0 +1,7 @@ +import { writable, type Writable } from "svelte/store"; +import type { ChellarisInfo } from '../../types/chellaris'; +import { createChellarisInfo } from '../../types/chellaris'; + +const AdminGameDataStore: Writable = writable(createChellarisInfo()); + +export default AdminGameDataStore; \ No newline at end of file diff --git a/src/lib/stores/admin-page/GameStore.ts b/src/lib/stores/admin-page/GameStore.ts new file mode 100644 index 0000000..aefd93a --- /dev/null +++ b/src/lib/stores/admin-page/GameStore.ts @@ -0,0 +1,5 @@ +import { writable, type Writable } from "svelte/store"; + +const AdminSelectedGameStore: Writable = writable(); + +export default AdminSelectedGameStore; \ No newline at end of file diff --git a/src/lib/types/chellaris.ts b/src/lib/types/chellaris.ts index 14083ce..98556c6 100644 --- a/src/lib/types/chellaris.ts +++ b/src/lib/types/chellaris.ts @@ -29,6 +29,11 @@ export type ChellarisEmpire = { ethics: { [key: number]: Ethic }, } +export type ChellarisGameInfo = { + id: number, + name: string +} + export const createChellarisInfo = (): ChellarisInfo => { const newChellarisInfo = { games: [], diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 32d1a32..0fbfc81 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -11,19 +11,12 @@ diff --git a/src/routes/Header.svelte b/src/routes/Header.svelte index 2be1cc5..cb67f51 100644 --- a/src/routes/Header.svelte +++ b/src/routes/Header.svelte @@ -53,6 +53,7 @@ diff --git a/src/routes/admin/+page.ts b/src/routes/admin/+page.ts new file mode 100644 index 0000000..04a4d5f --- /dev/null +++ b/src/routes/admin/+page.ts @@ -0,0 +1,30 @@ +import { apiBaseUrl } from "$lib/components/consts"; +import AdminSelectedEmpireStore from "$lib/stores/admin-page/EmpireStore"; +import AdminSelectedGameStore from "$lib/stores/admin-page/GameStore"; +import type { ChellarisGameInfo } from "$lib/types/chellaris"; + +export async function load ({ fetch }) { + const gameList: { [key: number]: ChellarisGameInfo } = await (await fetch(apiBaseUrl + "/v3/list_games")).json(); + + let store: string | null; + + if (typeof localStorage !== 'undefined') { + // Game Selection + store = localStorage.getItem('adminGameSelection'); + if (typeof store === 'string') { + AdminSelectedGameStore.set(JSON.parse(store)); + } + + // Empire Selection + store = localStorage.getItem('adminEmpireSelection'); + + if (typeof store === 'string' && store != "\"\"") { + AdminSelectedEmpireStore.set(JSON.parse(store)); + } + else if (typeof store === 'string') { + AdminSelectedEmpireStore.set({}); + } + } + + return { games: gameList }; +} \ No newline at end of file diff --git a/src/routes/admin/List.svelte b/src/routes/admin/List.svelte new file mode 100644 index 0000000..b2a8846 --- /dev/null +++ b/src/routes/admin/List.svelte @@ -0,0 +1,43 @@ + + +
+
+ {listTitle} +
+
+ +
+
+ + diff --git a/src/routes/graphs/+layout.svelte b/src/routes/graphs/+layout.svelte index 17c17b6..ba7bb97 100644 --- a/src/routes/graphs/+layout.svelte +++ b/src/routes/graphs/+layout.svelte @@ -44,19 +44,16 @@ diff --git a/src/routes/legacy-graphs/+page.svelte b/src/routes/legacy-graphs/+page.svelte index a042dbd..24a771a 100644 --- a/src/routes/legacy-graphs/+page.svelte +++ b/src/routes/legacy-graphs/+page.svelte @@ -23,83 +23,21 @@ {:else}
-
-
- -
- -
-
-
- -
-
- -
-
+ + + +
{/if} diff --git a/src/routes/legacy-graphs/EmpireStats.svelte b/src/routes/legacy-graphs/EmpireStats.svelte index e85e9db..7f0433f 100644 --- a/src/routes/legacy-graphs/EmpireStats.svelte +++ b/src/routes/legacy-graphs/EmpireStats.svelte @@ -14,16 +14,8 @@ diff --git a/src/routes/legacy-graphs/EthicsBar.svelte b/src/routes/legacy-graphs/EthicsBar.svelte index e55c0f7..6db9d71 100644 --- a/src/routes/legacy-graphs/EthicsBar.svelte +++ b/src/routes/legacy-graphs/EthicsBar.svelte @@ -61,6 +61,8 @@ }; const options = { + responsive: true, + maintainAspectRatio: false, animation: { duration: 0 }, @@ -100,16 +102,7 @@ diff --git a/src/routes/legacy-graphs/EthicsWeb.svelte b/src/routes/legacy-graphs/EthicsWeb.svelte index ac35f5f..a4ae62c 100644 --- a/src/routes/legacy-graphs/EthicsWeb.svelte +++ b/src/routes/legacy-graphs/EthicsWeb.svelte @@ -96,6 +96,8 @@ }; const options = { + responsive: true, + maintainAspectRatio: false, animation: { duration: 0 }, @@ -157,29 +159,33 @@ } -
- +
+
+ +
+ diff --git a/src/routes/legacy-graphs/PopsPie.svelte b/src/routes/legacy-graphs/PopsPie.svelte index 75a0ba2..499725b 100644 --- a/src/routes/legacy-graphs/PopsPie.svelte +++ b/src/routes/legacy-graphs/PopsPie.svelte @@ -42,6 +42,8 @@ }; const options = { + responsive: true, + maintainAspectRatio: false, animation: { duration: 0 }, @@ -86,16 +88,7 @@