From b9b861d68479c8f385021883cd7361c8b7c1daa2 Mon Sep 17 00:00:00 2001 From: zurdi Date: Thu, 27 Jun 2024 18:46:56 +0200 Subject: [PATCH 01/23] set main sibling added to the backend --- backend/alembic/versions/0021_fav_sibling.py | 36 +++++++++++ backend/endpoints/responses/rom.py | 2 + backend/endpoints/rom.py | 1 + backend/models/rom.py | 3 + .../__generated__/models/DetailedRomSchema.ts | 1 + .../src/__generated__/models/RomSchema.ts | 1 + .../src/components/Details/Info/FileInfo.vue | 60 ++++++++++++++++++- frontend/src/services/api/rom.ts | 2 + 8 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 backend/alembic/versions/0021_fav_sibling.py diff --git a/backend/alembic/versions/0021_fav_sibling.py b/backend/alembic/versions/0021_fav_sibling.py new file mode 100644 index 000000000..b2ad9c6ee --- /dev/null +++ b/backend/alembic/versions/0021_fav_sibling.py @@ -0,0 +1,36 @@ +"""empty message + +Revision ID: 0021_fav_sibling +Revises: 0020_created_and_updated +Create Date: 2024-06-27 18:04:55.707623 + +""" + +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = "0021_fav_sibling" +down_revision = "0020_created_and_updated" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table("roms", schema=None) as batch_op: + batch_op.add_column( + sa.Column( + "fav_sibling", sa.Boolean(), nullable=True, server_default=sa.false() + ) + ) + + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table("roms", schema=None) as batch_op: + batch_op.drop_column("fav_sibling") + + # ### end Alembic commands ### diff --git a/backend/endpoints/responses/rom.py b/backend/endpoints/responses/rom.py index 4e5280db8..5b101d881 100644 --- a/backend/endpoints/responses/rom.py +++ b/backend/endpoints/responses/rom.py @@ -94,6 +94,8 @@ class RomSchema(BaseModel): files: list[str] full_path: str + fav_sibling: bool + created_at: datetime updated_at: datetime diff --git a/backend/endpoints/rom.py b/backend/endpoints/rom.py index b43474657..a9c31ab1f 100644 --- a/backend/endpoints/rom.py +++ b/backend/endpoints/rom.py @@ -278,6 +278,7 @@ async def update_rom( cleaned_data = {} cleaned_data["igdb_id"] = data.get("igdb_id", None) cleaned_data["moby_id"] = data.get("moby_id", None) + cleaned_data["fav_sibling"] = bool(data.get("fav_sibling", None)) if cleaned_data["moby_id"]: moby_rom = meta_moby_handler.get_rom_by_id(cleaned_data["moby_id"]) diff --git a/backend/models/rom.py b/backend/models/rom.py index 8f53b3fc4..c88178353 100644 --- a/backend/models/rom.py +++ b/backend/models/rom.py @@ -81,6 +81,9 @@ class Rom(BaseModel): states: Mapped[list["State"]] = relationship(back_populates="rom") screenshots: Mapped[list["Screenshot"]] = relationship(back_populates="rom") notes: Mapped[list["RomNote"]] = relationship(back_populates="rom") + + fav_sibling: Mapped[bool | None] = mapped_column(default=False) + created_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), server_default=func.now() ) diff --git a/frontend/src/__generated__/models/DetailedRomSchema.ts b/frontend/src/__generated__/models/DetailedRomSchema.ts index 10ad1628c..257537027 100644 --- a/frontend/src/__generated__/models/DetailedRomSchema.ts +++ b/frontend/src/__generated__/models/DetailedRomSchema.ts @@ -48,6 +48,7 @@ export type DetailedRomSchema = { multi: boolean; files: Array; full_path: string; + fav_sibling: boolean; created_at: string; updated_at: string; merged_screenshots: Array; diff --git a/frontend/src/__generated__/models/RomSchema.ts b/frontend/src/__generated__/models/RomSchema.ts index 80f8b6d3a..a77c4d643 100644 --- a/frontend/src/__generated__/models/RomSchema.ts +++ b/frontend/src/__generated__/models/RomSchema.ts @@ -43,6 +43,7 @@ export type RomSchema = { multi: boolean; files: Array; full_path: string; + fav_sibling: boolean; created_at: string; updated_at: string; readonly sort_comparator: string; diff --git a/frontend/src/components/Details/Info/FileInfo.vue b/frontend/src/components/Details/Info/FileInfo.vue index 1ab1d7aca..426369b9d 100644 --- a/frontend/src/components/Details/Info/FileInfo.vue +++ b/frontend/src/components/Details/Info/FileInfo.vue @@ -1,12 +1,42 @@ - - diff --git a/frontend/src/stores/roms.ts b/frontend/src/stores/roms.ts index 96809f586..8babc3f63 100644 --- a/frontend/src/stores/roms.ts +++ b/frontend/src/stores/roms.ts @@ -60,10 +60,18 @@ export default defineStore("roms", { game.igdb_id || game.moby_id || nanoid(), ), ) - .map((games) => ({ - ...(games.shift() as SimpleRom), - siblings: games, - })) + .map((games) => { + const favSiblingIndex = games.findIndex((game) => game.fav_sibling); + const primaryGame = + favSiblingIndex !== -1 + ? games.splice(favSiblingIndex, 1)[0] + : games.shift(); + + return { + ...(primaryGame as SimpleRom), + siblings: games, + }; + }) .sort((a, b) => { return a.sort_comparator.localeCompare(b.sort_comparator); }); From 39877b13b7c9bfc8bfb5b3426fd3ebbdad23e1e5 Mon Sep 17 00:00:00 2001 From: zurdi Date: Thu, 27 Jun 2024 23:20:37 +0200 Subject: [PATCH 03/23] fixed game info details --- .../src/components/Details/Info/FileInfo.vue | 188 ++++++++-------- .../src/components/Details/Info/GameInfo.vue | 210 +++++++++--------- .../components/Details/VersionSwitcher.vue | 4 +- 3 files changed, 211 insertions(+), 191 deletions(-) diff --git a/frontend/src/components/Details/Info/FileInfo.vue b/frontend/src/components/Details/Info/FileInfo.vue index 555dc357d..b556e5e41 100644 --- a/frontend/src/components/Details/Info/FileInfo.vue +++ b/frontend/src/components/Details/Info/FileInfo.vue @@ -9,10 +9,12 @@ import { formatBytes } from "@/utils"; import type { Emitter } from "mitt"; import { inject } from "vue"; +// Props const props = defineProps<{ rom: DetailedRom; platform: Platform }>(); const emitter = inject>("emitter"); const downloadStore = storeDownload(); +// Functions async function updateMainSibling() { const updatedRom = props.rom; updatedRom.fav_sibling = !props.rom.fav_sibling; @@ -39,97 +41,107 @@ async function updateMainSibling() { } diff --git a/frontend/src/components/Details/Info/GameInfo.vue b/frontend/src/components/Details/Info/GameInfo.vue index b66121cf9..5681b425f 100644 --- a/frontend/src/components/Details/Info/GameInfo.vue +++ b/frontend/src/components/Details/Info/GameInfo.vue @@ -10,108 +10,116 @@ const galleryFilter = storeGalleryFilter(); const show = ref(false); + + diff --git a/frontend/src/components/Details/VersionSwitcher.vue b/frontend/src/components/Details/VersionSwitcher.vue index bd14a397c..b25bf68e1 100644 --- a/frontend/src/components/Details/VersionSwitcher.vue +++ b/frontend/src/components/Details/VersionSwitcher.vue @@ -32,8 +32,8 @@ function updateVersion() { v-model="version" label="Version" single-line - color="romm-gray" - variant="outlined" + rounded="0" + variant="solo-filled" density="compact" max-width="fit-content" hide-details From f6d476b7b6faf25b1570e2ae232b8025362cb07a Mon Sep 17 00:00:00 2001 From: zurdi Date: Fri, 28 Jun 2024 00:40:04 +0200 Subject: [PATCH 04/23] ui tweak play view --- frontend/src/views/Play/Base.vue | 64 ++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/frontend/src/views/Play/Base.vue b/frontend/src/views/Play/Base.vue index eadde72a1..2bcb1358d 100644 --- a/frontend/src/views/Play/Base.vue +++ b/frontend/src/views/Play/Base.vue @@ -116,6 +116,7 @@ onMounted(async () => { :disabled="gameRunning" v-model="coreRef" class="my-1" + rounded="0" hide-details variant="outlined" clearable @@ -132,6 +133,7 @@ onMounted(async () => { :disabled="gameRunning" class="my-1" hide-details + rounded="0" variant="outlined" clearable label="BIOS" @@ -149,6 +151,7 @@ onMounted(async () => { hide-details variant="outlined" clearable + rounded="0" label="Save" :items=" rom.user_saves?.map((s) => ({ @@ -163,6 +166,7 @@ onMounted(async () => { :disabled="gameRunning" class="my-1" hide-details + rounded="0" variant="outlined" clearable label="State" @@ -181,6 +185,7 @@ onMounted(async () => { hide-details variant="outlined" clearable + rounded="0" disabled label="Patch" :items="[ @@ -192,30 +197,43 @@ onMounted(async () => { - {{ - fullScreenOnPlay - ? "mdi-checkbox-outline" - : "mdi-checkbox-blank-outline" - }}Full screen - Play - + + + {{ + fullScreenOnPlay + ? "mdi-checkbox-outline" + : "mdi-checkbox-blank-outline" + }}Full screen + + + Play + + + Date: Fri, 28 Jun 2024 09:05:37 +0200 Subject: [PATCH 05/23] reverted size info --- .../src/components/Details/Info/FileInfo.vue | 54 +++++++++---------- .../src/components/Details/Info/GameInfo.vue | 2 +- frontend/src/views/GameDetails.vue | 6 ++- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/frontend/src/components/Details/Info/FileInfo.vue b/frontend/src/components/Details/Info/FileInfo.vue index b556e5e41..644e710d0 100644 --- a/frontend/src/components/Details/Info/FileInfo.vue +++ b/frontend/src/components/Details/Info/FileInfo.vue @@ -41,7 +41,7 @@ async function updateMainSibling() { }