From 669190d2bac5686c58ba16e45e2e35d563a3385b Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Tue, 2 Jan 2024 19:34:30 -0500 Subject: [PATCH] Complete components --- frontend/src/components/Drawer/Base.vue | 4 +- .../components/Gallery/AppBar/FilterBar.vue | 4 +- .../src/components/Gallery/FabMenu/Base.vue | 4 +- frontend/src/components/Game/Card/Base.vue | 2 +- frontend/src/components/Game/Card/Cover.vue | 14 +++---- .../src/components/Game/DataTable/Base.vue | 42 ++++++++++--------- .../Settings/Config/PlatformBindingCard.vue | 6 +-- .../General/Interface/InterfaceOptions.vue | 2 +- .../Settings/General/Theme/ThemeCard.vue | 6 +-- frontend/src/stores/auth.ts | 2 +- frontend/src/stores/heartbeat.ts | 7 ++++ frontend/tsconfig.json | 2 +- 12 files changed, 52 insertions(+), 43 deletions(-) diff --git a/frontend/src/components/Drawer/Base.vue b/frontend/src/components/Drawer/Base.vue index c3379cd36..aadd38eaf 100644 --- a/frontend/src/components/Drawer/Base.vue +++ b/frontend/src/components/Drawer/Base.vue @@ -12,7 +12,7 @@ import RailFooter from "@/components/Drawer/Footer.vue"; // Props const platforms = storePlatforms(); const auth = storeAuth(); -const drawer = ref(undefined); +const drawer = ref(false); const open = ref(["Platforms", "Library", "Settings"]); const rail = ref(localStorage.getItem("rail") == "true"); @@ -23,7 +23,7 @@ emitter?.on("toggleDrawer", () => { }); emitter?.on("toggleDrawerRail", () => { rail.value = !rail.value; - localStorage.setItem("rail", rail.value); + localStorage.setItem("rail", rail.value.toString()); }); diff --git a/frontend/src/components/Gallery/AppBar/FilterBar.vue b/frontend/src/components/Gallery/AppBar/FilterBar.vue index 82b9153fb..3080fb334 100644 --- a/frontend/src/components/Gallery/AppBar/FilterBar.vue +++ b/frontend/src/components/Gallery/AppBar/FilterBar.vue @@ -18,12 +18,12 @@ onMounted(() => { function clearFilter() { galleryFilter.set(""); - emitter?.emit("filter"); + emitter?.emit("filter", null); } const filterRoms = debounce(() => { galleryFilter.set(filterValue.value); - emitter?.emit("filter"); + emitter?.emit("filter", null); }, 500); diff --git a/frontend/src/components/Gallery/FabMenu/Base.vue b/frontend/src/components/Gallery/FabMenu/Base.vue index a845ecb6d..870ec8cc4 100644 --- a/frontend/src/components/Gallery/FabMenu/Base.vue +++ b/frontend/src/components/Gallery/FabMenu/Base.vue @@ -21,7 +21,7 @@ const route = useRoute(); socket.on("scan:scanning_rom", ({ id }) => { const rom = romsStore.selectedRoms.find((r) => r.id === id); - romsStore.removeFromSelection(rom); + if (rom) romsStore.removeFromSelection(rom); }); socket.on("scan:done", () => { @@ -34,7 +34,7 @@ socket.on("scan:done", () => { socket.disconnect(); }); -socket.on("scan:done_ko", (msg) => { +socket.on("scan:done_ko", (msg: string) => { scanning.set(false); emitter?.emit("snackbarShow", { msg: `Scan couldn't be completed. Something went wrong: ${msg}`, diff --git a/frontend/src/components/Game/Card/Base.vue b/frontend/src/components/Game/Card/Base.vue index 3a626a957..0174d3658 100644 --- a/frontend/src/components/Game/Card/Base.vue +++ b/frontend/src/components/Game/Card/Base.vue @@ -9,7 +9,7 @@ const emit = defineEmits(["selectRom"]); const romsStore = storeRoms(); // Functions -function selectRom(event) { +function selectRom(event: MouseEvent) { if (!props.selected) { romsStore.addToSelection(props.rom); } else { diff --git a/frontend/src/components/Game/Card/Cover.vue b/frontend/src/components/Game/Card/Cover.vue index c4fb9ac6d..32bf9e1a0 100644 --- a/frontend/src/components/Game/Card/Cover.vue +++ b/frontend/src/components/Game/Card/Cover.vue @@ -17,17 +17,17 @@ const downloadStore = storeDownload(); const romsStore = storeRoms(); const card = ref(); -let timeout; +let timeout: ReturnType; // Functions -function onSelectRom(event) { +function onSelectRom(event: MouseEvent) { if (!event.ctrlKey && !event.shiftKey) { event.preventDefault(); emit("selectRom", event); } } -function onNavigate(event) { +function onNavigate(event: MouseEvent) { if ( event.ctrlKey || event.shiftKey || @@ -39,8 +39,8 @@ function onNavigate(event) { } } -function onTouchStart(event) { - card.value.$el.addEventListener("contextmenu", (event) => { +function onTouchStart(event: TouchEvent) { + card.value.$el.addEventListener("contextmenu", (event: Event) => { event.preventDefault(); }); romsStore.isTouchScreen(true); @@ -103,7 +103,7 @@ function onTouchEnd() { -import { ref, inject } from "vue"; +import { ref } from "vue"; import { useRouter } from "vue-router"; +import { VDataTable } from "vuetify/labs/VDataTable"; + import api from "@/services/api"; import storeDownload from "@/stores/download"; -import storeRoms from "@/stores/roms"; +import storeRoms, { type Rom } from "@/stores/roms"; import storeAuth from "@/stores/auth"; -import { VDataTable } from "vuetify/labs/VDataTable"; import AdminMenu from "@/components/AdminMenu/Base.vue"; import { regionToEmoji, languageToEmoji } from "@/utils"; @@ -52,11 +53,12 @@ const HEADERS = [ sortable: true, key: "revision", }, - { align: "end", key: "actions", sortable: false }, -]; + { title: "", align: "end", key: "actions", sortable: false }, +] as const; + const PER_PAGE_OPTIONS = [ { value: -1, title: "$vuetify.dataFooter.itemsPerPageAll" }, -]; +] as const; // Props const location = window.location.origin; @@ -68,9 +70,9 @@ const auth = storeAuth(); const romsPerPage = ref(-1); // Functions -function rowClick(_, row) { +function rowClick(_: Event, row: any) { router.push( - `/platform/${row.item.selectable.platform_slug}/${row.item.selectable.id}` + `/platform/${row.item.value.platform_slug}/${row.item.value.id}` ); } @@ -91,40 +93,40 @@ function rowClick(_, row) {