diff --git a/frontend/src/components/Drawer/Footer.vue b/frontend/src/components/Drawer/Footer.vue index ea869c672..0c0b4ad1e 100644 --- a/frontend/src/components/Drawer/Footer.vue +++ b/frontend/src/components/Drawer/Footer.vue @@ -29,10 +29,10 @@ onBeforeMount(async () => { "https://api.github.com/repos/rommapp/romm/releases/latest" ); const json = await response.json(); - GITHUB_VERSION.value = json.name; + GITHUB_VERSION.value = json.tag_name; latestVersionDismissed.value = VERSION === "development" || - json.name === localStorage.getItem("dismissedVersion"); + json.tag_name === localStorage.getItem("dismissedVersion"); }); async function logout() { @@ -108,7 +108,7 @@ async function logout() { New version available - {{ GITHUB_VERSION }}v{{ GITHUB_VERSION }} diff --git a/frontend/src/components/Gallery/AppBar/FilterBar.vue b/frontend/src/components/Gallery/AppBar/FilterBar.vue index 9c7edd8bb..b6a1c7711 100644 --- a/frontend/src/components/Gallery/AppBar/FilterBar.vue +++ b/frontend/src/components/Gallery/AppBar/FilterBar.vue @@ -27,7 +27,7 @@ const {
- - + - + - + + > +import LazyImage from "@/components/LazyImage.vue"; import storeDownload from "@/stores/download"; import storeGalleryView from "@/stores/galleryView"; import storeRoms, { type SimpleRom } from "@/stores/roms"; @@ -82,9 +83,10 @@ function onTouchEnd() { absolute /> - -import { ref } from "vue"; +import { ref, inject, onMounted, watch } from "vue"; import { useRouter } from "vue-router"; import AdminMenu from "@/components/Game/AdminMenu/Base.vue"; @@ -7,6 +7,8 @@ import romApi from "@/services/api/rom"; import storeAuth from "@/stores/auth"; import storeDownload from "@/stores/download"; import storeRoms from "@/stores/roms"; +import type { Events } from "@/types/emitter"; +import type { Emitter } from "mitt"; import { formatBytes, languageToEmoji, @@ -62,21 +64,39 @@ const HEADERS = [ { title: "", align: "end", key: "actions", sortable: false }, ] as const; -const PER_PAGE_OPTIONS = [ - { value: -1, title: "$vuetify.dataFooter.itemsPerPageAll" }, -] as const; +const PER_PAGE_OPTIONS = [10, 25, 50, 100]; +const emitter = inject>("emitter"); +emitter?.on("updateDataTablePages", updateDataTablePages); // Props const router = useRouter(); const downloadStore = storeDownload(); const romsStore = storeRoms(); const auth = storeAuth(); -const romsPerPage = ref(-1); +const page = ref(1); +const storedRomsPerPage = parseInt(localStorage.getItem("romsPerPage") ?? ""); +const romsPerPage = ref(isNaN(storedRomsPerPage) ? 25 : storedRomsPerPage); +const pageCount = ref(0); // Functions function rowClick(_: Event, row: any) { router.push({ name: "rom", params: { rom: row.item.id } }); } + +function updateDataTablePages() { + pageCount.value = Math.ceil( + romsStore.filteredRoms.length / romsPerPage.value + ); +} + +watch(romsPerPage, async () => { + localStorage.setItem("romsPerPage", romsPerPage.value.toString()); + updateDataTablePages(); +}); + +onMounted(() => { + updateDataTablePages(); +}); diff --git a/frontend/src/services/api/rom.ts b/frontend/src/services/api/rom.ts index 9a17e9873..1663a8b0d 100644 --- a/frontend/src/services/api/rom.ts +++ b/frontend/src/services/api/rom.ts @@ -32,7 +32,7 @@ async function uploadRoms({ async function getRoms({ platformId = null, - size = 60, + size = 5000, cursor = "", searchTerm = "", orderBy = "name", diff --git a/frontend/src/stores/roms.ts b/frontend/src/stores/roms.ts index faeaa1288..fe7992dd9 100644 --- a/frontend/src/stores/roms.ts +++ b/frontend/src/stores/roms.ts @@ -26,6 +26,7 @@ export default defineStore("roms", { cursor: "" as string | null, searchCursor: "" as string | null, selecting: false, + itemsPerBatch: 72, }), getters: { diff --git a/frontend/src/types/emitter.d.ts b/frontend/src/types/emitter.d.ts index d0b36199e..0c049aca2 100644 --- a/frontend/src/types/emitter.d.ts +++ b/frontend/src/types/emitter.d.ts @@ -68,6 +68,7 @@ export type Events = { filter: null; filterBarShow: null; filterBarReset: null; + updateDataTablePages: null; sortBarShow: null; romUpdated: DetailedRom; }; diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index 93c738d1b..4e44f5758 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -48,14 +48,6 @@ export const views: Record< export const defaultAvatarPath = "/assets/default/user.png"; -export function toTop() { - window.scrollTo({ - top: 0, - left: 0, - behavior: "smooth", - }); -} - export function normalizeString(s: string) { return s .toLowerCase() diff --git a/frontend/src/views/Details/Base.vue b/frontend/src/views/Details/Base.vue index 7b7617c65..61032a610 100644 --- a/frontend/src/views/Details/Base.vue +++ b/frontend/src/views/Details/Base.vue @@ -42,6 +42,7 @@ emitter?.on("showEmulation", () => { showEmulation.value = !showEmulation.value; tab.value = showEmulation.value ? "emulation" : "details"; }); +const noRomError = ref(false); async function fetchDetails() { if (!route.params.rom) return; @@ -52,6 +53,7 @@ async function fetchDetails() { rom.value = response.data; }) .catch((error) => { + console.log(error); emitter?.emit("snackbarShow", { msg: error.response.data.detail, @@ -69,6 +71,7 @@ async function fetchDetails() { platform.value = response.data; }) .catch((error) => { + noRomError.value = true; console.log(error); emitter?.emit("snackbarShow", { msg: error.response.data.detail, @@ -269,6 +272,15 @@ watch( + +