From 980a6cef64bd917a7511aea9d266ed362c5de1a9 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sat, 24 Aug 2024 13:31:41 +0100 Subject: [PATCH 01/27] fix: typo in server `package.json` main url (mjs) --- server/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/package.json b/server/package.json index 585b351..a67bb08 100644 --- a/server/package.json +++ b/server/package.json @@ -2,7 +2,7 @@ "name": "server", "version": "1.0.0", "description": "", - "main": "websocket.mjjs", + "main": "websocket.mjs", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -11,4 +11,4 @@ "dependencies": { "ws": "^8.17.0" } -} +} \ No newline at end of file From afa668827b91661101a37b84ce9d5d8ea94f8235 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sat, 24 Aug 2024 13:31:57 +0100 Subject: [PATCH 02/27] feat: add better type checking with netrunnerDB API response --- dashboard/src/lib/store.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/dashboard/src/lib/store.ts b/dashboard/src/lib/store.ts index 1184466..7b7058b 100644 --- a/dashboard/src/lib/store.ts +++ b/dashboard/src/lib/store.ts @@ -4,6 +4,7 @@ import type { PlayerData, TimerData, PlayerAttributes, + Card } from "./types"; // JSON @@ -15,7 +16,18 @@ import DefaultTimer from "$lib/data/default/timer.json"; export const websocketToken = writable(); // API data -export const netrunnerDB = writable>(new Map()); +export const netrunnerDB = writable<{ + data: Card[]; + links: { + first: string; + last?: string; + }; +}>({ + data: [], + links: { + first: "" + } +}); // Websocket data export const globalData = writable(DefaultGlobal); From 212d157c454cfbea79de93e78a05d2e5d794b497 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sat, 24 Aug 2024 13:32:13 +0100 Subject: [PATCH 03/27] chore: update netrunnerdb api to use production endpoint --- dashboard/src/lib/data/api.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dashboard/src/lib/data/api.json b/dashboard/src/lib/data/api.json index 23cc178..f0f7d26 100644 --- a/dashboard/src/lib/data/api.json +++ b/dashboard/src/lib/data/api.json @@ -1,6 +1,6 @@ { - "endpoint": "https://api-preview.netrunnerdb.com/api/v3/public", + "endpoint": "https://api.netrunnerdb.com/api/v3/public", "cards": "/cards?page[limit]=2000", "factions": "/factions", "identities": "/cards?filter[card_type_id]=corp_identity&runner_identity&page[limit]=1000" -} +} \ No newline at end of file From da59b1655dd31ce4ac63577c82fbb5cc68e89780 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sat, 24 Aug 2024 13:32:47 +0100 Subject: [PATCH 04/27] misc: formatting in `` component --- .../lib/components/dashboard/Search.svelte | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/dashboard/src/lib/components/dashboard/Search.svelte b/dashboard/src/lib/components/dashboard/Search.svelte index cba6b6f..5b3f025 100644 --- a/dashboard/src/lib/components/dashboard/Search.svelte +++ b/dashboard/src/lib/components/dashboard/Search.svelte @@ -31,17 +31,24 @@ let selected: string[] = []; const filter = () => { - results = new Fuse($netrunnerDB.data.filter((i: any) => true), { - keys: ["attributes.title", "attributes.stripped_title"] - }) - .search(searchText) - .slice(0, 8); - } + results = new Fuse( + $netrunnerDB.data.filter((i: boolean) => true), + { + keys: ["attributes.title", "attributes.stripped_title"], + }, + ) + .search(searchText) + .slice(0, 8); + };
- +
dispatch("card", card.attributes.latest_printing_id)} + on:click={() => + dispatch("card", card.attributes.latest_printing_id)} > -

{card.attributes.stripped_title}

+

+ {card.attributes.stripped_title} +

{/each}
-
\ No newline at end of file + From 5a0fa752b26737ec0153572c3c4881c974d9f1e2 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sat, 24 Aug 2024 13:34:38 +0100 Subject: [PATCH 05/27] misc: formatting --- dashboard/src/routes/dashboard/+page.svelte | 4 +- .../overlay/player/[slug]/cards/+page.svelte | 42 +++++++++---------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/dashboard/src/routes/dashboard/+page.svelte b/dashboard/src/routes/dashboard/+page.svelte index 336c1e0..bca99d4 100644 --- a/dashboard/src/routes/dashboard/+page.svelte +++ b/dashboard/src/routes/dashboard/+page.svelte @@ -146,7 +146,9 @@ }; -
+
diff --git a/dashboard/src/routes/overlay/player/[slug]/cards/+page.svelte b/dashboard/src/routes/overlay/player/[slug]/cards/+page.svelte index e84e7a0..9fc99fc 100644 --- a/dashboard/src/routes/overlay/player/[slug]/cards/+page.svelte +++ b/dashboard/src/routes/overlay/player/[slug]/cards/+page.svelte @@ -1,32 +1,32 @@ - {#if side === "left"} - -
- {:else if side === "right"} -
- - {/if} - \ No newline at end of file + {#if side === "left"} + +
+ {:else if side === "right"} +
+ + {/if} + From 2bcdd7107bd55dfc139c95494923f943389631dc Mon Sep 17 00:00:00 2001 From: AlexR Date: Sat, 24 Aug 2024 13:35:07 +0100 Subject: [PATCH 06/27] refactor: remove redundant `console.log`'s --- .../lib/components/dashboard/Player.svelte | 22 +++++++------------ dashboard/src/lib/utils.ts | 4 +--- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/dashboard/src/lib/components/dashboard/Player.svelte b/dashboard/src/lib/components/dashboard/Player.svelte index b8ff11f..19771fc 100644 --- a/dashboard/src/lib/components/dashboard/Player.svelte +++ b/dashboard/src/lib/components/dashboard/Player.svelte @@ -46,14 +46,6 @@ const togglePlayerID = (active: TGameSide) => { let opposite: TGameSide = active === "corp" ? "runner" : "corp"; - // console.log('================================================', { - // currentPlayer: name, - // selected: { - // active: active, - // inactive: opposite, - // }, - // }) - dispatch("swap_deck", { currentPlayer: name, selected: { @@ -294,14 +286,17 @@
{ - playerCurrent.highlight[type].active = !playerCurrent.highlight[type].active; - console.log(playerCurrent.highlight[type].active); + playerCurrent.highlight[type].active = + !playerCurrent.highlight[type].active; deploy(); }} /> - +
@@ -309,7 +304,7 @@ { playerCurrent.highlight[type].current = e.detail; deploy(); @@ -318,6 +313,5 @@ {/each} - diff --git a/dashboard/src/lib/utils.ts b/dashboard/src/lib/utils.ts index 8d3bda1..a6d3fea 100644 --- a/dashboard/src/lib/utils.ts +++ b/dashboard/src/lib/utils.ts @@ -144,9 +144,7 @@ export const fetch_cards = async () => { try { const response = await fetch(api.endpoint + api.cards); - netrunnerDB.subscribe((value) => { - // console.log(value); - }); + netrunnerDB.subscribe((value) => { }); if (!response.ok) { throw new Error("Network response was not ok"); From c7172fc13dffd3a7b1086cc77393a0c68181a7e8 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 13:06:47 +0100 Subject: [PATCH 07/27] style: improve wording/iconography of Connection component (websocket status) --- .../components/dashboard/Connection.svelte | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/dashboard/src/lib/components/dashboard/Connection.svelte b/dashboard/src/lib/components/dashboard/Connection.svelte index b81014f..0f8b5bb 100644 --- a/dashboard/src/lib/components/dashboard/Connection.svelte +++ b/dashboard/src/lib/components/dashboard/Connection.svelte @@ -2,17 +2,26 @@ import { PUBLIC_WEBSOCKET_CONNECTION } from "$env/static/public"; import { globalData } from "$lib/store"; import Loading from "$components/Loading.svelte"; + import { Button } from "$lib/components/ui/button"; + import { Check } from "lucide-svelte"; $: connection = $globalData.websocket.status; {#if PUBLIC_WEBSOCKET_CONNECTION.toLowerCase() === "true"} -

+ {/if} From 9b3d1b463f83f786a5108339ca8e8aaf76322492 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 13:07:02 +0100 Subject: [PATCH 08/27] chore: remove title attribute from card component --- dashboard/src/lib/components/dashboard/GlobalSettings.svelte | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dashboard/src/lib/components/dashboard/GlobalSettings.svelte b/dashboard/src/lib/components/dashboard/GlobalSettings.svelte index 4da69e8..75a761f 100644 --- a/dashboard/src/lib/components/dashboard/GlobalSettings.svelte +++ b/dashboard/src/lib/components/dashboard/GlobalSettings.svelte @@ -43,7 +43,7 @@ {$t("global_settings")}

- + @@ -188,7 +188,6 @@ --> -
From 5bce5a5cbaa8d71015aef898a1cc14085de556d7 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 13:09:07 +0100 Subject: [PATCH 09/27] Fix manual deployment logic feat: add disable state to deploy button feat: add conditional text based on `$deploy.proceed` value feat: passed in deploy_data function as prop to dashboard's `
` component, to be called by deploy button, if not disabled refactor: update `store_data` function to only `deploy_data` if not manual deployment refactor: move `$deploy.proceed = false` to outside the `forEach` loop on `deploy_data` function, was uncessariyl assigning false several times --- .../lib/components/dashboard/Header.svelte | 10 +++++---- dashboard/src/routes/dashboard/+page.svelte | 21 +++++++------------ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/dashboard/src/lib/components/dashboard/Header.svelte b/dashboard/src/lib/components/dashboard/Header.svelte index 62f8071..bf6fc54 100644 --- a/dashboard/src/lib/components/dashboard/Header.svelte +++ b/dashboard/src/lib/components/dashboard/Header.svelte @@ -1,5 +1,4 @@ @@ -150,7 +145,7 @@ class="bg-[#101010] text-foreground w-screen min-h-screen grid grid-rows-[auto_1fr]" > -
+
Date: Sun, 25 Aug 2024 13:09:42 +0100 Subject: [PATCH 10/27] style: remove grid cols from button component, unnecessary, and caused buttons without an after icon to be longer than the inner content --- dashboard/src/lib/components/ui/button/button.svelte | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dashboard/src/lib/components/ui/button/button.svelte b/dashboard/src/lib/components/ui/button/button.svelte index 6b677e8..4248826 100644 --- a/dashboard/src/lib/components/ui/button/button.svelte +++ b/dashboard/src/lib/components/ui/button/button.svelte @@ -16,10 +16,7 @@ Date: Sun, 25 Aug 2024 13:57:48 +0100 Subject: [PATCH 11/27] fix: correct dashboad header to use reactive variable for update func call --- dashboard/src/lib/components/dashboard/Header.svelte | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dashboard/src/lib/components/dashboard/Header.svelte b/dashboard/src/lib/components/dashboard/Header.svelte index bf6fc54..4cb41b5 100644 --- a/dashboard/src/lib/components/dashboard/Header.svelte +++ b/dashboard/src/lib/components/dashboard/Header.svelte @@ -160,19 +160,19 @@ on:click={() => { update({ type: "global", - data: global, + data: $globalData, }); update({ type: "timer", - data: timer, + data: $timerData, }); update({ type: "playerOne", - data: playerOneData, + data: $playerOneData, }); update({ type: "playerTwo", - data: playerTwoData, + data: $playerTwoData, }); deploy_data(); }} From 20c5942e705142aea7daa779c9ead959227593bc Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 13:58:06 +0100 Subject: [PATCH 12/27] misc: add i18n for 'ID' and set max character length of name and pronoun inputs --- dashboard/src/lib/components/dashboard/Player.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dashboard/src/lib/components/dashboard/Player.svelte b/dashboard/src/lib/components/dashboard/Player.svelte index 19771fc..5135d36 100644 --- a/dashboard/src/lib/components/dashboard/Player.svelte +++ b/dashboard/src/lib/components/dashboard/Player.svelte @@ -134,7 +134,7 @@
\ No newline at end of file +
+ +
diff --git a/dashboard/src/routes/dashboard/+page.svelte b/dashboard/src/routes/dashboard/+page.svelte index bac5272..32fcdc4 100644 --- a/dashboard/src/routes/dashboard/+page.svelte +++ b/dashboard/src/routes/dashboard/+page.svelte @@ -4,7 +4,12 @@ PUBLIC_WEBSOCKET_URL, } from "$env/static/public"; import { onMount } from "svelte"; - import { playerOneData, playerTwoData, deploy } from "$lib/store"; + import { + globalData, + playerOneData, + playerTwoData, + deploy, + } from "$lib/store"; import type { PlayerAttributes as TPlayerAttributes, GlobalData as TGlobalData, diff --git a/dashboard/src/routes/overlay/+page.svelte b/dashboard/src/routes/overlay/+page.svelte index 93e2637..127942f 100644 --- a/dashboard/src/routes/overlay/+page.svelte +++ b/dashboard/src/routes/overlay/+page.svelte @@ -16,32 +16,44 @@ const theme: TThemeClasses = layout[$globalData.overlay.layout]; $: { - import(`$lib/styles/${$globalData.overlay.layout}.css`) - .catch(error => { + import(`$lib/styles/${$globalData.overlay.layout}.css`).catch( + (error) => { console.error(`Failed to import CSS file: ${error}`); - }); + }, + ); } {#if $netrunnerDB && $playerOneData && $playerTwoData} - - - - -
+ +
+ +
+
+ +
+
+ +
+ +
+
+
-
+
{:else}

Awaiting data...

-{/if} \ No newline at end of file +{/if} diff --git a/dashboard/src/routes/overlay/player/[slug]/cards/+page.svelte b/dashboard/src/routes/overlay/player/[slug]/cards/+page.svelte index 9fc99fc..3365990 100644 --- a/dashboard/src/routes/overlay/player/[slug]/cards/+page.svelte +++ b/dashboard/src/routes/overlay/player/[slug]/cards/+page.svelte @@ -13,20 +13,22 @@ let side = data.slug; - + {#if side === "left"} -
{:else if side === "right"} -
{/if} diff --git a/dashboard/src/routes/overlay/player/[slug]/details/+page.svelte b/dashboard/src/routes/overlay/player/[slug]/details/+page.svelte index 65f63f6..f174850 100644 --- a/dashboard/src/routes/overlay/player/[slug]/details/+page.svelte +++ b/dashboard/src/routes/overlay/player/[slug]/details/+page.svelte @@ -1,27 +1,25 @@ - -
- {#if side === "left"} - - {:else if side === "right"} - - {/if} -
-
\ No newline at end of file + + {#if side === "left"} + + {:else if side === "right"} + + {/if} + From 79f42a18ddc8bec4d49abb5dc5b09ffcb4e188dd Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 16:45:50 +0100 Subject: [PATCH 16/27] refactor: remove animated svg from timer component --- .../src/lib/components/dashboard/Timer.svelte | 44 +++---------------- 1 file changed, 7 insertions(+), 37 deletions(-) diff --git a/dashboard/src/lib/components/dashboard/Timer.svelte b/dashboard/src/lib/components/dashboard/Timer.svelte index 55aefd8..dd4c6e3 100644 --- a/dashboard/src/lib/components/dashboard/Timer.svelte +++ b/dashboard/src/lib/components/dashboard/Timer.svelte @@ -5,6 +5,7 @@ import { Timer } from "lucide-svelte"; import { Button, buttonVariants } from "$lib/components/ui/button"; import * as Dialog from "$lib/components/ui/dialog"; + import { Input } from "$lib/components/ui/input"; let timer: TTimerData = $timerData; @@ -14,7 +15,6 @@ const dispatch = createEventDispatcher(); const deploy = () => { - // console.log(timer); dispatch("timer", timer); }; @@ -42,41 +42,11 @@ Timer -
-

Timer

- - - {#if timer.action === "set"} - - - - - - Created with Snap - {/if} - + + -
+ From 623a3c12000f6ef286e3c23c576b47e84aa39a8a Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 19:43:14 +0100 Subject: [PATCH 17/27] fix: default country selection value --- dashboard/src/lib/components/dashboard/Country.svelte | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dashboard/src/lib/components/dashboard/Country.svelte b/dashboard/src/lib/components/dashboard/Country.svelte index 44e7116..c737385 100644 --- a/dashboard/src/lib/components/dashboard/Country.svelte +++ b/dashboard/src/lib/components/dashboard/Country.svelte @@ -13,9 +13,10 @@ let open = false; let value = ""; - $: selected = - JSON_COUNTRIES.find((f: any) => f.alpha2 === value) ?? - "Select a country"; + $: selected = JSON_COUNTRIES.find((f: any) => f.alpha2 === value) ?? { + name: "Select a country", + alpha2: "", + }; // We want to refocus the trigger button when the user selects // an item from the list so users can continue navigating the From 21f6bd1538af1c137a6b55037732ba6a503ace4b Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 19:43:33 +0100 Subject: [PATCH 18/27] fix: default win counter to 0 (stored as string) --- dashboard/src/lib/components/dashboard/Player.svelte | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dashboard/src/lib/components/dashboard/Player.svelte b/dashboard/src/lib/components/dashboard/Player.svelte index 5135d36..1e02f6f 100644 --- a/dashboard/src/lib/components/dashboard/Player.svelte +++ b/dashboard/src/lib/components/dashboard/Player.svelte @@ -150,7 +150,6 @@ }} /> { playerCurrent.decks.corp.id = e.detail; @@ -177,7 +176,6 @@ }} /> { playerCurrent.decks.runner.id = e.detail; @@ -230,7 +228,7 @@ ? "primary" : "outline"} align="center" - {value} + value={value.toString()} name="wins_{name}" on:click={(event) => { playerCurrent.player.wins = value; From bcfafbe28dc67a9abe03c6e6818620648a4916a6 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 19:44:07 +0100 Subject: [PATCH 19/27] refactor: remove unused play exported property from `` component --- dashboard/src/lib/components/dashboard/SearchIdentity.svelte | 1 - 1 file changed, 1 deletion(-) diff --git a/dashboard/src/lib/components/dashboard/SearchIdentity.svelte b/dashboard/src/lib/components/dashboard/SearchIdentity.svelte index 6b971e9..290242c 100644 --- a/dashboard/src/lib/components/dashboard/SearchIdentity.svelte +++ b/dashboard/src/lib/components/dashboard/SearchIdentity.svelte @@ -10,7 +10,6 @@ import { find_faction_by_id, slugify } from "$lib/utils"; import { t } from "$lib/translations"; - export let player: TPlayerSide; export let side: TGameSide; const dispatch = createEventDispatcher(); From c7eb3f56e1acc776577649e730c9439e52cc8234 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 19:50:39 +0100 Subject: [PATCH 20/27] refactor: remove unused imports --- .../lib/components/dashboard/Counter.svelte | 1 - .../dashboard/GlobalSettings.svelte | 3 +- .../lib/components/dashboard/Preview.svelte | 2 +- .../components/dashboard/SaveConfig.svelte | 1 - .../lib/components/dashboard/Search.svelte | 1 - .../dashboard/SearchIdentity.svelte | 2 +- .../dashboard/_SearchIdentity.svelte | 84 ------------------- .../components/dashboard/ui/Heading.svelte | 2 +- 8 files changed, 4 insertions(+), 92 deletions(-) delete mode 100644 dashboard/src/lib/components/dashboard/_SearchIdentity.svelte diff --git a/dashboard/src/lib/components/dashboard/Counter.svelte b/dashboard/src/lib/components/dashboard/Counter.svelte index 5d759d5..b8a50fa 100644 --- a/dashboard/src/lib/components/dashboard/Counter.svelte +++ b/dashboard/src/lib/components/dashboard/Counter.svelte @@ -3,7 +3,6 @@ import { createEventDispatcher } from "svelte"; import { Button } from "$lib/components/ui/button"; import { Input } from "$lib/components/ui/input"; - import { Label } from "$lib/components/ui/label"; const dispatch = createEventDispatcher(); diff --git a/dashboard/src/lib/components/dashboard/GlobalSettings.svelte b/dashboard/src/lib/components/dashboard/GlobalSettings.svelte index 75a761f..b6ae902 100644 --- a/dashboard/src/lib/components/dashboard/GlobalSettings.svelte +++ b/dashboard/src/lib/components/dashboard/GlobalSettings.svelte @@ -10,7 +10,7 @@ import ICON_CREDITS from "$lib/assets/icons/NSG_CREDIT.svg"; import ICON_AGENDAS from "$lib/assets/icons/NSG_AGENDA.svg"; import { Settings } from "lucide-svelte"; - import { Button, buttonVariants } from "$lib/components/ui/button"; + import { buttonVariants } from "$lib/components/ui/button"; import Column from "./ui/Column.svelte"; import { Label } from "$lib/components/ui/label"; import { Switch } from "$lib/components/ui/switch"; @@ -19,7 +19,6 @@ import type { GlobalData as TGlobalData } from "$lib/types"; import { Slider } from "$lib/components/ui/slider"; import { Input } from "$lib/components/ui/input"; - import * as Select from "$lib/components/ui/select"; let global: TGlobalData = $globalData; let deployType: boolean = $deploy.type !== "automatic"; diff --git a/dashboard/src/lib/components/dashboard/Preview.svelte b/dashboard/src/lib/components/dashboard/Preview.svelte index 5aa4052..65fd8c6 100644 --- a/dashboard/src/lib/components/dashboard/Preview.svelte +++ b/dashboard/src/lib/components/dashboard/Preview.svelte @@ -1,6 +1,6 @@ - - diff --git a/dashboard/src/lib/components/dashboard/ui/Heading.svelte b/dashboard/src/lib/components/dashboard/ui/Heading.svelte index 6f31763..b6f9758 100644 --- a/dashboard/src/lib/components/dashboard/ui/Heading.svelte +++ b/dashboard/src/lib/components/dashboard/ui/Heading.svelte @@ -1,6 +1,6 @@ From 1d15070f3f4631df11663a793383dfb6d7a237e9 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 20:01:51 +0100 Subject: [PATCH 21/27] refactor: move all NSG icons to `static/` directory, instead of `lib/` as imported assets, as we want to preload these in the `` --- .../dashboard/GlobalSettings.svelte | 67 ++++++++++--------- .../lib/components/dashboard/Player.svelte | 9 +-- .../lib/components/overlay/MetaSide.svelte | 9 +-- dashboard/src/routes/+layout.svelte | 7 ++ dashboard/static/NSG_AGENDA.svg | 1 + dashboard/static/NSG_Archives_Icon.svg | 5 ++ dashboard/static/NSG_CLICK.svg | 1 + dashboard/static/NSG_CREDIT.svg | 1 + dashboard/static/NSG_HQ_Icon.svg | 7 ++ dashboard/static/NSG_INTERRUPT.svg | 1 + dashboard/static/NSG_LINK.svg | 1 + dashboard/static/NSG_Mu.svg | 1 + dashboard/static/NSG_RD_Icon.svg | 5 ++ dashboard/static/NSG_RECURRING_CREDIT.svg | 1 + dashboard/static/NSG_REZ_COST.svg | 1 + dashboard/static/NSG_SUBROUTINE.svg | 1 + dashboard/static/NSG_TRASH_ABILITY.svg | 1 + dashboard/static/NSG_TRASH_COST bw.svg | 1 + 18 files changed, 76 insertions(+), 44 deletions(-) create mode 100644 dashboard/static/NSG_AGENDA.svg create mode 100644 dashboard/static/NSG_Archives_Icon.svg create mode 100644 dashboard/static/NSG_CLICK.svg create mode 100644 dashboard/static/NSG_CREDIT.svg create mode 100644 dashboard/static/NSG_HQ_Icon.svg create mode 100644 dashboard/static/NSG_INTERRUPT.svg create mode 100644 dashboard/static/NSG_LINK.svg create mode 100644 dashboard/static/NSG_Mu.svg create mode 100644 dashboard/static/NSG_RD_Icon.svg create mode 100644 dashboard/static/NSG_RECURRING_CREDIT.svg create mode 100644 dashboard/static/NSG_REZ_COST.svg create mode 100644 dashboard/static/NSG_SUBROUTINE.svg create mode 100644 dashboard/static/NSG_TRASH_ABILITY.svg create mode 100644 dashboard/static/NSG_TRASH_COST bw.svg diff --git a/dashboard/src/lib/components/dashboard/GlobalSettings.svelte b/dashboard/src/lib/components/dashboard/GlobalSettings.svelte index b6ae902..fe446e3 100644 --- a/dashboard/src/lib/components/dashboard/GlobalSettings.svelte +++ b/dashboard/src/lib/components/dashboard/GlobalSettings.svelte @@ -2,13 +2,9 @@ import { createEventDispatcher } from "svelte"; import Card from "$components/dashboard/ui/Card.svelte"; import { globalData, deploy } from "$lib/store"; - import Heading from "$components/dashboard/ui/Heading.svelte"; import * as Dialog from "$lib/components/ui/dialog"; // Icons - import ICON_CLICKS from "$lib/assets/icons/NSG_CLICK.svg"; - import ICON_CREDITS from "$lib/assets/icons/NSG_CREDIT.svg"; - import ICON_AGENDAS from "$lib/assets/icons/NSG_AGENDA.svg"; import { Settings } from "lucide-svelte"; import { buttonVariants } from "$lib/components/ui/button"; import Column from "./ui/Column.svelte"; @@ -24,9 +20,9 @@ let deployType: boolean = $deploy.type !== "automatic"; const icons: Record = { - clicks: ICON_CLICKS, - credits: ICON_CREDITS, - agendas: ICON_AGENDAS, + clicks: "/NSG_CLICK.svg", + credits: "/NSG_CREDIT.svg", + agendas: "/NSG_AGENDA.svg", }; const dispatch = createEventDispatcher(); @@ -43,31 +39,38 @@
- - - - Deployment type - - { - $deploy.type = deployType - ? "automatic" - : "manual"; - $deploy.proceed = - $deploy.type === "automatic"; - }} - /> - - - - + + + Deployment type + + { + $deploy.type = deployType + ? "automatic" + : "manual"; + $deploy.proceed = + $deploy.type === "automatic"; + }} + /> + + + + + +
+ + {$t("global_settings")} + +
+ + - +
{/if} @@ -105,7 +102,7 @@ {#if global?.credits}
- +
{/if} @@ -113,7 +110,7 @@ {#if global?.agendas}
- +
{/if} diff --git a/dashboard/src/routes/+layout.svelte b/dashboard/src/routes/+layout.svelte index ed3e094..e334ec1 100644 --- a/dashboard/src/routes/+layout.svelte +++ b/dashboard/src/routes/+layout.svelte @@ -15,6 +15,7 @@ import { page } from "$app/stores"; import { fetch_cards } from "$lib/utils"; import { t } from "$lib/translations"; + import JSON_FACTIONS from "$lib/data/factions.json"; let socket: WebSocket; let storage_keys: string[] = ["global", "playerOne", "playerTwo", "timer"]; @@ -153,6 +154,12 @@ + {#each JSON_FACTIONS as faction} + + {/each} + + + {#await fetch_cards()} diff --git a/dashboard/static/NSG_AGENDA.svg b/dashboard/static/NSG_AGENDA.svg new file mode 100644 index 0000000..e20c89d --- /dev/null +++ b/dashboard/static/NSG_AGENDA.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dashboard/static/NSG_Archives_Icon.svg b/dashboard/static/NSG_Archives_Icon.svg new file mode 100644 index 0000000..c612ba5 --- /dev/null +++ b/dashboard/static/NSG_Archives_Icon.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/dashboard/static/NSG_CLICK.svg b/dashboard/static/NSG_CLICK.svg new file mode 100644 index 0000000..6e831b0 --- /dev/null +++ b/dashboard/static/NSG_CLICK.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dashboard/static/NSG_CREDIT.svg b/dashboard/static/NSG_CREDIT.svg new file mode 100644 index 0000000..4597fe1 --- /dev/null +++ b/dashboard/static/NSG_CREDIT.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dashboard/static/NSG_HQ_Icon.svg b/dashboard/static/NSG_HQ_Icon.svg new file mode 100644 index 0000000..4bdf400 --- /dev/null +++ b/dashboard/static/NSG_HQ_Icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/dashboard/static/NSG_INTERRUPT.svg b/dashboard/static/NSG_INTERRUPT.svg new file mode 100644 index 0000000..7b71b19 --- /dev/null +++ b/dashboard/static/NSG_INTERRUPT.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dashboard/static/NSG_LINK.svg b/dashboard/static/NSG_LINK.svg new file mode 100644 index 0000000..a76ae56 --- /dev/null +++ b/dashboard/static/NSG_LINK.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dashboard/static/NSG_Mu.svg b/dashboard/static/NSG_Mu.svg new file mode 100644 index 0000000..5dd4174 --- /dev/null +++ b/dashboard/static/NSG_Mu.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dashboard/static/NSG_RD_Icon.svg b/dashboard/static/NSG_RD_Icon.svg new file mode 100644 index 0000000..e82b4a7 --- /dev/null +++ b/dashboard/static/NSG_RD_Icon.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/dashboard/static/NSG_RECURRING_CREDIT.svg b/dashboard/static/NSG_RECURRING_CREDIT.svg new file mode 100644 index 0000000..8e1fbcf --- /dev/null +++ b/dashboard/static/NSG_RECURRING_CREDIT.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dashboard/static/NSG_REZ_COST.svg b/dashboard/static/NSG_REZ_COST.svg new file mode 100644 index 0000000..6d371c0 --- /dev/null +++ b/dashboard/static/NSG_REZ_COST.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dashboard/static/NSG_SUBROUTINE.svg b/dashboard/static/NSG_SUBROUTINE.svg new file mode 100644 index 0000000..d2293a9 --- /dev/null +++ b/dashboard/static/NSG_SUBROUTINE.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dashboard/static/NSG_TRASH_ABILITY.svg b/dashboard/static/NSG_TRASH_ABILITY.svg new file mode 100644 index 0000000..1fffe1f --- /dev/null +++ b/dashboard/static/NSG_TRASH_ABILITY.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dashboard/static/NSG_TRASH_COST bw.svg b/dashboard/static/NSG_TRASH_COST bw.svg new file mode 100644 index 0000000..5fdb25f --- /dev/null +++ b/dashboard/static/NSG_TRASH_COST bw.svg @@ -0,0 +1 @@ + \ No newline at end of file From a7a72304348f56b10158e18498ffd816d854e148 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 20:02:06 +0100 Subject: [PATCH 22/27] feat: setup basic test to increment agendas --- dashboard/tests/test.ts | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 dashboard/tests/test.ts diff --git a/dashboard/tests/test.ts b/dashboard/tests/test.ts new file mode 100644 index 0000000..414ab7a --- /dev/null +++ b/dashboard/tests/test.ts @@ -0,0 +1,50 @@ +import { test, expect } from "@playwright/test"; + +test("home has dashboard button", async ({ page }) => { + await page.goto("/"); + // await expect(page.waitForSelector('button[href="/overlay"]')).toBeVisible(); + await page.isVisible("a.button[href='/overlay']"); +}); + +test("Increment agendas", async ({ page }) => { + // Create two pages + const dashboard = await page.context().newPage(); + const overlay = await page.context().newPage(); + + // Load pages in parallel to ensure the overlay recieves a websocket connection + await Promise.all([dashboard.goto("/dashboard"), overlay.goto("/overlay")]); + + await dashboard.waitForTimeout(1000); + + const elements = [ + { + query: "#counter-agendas-playerOne button:last-of-type", + clicks: 4, + }, + ]; + + elements.forEach(({ query, clicks }) => { + for (let i = 0; i < clicks; i++) { + dashboard.click(query); + } + }); + + await dashboard.waitForTimeout(1000); + + dashboard.click("#counter-agendas-playerOne button:first-of-type"); // Remove one point + + await dashboard.waitForTimeout(1000); + + // Step 5: Check if the value matches + const count = await overlay.$eval( + ".side.side--left .counter__number:last-of-type", + (element) => { + return element.textContent; + } + ); + + expect(count).toBe("3"); + + // console.info("counterNumber:", counterNumber); + // console.info(counterNumber === "4"); +}); From 1b3aa3afa774faa72ccdf14dc8d1756d02c3af49 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 20:10:01 +0100 Subject: [PATCH 23/27] style: improve console log/info/warning/error styling for easier debugging --- dashboard/src/routes/+layout.svelte | 9 ++++---- dashboard/src/routes/dashboard/+page.svelte | 25 +++++---------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/dashboard/src/routes/+layout.svelte b/dashboard/src/routes/+layout.svelte index e334ec1..45b64ee 100644 --- a/dashboard/src/routes/+layout.svelte +++ b/dashboard/src/routes/+layout.svelte @@ -21,7 +21,7 @@ let storage_keys: string[] = ["global", "playerOne", "playerTwo", "timer"]; onMount(async () => { - console.info("✔️ Window loaded"); + console.info(`%c Loaded %cWindow`, "background: gray"); if (!localStorage.getItem("language")) { localStorage.setItem( @@ -57,8 +57,8 @@ if (store && typeof store === "object") { console.info( - `✔️ Loaded %c${type}%cdata from localStorage`, - "background: blue", + `%c Loaded %c${type} data from localStorage`, + "background: gray", ); // Update svelte store with cached (localStorage) data @@ -92,7 +92,8 @@ socket.addEventListener("message", (event) => { console.log( - "recieving websocket connection...", + "%c WEBSOCKET %c Message recieved", + "background: blue", JSON.parse(event.data), ); diff --git a/dashboard/src/routes/dashboard/+page.svelte b/dashboard/src/routes/dashboard/+page.svelte index 32fcdc4..27e307b 100644 --- a/dashboard/src/routes/dashboard/+page.svelte +++ b/dashboard/src/routes/dashboard/+page.svelte @@ -94,20 +94,10 @@ }; const deploy_data = () => { - console.log( - "DEPLOYING ===========================================================", - ); - ["global", "playerOne", "playerTwo", "timer"].forEach( (type: string) => { - console.log( - "------------------------------------------------------------", - ); - console.log(`Processing ${type}...`); - const hold_key = `hold_${type}`; const raw_data = localStorage.getItem(hold_key); - console.log(`Raw data for ${hold_key}:`, raw_data); if (!raw_data) { console.warn(`No data found for ${hold_key}, skipping`); @@ -117,7 +107,6 @@ let hold; try { hold = JSON.parse(raw_data); - console.log(`Parsed data for ${hold_key}:`, hold); } catch (error) { console.error(`Error parsing data for ${hold_key}:`, error); return; @@ -134,12 +123,9 @@ return; } - console.info(`Deploying ${type} data:`, hold); - if (websocket) { try { socket.send(JSON.stringify({ _type: type, ...hold })); - console.log(`Sent ${type} data via WebSocket`); } catch (error) { console.error( `Failed to update ${type} data via WebSocket:`, @@ -149,17 +135,16 @@ } } + console.info( + `%c DEPLOYED %c${type}'s' data`, + "background: DarkGreen", + ); + // Update the real value localStorage.setItem(type, JSON.stringify(hold)); - console.log(`Updated ${type} in localStorage`); // Remove hold value localStorage.removeItem(hold_key); - console.log(`Removed ${hold_key} from localStorage`); - - // Verify the update - const updated = localStorage.getItem(type); - console.log(`Verified ${type} data after update:`, updated); }, ); From a8b9608078e2be5256e30572321a086f18071a04 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 20:40:23 +0100 Subject: [PATCH 24/27] feat: if primary card is disabled (toggled off), disable the secondary card --- dashboard/src/lib/components/dashboard/Player.svelte | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dashboard/src/lib/components/dashboard/Player.svelte b/dashboard/src/lib/components/dashboard/Player.svelte index d1229be..9e9399e 100644 --- a/dashboard/src/lib/components/dashboard/Player.svelte +++ b/dashboard/src/lib/components/dashboard/Player.svelte @@ -288,6 +288,14 @@ on:click={(event) => { playerCurrent.highlight[type].active = !playerCurrent.highlight[type].active; + + if ( + type === "primary" && + !playerCurrent.highlight[type].active + ) { + playerCurrent.highlight.secondary.active = false; + } + deploy(); }} /> From fb05a178f0133fc969df885bee2130efb1cc0662 Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 20:40:31 +0100 Subject: [PATCH 25/27] refactor: remove unused types --- dashboard/src/lib/components/dashboard/Search.svelte | 2 -- 1 file changed, 2 deletions(-) diff --git a/dashboard/src/lib/components/dashboard/Search.svelte b/dashboard/src/lib/components/dashboard/Search.svelte index e9ed975..fc9ec5c 100644 --- a/dashboard/src/lib/components/dashboard/Search.svelte +++ b/dashboard/src/lib/components/dashboard/Search.svelte @@ -2,8 +2,6 @@ import { createEventDispatcher } from "svelte"; import { netrunnerDB, playerOneData, playerTwoData } from "$lib/store"; import type { - Card as TCard, - PlayerAttributes as TPlayerAttributes, GameSide as TGameSide, PlayerSide as TPlayerSide, } from "$lib/types"; From 92c787c8c48e5778a0a3afb1c350cbaf2e1a11ad Mon Sep 17 00:00:00 2001 From: AlexR Date: Sun, 25 Aug 2024 20:40:54 +0100 Subject: [PATCH 26/27] style: ensure cards animate/transition as expected after previous breaking changes --- .../components/overlay/CardHighlight.svelte | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/dashboard/src/lib/components/overlay/CardHighlight.svelte b/dashboard/src/lib/components/overlay/CardHighlight.svelte index 3d672c9..2785b2c 100644 --- a/dashboard/src/lib/components/overlay/CardHighlight.svelte +++ b/dashboard/src/lib/components/overlay/CardHighlight.svelte @@ -27,38 +27,49 @@ default: "z-10 h-[90%]", inactive: "50vw", }, - left: "left-[2.5%] origin-bottom-left -rotate-2", - right: "right-[2.5%] origin-bottom-right rotate-2", + left: "left-[2.5%] origin-bottom-left", + right: "right-[2.5%] origin-bottom-right", }, secondary: { shared: { - default: "top-1/2 -translate-y-1/2 h-[80%] -mt-6", + default: "h-[80%] -mt-4", inactive: "-50vw", }, - left: "left-[25%] origin-bottom-left rotate-3", - right: "right-[25%] origin-bottom-right -rotate-3", + left: "left-[35%] origin-bottom-left", + right: "right-[35%] origin-bottom-right", }, }, }; -
{#each ["primary", "secondary"] as type}
Date: Sun, 25 Aug 2024 20:51:26 +0100 Subject: [PATCH 27/27] feat: disable secondary card switch/toggle if primary is not true/active --- dashboard/src/lib/components/dashboard/Player.svelte | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dashboard/src/lib/components/dashboard/Player.svelte b/dashboard/src/lib/components/dashboard/Player.svelte index 9e9399e..b19775c 100644 --- a/dashboard/src/lib/components/dashboard/Player.svelte +++ b/dashboard/src/lib/components/dashboard/Player.svelte @@ -298,6 +298,8 @@ deploy(); }} + disabled={type === "secondary" && + !playerCurrent.highlight?.primary.active} />