mirror of
https://github.com/rommapp/romm.git
synced 2026-12-02 18:18:47 +01:00
@@ -2,12 +2,12 @@
|
||||
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
|
||||
version: 0.1
|
||||
cli:
|
||||
version: 1.22.11
|
||||
version: 1.22.12
|
||||
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
|
||||
plugins:
|
||||
sources:
|
||||
- id: trunk
|
||||
ref: v1.6.7
|
||||
ref: v1.6.8
|
||||
uri: https://github.com/trunk-io/plugins
|
||||
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
|
||||
runtimes:
|
||||
@@ -17,27 +17,29 @@ runtimes:
|
||||
- python@3.12.2
|
||||
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
|
||||
lint:
|
||||
disabled:
|
||||
- pyright
|
||||
enabled:
|
||||
- markdownlint@0.44.0
|
||||
- eslint@9.22.0
|
||||
- eslint@9.25.1
|
||||
- actionlint@1.7.7
|
||||
- bandit@1.8.3
|
||||
- black@25.1.0
|
||||
- checkov@3.2.386
|
||||
- checkov@3.2.408
|
||||
- git-diff-check
|
||||
- isort@6.0.1
|
||||
- mypy@1.15.0
|
||||
- osv-scanner@2.0.0
|
||||
- osv-scanner@2.0.1
|
||||
- oxipng@9.1.4
|
||||
- prettier@3.5.3
|
||||
- ruff@0.11.0
|
||||
- ruff@0.11.6
|
||||
- shellcheck@0.10.0
|
||||
- shfmt@3.6.0
|
||||
- svgo@3.3.2
|
||||
- taplo@0.9.3
|
||||
- trivy@0.60.0
|
||||
- trufflehog@3.88.17
|
||||
- yamllint@1.36.2
|
||||
- trivy@0.61.1
|
||||
- trufflehog@3.88.25
|
||||
- yamllint@1.37.0
|
||||
ignore:
|
||||
- linters: [ALL]
|
||||
paths:
|
||||
|
||||
@@ -212,7 +212,6 @@ Here are a few projects maintained by members of our community. Please note that
|
||||
- [romm-comm][romm-comm-discord-bot]: Discord Bot by @idio-sync
|
||||
- [DeckRommSync][deck-romm-sync]: SteamOS downloader and sync by @PeriBluGaming
|
||||
- CasaOS app via the [BigBear App Store][big-bear-casaos]
|
||||
- [Helm Chart to deploy on Kubernetes][kubernetes-helm-chart] by @psych0d0g
|
||||
|
||||
Join us on Discord, where you can ask questions, submit ideas, get help, showcase your collection, and discuss RomM with other users.
|
||||
|
||||
@@ -283,7 +282,6 @@ Here are a few projects that we think you might like:
|
||||
[screenscraper-api]: https://www.screenscraper.fr/membreinscription.php
|
||||
[mobygames-api]: https://www.mobygames.com/info/api/
|
||||
[big-bear-casaos]: https://github.com/bigbeartechworld/big-bear-casaos
|
||||
[kubernetes-helm-chart]: https://artifacthub.io/packages/helm/crystalnet/romm
|
||||
[romm-comm-discord-bot]: https://github.com/idio-sync/romm-comm
|
||||
[deck-romm-sync]: https://github.com/PeriBluGaming/DeckRommSync-Standalone
|
||||
[playnite-app]: https://github.com/rommapp/playnite-plugin
|
||||
|
||||
@@ -9,7 +9,7 @@ from models.base import BaseModel
|
||||
from models.collection import VirtualCollection
|
||||
from models.firmware import Firmware # noqa
|
||||
from models.platform import Platform # noqa
|
||||
from models.rom import Rom, SiblingRom # noqa
|
||||
from models.rom import Rom, RomMetadata, SiblingRom # noqa
|
||||
from models.user import User # noqa
|
||||
from sqlalchemy import create_engine
|
||||
|
||||
@@ -39,6 +39,7 @@ def include_object(object, name, type_, reflected, compare_to):
|
||||
if type_ == "table" and name in [
|
||||
SiblingRom.__tablename__,
|
||||
VirtualCollection.__tablename__,
|
||||
RomMetadata.__tablename__,
|
||||
]: # Virtual table
|
||||
return False
|
||||
|
||||
|
||||
228
backend/alembic/versions/0037_virtual_rom_columns.py
Normal file
228
backend/alembic/versions/0037_virtual_rom_columns.py
Normal file
@@ -0,0 +1,228 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0037_virtual_rom_columns
|
||||
Revises: 0036_screenscraper_platforms_id
|
||||
Create Date: 2025-03-17 00:00:00.000000
|
||||
|
||||
"""
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from utils.database import is_postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "0037_virtual_rom_columns"
|
||||
down_revision = "0036_screenscraper_platforms_id"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
connection = op.get_bind()
|
||||
if is_postgresql(connection):
|
||||
connection.execute(
|
||||
sa.text(
|
||||
"""
|
||||
CREATE OR REPLACE VIEW roms_metadata AS
|
||||
SELECT
|
||||
r.id AS rom_id,
|
||||
NOW() AS created_at,
|
||||
NOW() AS updated_at,
|
||||
COALESCE(
|
||||
(r.igdb_metadata -> 'genres'),
|
||||
(r.moby_metadata -> 'genres'),
|
||||
(r.ss_metadata -> 'genres'),
|
||||
'[]'::jsonb
|
||||
) AS genres,
|
||||
|
||||
CASE
|
||||
WHEN r.igdb_metadata IS NOT NULL AND r.igdb_metadata ? 'franchises' THEN r.igdb_metadata -> 'franchises'
|
||||
WHEN r.ss_metadata IS NOT NULL AND r.ss_metadata ? 'franchises' THEN r.ss_metadata -> 'franchises'
|
||||
ELSE '[]'::jsonb
|
||||
END AS franchises,
|
||||
|
||||
CASE
|
||||
WHEN r.igdb_metadata IS NOT NULL AND r.igdb_metadata ? 'collections' THEN r.igdb_metadata -> 'collections'
|
||||
ELSE '[]'::jsonb
|
||||
END AS collections,
|
||||
|
||||
CASE
|
||||
WHEN r.igdb_metadata IS NOT NULL AND r.igdb_metadata ? 'companies' THEN r.igdb_metadata -> 'companies'
|
||||
WHEN r.ss_metadata IS NOT NULL AND r.ss_metadata ? 'companies' THEN r.ss_metadata -> 'companies'
|
||||
ELSE '[]'::jsonb
|
||||
END AS companies,
|
||||
|
||||
CASE
|
||||
WHEN r.igdb_metadata IS NOT NULL AND r.igdb_metadata ? 'game_modes' THEN r.igdb_metadata -> 'game_modes'
|
||||
WHEN r.ss_metadata IS NOT NULL AND r.ss_metadata ? 'game_modes' THEN r.ss_metadata -> 'game_modes'
|
||||
ELSE '[]'::jsonb
|
||||
END AS game_modes,
|
||||
|
||||
COALESCE(
|
||||
jsonb_path_query_array(
|
||||
r.igdb_metadata,
|
||||
'$.age_ratings[*].rating'
|
||||
),
|
||||
'[]'::jsonb
|
||||
) AS age_ratings,
|
||||
|
||||
CASE
|
||||
WHEN r.igdb_metadata IS NOT NULL AND r.igdb_metadata ? 'first_release_date' AND
|
||||
r.igdb_metadata ->> 'first_release_date' NOT IN ('null', 'None', '') AND
|
||||
r.igdb_metadata ->> 'first_release_date' ~ '^[0-9]+$'
|
||||
THEN (r.igdb_metadata ->> 'first_release_date')::bigint * 1000
|
||||
|
||||
WHEN r.ss_metadata IS NOT NULL AND r.ss_metadata ? 'first_release_date' AND
|
||||
r.ss_metadata ->> 'first_release_date' NOT IN ('null', 'None', '') AND
|
||||
r.ss_metadata ->> 'first_release_date' ~ '^[0-9]+$'
|
||||
THEN (r.ss_metadata ->> 'first_release_date')::bigint * 1000
|
||||
|
||||
ELSE NULL
|
||||
END AS first_release_date,
|
||||
|
||||
CASE
|
||||
WHEN (igdb_rating IS NOT NULL OR moby_rating IS NOT NULL OR ss_rating IS NOT NULL) THEN
|
||||
(COALESCE(igdb_rating, 0) + COALESCE(moby_rating, 0) + COALESCE(ss_rating, 0)) /
|
||||
(CASE WHEN igdb_rating IS NOT NULL THEN 1 ELSE 0 END +
|
||||
CASE WHEN moby_rating IS NOT NULL THEN 1 ELSE 0 END +
|
||||
CASE WHEN ss_rating IS NOT NULL THEN 1 ELSE 0 END)
|
||||
ELSE NULL
|
||||
END AS average_rating
|
||||
FROM (
|
||||
SELECT
|
||||
r.id,
|
||||
r.igdb_metadata,
|
||||
r.moby_metadata,
|
||||
r.ss_metadata,
|
||||
CASE
|
||||
WHEN r.igdb_metadata IS NOT NULL AND r.igdb_metadata ? 'total_rating' AND
|
||||
r.igdb_metadata ->> 'total_rating' NOT IN ('null', 'None', '') AND
|
||||
r.igdb_metadata ->> 'total_rating' ~ '^[0-9]+(\\.[0-9]+)?$'
|
||||
THEN (r.igdb_metadata ->> 'total_rating')::float
|
||||
ELSE NULL
|
||||
END AS igdb_rating,
|
||||
CASE
|
||||
WHEN r.moby_metadata IS NOT NULL AND r.moby_metadata ? 'moby_score' AND
|
||||
r.moby_metadata ->> 'moby_score' NOT IN ('null', 'None', '') AND
|
||||
r.moby_metadata ->> 'moby_score' ~ '^[0-9]+(\\.[0-9]+)?$'
|
||||
THEN (r.moby_metadata ->> 'moby_score')::float * 10
|
||||
ELSE NULL
|
||||
END AS moby_rating,
|
||||
CASE
|
||||
WHEN r.ss_metadata IS NOT NULL AND r.ss_metadata ? 'ss_score' AND
|
||||
r.ss_metadata ->> 'ss_score' NOT IN ('null', 'None', '') AND
|
||||
r.ss_metadata ->> 'ss_score' ~ '^[0-9]+(\\.[0-9]+)?$'
|
||||
THEN (r.ss_metadata ->> 'ss_score')::float
|
||||
ELSE NULL
|
||||
END AS ss_rating
|
||||
FROM roms r
|
||||
) AS r;
|
||||
"""
|
||||
)
|
||||
)
|
||||
else:
|
||||
connection.execute(
|
||||
sa.text(
|
||||
"""CREATE OR REPLACE VIEW roms_metadata AS
|
||||
SELECT
|
||||
r.id as rom_id,
|
||||
NOW() AS created_at,
|
||||
NOW() AS updated_at,
|
||||
COALESCE(
|
||||
JSON_EXTRACT(r.igdb_metadata, '$.genres'),
|
||||
JSON_EXTRACT(r.moby_metadata, '$.genres'),
|
||||
JSON_EXTRACT(r.ss_metadata, '$.genres'),
|
||||
JSON_ARRAY()
|
||||
) AS genres,
|
||||
|
||||
CASE
|
||||
WHEN JSON_CONTAINS_PATH(r.igdb_metadata, 'one', '$.franchises') THEN JSON_EXTRACT(r.igdb_metadata, '$.franchises')
|
||||
WHEN JSON_CONTAINS_PATH(r.ss_metadata, 'one', '$.franchises') THEN JSON_EXTRACT(r.ss_metadata, '$.franchises')
|
||||
ELSE JSON_ARRAY()
|
||||
END AS franchises,
|
||||
|
||||
CASE
|
||||
WHEN JSON_CONTAINS_PATH(r.igdb_metadata, 'one', '$.collections') THEN JSON_EXTRACT(r.igdb_metadata, '$.collections')
|
||||
ELSE JSON_ARRAY()
|
||||
END AS collections,
|
||||
|
||||
CASE
|
||||
WHEN JSON_CONTAINS_PATH(r.igdb_metadata, 'one', '$.companies') THEN JSON_EXTRACT(r.igdb_metadata, '$.companies')
|
||||
WHEN JSON_CONTAINS_PATH(r.ss_metadata, 'one', '$.companies') THEN JSON_EXTRACT(r.ss_metadata, '$.companies')
|
||||
ELSE JSON_ARRAY()
|
||||
END AS companies,
|
||||
|
||||
CASE
|
||||
WHEN JSON_CONTAINS_PATH(r.igdb_metadata, 'one', '$.game_modes') THEN JSON_EXTRACT(r.igdb_metadata, '$.game_modes')
|
||||
WHEN JSON_CONTAINS_PATH(r.ss_metadata, 'one', '$.game_modes') THEN JSON_EXTRACT(r.ss_metadata, '$.game_modes')
|
||||
ELSE JSON_ARRAY()
|
||||
END AS game_modes,
|
||||
|
||||
CASE
|
||||
WHEN JSON_CONTAINS_PATH(r.igdb_metadata, 'one', '$.age_ratings')
|
||||
AND JSON_LENGTH(JSON_EXTRACT(r.igdb_metadata, '$.age_ratings')) > 0
|
||||
THEN
|
||||
JSON_EXTRACT(r.igdb_metadata, '$.age_ratings[*].rating')
|
||||
ELSE
|
||||
JSON_ARRAY()
|
||||
END AS age_ratings,
|
||||
|
||||
CASE
|
||||
WHEN JSON_CONTAINS_PATH(r.igdb_metadata, 'one', '$.first_release_date') AND
|
||||
JSON_UNQUOTE(JSON_EXTRACT(r.igdb_metadata, '$.first_release_date')) NOT IN ('null', 'None', '') AND
|
||||
JSON_UNQUOTE(JSON_EXTRACT(r.igdb_metadata, '$.first_release_date')) REGEXP '^[0-9]+$'
|
||||
THEN CAST(JSON_EXTRACT(r.igdb_metadata, '$.first_release_date') AS SIGNED) * 1000
|
||||
|
||||
WHEN JSON_CONTAINS_PATH(r.ss_metadata, 'one', '$.first_release_date') AND
|
||||
JSON_UNQUOTE(JSON_EXTRACT(r.ss_metadata, '$.first_release_date')) NOT IN ('null', 'None', '') AND
|
||||
JSON_UNQUOTE(JSON_EXTRACT(r.ss_metadata, '$.first_release_date')) REGEXP '^[0-9]+$'
|
||||
THEN CAST(JSON_EXTRACT(r.ss_metadata, '$.first_release_date') AS SIGNED) * 1000
|
||||
|
||||
ELSE NULL
|
||||
END AS first_release_date,
|
||||
|
||||
CASE
|
||||
WHEN (igdb_rating IS NOT NULL OR moby_rating IS NOT NULL OR ss_rating IS NOT NULL) THEN
|
||||
(COALESCE(igdb_rating, 0) + COALESCE(moby_rating, 0) + COALESCE(ss_rating, 0)) /
|
||||
(CASE WHEN igdb_rating IS NOT NULL THEN 1 ELSE 0 END +
|
||||
CASE WHEN moby_rating IS NOT NULL THEN 1 ELSE 0 END +
|
||||
CASE WHEN ss_rating IS NOT NULL THEN 1 ELSE 0 END)
|
||||
ELSE NULL
|
||||
END AS average_rating
|
||||
|
||||
FROM (
|
||||
SELECT
|
||||
id,
|
||||
igdb_metadata,
|
||||
moby_metadata,
|
||||
ss_metadata,
|
||||
CASE
|
||||
WHEN JSON_CONTAINS_PATH(igdb_metadata, 'one', '$.total_rating') AND
|
||||
JSON_UNQUOTE(JSON_EXTRACT(igdb_metadata, '$.total_rating')) NOT IN ('null', 'None', '') AND
|
||||
JSON_UNQUOTE(JSON_EXTRACT(igdb_metadata, '$.total_rating')) REGEXP '^[0-9]+(\\.[0-9]+)?$'
|
||||
THEN CAST(JSON_EXTRACT(igdb_metadata, '$.total_rating') AS DECIMAL(10,2))
|
||||
ELSE NULL
|
||||
END AS igdb_rating,
|
||||
CASE
|
||||
WHEN JSON_CONTAINS_PATH(moby_metadata, 'one', '$.moby_score') AND
|
||||
JSON_UNQUOTE(JSON_EXTRACT(moby_metadata, '$.moby_score')) NOT IN ('null', 'None', '') AND
|
||||
JSON_UNQUOTE(JSON_EXTRACT(moby_metadata, '$.moby_score')) REGEXP '^[0-9]+(\\.[0-9]+)?$'
|
||||
THEN CAST(JSON_EXTRACT(moby_metadata, '$.moby_score') AS DECIMAL(10,2)) * 10
|
||||
ELSE NULL
|
||||
END AS moby_rating,
|
||||
CASE
|
||||
WHEN JSON_CONTAINS_PATH(ss_metadata, 'one', '$.ss_score') AND
|
||||
JSON_UNQUOTE(JSON_EXTRACT(ss_metadata, '$.ss_score')) NOT IN ('null', 'None', '') AND
|
||||
JSON_UNQUOTE(JSON_EXTRACT(ss_metadata, '$.ss_score')) REGEXP '^[0-9]+(\\.[0-9]+)?$'
|
||||
THEN CAST(JSON_EXTRACT(ss_metadata, '$.ss_score') AS DECIMAL(10,2)) * 10
|
||||
ELSE NULL
|
||||
END AS ss_rating
|
||||
FROM roms
|
||||
) AS r;
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute("DROP VIEW IF EXISTS roms_metadata")
|
||||
92
backend/alembic/versions/0038_add_ssid_to_sibling_roms.py
Normal file
92
backend/alembic/versions/0038_add_ssid_to_sibling_roms.py
Normal file
@@ -0,0 +1,92 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0038_add_ssid_to_sibling_roms
|
||||
Revises: 0037_virtual_rom_columns
|
||||
Create Date: 2025-04-23 00:00:00.000000
|
||||
|
||||
"""
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from utils.database import is_postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "0038_add_ssid_to_sibling_roms"
|
||||
down_revision = "0037_virtual_rom_columns"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
connection = op.get_bind()
|
||||
null_safe_equal_operator = (
|
||||
"IS NOT DISTINCT FROM" if is_postgresql(connection) else "<=>"
|
||||
)
|
||||
|
||||
connection.execute(
|
||||
sa.text(
|
||||
f"""
|
||||
CREATE OR REPLACE VIEW sibling_roms AS
|
||||
SELECT
|
||||
r1.id AS rom_id,
|
||||
r2.id AS sibling_rom_id,
|
||||
r1.platform_id AS platform_id,
|
||||
NOW() AS created_at,
|
||||
NOW() AS updated_at,
|
||||
CASE WHEN r1.igdb_id {null_safe_equal_operator} r2.igdb_id THEN r1.igdb_id END AS igdb_id,
|
||||
CASE WHEN r1.moby_id {null_safe_equal_operator} r2.moby_id THEN r1.moby_id END AS moby_id,
|
||||
CASE WHEN r1.ss_id {null_safe_equal_operator} r2.ss_id THEN r1.ss_id END AS ss_id
|
||||
FROM
|
||||
roms r1
|
||||
JOIN
|
||||
roms r2
|
||||
ON
|
||||
r1.platform_id = r2.platform_id
|
||||
AND r1.id != r2.id
|
||||
AND (
|
||||
(r1.igdb_id = r2.igdb_id AND r1.igdb_id IS NOT NULL)
|
||||
OR
|
||||
(r1.moby_id = r2.moby_id AND r1.moby_id IS NOT NULL)
|
||||
OR
|
||||
(r1.ss_id = r2.ss_id AND r1.ss_id IS NOT NULL)
|
||||
);
|
||||
""" # nosec B608
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
connection = op.get_bind()
|
||||
null_safe_equal_operator = (
|
||||
"IS NOT DISTINCT FROM" if is_postgresql(connection) else "<=>"
|
||||
)
|
||||
|
||||
connection.execute(sa.text("DROP VIEW IF EXISTS sibling_roms;"))
|
||||
|
||||
connection.execute(
|
||||
sa.text(
|
||||
f"""
|
||||
CREATE VIEW sibling_roms AS
|
||||
SELECT
|
||||
r1.id AS rom_id,
|
||||
r2.id AS sibling_rom_id,
|
||||
r1.platform_id AS platform_id,
|
||||
NOW() AS created_at,
|
||||
NOW() AS updated_at,
|
||||
CASE WHEN r1.igdb_id {null_safe_equal_operator} r2.igdb_id THEN r1.igdb_id END AS igdb_id,
|
||||
CASE WHEN r1.moby_id {null_safe_equal_operator} r2.moby_id THEN r1.moby_id END AS moby_id
|
||||
FROM
|
||||
roms r1
|
||||
JOIN
|
||||
roms r2
|
||||
ON
|
||||
r1.platform_id = r2.platform_id
|
||||
AND r1.id != r2.id
|
||||
AND (
|
||||
(r1.igdb_id = r2.igdb_id AND r1.igdb_id IS NOT NULL)
|
||||
OR
|
||||
(r1.moby_id = r2.moby_id AND r1.moby_id IS NOT NULL)
|
||||
);
|
||||
""" # nosec B608
|
||||
),
|
||||
)
|
||||
@@ -16,6 +16,7 @@ def str_to_bool(value: str) -> bool:
|
||||
DEV_MODE: Final = str_to_bool(os.environ.get("DEV_MODE", "false"))
|
||||
DEV_HOST: Final = os.environ.get("DEV_HOST", "127.0.0.1")
|
||||
DEV_PORT: Final = int(os.environ.get("DEV_PORT", "5000"))
|
||||
DEV_SQL_ECHO: Final = str_to_bool(os.environ.get("DEV_SQL_ECHO", "false"))
|
||||
|
||||
# PATHS
|
||||
ROMM_BASE_PATH: Final = os.environ.get("ROMM_BASE_PATH", "/romm")
|
||||
|
||||
@@ -51,7 +51,8 @@ def platforms_webrcade_feed(request: Request) -> WebrcadeFeedSchema:
|
||||
continue
|
||||
|
||||
category_items = []
|
||||
for rom in db_rom_handler.get_roms(platform_id=p.id):
|
||||
roms = db_rom_handler.get_roms_scalar(platform_id=p.id)
|
||||
for rom in roms:
|
||||
category_item = WebrcadeFeedItemSchema(
|
||||
title=rom.name or "",
|
||||
description=rom.summary or "",
|
||||
@@ -134,8 +135,6 @@ async def tinfoil_index_feed(
|
||||
error="Nintendo Switch platform not found",
|
||||
)
|
||||
|
||||
roms = db_rom_handler.get_roms(platform_id=switch.id)
|
||||
|
||||
async def extract_titledb(
|
||||
roms: Sequence[Rom],
|
||||
) -> dict[str, TinfoilFeedTitleDBSchema]:
|
||||
@@ -184,6 +183,8 @@ async def tinfoil_index_feed(
|
||||
|
||||
return titledb
|
||||
|
||||
roms = db_rom_handler.get_roms_scalar(platform_id=switch.id)
|
||||
|
||||
return TinfoilFeedSchema(
|
||||
files=[
|
||||
TinfoilFeedFileSchema(
|
||||
|
||||
@@ -121,6 +121,45 @@ class RomFileSchema(BaseModel):
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class RomMetadataSchema(BaseModel):
|
||||
rom_id: int
|
||||
genres: list[str]
|
||||
franchises: list[str]
|
||||
collections: list[str]
|
||||
companies: list[str]
|
||||
game_modes: list[str]
|
||||
age_ratings: list[str]
|
||||
first_release_date: int | None
|
||||
average_rating: float | None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
@field_validator("genres")
|
||||
def sort_genres(cls, v: list[str]) -> list[str]:
|
||||
return sorted(v)
|
||||
|
||||
@field_validator("franchises")
|
||||
def sort_franchises(cls, v: list[str]) -> list[str]:
|
||||
return sorted(v)
|
||||
|
||||
@field_validator("collections")
|
||||
def sort_collections(cls, v: list[str]) -> list[str]:
|
||||
return sorted(v)
|
||||
|
||||
@field_validator("companies")
|
||||
def sort_companies(cls, v: list[str]) -> list[str]:
|
||||
return sorted(v)
|
||||
|
||||
@field_validator("game_modes")
|
||||
def sort_game_modes(cls, v: list[str]) -> list[str]:
|
||||
return sorted(v)
|
||||
|
||||
@field_validator("age_ratings")
|
||||
def sort_age_ratings(cls, v: list[str]) -> list[str]:
|
||||
return sorted(v)
|
||||
|
||||
|
||||
class RomSchema(BaseModel):
|
||||
id: int
|
||||
igdb_id: int | None
|
||||
@@ -147,16 +186,9 @@ class RomSchema(BaseModel):
|
||||
summary: str | None
|
||||
|
||||
# Metadata fields
|
||||
first_release_date: int | None
|
||||
youtube_video_id: str | None
|
||||
average_rating: float | None
|
||||
alternative_names: list[str]
|
||||
genres: list[str]
|
||||
franchises: list[str]
|
||||
meta_collections: list[str]
|
||||
companies: list[str]
|
||||
game_modes: list[str]
|
||||
age_ratings: list[str]
|
||||
youtube_video_id: str | None
|
||||
metadatum: RomMetadataSchema
|
||||
igdb_metadata: RomIGDBMetadata | None
|
||||
moby_metadata: RomMobyMetadata | None
|
||||
ss_metadata: RomSSMetadata | None
|
||||
@@ -189,6 +221,25 @@ class RomSchema(BaseModel):
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
@classmethod
|
||||
def from_orm_with_request(cls, db_rom: Rom, _request: Request) -> RomSchema:
|
||||
return cls.model_validate(db_rom)
|
||||
|
||||
@field_validator("alternative_names")
|
||||
def sort_alternative_names(cls, v: list[str]) -> list[str]:
|
||||
return sorted(v)
|
||||
|
||||
@field_validator("files")
|
||||
def sort_files(cls, v: list[RomFileSchema]) -> list[RomFileSchema]:
|
||||
return sorted(v, key=lambda x: x.file_name)
|
||||
|
||||
|
||||
class SiblingRomSchema(BaseModel):
|
||||
id: int
|
||||
name: str | None
|
||||
fs_name_no_tags: str
|
||||
fs_name_no_ext: str
|
||||
|
||||
@computed_field # type: ignore
|
||||
@property
|
||||
def sort_comparator(self) -> str:
|
||||
@@ -201,66 +252,40 @@ class RomSchema(BaseModel):
|
||||
.lower()
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_orm_with_request(cls, db_rom: Rom, _request: Request) -> RomSchema:
|
||||
return cls.model_validate(db_rom)
|
||||
|
||||
@field_validator("alternative_names")
|
||||
def sort_alternative_names(cls, v: list[str]) -> list[str]:
|
||||
return sorted(v)
|
||||
|
||||
@field_validator("genres")
|
||||
def sort_genres(cls, v: list[str]) -> list[str]:
|
||||
return sorted(v)
|
||||
|
||||
@field_validator("franchises")
|
||||
def sort_franchises(cls, v: list[str]) -> list[str]:
|
||||
return sorted(v)
|
||||
|
||||
@field_validator("meta_collections")
|
||||
def sort_meta_collections(cls, v: list[str]) -> list[str]:
|
||||
return sorted(v)
|
||||
|
||||
@field_validator("companies")
|
||||
def sort_companies(cls, v: list[str]) -> list[str]:
|
||||
return sorted(v)
|
||||
|
||||
@field_validator("game_modes")
|
||||
def sort_game_modes(cls, v: list[str]) -> list[str]:
|
||||
return sorted(v)
|
||||
|
||||
@field_validator("age_ratings")
|
||||
def sort_age_ratings(cls, v: list[str]) -> list[str]:
|
||||
return sorted(v)
|
||||
|
||||
@field_validator("files")
|
||||
def sort_files(cls, v: list[RomFileSchema]) -> list[RomFileSchema]:
|
||||
return sorted(v, key=lambda x: x.file_name)
|
||||
|
||||
|
||||
class SimpleRomSchema(RomSchema):
|
||||
sibling_roms: list[RomSchema]
|
||||
siblings: list[SiblingRomSchema]
|
||||
rom_user: RomUserSchema
|
||||
|
||||
@classmethod
|
||||
def from_orm_with_request(cls, db_rom: Rom, request: Request) -> SimpleRomSchema:
|
||||
user_id = request.user.id
|
||||
db_rom.rom_user = RomUserSchema.for_user(user_id, db_rom) # type: ignore
|
||||
db_rom.siblings = [ # type: ignore
|
||||
SiblingRomSchema(
|
||||
id=s.id,
|
||||
name=s.name,
|
||||
fs_name_no_tags=s.fs_name_no_tags,
|
||||
fs_name_no_ext=s.fs_name_no_ext,
|
||||
)
|
||||
for s in db_rom.sibling_roms
|
||||
]
|
||||
return cls.model_validate(db_rom)
|
||||
|
||||
@classmethod
|
||||
def from_orm_with_factory(cls, db_rom: Rom) -> SimpleRomSchema:
|
||||
db_rom.rom_user = rom_user_schema_factory() # type: ignore
|
||||
db_rom.siblings = [] # type: ignore
|
||||
return cls.model_validate(db_rom)
|
||||
|
||||
@field_validator("sibling_roms")
|
||||
def sort_sibling_roms(cls, v: list[RomSchema]) -> list[RomSchema]:
|
||||
@field_validator("siblings")
|
||||
def sort_siblings(cls, v: list[SiblingRomSchema]) -> list[SiblingRomSchema]:
|
||||
return sorted(v, key=lambda x: x.sort_comparator)
|
||||
|
||||
|
||||
class DetailedRomSchema(RomSchema):
|
||||
merged_screenshots: list[str]
|
||||
sibling_roms: list[RomSchema]
|
||||
siblings: list[SiblingRomSchema]
|
||||
rom_user: RomUserSchema
|
||||
user_saves: list[SaveSchema]
|
||||
user_states: list[StateSchema]
|
||||
@@ -288,11 +313,20 @@ class DetailedRomSchema(RomSchema):
|
||||
db_rom.user_collections = CollectionSchema.for_user( # type: ignore
|
||||
user_id, db_rom.collections
|
||||
)
|
||||
db_rom.siblings = [ # type: ignore
|
||||
SiblingRomSchema(
|
||||
id=s.id,
|
||||
name=s.name,
|
||||
fs_name_no_tags=s.fs_name_no_tags,
|
||||
fs_name_no_ext=s.fs_name_no_ext,
|
||||
)
|
||||
for s in db_rom.sibling_roms
|
||||
]
|
||||
|
||||
return cls.model_validate(db_rom)
|
||||
|
||||
@field_validator("sibling_roms")
|
||||
def sort_sibling_roms(cls, v: list[RomSchema]) -> list[RomSchema]:
|
||||
@field_validator("siblings")
|
||||
def sort_siblings(cls, v: list[SiblingRomSchema]) -> list[SiblingRomSchema]:
|
||||
return sorted(v, key=lambda x: x.sort_comparator)
|
||||
|
||||
@field_validator("user_saves")
|
||||
|
||||
@@ -5,7 +5,7 @@ from datetime import datetime, timezone
|
||||
from io import BytesIO
|
||||
from shutil import rmtree
|
||||
from stat import S_IFREG
|
||||
from typing import Any
|
||||
from typing import Any, TypeVar
|
||||
from urllib.parse import quote
|
||||
from zipfile import ZIP_DEFLATED, ZIP_STORED, ZipFile, ZipInfo
|
||||
|
||||
@@ -22,22 +22,24 @@ from endpoints.responses import MessageResponse
|
||||
from endpoints.responses.rom import (
|
||||
DetailedRomSchema,
|
||||
RomFileSchema,
|
||||
RomSchema,
|
||||
RomUserSchema,
|
||||
SimpleRomSchema,
|
||||
)
|
||||
from exceptions.endpoint_exceptions import RomNotFoundInDatabaseException
|
||||
from exceptions.fs_exceptions import RomAlreadyExistsException
|
||||
from fastapi import HTTPException, Request, UploadFile, status
|
||||
from fastapi import HTTPException, Query, Request, UploadFile, status
|
||||
from fastapi.responses import Response
|
||||
from fastapi_pagination.ext.sqlalchemy import paginate
|
||||
from fastapi_pagination.limit_offset import LimitOffsetPage, LimitOffsetParams
|
||||
from handler.auth.constants import Scope
|
||||
from handler.database import db_platform_handler, db_rom_handler
|
||||
from handler.database.base_handler import sync_session
|
||||
from handler.filesystem import fs_resource_handler, fs_rom_handler
|
||||
from handler.filesystem.base_handler import CoverSize
|
||||
from handler.metadata import meta_igdb_handler, meta_moby_handler, meta_ss_handler
|
||||
from logger.formatter import highlight as hl
|
||||
from logger.logger import log
|
||||
from models.rom import Rom, RomFile, RomUser
|
||||
from models.rom import RomFile
|
||||
from PIL import Image
|
||||
from starlette.requests import ClientDisconnect
|
||||
from starlette.responses import FileResponse
|
||||
@@ -48,6 +50,8 @@ from utils.hashing import crc32_to_hex
|
||||
from utils.nginx import FileRedirectResponse, ZipContentLine, ZipResponse
|
||||
from utils.router import APIRouter
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/roms",
|
||||
tags=["roms"],
|
||||
@@ -116,6 +120,17 @@ async def add_rom(request: Request):
|
||||
return Response(status_code=status.HTTP_201_CREATED)
|
||||
|
||||
|
||||
class CustomLimitOffsetParams(LimitOffsetParams):
|
||||
# Temporarily increase the limit until we can implement pagination on all apps
|
||||
limit: int = Query(50, ge=1, le=10_000, description="Page size limit")
|
||||
offset: int = Query(0, ge=0, description="Page offset")
|
||||
|
||||
|
||||
class CustomLimitOffsetPage(LimitOffsetPage[T]):
|
||||
char_index: dict[str, int]
|
||||
__params_type__ = CustomLimitOffsetParams
|
||||
|
||||
|
||||
@protected_route(router.get, "", [Scope.ROMS_READ])
|
||||
def get_roms(
|
||||
request: Request,
|
||||
@@ -123,60 +138,93 @@ def get_roms(
|
||||
collection_id: int | None = None,
|
||||
virtual_collection_id: str | None = None,
|
||||
search_term: str | None = None,
|
||||
limit: int | None = None,
|
||||
offset: int | None = None,
|
||||
order_by: str = "name",
|
||||
order_dir: str = "asc",
|
||||
with_extra: bool = True,
|
||||
) -> list[SimpleRomSchema | RomSchema]:
|
||||
unmatched_only: bool = False,
|
||||
matched_only: bool = False,
|
||||
favourites_only: bool = False,
|
||||
duplicates_only: bool = False,
|
||||
group_by_meta_id: bool = False,
|
||||
selected_genre: str | None = None,
|
||||
selected_franchise: str | None = None,
|
||||
selected_collection: str | None = None,
|
||||
selected_company: str | None = None,
|
||||
selected_age_rating: str | None = None,
|
||||
selected_status: str | None = None,
|
||||
selected_region: str | None = None,
|
||||
selected_language: str | None = None,
|
||||
) -> CustomLimitOffsetPage[SimpleRomSchema]:
|
||||
"""Get roms endpoint
|
||||
|
||||
Args:
|
||||
request (Request): Fastapi Request object
|
||||
platform_id (int, optional): Platform ID to filter ROMs
|
||||
collection_id (int, optional): Collection ID to filter ROMs
|
||||
virtual_collection_id (str, optional): Virtual Collection ID to filter ROMs
|
||||
search_term (str, optional): Search term to filter ROMs
|
||||
limit (int, optional): Limit the number of ROMs returned
|
||||
offset (int, optional): Offset for pagination
|
||||
order_by (str, optional): Field to order ROMs by
|
||||
order_dir (str, optional): Direction to order ROMs (asc or desc)
|
||||
last_played (bool, optional): Flag to filter ROMs by last played
|
||||
request: Fastapi Request object
|
||||
platform_id (int, optional): Platform internal id. Defaults to None.
|
||||
collection_id (int, optional): Collection internal id. Defaults to None.
|
||||
virtual_collection_id (str, optional): Virtual collection internal id. Defaults to None.
|
||||
search_term (str, optional): Search term to filter roms. Defaults to None.
|
||||
order_by (str, optional): Field to order by. Defaults to "name".
|
||||
order_dir (str, optional): Order direction. Defaults to "asc".
|
||||
unmatched_only (bool, optional): Filter only unmatched roms. Defaults to False.
|
||||
matched_only (bool, optional): Filter only matched roms. Defaults to False.
|
||||
favourites_only (bool, optional): Filter only favourite roms. Defaults to False.
|
||||
duplicates_only (bool, optional): Filter only duplicate roms. Defaults to False.
|
||||
group_by_meta_id (bool, optional): Group roms by igdb/moby/ssrf ID. Defaults to False.
|
||||
selected_genre (str, optional): Filter by genre. Defaults to None.
|
||||
selected_franchise (str, optional): Filter by franchise. Defaults to None.
|
||||
selected_collection (str, optional): Filter by collection. Defaults to None.
|
||||
selected_company (str, optional): Filter by company. Defaults to None.
|
||||
selected_age_rating (str, optional): Filter by age rating. Defaults to None.
|
||||
selected_status (str, optional): Filter by status. Defaults to None.
|
||||
selected_region (str, optional): Filter by region tag. Defaults to None.
|
||||
selected_language (str, optional): Filter by language tag. Defaults to None.
|
||||
|
||||
Returns:
|
||||
list[DetailedRomSchema]: List of ROMs stored in the database
|
||||
list[RomSchema | SimpleRomSchema]: List of ROMs stored in the database
|
||||
"""
|
||||
|
||||
if hasattr(Rom, order_by):
|
||||
roms = db_rom_handler.get_roms(
|
||||
platform_id=platform_id,
|
||||
collection_id=collection_id,
|
||||
virtual_collection_id=virtual_collection_id,
|
||||
search_term=search_term,
|
||||
order_by=order_by.lower(),
|
||||
order_dir=order_dir.lower(),
|
||||
limit=limit,
|
||||
offset=offset,
|
||||
)
|
||||
elif hasattr(RomUser, order_by):
|
||||
roms = db_rom_handler.get_roms_user(
|
||||
user_id=request.user.id,
|
||||
platform_id=platform_id,
|
||||
collection_id=collection_id,
|
||||
virtual_collection_id=virtual_collection_id,
|
||||
search_term=search_term,
|
||||
limit=limit,
|
||||
offset=offset,
|
||||
)
|
||||
else:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Invalid order_by field",
|
||||
)
|
||||
# Get the base roms query
|
||||
query = db_rom_handler.get_roms_query(
|
||||
user_id=request.user.id,
|
||||
order_by=order_by.lower(),
|
||||
order_dir=order_dir.lower(),
|
||||
)
|
||||
|
||||
SelectedSchema = SimpleRomSchema if with_extra else RomSchema
|
||||
roms = [SelectedSchema.from_orm_with_request(rom, request) for rom in roms]
|
||||
return [rom for rom in roms if rom]
|
||||
# Filter down the query
|
||||
query = db_rom_handler.filter_roms(
|
||||
query=query,
|
||||
user_id=request.user.id,
|
||||
platform_id=platform_id,
|
||||
collection_id=collection_id,
|
||||
virtual_collection_id=virtual_collection_id,
|
||||
search_term=search_term,
|
||||
unmatched_only=unmatched_only,
|
||||
matched_only=matched_only,
|
||||
favourites_only=favourites_only,
|
||||
duplicates_only=duplicates_only,
|
||||
selected_genre=selected_genre,
|
||||
selected_franchise=selected_franchise,
|
||||
selected_collection=selected_collection,
|
||||
selected_company=selected_company,
|
||||
selected_age_rating=selected_age_rating,
|
||||
selected_status=selected_status,
|
||||
selected_region=selected_region,
|
||||
selected_language=selected_language,
|
||||
group_by_meta_id=group_by_meta_id,
|
||||
)
|
||||
|
||||
# Get the char index for the roms
|
||||
char_index = db_rom_handler.get_char_index(query=query)
|
||||
char_index_dict = {char: index for (char, index) in char_index}
|
||||
|
||||
with sync_session.begin() as session:
|
||||
return paginate(
|
||||
session,
|
||||
query,
|
||||
transformer=lambda items: [
|
||||
SimpleRomSchema.from_orm_with_request(i, request) for i in items
|
||||
],
|
||||
additional_data={"char_index": char_index_dict},
|
||||
)
|
||||
|
||||
|
||||
@protected_route(
|
||||
@@ -428,7 +476,6 @@ async def get_rom_content(
|
||||
async def update_rom(
|
||||
request: Request,
|
||||
id: int,
|
||||
rename_as_source: bool = False,
|
||||
remove_cover: bool = False,
|
||||
artwork: UploadFile | None = None,
|
||||
unmatch_metadata: bool = False,
|
||||
@@ -438,12 +485,11 @@ async def update_rom(
|
||||
Args:
|
||||
request (Request): Fastapi Request object
|
||||
id (Rom): Rom internal id
|
||||
rename_as_source (bool, optional): Flag to rename rom file as matched IGDB game. Defaults to False.
|
||||
artwork (UploadFile, optional): Custom artwork to set as cover. Defaults to File(None).
|
||||
unmatch_metadata: Remove the metadata matches for this game. Defaults to False.
|
||||
|
||||
Raises:
|
||||
HTTPException: If a rom already have that name when enabling the rename_as_source flag
|
||||
HTTPException: Rom not found in database
|
||||
|
||||
Returns:
|
||||
DetailedRomSchema: Rom stored in the database
|
||||
@@ -492,9 +538,13 @@ async def update_rom(
|
||||
"ss_id": data.get("ss_id", rom.ss_id),
|
||||
}
|
||||
|
||||
moby_id = cleaned_data["moby_id"]
|
||||
if moby_id and int(moby_id) != rom.moby_id:
|
||||
moby_rom = await meta_moby_handler.get_rom_by_id(int(moby_id))
|
||||
if (
|
||||
cleaned_data.get("moby_id", "")
|
||||
and int(cleaned_data.get("moby_id", "")) != rom.moby_id
|
||||
):
|
||||
moby_rom = await meta_moby_handler.get_rom_by_id(
|
||||
int(cleaned_data.get("moby_id", ""))
|
||||
)
|
||||
cleaned_data.update(moby_rom)
|
||||
path_screenshots = await fs_resource_handler.get_rom_screenshots(
|
||||
rom=rom,
|
||||
@@ -603,33 +653,22 @@ async def update_rom(
|
||||
|
||||
# Rename the file/folder if the name has changed
|
||||
should_update_fs = new_fs_name != rom.fs_name
|
||||
try:
|
||||
if rename_as_source:
|
||||
new_fs_name = rom.fs_name.replace(
|
||||
rom.fs_name_no_tags or rom.fs_name_no_ext,
|
||||
rom.name or rom.fs_name,
|
||||
)
|
||||
if should_update_fs:
|
||||
try:
|
||||
new_fs_name = sanitize_filename(new_fs_name)
|
||||
fs_rom_handler.rename_fs_rom(
|
||||
old_name=rom.fs_name,
|
||||
new_name=new_fs_name,
|
||||
fs_path=rom.fs_path,
|
||||
)
|
||||
elif should_update_fs:
|
||||
new_fs_name = sanitize_filename(new_fs_name)
|
||||
fs_rom_handler.rename_fs_rom(
|
||||
old_name=rom.fs_name,
|
||||
new_name=new_fs_name,
|
||||
fs_path=rom.fs_path,
|
||||
)
|
||||
except RomAlreadyExistsException as exc:
|
||||
log.error(exc)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=exc
|
||||
) from exc
|
||||
except RomAlreadyExistsException as exc:
|
||||
log.error(exc)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=exc
|
||||
) from exc
|
||||
|
||||
# Update the rom files with the new fs_name
|
||||
if rename_as_source or should_update_fs:
|
||||
if should_update_fs:
|
||||
for file in rom.files:
|
||||
db_rom_handler.update_rom_file(
|
||||
file.id,
|
||||
|
||||
@@ -33,8 +33,14 @@ def test_get_all_roms(client, access_token, rom, platform):
|
||||
assert response.status_code == 200
|
||||
|
||||
body = response.json()
|
||||
assert len(body) == 1
|
||||
assert body[0]["id"] == rom.id
|
||||
|
||||
assert body["total"] == 1
|
||||
assert body["limit"] == 50
|
||||
assert body["offset"] == 0
|
||||
|
||||
items = body["items"]
|
||||
assert len(items) == 1
|
||||
assert items[0]["id"] == rom.id
|
||||
|
||||
|
||||
@patch.object(FSRomsHandler, "rename_fs_rom")
|
||||
@@ -43,7 +49,6 @@ def test_update_rom(rename_fs_rom_mock, get_rom_by_id_mock, client, access_token
|
||||
response = client.put(
|
||||
f"/api/roms/{rom.id}",
|
||||
headers={"Authorization": f"Bearer {access_token}"},
|
||||
params={"rename_as_source": True},
|
||||
data={
|
||||
"igdb_id": "236663",
|
||||
"name": "Metroid Prime Remastered",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Annotated, Any
|
||||
|
||||
@@ -194,7 +195,10 @@ async def update_user(
|
||||
|
||||
if form_data.avatar is not None:
|
||||
user_avatar_path = fs_asset_handler.build_avatar_path(user=db_user)
|
||||
file_location = f"{user_avatar_path}/{form_data.avatar.filename}"
|
||||
# Extract the file extension from the uploaded file
|
||||
file_extension = os.path.splitext(form_data.avatar.filename)[1]
|
||||
# Set the file name to "avatar" with the original extension
|
||||
file_location = f"{user_avatar_path}/avatar{file_extension}"
|
||||
cleaned_data["avatar_path"] = file_location
|
||||
Path(f"{ASSETS_BASE_PATH}/{user_avatar_path}").mkdir(
|
||||
parents=True, exist_ok=True
|
||||
|
||||
@@ -1,9 +1,30 @@
|
||||
import time
|
||||
|
||||
from config import DEV_SQL_ECHO
|
||||
from config.config_manager import ConfigManager
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy import create_engine, event
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
sync_engine = create_engine(ConfigManager.get_db_engine(), pool_pre_ping=True)
|
||||
sync_engine = create_engine(
|
||||
ConfigManager.get_db_engine(), pool_pre_ping=True, echo=DEV_SQL_ECHO
|
||||
)
|
||||
sync_session = sessionmaker(bind=sync_engine, expire_on_commit=False)
|
||||
|
||||
|
||||
if DEV_SQL_ECHO:
|
||||
|
||||
@event.listens_for(sync_engine, "before_cursor_execute")
|
||||
def before_cursor_execute(
|
||||
conn, cursor, statement, parameters, context, executemany
|
||||
):
|
||||
context._query_start_time = time.time()
|
||||
print(f"SQL: {statement}")
|
||||
print(f"Parameters: {parameters}")
|
||||
|
||||
@event.listens_for(sync_engine, "after_cursor_execute")
|
||||
def after_cursor_execute(conn, cursor, statement, parameters, context, executemany):
|
||||
total_time = time.time() - context._query_start_time
|
||||
print(f"Execution time: {total_time:.4f} seconds")
|
||||
|
||||
|
||||
class DBBaseHandler: ...
|
||||
|
||||
@@ -1,43 +1,60 @@
|
||||
import functools
|
||||
from typing import Sequence
|
||||
|
||||
from decorators.database import begin_session
|
||||
from models.platform import Platform
|
||||
from models.rom import Rom
|
||||
from sqlalchemy import delete, or_, select
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy.orm import Query, Session, selectinload
|
||||
|
||||
from .base_handler import DBBaseHandler
|
||||
|
||||
|
||||
def with_firmware(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
kwargs["query"] = select(Platform).options(
|
||||
selectinload(Platform.firmware),
|
||||
)
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
class DBPlatformsHandler(DBBaseHandler):
|
||||
@begin_session
|
||||
@with_firmware
|
||||
def add_platform(
|
||||
self,
|
||||
platform: Platform,
|
||||
query: Query = None,
|
||||
session: Session = None,
|
||||
) -> Platform:
|
||||
platform = session.merge(platform)
|
||||
session.flush()
|
||||
|
||||
return session.query(Platform).filter_by(id=platform.id).one()
|
||||
return session.scalar(query.filter_by(id=platform.id).limit(1))
|
||||
|
||||
@begin_session
|
||||
def get_platform(self, id: int, *, session: Session = None) -> Platform | None:
|
||||
return session.scalar(select(Platform).filter_by(id=id).limit(1))
|
||||
|
||||
@begin_session
|
||||
def get_platforms(self, *, session: Session = None) -> Sequence[Platform]:
|
||||
return (
|
||||
session.scalars(select(Platform).order_by(Platform.name.asc()))
|
||||
.unique()
|
||||
.all()
|
||||
)
|
||||
|
||||
@begin_session
|
||||
def get_platform_by_fs_slug(
|
||||
self, fs_slug: str, session: Session = None
|
||||
@with_firmware
|
||||
def get_platform(
|
||||
self, id: int, query: Query = None, session: Session = None
|
||||
) -> Platform | None:
|
||||
return session.scalar(select(Platform).filter_by(fs_slug=fs_slug).limit(1))
|
||||
return session.scalar(query.filter_by(id=id).limit(1))
|
||||
|
||||
@begin_session
|
||||
@with_firmware
|
||||
def get_platforms(
|
||||
self, query: Query = None, session: Session = None
|
||||
) -> Sequence[Platform]:
|
||||
return session.scalars(query.order_by(Platform.name.asc())).unique().all()
|
||||
|
||||
@begin_session
|
||||
@with_firmware
|
||||
def get_platform_by_fs_slug(
|
||||
self, fs_slug: str, query: Query = None, session: Session = None
|
||||
) -> Platform | None:
|
||||
return session.scalar(query.filter_by(fs_slug=fs_slug).limit(1))
|
||||
|
||||
@begin_session
|
||||
def delete_platform(self, id: int, session: Session = None) -> None:
|
||||
@@ -56,7 +73,10 @@ class DBPlatformsHandler(DBBaseHandler):
|
||||
|
||||
@begin_session
|
||||
def purge_platforms(
|
||||
self, fs_platforms_to_keep: list[str], session: Session = None
|
||||
self,
|
||||
fs_platforms_to_keep: list[str],
|
||||
query: Query = None,
|
||||
session: Session = None,
|
||||
) -> Sequence[Platform]:
|
||||
purged_platforms = (
|
||||
session.scalars(
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
import functools
|
||||
from collections.abc import Iterable
|
||||
from typing import Sequence
|
||||
from typing import List, Sequence, Tuple
|
||||
|
||||
from config import ROMM_DB_DRIVER
|
||||
from decorators.database import begin_session
|
||||
from models.collection import Collection, VirtualCollection
|
||||
from models.rom import Rom, RomFile, RomUser
|
||||
from sqlalchemy import and_, delete, func, or_, select, update
|
||||
from sqlalchemy.orm import Query, Session, selectinload
|
||||
from models.rom import Rom, RomFile, RomMetadata, RomUser
|
||||
from sqlalchemy import (
|
||||
Integer,
|
||||
Row,
|
||||
String,
|
||||
Text,
|
||||
and_,
|
||||
case,
|
||||
cast,
|
||||
delete,
|
||||
func,
|
||||
literal,
|
||||
or_,
|
||||
select,
|
||||
text,
|
||||
update,
|
||||
)
|
||||
from sqlalchemy.orm import InstrumentedAttribute, Query, Session, selectinload
|
||||
|
||||
from .base_handler import DBBaseHandler
|
||||
|
||||
@@ -14,18 +30,14 @@ from .base_handler import DBBaseHandler
|
||||
def with_details(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
session = kwargs.get("session")
|
||||
if session is None:
|
||||
raise TypeError(
|
||||
f"{func} is missing required kwarg 'session' with type 'Session'"
|
||||
)
|
||||
|
||||
kwargs["query"] = select(Rom).options(
|
||||
selectinload(Rom.saves),
|
||||
selectinload(Rom.states),
|
||||
selectinload(Rom.screenshots),
|
||||
selectinload(Rom.rom_users),
|
||||
selectinload(Rom.sibling_roms),
|
||||
selectinload(Rom.metadatum),
|
||||
selectinload(Rom.files),
|
||||
selectinload(Rom.collections),
|
||||
)
|
||||
return func(*args, **kwargs)
|
||||
@@ -36,14 +48,10 @@ def with_details(func):
|
||||
def with_simple(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
session = kwargs.get("session")
|
||||
if session is None:
|
||||
raise TypeError(
|
||||
f"{func} is missing required kwarg 'session' with type 'Session'"
|
||||
)
|
||||
|
||||
kwargs["query"] = select(Rom).options(
|
||||
selectinload(Rom.rom_users), selectinload(Rom.sibling_roms)
|
||||
selectinload(Rom.rom_users),
|
||||
selectinload(Rom.metadatum),
|
||||
selectinload(Rom.files),
|
||||
)
|
||||
return func(*args, **kwargs)
|
||||
|
||||
@@ -51,58 +59,6 @@ def with_simple(func):
|
||||
|
||||
|
||||
class DBRomsHandler(DBBaseHandler):
|
||||
def _filter(
|
||||
self,
|
||||
data,
|
||||
platform_id: int | None,
|
||||
collection_id: int | None,
|
||||
virtual_collection_id: str | None,
|
||||
search_term: str | None,
|
||||
session: Session,
|
||||
):
|
||||
if platform_id:
|
||||
data = data.filter(Rom.platform_id == platform_id)
|
||||
|
||||
if collection_id:
|
||||
collection = (
|
||||
session.query(Collection)
|
||||
.filter(Collection.id == collection_id)
|
||||
.one_or_none()
|
||||
)
|
||||
if collection:
|
||||
data = data.filter(Rom.id.in_(collection.rom_ids))
|
||||
|
||||
if virtual_collection_id:
|
||||
name, type = VirtualCollection.from_id(virtual_collection_id)
|
||||
v_collection = (
|
||||
session.query(VirtualCollection)
|
||||
.filter(VirtualCollection.name == name, VirtualCollection.type == type)
|
||||
.one_or_none()
|
||||
)
|
||||
if v_collection:
|
||||
data = data.filter(Rom.id.in_(v_collection.rom_ids))
|
||||
|
||||
if search_term is not None:
|
||||
data = data.filter(
|
||||
or_(
|
||||
Rom.fs_name.ilike(f"%{search_term}%"),
|
||||
Rom.name.ilike(f"%{search_term}%"),
|
||||
)
|
||||
)
|
||||
|
||||
return data
|
||||
|
||||
def _order(self, data, order_by: str, order_dir: str):
|
||||
if order_by == "id":
|
||||
_column = Rom.id
|
||||
else:
|
||||
_column = func.lower(Rom.name)
|
||||
|
||||
if order_dir == "desc":
|
||||
return data.order_by(_column.desc())
|
||||
else:
|
||||
return data.order_by(_column.asc())
|
||||
|
||||
@begin_session
|
||||
@with_details
|
||||
def add_rom(self, rom: Rom, query: Query = None, session: Session = None) -> Rom:
|
||||
@@ -118,34 +74,420 @@ class DBRomsHandler(DBBaseHandler):
|
||||
) -> Rom | None:
|
||||
return session.scalar(query.filter_by(id=id).limit(1))
|
||||
|
||||
def filter_by_platform_id(self, query: Query, platform_id: int):
|
||||
return query.filter(Rom.platform_id == platform_id)
|
||||
|
||||
def filter_by_collection_id(
|
||||
self, query: Query, session: Session, collection_id: int
|
||||
):
|
||||
collection = (
|
||||
session.query(Collection)
|
||||
.filter(Collection.id == collection_id)
|
||||
.one_or_none()
|
||||
)
|
||||
if collection:
|
||||
return query.filter(Rom.id.in_(collection.rom_ids))
|
||||
return query
|
||||
|
||||
def filter_by_virtual_collection_id(
|
||||
self, query: Query, session: Session, virtual_collection_id: str
|
||||
):
|
||||
name, type = VirtualCollection.from_id(virtual_collection_id)
|
||||
v_collection = (
|
||||
session.query(VirtualCollection)
|
||||
.filter(VirtualCollection.name == name, VirtualCollection.type == type)
|
||||
.one_or_none()
|
||||
)
|
||||
if v_collection:
|
||||
return query.filter(Rom.id.in_(v_collection.rom_ids))
|
||||
return query
|
||||
|
||||
def filter_by_search_term(self, query: Query, search_term: str):
|
||||
return query.filter(
|
||||
or_(
|
||||
Rom.fs_name.ilike(f"%{search_term}%"),
|
||||
Rom.name.ilike(f"%{search_term}%"),
|
||||
)
|
||||
)
|
||||
|
||||
def filter_by_unmatched_only(self, query: Query):
|
||||
return query.filter(
|
||||
and_(
|
||||
Rom.igdb_id.is_(None),
|
||||
Rom.moby_id.is_(None),
|
||||
Rom.ss_id.is_(None),
|
||||
)
|
||||
)
|
||||
|
||||
def filter_by_matched_only(self, query: Query):
|
||||
return query.filter(
|
||||
or_(
|
||||
Rom.igdb_id.isnot(None),
|
||||
Rom.moby_id.isnot(None),
|
||||
Rom.ss_id.isnot(None),
|
||||
)
|
||||
)
|
||||
|
||||
def filter_by_favourites_only(self, query: Query, session: Session, user_id: int):
|
||||
favourites_collection = (
|
||||
session.query(Collection)
|
||||
.filter(Collection.name.ilike("favourites"))
|
||||
.filter(Collection.user_id == user_id)
|
||||
.one_or_none()
|
||||
)
|
||||
|
||||
if favourites_collection:
|
||||
return query.filter(Rom.id.in_(favourites_collection.rom_ids))
|
||||
|
||||
return query
|
||||
|
||||
def filter_by_duplicates_only(self, query: Query):
|
||||
return query.filter(Rom.sibling_roms.any())
|
||||
|
||||
def filter_by_genre(self, query: Query, selected_genre: str):
|
||||
if ROMM_DB_DRIVER == "postgresql":
|
||||
return query.filter(
|
||||
text("genres @> (:genre)::jsonb").bindparams(
|
||||
genre=f'["{selected_genre}"]'
|
||||
)
|
||||
)
|
||||
else:
|
||||
return query.filter(
|
||||
text("JSON_OVERLAPS(genres, JSON_ARRAY(:genre))").bindparams(
|
||||
genre=selected_genre
|
||||
)
|
||||
)
|
||||
|
||||
def filter_by_franchise(self, query: Query, selected_franchise: str):
|
||||
if ROMM_DB_DRIVER == "postgresql":
|
||||
return query.filter(
|
||||
text("franchises @> (:franchise)::jsonb").bindparams(
|
||||
franchise=f'["{selected_franchise}"]'
|
||||
)
|
||||
)
|
||||
else:
|
||||
return query.filter(
|
||||
text("JSON_OVERLAPS(franchises, JSON_ARRAY(:franchise))").bindparams(
|
||||
franchise=selected_franchise
|
||||
)
|
||||
)
|
||||
|
||||
def filter_by_collection(self, query: Query, selected_collection: str):
|
||||
if ROMM_DB_DRIVER == "postgresql":
|
||||
return query.filter(
|
||||
text("collections @> (:collection)::jsonb").bindparams(
|
||||
collection=f'["{selected_collection}"]'
|
||||
)
|
||||
)
|
||||
else:
|
||||
return query.filter(
|
||||
text("JSON_OVERLAPS(collections, JSON_ARRAY(:collection))").bindparams(
|
||||
collection=selected_collection
|
||||
)
|
||||
)
|
||||
|
||||
def filter_by_company(self, query: Query, selected_company: str):
|
||||
if ROMM_DB_DRIVER == "postgresql":
|
||||
return query.filter(
|
||||
text("companies @> (:company)::jsonb").bindparams(
|
||||
company=f'["{selected_company}"]'
|
||||
)
|
||||
)
|
||||
else:
|
||||
return query.filter(
|
||||
text("JSON_OVERLAPS(companies, JSON_ARRAY(:company))").bindparams(
|
||||
company=selected_company
|
||||
)
|
||||
)
|
||||
|
||||
def filter_by_age_rating(self, query: Query, selected_age_rating: str):
|
||||
if ROMM_DB_DRIVER == "postgresql":
|
||||
return query.filter(
|
||||
text("age_ratings @> (:age_rating)::jsonb").bindparams(
|
||||
age_rating=f'["{selected_age_rating}"]'
|
||||
)
|
||||
)
|
||||
else:
|
||||
return query.filter(
|
||||
text("JSON_OVERLAPS(age_ratings, JSON_ARRAY(:age_rating))").bindparams(
|
||||
age_rating=selected_age_rating
|
||||
)
|
||||
)
|
||||
|
||||
def filter_by_status(self, query: Query, selected_status: str):
|
||||
query = query.join(RomUser)
|
||||
|
||||
status_filter = RomUser.status == selected_status
|
||||
if selected_status == "now_playing":
|
||||
status_filter = RomUser.now_playing.is_(True)
|
||||
elif selected_status == "backlogged":
|
||||
status_filter = RomUser.backlogged.is_(True)
|
||||
elif selected_status == "hidden":
|
||||
status_filter = RomUser.hidden.is_(True)
|
||||
|
||||
if selected_status == "hidden":
|
||||
return query.filter(status_filter)
|
||||
|
||||
return query.filter(status_filter, RomUser.hidden.is_(False))
|
||||
|
||||
def filter_by_region(self, query: Query, selected_region: str):
|
||||
if ROMM_DB_DRIVER == "postgresql":
|
||||
return query.filter(
|
||||
text("regions @> (:region)::jsonb").bindparams(
|
||||
region=f'["{selected_region}"]'
|
||||
)
|
||||
)
|
||||
else:
|
||||
return query.filter(
|
||||
text("JSON_OVERLAPS(regions, JSON_ARRAY(:region))").bindparams(
|
||||
region=selected_region
|
||||
)
|
||||
)
|
||||
|
||||
def filter_by_language(self, query: Query, selected_language: str):
|
||||
if ROMM_DB_DRIVER == "postgresql":
|
||||
return query.filter(
|
||||
text("languages @> (:language)::jsonb").bindparams(
|
||||
language=f'["{selected_language}"]'
|
||||
)
|
||||
)
|
||||
else:
|
||||
return query.filter(
|
||||
text("JSON_OVERLAPS(languages, JSON_ARRAY(:language))").bindparams(
|
||||
language=selected_language
|
||||
)
|
||||
)
|
||||
|
||||
@begin_session
|
||||
@with_simple
|
||||
def get_roms(
|
||||
def filter_roms(
|
||||
self,
|
||||
*,
|
||||
query: Query,
|
||||
platform_id: int | None = None,
|
||||
collection_id: int | None = None,
|
||||
virtual_collection_id: str | None = None,
|
||||
search_term: str | None = None,
|
||||
unmatched_only: bool = False,
|
||||
matched_only: bool = False,
|
||||
favourites_only: bool = False,
|
||||
duplicates_only: bool = False,
|
||||
group_by_meta_id: bool = False,
|
||||
selected_genre: str | None = None,
|
||||
selected_franchise: str | None = None,
|
||||
selected_collection: str | None = None,
|
||||
selected_company: str | None = None,
|
||||
selected_age_rating: str | None = None,
|
||||
selected_status: str | None = None,
|
||||
selected_region: str | None = None,
|
||||
selected_language: str | None = None,
|
||||
user_id: int | None = None,
|
||||
session: Session = None,
|
||||
) -> Query[Rom]:
|
||||
if platform_id:
|
||||
query = self.filter_by_platform_id(query, platform_id)
|
||||
|
||||
if collection_id:
|
||||
query = self.filter_by_collection_id(query, session, collection_id)
|
||||
|
||||
if virtual_collection_id:
|
||||
query = self.filter_by_virtual_collection_id(
|
||||
query, session, virtual_collection_id
|
||||
)
|
||||
|
||||
if search_term:
|
||||
query = self.filter_by_search_term(query, search_term)
|
||||
|
||||
if unmatched_only:
|
||||
query = self.filter_by_unmatched_only(query)
|
||||
|
||||
if matched_only:
|
||||
query = self.filter_by_matched_only(query)
|
||||
|
||||
if favourites_only and user_id:
|
||||
query = self.filter_by_favourites_only(query, session, user_id)
|
||||
|
||||
if duplicates_only:
|
||||
query = self.filter_by_duplicates_only(query)
|
||||
|
||||
if group_by_meta_id:
|
||||
|
||||
def build_func(provider: str, column: InstrumentedAttribute):
|
||||
if platform_id:
|
||||
return func.concat(provider, "-", Rom.platform_id, "-", column)
|
||||
|
||||
return func.concat(provider, "-", Rom.platform_id, "-", column)
|
||||
|
||||
group_id = case(
|
||||
{
|
||||
Rom.igdb_id.isnot(None): build_func("igdb", Rom.igdb_id),
|
||||
Rom.moby_id.isnot(None): build_func("moby", Rom.moby_id),
|
||||
Rom.ss_id.isnot(None): build_func("ss", Rom.ss_id),
|
||||
},
|
||||
else_=build_func("romm", Rom.id),
|
||||
)
|
||||
|
||||
# Convert NULL is_main_sibling to 0 (false) so it sorts after true values
|
||||
is_main_sibling_order = (
|
||||
func.coalesce(cast(RomUser.is_main_sibling, Integer), 0).desc()
|
||||
if user_id
|
||||
else literal(1)
|
||||
)
|
||||
|
||||
# Create a subquery that identifies the first ROM in each group
|
||||
group_subquery = (
|
||||
session.query(Rom.id)
|
||||
.outerjoin(
|
||||
RomUser, and_(RomUser.rom_id == Rom.id, RomUser.user_id == user_id)
|
||||
)
|
||||
.add_columns(
|
||||
group_id.label("group_id"),
|
||||
func.row_number()
|
||||
.over(
|
||||
partition_by=group_id,
|
||||
order_by=[is_main_sibling_order, Rom.fs_name_no_ext],
|
||||
)
|
||||
.label("row_num"),
|
||||
)
|
||||
.subquery()
|
||||
)
|
||||
|
||||
# Add a filter to the original query to only include the first ROM from each group
|
||||
query = query.filter(
|
||||
Rom.id.in_(
|
||||
session.query(group_subquery.c.id).filter(
|
||||
group_subquery.c.row_num == 1
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if (
|
||||
selected_genre
|
||||
or selected_franchise
|
||||
or selected_collection
|
||||
or selected_company
|
||||
or selected_age_rating
|
||||
):
|
||||
query = query.join(RomMetadata)
|
||||
|
||||
if selected_genre:
|
||||
query = self.filter_by_genre(query, selected_genre)
|
||||
|
||||
if selected_franchise:
|
||||
query = self.filter_by_franchise(query, selected_franchise)
|
||||
|
||||
if selected_collection:
|
||||
query = self.filter_by_collection(query, selected_collection)
|
||||
|
||||
if selected_company:
|
||||
query = self.filter_by_company(query, selected_company)
|
||||
|
||||
if selected_age_rating:
|
||||
query = self.filter_by_age_rating(query, selected_age_rating)
|
||||
|
||||
if selected_status:
|
||||
query = self.filter_by_status(query, selected_status)
|
||||
|
||||
if selected_region:
|
||||
query = self.filter_by_region(query, selected_region)
|
||||
|
||||
if selected_language:
|
||||
query = self.filter_by_language(query, selected_language)
|
||||
|
||||
return query
|
||||
|
||||
@with_simple
|
||||
def get_roms_query(
|
||||
self,
|
||||
*,
|
||||
order_by: str = "name",
|
||||
order_dir: str = "asc",
|
||||
limit: int | None = None,
|
||||
offset: int | None = None,
|
||||
user_id: int | None = None,
|
||||
query: Query = None,
|
||||
) -> Query[Rom]:
|
||||
if user_id:
|
||||
query = query.outerjoin(
|
||||
RomUser, and_(RomUser.rom_id == Rom.id, RomUser.user_id == user_id)
|
||||
)
|
||||
|
||||
if user_id and hasattr(RomUser, order_by) and not hasattr(Rom, order_by):
|
||||
order_attr = getattr(RomUser, order_by)
|
||||
query = query.filter(RomUser.user_id == user_id, order_attr.isnot(None))
|
||||
elif hasattr(RomMetadata, order_by) and not hasattr(Rom, order_by):
|
||||
order_attr = getattr(RomMetadata, order_by)
|
||||
query = query.outerjoin(RomMetadata, RomMetadata.rom_id == Rom.id).filter(
|
||||
order_attr.isnot(None)
|
||||
)
|
||||
elif hasattr(Rom, order_by):
|
||||
order_attr = getattr(Rom, order_by)
|
||||
else:
|
||||
order_attr = Rom.name
|
||||
|
||||
# Ignore case when the order attribute is a number
|
||||
if isinstance(order_attr.type, (String, Text)):
|
||||
# Remove any leading articles
|
||||
order_attr = func.trim(
|
||||
func.lower(order_attr).regexp_replace(r"^(the|a|an)\s+", "", "i")
|
||||
)
|
||||
|
||||
if order_dir.lower() == "desc":
|
||||
order_attr = order_attr.desc()
|
||||
else:
|
||||
order_attr = order_attr.asc()
|
||||
|
||||
return query.order_by(order_attr)
|
||||
|
||||
@begin_session
|
||||
def get_roms_scalar(
|
||||
self,
|
||||
*,
|
||||
session: Session = None,
|
||||
**kwargs,
|
||||
) -> Sequence[Rom]:
|
||||
filtered_query = self._filter(
|
||||
query,
|
||||
platform_id,
|
||||
collection_id,
|
||||
virtual_collection_id,
|
||||
search_term,
|
||||
session,
|
||||
query = self.get_roms_query(
|
||||
order_by=kwargs.pop("order_by", "name"),
|
||||
order_dir=kwargs.pop("order_dir", "asc"),
|
||||
user_id=kwargs.pop("user_id", None),
|
||||
)
|
||||
roms = self.filter_roms(
|
||||
query=query,
|
||||
platform_id=kwargs.pop("platform_id", None),
|
||||
collection_id=kwargs.pop("collection_id", None),
|
||||
virtual_collection_id=kwargs.pop("virtual_collection_id", None),
|
||||
search_term=kwargs.pop("search_term", None),
|
||||
unmatched_only=kwargs.pop("unmatched_only", False),
|
||||
matched_only=kwargs.pop("matched_only", False),
|
||||
favourites_only=kwargs.pop("favourites_only", False),
|
||||
duplicates_only=kwargs.pop("duplicates_only", False),
|
||||
selected_genre=kwargs.pop("selected_genre", None),
|
||||
selected_franchise=kwargs.pop("selected_franchise", None),
|
||||
selected_collection=kwargs.pop("selected_collection", None),
|
||||
selected_company=kwargs.pop("selected_company", None),
|
||||
selected_age_rating=kwargs.pop("selected_age_rating", None),
|
||||
selected_status=kwargs.pop("selected_status", None),
|
||||
selected_region=kwargs.pop("selected_region", None),
|
||||
selected_language=kwargs.pop("selected_language", None),
|
||||
user_id=kwargs.pop("user_id", None),
|
||||
)
|
||||
return session.scalars(roms).all()
|
||||
|
||||
@begin_session
|
||||
def get_char_index(
|
||||
self, query: Query, session: Session = None
|
||||
) -> List[Row[Tuple[str, int]]]:
|
||||
# Get the row number and first letter for each item
|
||||
subquery = query.add_columns(
|
||||
func.lower(func.substring(Rom.name, 1, 1)).label("letter"),
|
||||
func.row_number().over(order_by=Rom.name).label("position"),
|
||||
).subquery()
|
||||
|
||||
# Get the minimum position for each letter
|
||||
return (
|
||||
session.query(
|
||||
subquery.c.letter, func.min(subquery.c.position - 1).label("position")
|
||||
)
|
||||
.group_by(subquery.c.letter)
|
||||
.order_by(subquery.c.letter)
|
||||
.all()
|
||||
)
|
||||
ordered_query = self._order(filtered_query, order_by, order_dir)
|
||||
offset_query = ordered_query.offset(offset)
|
||||
limited_query = offset_query.limit(limit)
|
||||
return session.scalars(limited_query).unique().all()
|
||||
|
||||
@begin_session
|
||||
@with_details
|
||||
@@ -161,6 +503,7 @@ class DBRomsHandler(DBBaseHandler):
|
||||
)
|
||||
|
||||
@begin_session
|
||||
@with_details
|
||||
def get_roms_by_fs_name(
|
||||
self,
|
||||
platform_id: int,
|
||||
@@ -169,7 +512,6 @@ class DBRomsHandler(DBBaseHandler):
|
||||
session: Session = None,
|
||||
) -> dict[str, Rom]:
|
||||
"""Retrieve a dictionary of roms by their filesystem names."""
|
||||
query = query or select(Rom)
|
||||
roms = (
|
||||
session.scalars(
|
||||
query.filter(Rom.fs_name.in_(fs_names)).filter_by(
|
||||
@@ -256,38 +598,6 @@ class DBRomsHandler(DBBaseHandler):
|
||||
select(RomUser).filter_by(rom_id=rom_id, user_id=user_id).limit(1)
|
||||
)
|
||||
|
||||
@begin_session
|
||||
@with_simple
|
||||
def get_roms_user(
|
||||
self,
|
||||
*,
|
||||
user_id: int,
|
||||
platform_id: int | None = None,
|
||||
collection_id: int | None = None,
|
||||
virtual_collection_id: str | None = None,
|
||||
search_term: str | None = None,
|
||||
limit: int | None = None,
|
||||
offset: int | None = None,
|
||||
query: Query = None,
|
||||
session: Session = None,
|
||||
) -> Sequence[Rom]:
|
||||
filtered_query = (
|
||||
query.join(RomUser)
|
||||
.filter(RomUser.user_id == user_id)
|
||||
.order_by(RomUser.last_played.desc())
|
||||
)
|
||||
filtered_query = self._filter(
|
||||
filtered_query,
|
||||
platform_id,
|
||||
collection_id,
|
||||
virtual_collection_id,
|
||||
search_term,
|
||||
session,
|
||||
)
|
||||
offset_query = filtered_query.offset(offset)
|
||||
limited_query = offset_query.limit(limit)
|
||||
return session.scalars(limited_query).unique().all()
|
||||
|
||||
@begin_session
|
||||
def get_rom_user_by_id(self, id: int, session: Session = None) -> RomUser | None:
|
||||
return session.scalar(select(RomUser).filter_by(id=id).limit(1))
|
||||
|
||||
@@ -101,14 +101,13 @@ class FSHandler:
|
||||
file_name_no_extension = self.get_file_name_with_no_extension(file_name)
|
||||
return TAG_REGEX.split(file_name_no_extension)[0].strip()
|
||||
|
||||
def parse_file_extension(self, file_name) -> str:
|
||||
def parse_file_extension(self, file_name: str) -> str:
|
||||
match = EXTENSION_REGEX.search(file_name)
|
||||
return match.group(1) if match else ""
|
||||
|
||||
def _exclude_files(self, files, filetype) -> list[str]:
|
||||
cnfg = cm.get_config()
|
||||
excluded_extensions = getattr(cnfg, f"EXCLUDED_{filetype.upper()}_EXT")
|
||||
excluded_names = getattr(cnfg, f"EXCLUDED_{filetype.upper()}_FILES")
|
||||
def exclude_single_files(self, files: list[str]) -> list[str]:
|
||||
excluded_extensions = cm.get_config().EXCLUDED_SINGLE_EXT
|
||||
excluded_names = cm.get_config().EXCLUDED_SINGLE_FILES
|
||||
excluded_files: list = []
|
||||
|
||||
for file_name in files:
|
||||
@@ -120,10 +119,9 @@ class FSHandler:
|
||||
excluded_files.append(file_name)
|
||||
|
||||
# Additionally, check if the file name mathes a pattern in the excluded list.
|
||||
if len(excluded_names) > 0:
|
||||
for name in excluded_names:
|
||||
if file_name == name or fnmatch.fnmatch(file_name, name):
|
||||
excluded_files.append(file_name)
|
||||
for name in excluded_names:
|
||||
if file_name == name or fnmatch.fnmatch(file_name, name):
|
||||
excluded_files.append(file_name)
|
||||
|
||||
# Return files that are not in the filtered list.
|
||||
return [f for f in files if f not in excluded_files]
|
||||
|
||||
@@ -43,7 +43,7 @@ class FSFirmwareHandler(FSHandler):
|
||||
except IndexError as exc:
|
||||
raise FirmwareNotFoundException(platform_fs_slug) from exc
|
||||
|
||||
return [f for f in self._exclude_files(fs_firmware_files, "single")]
|
||||
return [f for f in self.exclude_single_files(fs_firmware_files)]
|
||||
|
||||
def get_firmware_file_size(self, firmware_path: str, file_name: str):
|
||||
files = [f"{LIBRARY_BASE_PATH}/{firmware_path}/{file_name}"]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import binascii
|
||||
import bz2
|
||||
import fnmatch
|
||||
import hashlib
|
||||
import os
|
||||
import re
|
||||
@@ -273,11 +274,27 @@ class FSRomsHandler(FSHandler):
|
||||
abs_fs_path = f"{LIBRARY_BASE_PATH}/{roms_path}" # Absolute path to roms
|
||||
rom_files: list[RomFile] = []
|
||||
|
||||
excluded_file_names = cm.get_config().EXCLUDED_MULTI_PARTS_FILES
|
||||
excluded_file_exts = cm.get_config().EXCLUDED_MULTI_PARTS_EXT
|
||||
|
||||
# Check if rom is a multi-part rom
|
||||
if os.path.isdir(f"{abs_fs_path}/{rom}"):
|
||||
for f_path, file in iter_files(f"{abs_fs_path}/{rom}", recursive=True):
|
||||
for f_path, file_name in iter_files(f"{abs_fs_path}/{rom}", recursive=True):
|
||||
# Check if file is excluded
|
||||
ext = self.parse_file_extension(file_name)
|
||||
if not ext or ext in excluded_file_exts:
|
||||
continue
|
||||
|
||||
if any(
|
||||
file_name == exc_name or fnmatch.fnmatch(file_name, exc_name)
|
||||
for exc_name in excluded_file_names
|
||||
):
|
||||
continue
|
||||
|
||||
rom_files.append(
|
||||
self._build_rom_file(f_path.relative_to(LIBRARY_BASE_PATH), file)
|
||||
self._build_rom_file(
|
||||
f_path.relative_to(LIBRARY_BASE_PATH), file_name
|
||||
)
|
||||
)
|
||||
else:
|
||||
rom_files.append(self._build_rom_file(Path(roms_path), rom))
|
||||
@@ -424,7 +441,7 @@ class FSRomsHandler(FSHandler):
|
||||
|
||||
fs_roms: list[dict] = [
|
||||
{"multi": False, "fs_name": rom}
|
||||
for rom in self._exclude_files(fs_single_roms, "single")
|
||||
for rom in self.exclude_single_files(fs_single_roms)
|
||||
] + [
|
||||
{"multi": True, "fs_name": rom}
|
||||
for rom in self._exclude_multi_roms(fs_multi_roms)
|
||||
|
||||
@@ -39,7 +39,7 @@ def test_get_roms():
|
||||
assert roms[1]["multi"]
|
||||
|
||||
|
||||
def test_exclude_files():
|
||||
def testexclude_single_files():
|
||||
from config.config_manager import ConfigManager
|
||||
|
||||
empty_config_file = os.path.join(
|
||||
@@ -52,50 +52,46 @@ def test_exclude_files():
|
||||
|
||||
cm.add_exclusion("EXCLUDED_SINGLE_FILES", "Super Mario 64 (J) (Rev A) [Part 1].z64")
|
||||
|
||||
filtered_files = fs_rom_handler._exclude_files(
|
||||
filtered_files = fs_rom_handler.exclude_single_files(
|
||||
files=[
|
||||
"Super Mario 64 (J) (Rev A) [Part 1].z64",
|
||||
"Super Mario 64 (J) (Rev A) [Part 2].z64",
|
||||
],
|
||||
filetype="single",
|
||||
)
|
||||
|
||||
assert len(filtered_files) == 1
|
||||
|
||||
cm.add_exclusion("EXCLUDED_SINGLE_EXT", "z64")
|
||||
|
||||
filtered_files = fs_rom_handler._exclude_files(
|
||||
filtered_files = fs_rom_handler.exclude_single_files(
|
||||
files=[
|
||||
"Super Mario 64 (J) (Rev A) [Part 1].z64",
|
||||
"Super Mario 64 (J) (Rev A) [Part 2].z64",
|
||||
],
|
||||
filetype="single",
|
||||
)
|
||||
|
||||
assert len(filtered_files) == 0
|
||||
|
||||
cm.add_exclusion("EXCLUDED_SINGLE_FILES", "*.z64")
|
||||
|
||||
filtered_files = fs_rom_handler._exclude_files(
|
||||
filtered_files = fs_rom_handler.exclude_single_files(
|
||||
files=[
|
||||
"Super Mario 64 (J) (Rev A) [Part 1].z64",
|
||||
"Super Mario 64 (J) (Rev A) [Part 2].z64",
|
||||
],
|
||||
filetype="single",
|
||||
)
|
||||
|
||||
assert len(filtered_files) == 0
|
||||
|
||||
cm.add_exclusion("EXCLUDED_SINGLE_FILES", "_.*")
|
||||
|
||||
filtered_files = fs_rom_handler._exclude_files(
|
||||
filtered_files = fs_rom_handler.exclude_single_files(
|
||||
files=[
|
||||
"Links Awakening.nsp",
|
||||
"_.Links Awakening.nsp",
|
||||
"Kirby's Adventure.nsp",
|
||||
"_.Kirby's Adventure.nsp",
|
||||
],
|
||||
filetype="single",
|
||||
)
|
||||
|
||||
assert len(filtered_files) == 2
|
||||
|
||||
@@ -98,7 +98,7 @@ class IGDBRom(TypedDict):
|
||||
def extract_metadata_from_igdb_rom(rom: dict) -> IGDBMetadata:
|
||||
return IGDBMetadata(
|
||||
{
|
||||
"youtube_video_id": str(pydash.get(rom, "videos[0].video_id", None)),
|
||||
"youtube_video_id": pydash.get(rom, "videos[0].video_id", None),
|
||||
"total_rating": str(round(rom.get("total_rating", 0.0), 2)),
|
||||
"aggregated_rating": str(round(rom.get("aggregated_rating", 0.0), 2)),
|
||||
"first_release_date": rom.get("first_release_date", None),
|
||||
|
||||
@@ -52,7 +52,6 @@ class MobyMetadata(TypedDict):
|
||||
|
||||
class MobyGamesRom(TypedDict):
|
||||
moby_id: int | None
|
||||
slug: NotRequired[str]
|
||||
name: NotRequired[str]
|
||||
summary: NotRequired[str]
|
||||
url_cover: NotRequired[str]
|
||||
@@ -280,7 +279,6 @@ class MobyGamesHandler(MetadataHandler):
|
||||
rom = {
|
||||
"moby_id": res["game_id"],
|
||||
"name": res["title"],
|
||||
"slug": res["moby_url"].split("/")[-1],
|
||||
"summary": res.get("description", ""),
|
||||
"url_cover": pydash.get(res, "sample_cover.image", ""),
|
||||
"url_screenshots": [s["image"] for s in res.get("sample_screenshots", [])],
|
||||
@@ -303,7 +301,6 @@ class MobyGamesHandler(MetadataHandler):
|
||||
rom = {
|
||||
"moby_id": res["game_id"],
|
||||
"name": res["title"],
|
||||
"slug": res["moby_url"].split("/")[-1],
|
||||
"summary": res.get("description", None),
|
||||
"url_cover": pydash.get(res, "sample_cover.image", None),
|
||||
"url_screenshots": [s["image"] for s in res.get("sample_screenshots", [])],
|
||||
@@ -341,7 +338,6 @@ class MobyGamesHandler(MetadataHandler):
|
||||
for k, v in {
|
||||
"moby_id": rom["game_id"],
|
||||
"name": rom["title"],
|
||||
"slug": rom["moby_url"].split("/")[-1],
|
||||
"summary": rom.get("description", ""),
|
||||
"url_cover": pydash.get(rom, "sample_cover.image", ""),
|
||||
"url_screenshots": [
|
||||
|
||||
@@ -129,7 +129,6 @@ class SSMetadata(TypedDict):
|
||||
|
||||
class SSRom(TypedDict):
|
||||
ss_id: int | None
|
||||
slug: NotRequired[str]
|
||||
name: NotRequired[str]
|
||||
summary: NotRequired[str]
|
||||
url_cover: NotRequired[str]
|
||||
@@ -422,35 +421,44 @@ class SSHandler(MetadataHandler):
|
||||
if res:
|
||||
break
|
||||
|
||||
if not res or not res.get("id", None):
|
||||
if not res:
|
||||
return fallback_rom
|
||||
|
||||
ss_id: int = int(res.get("id", None))
|
||||
res_ss_id = res.get("id", None)
|
||||
if not res_ss_id:
|
||||
return fallback_rom
|
||||
|
||||
rom = {
|
||||
"ss_id": ss_id,
|
||||
"name": pydash.chain(res.get("noms", []))
|
||||
ss_id: int = int(res_ss_id)
|
||||
|
||||
res_name = (
|
||||
pydash.chain(res.get("noms", []))
|
||||
.filter({"region": "ss"})
|
||||
.map("text")
|
||||
.head()
|
||||
.value(),
|
||||
"slug": pydash.chain(res.get("noms", []))
|
||||
.filter({"region": "ss"})
|
||||
.map("text")
|
||||
.head()
|
||||
.value(),
|
||||
"summary": pydash.chain(res.get("synopsis", []))
|
||||
.value()
|
||||
)
|
||||
res_summary = (
|
||||
pydash.chain(res.get("synopsis", []))
|
||||
.filter({"langue": "en"})
|
||||
.map("text")
|
||||
.head()
|
||||
.value(),
|
||||
"url_cover": pydash.chain(res.get("medias", []))
|
||||
.value()
|
||||
)
|
||||
res_url_cover = (
|
||||
pydash.chain(res.get("medias", []))
|
||||
.filter({"region": "us", "type": "box-2D", "parent": "jeu"})
|
||||
.map("url")
|
||||
.head()
|
||||
.value()
|
||||
or "",
|
||||
"url_manual": pydash.chain(res.get("medias", []))
|
||||
or pydash.chain(res.get("medias", []))
|
||||
.filter({"region": "ss", "type": "box-2D", "parent": "jeu"})
|
||||
.map("url")
|
||||
.head()
|
||||
.value()
|
||||
or ""
|
||||
)
|
||||
res_url_manual = (
|
||||
pydash.chain(res.get("medias", []))
|
||||
.filter(
|
||||
{"region": "us", "type": "manuel", "parent": "jeu", "format": "pdf"}
|
||||
)
|
||||
@@ -464,7 +472,15 @@ class SSHandler(MetadataHandler):
|
||||
.map("url")
|
||||
.head()
|
||||
.value()
|
||||
or "",
|
||||
or ""
|
||||
)
|
||||
|
||||
rom = {
|
||||
"ss_id": ss_id,
|
||||
"name": res_name,
|
||||
"summary": res_summary,
|
||||
"url_cover": res_url_cover,
|
||||
"url_manual": res_url_manual,
|
||||
"url_screenshots": [],
|
||||
"ss_metadata": extract_metadata_from_ss_rom(res),
|
||||
}
|
||||
@@ -481,30 +497,35 @@ class SSHandler(MetadataHandler):
|
||||
if not res:
|
||||
return SSRom(ss_id=None)
|
||||
|
||||
rom = {
|
||||
"ss_id": res.get("id"),
|
||||
"name": pydash.chain(res.get("noms", []))
|
||||
res_name = (
|
||||
pydash.chain(res.get("noms", []))
|
||||
.filter({"region": "ss"})
|
||||
.map("text")
|
||||
.head()
|
||||
.value(),
|
||||
"slug": pydash.chain(res.get("noms", []))
|
||||
.filter({"region": "ss"})
|
||||
.map("text")
|
||||
.head()
|
||||
.value(),
|
||||
"summary": pydash.chain(res.get("synopsis", []))
|
||||
.value()
|
||||
)
|
||||
res_summary = (
|
||||
pydash.chain(res.get("synopsis", []))
|
||||
.filter({"langue": "en"})
|
||||
.map("text")
|
||||
.head()
|
||||
.value(),
|
||||
"url_cover": pydash.chain(res.get("medias", []))
|
||||
.value()
|
||||
)
|
||||
res_url_cover = (
|
||||
pydash.chain(res.get("medias", []))
|
||||
.filter({"region": "us", "type": "box-2D", "parent": "jeu"})
|
||||
.map("url")
|
||||
.head()
|
||||
.value()
|
||||
or "",
|
||||
"url_manual": pydash.chain(res.get("medias", []))
|
||||
or pydash.chain(res.get("medias", []))
|
||||
.filter({"region": "ss", "type": "box-2D", "parent": "jeu"})
|
||||
.map("url")
|
||||
.head()
|
||||
.value()
|
||||
or ""
|
||||
)
|
||||
res_url_manual = (
|
||||
pydash.chain(res.get("medias", []))
|
||||
.filter(
|
||||
{"region": "us", "type": "manuel", "parent": "jeu", "format": "pdf"}
|
||||
)
|
||||
@@ -518,7 +539,15 @@ class SSHandler(MetadataHandler):
|
||||
.map("url")
|
||||
.head()
|
||||
.value()
|
||||
or "",
|
||||
or ""
|
||||
)
|
||||
|
||||
rom = {
|
||||
"ss_id": res.get("id"),
|
||||
"name": res_name,
|
||||
"summary": res_summary,
|
||||
"url_cover": res_url_cover,
|
||||
"url_manual": res_url_manual,
|
||||
"url_screenshots": [],
|
||||
"ss_metadata": extract_metadata_from_ss_rom(res),
|
||||
}
|
||||
@@ -533,7 +562,7 @@ class SSHandler(MetadataHandler):
|
||||
return rom if rom.get("ss_id", "") else None
|
||||
|
||||
async def get_matched_roms_by_name(
|
||||
self, search_term: str, platform_ss_id: int
|
||||
self, search_term: str, platform_ss_id: int | None
|
||||
) -> list[SSRom]:
|
||||
if not SS_API_ENABLED:
|
||||
return []
|
||||
@@ -559,15 +588,6 @@ class SSHandler(MetadataHandler):
|
||||
.value()
|
||||
)
|
||||
|
||||
def _get_slug(rom: dict) -> str | None:
|
||||
return (
|
||||
pydash.chain(rom.get("noms", []))
|
||||
.filter({"region": "ss"})
|
||||
.map("text")
|
||||
.head()
|
||||
.value()
|
||||
)
|
||||
|
||||
def _get_summary(rom: dict) -> str | None:
|
||||
return (
|
||||
pydash.chain(rom.get("synopsis", []))
|
||||
@@ -584,6 +604,11 @@ class SSHandler(MetadataHandler):
|
||||
.map("url")
|
||||
.head()
|
||||
.value()
|
||||
or pydash.chain(rom.get("medias", []))
|
||||
.filter({"region": "ss", "type": "box-2D", "parent": "jeu"})
|
||||
.map("url")
|
||||
.head()
|
||||
.value()
|
||||
or ""
|
||||
)
|
||||
|
||||
@@ -632,7 +657,6 @@ class SSHandler(MetadataHandler):
|
||||
for k, v in {
|
||||
"ss_id": rom.get("id"),
|
||||
"name": _get_name(rom),
|
||||
"slug": _get_slug(rom),
|
||||
"summary": _get_summary(rom),
|
||||
"url_cover": _get_url_cover(rom),
|
||||
"url_manual": _get_url_manual(rom),
|
||||
@@ -811,7 +835,7 @@ SLUG_TO_SS_ID: dict[str, SlugToSSId] = {
|
||||
"videopac-g7400": {"id": 104, "name": "Videopac G7000"},
|
||||
"virtual-boy": {"id": 11, "name": "Virtual Boy"},
|
||||
"virtualboy": {"id": 11, "name": "Virtual Boy"},
|
||||
"wii": {"id": 18, "name": "Wii"},
|
||||
"wii": {"id": 16, "name": "Wii"},
|
||||
"wii-u": {"id": 18, "name": "Wii U"},
|
||||
"wiiu": {"id": 18, "name": "Wii U"},
|
||||
"windows": {"id": 3, "name": "Windows"},
|
||||
|
||||
@@ -46,7 +46,7 @@ def test_roms(rom: Rom, platform: Platform):
|
||||
)
|
||||
)
|
||||
|
||||
roms = db_rom_handler.get_roms(platform_id=platform.id)
|
||||
roms = db_rom_handler.get_roms_scalar(platform_id=platform.id)
|
||||
assert len(roms) == 2
|
||||
|
||||
rom_1 = db_rom_handler.get_rom(roms[0].id)
|
||||
@@ -60,17 +60,17 @@ def test_roms(rom: Rom, platform: Platform):
|
||||
|
||||
db_rom_handler.delete_rom(rom.id)
|
||||
|
||||
roms = db_rom_handler.get_roms(platform_id=platform.id)
|
||||
roms = db_rom_handler.get_roms_scalar(platform_id=platform.id)
|
||||
assert len(roms) == 1
|
||||
|
||||
db_rom_handler.purge_roms(rom_2.platform_id, [])
|
||||
|
||||
roms = db_rom_handler.get_roms(platform_id=platform.id)
|
||||
roms = db_rom_handler.get_roms_scalar(platform_id=platform.id)
|
||||
assert len(roms) == 0
|
||||
|
||||
|
||||
def test_utils(rom: Rom, platform: Platform):
|
||||
roms = db_rom_handler.get_roms(platform_id=platform.id)
|
||||
roms = db_rom_handler.get_roms_scalar(platform_id=platform.id)
|
||||
rom_1 = db_rom_handler.get_rom_by_fs_name(
|
||||
platform_id=platform.id, fs_name=rom.fs_name
|
||||
)
|
||||
|
||||
@@ -34,6 +34,7 @@ from endpoints import (
|
||||
)
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi_pagination import add_pagination
|
||||
from handler.auth.constants import ALGORITHM
|
||||
from handler.auth.hybrid_auth import HybridAuthBackend
|
||||
from handler.auth.middleware import CustomCSRFMiddleware, SessionMiddleware
|
||||
@@ -118,6 +119,8 @@ app.include_router(collections.router, prefix="/api")
|
||||
|
||||
app.mount("/ws", socket_handler.socket_app)
|
||||
|
||||
add_pagination(app)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Run migrations
|
||||
|
||||
@@ -39,9 +39,7 @@ class Firmware(BaseModel):
|
||||
md5_hash: Mapped[str] = mapped_column(String(length=100))
|
||||
sha1_hash: Mapped[str] = mapped_column(String(length=100))
|
||||
|
||||
platform: Mapped[Platform] = relationship(
|
||||
lazy="immediate", back_populates="firmware"
|
||||
)
|
||||
platform: Mapped[Platform] = relationship(lazy="joined", back_populates="firmware")
|
||||
|
||||
@property
|
||||
def platform_slug(self) -> str:
|
||||
|
||||
@@ -35,9 +35,9 @@ class Platform(BaseModel):
|
||||
url_logo: Mapped[str | None] = mapped_column(String(length=1000), default="")
|
||||
logo_path: Mapped[str | None] = mapped_column(String(length=1000), default="")
|
||||
|
||||
roms: Mapped[list[Rom]] = relationship(back_populates="platform")
|
||||
roms: Mapped[list[Rom]] = relationship(lazy="select", back_populates="platform")
|
||||
firmware: Mapped[list[Firmware]] = relationship(
|
||||
lazy="selectin", back_populates="platform"
|
||||
lazy="select", back_populates="platform"
|
||||
)
|
||||
|
||||
aspect_ratio: Mapped[str] = mapped_column(
|
||||
|
||||
@@ -19,7 +19,7 @@ from sqlalchemy import (
|
||||
UniqueConstraint,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from utils.database import CustomJSON, safe_float, safe_int
|
||||
from utils.database import CustomJSON
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from models.assets import Save, Screenshot, State
|
||||
@@ -56,7 +56,7 @@ class RomFile(BaseModel):
|
||||
Enum(RomFileCategory), default=None
|
||||
)
|
||||
|
||||
rom: Mapped[Rom] = relationship(lazy="joined")
|
||||
rom: Mapped[Rom] = relationship(lazy="joined", back_populates="files")
|
||||
|
||||
@cached_property
|
||||
def full_path(self) -> str:
|
||||
@@ -87,6 +87,25 @@ class RomFile(BaseModel):
|
||||
)
|
||||
|
||||
|
||||
class RomMetadata(BaseModel):
|
||||
__tablename__ = "roms_metadata"
|
||||
|
||||
rom_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("roms.id", ondelete="CASCADE"), primary_key=True
|
||||
)
|
||||
|
||||
genres: Mapped[list[str] | None] = mapped_column(CustomJSON(), default=[])
|
||||
franchises: Mapped[list[str] | None] = mapped_column(CustomJSON(), default=[])
|
||||
collections: Mapped[list[str] | None] = mapped_column(CustomJSON(), default=[])
|
||||
companies: Mapped[list[str] | None] = mapped_column(CustomJSON(), default=[])
|
||||
game_modes: Mapped[list[str] | None] = mapped_column(CustomJSON(), default=[])
|
||||
age_ratings: Mapped[list[str] | None] = mapped_column(CustomJSON(), default=[])
|
||||
first_release_date: Mapped[int | None] = mapped_column(BigInteger(), default=None)
|
||||
average_rating: Mapped[float | None] = mapped_column(default=None)
|
||||
|
||||
rom: Mapped[Rom] = relationship(lazy="joined", back_populates="metadatum")
|
||||
|
||||
|
||||
class Rom(BaseModel):
|
||||
__tablename__ = "roms"
|
||||
|
||||
@@ -151,22 +170,28 @@ class Rom(BaseModel):
|
||||
ForeignKey("platforms.id", ondelete="CASCADE")
|
||||
)
|
||||
|
||||
platform: Mapped[Platform] = relationship(lazy="immediate")
|
||||
platform: Mapped[Platform] = relationship(lazy="immediate", back_populates="roms")
|
||||
sibling_roms: Mapped[list[Rom]] = relationship(
|
||||
secondary="sibling_roms",
|
||||
primaryjoin="Rom.id == SiblingRom.rom_id",
|
||||
secondaryjoin="Rom.id == SiblingRom.sibling_rom_id",
|
||||
lazy="select",
|
||||
)
|
||||
files: Mapped[list[RomFile]] = relationship(lazy="select", back_populates="rom")
|
||||
saves: Mapped[list[Save]] = relationship(lazy="select", back_populates="rom")
|
||||
states: Mapped[list[State]] = relationship(lazy="select", back_populates="rom")
|
||||
screenshots: Mapped[list[Screenshot]] = relationship(
|
||||
lazy="select", back_populates="rom"
|
||||
)
|
||||
rom_users: Mapped[list[RomUser]] = relationship(lazy="select", back_populates="rom")
|
||||
metadatum: Mapped[RomMetadata] = relationship(
|
||||
lazy="select", back_populates="rom", uselist=False
|
||||
)
|
||||
files: Mapped[list[RomFile]] = relationship(lazy="immediate", back_populates="rom")
|
||||
saves: Mapped[list[Save]] = relationship(back_populates="rom")
|
||||
states: Mapped[list[State]] = relationship(back_populates="rom")
|
||||
screenshots: Mapped[list[Screenshot]] = relationship(back_populates="rom")
|
||||
rom_users: Mapped[list[RomUser]] = relationship(back_populates="rom")
|
||||
|
||||
collections: Mapped[list[Collection]] = relationship(
|
||||
"Collection",
|
||||
secondary="collections_roms",
|
||||
collection_class=set,
|
||||
lazy="select",
|
||||
back_populates="roms",
|
||||
)
|
||||
|
||||
@@ -233,12 +258,12 @@ class Rom(BaseModel):
|
||||
else ""
|
||||
)
|
||||
|
||||
# Metadata fields
|
||||
# # Metadata fields
|
||||
@property
|
||||
def youtube_video_id(self) -> str:
|
||||
def youtube_video_id(self) -> str | None:
|
||||
if self.igdb_metadata:
|
||||
return self.igdb_metadata.get("youtube_video_id", "")
|
||||
return ""
|
||||
return self.igdb_metadata.get("youtube_video_id", None)
|
||||
return None
|
||||
|
||||
@property
|
||||
def alternative_names(self) -> list[str]:
|
||||
@@ -249,82 +274,6 @@ class Rom(BaseModel):
|
||||
or []
|
||||
)
|
||||
|
||||
@property
|
||||
def first_release_date(self) -> int | None:
|
||||
if self.igdb_metadata:
|
||||
return safe_int(self.igdb_metadata.get("first_release_date") or 0) * 1000
|
||||
elif self.ss_metadata:
|
||||
return safe_int(self.ss_metadata.get("first_release_date") or 0) * 1000
|
||||
|
||||
return None
|
||||
|
||||
@property
|
||||
def average_rating(self) -> float | None:
|
||||
igdb_rating = (
|
||||
safe_float(self.igdb_metadata.get("total_rating") or 0)
|
||||
if self.igdb_metadata
|
||||
else 0.0
|
||||
)
|
||||
moby_rating = (
|
||||
safe_float(self.moby_metadata.get("moby_score") or 0)
|
||||
if self.moby_metadata
|
||||
else 0.0
|
||||
)
|
||||
ss_rating = (
|
||||
safe_float(self.ss_metadata.get("ss_score") or 0)
|
||||
if self.ss_metadata
|
||||
else 0.0
|
||||
)
|
||||
|
||||
ratings = [r for r in [igdb_rating, moby_rating * 10, ss_rating] if r != 0.0]
|
||||
|
||||
return sum(ratings) / len([r for r in ratings if r]) if any(ratings) else None
|
||||
|
||||
@property
|
||||
def genres(self) -> list[str]:
|
||||
return (
|
||||
(self.igdb_metadata or {}).get("genres", None)
|
||||
or (self.moby_metadata or {}).get("genres", None)
|
||||
or (self.ss_metadata or {}).get("genres", None)
|
||||
or []
|
||||
)
|
||||
|
||||
@property
|
||||
def franchises(self) -> list[str]:
|
||||
if self.igdb_metadata:
|
||||
return self.igdb_metadata.get("franchises", [])
|
||||
elif self.ss_metadata:
|
||||
return self.ss_metadata.get("franchises", [])
|
||||
return []
|
||||
|
||||
@property
|
||||
def meta_collections(self) -> list[str]:
|
||||
if self.igdb_metadata:
|
||||
return self.igdb_metadata.get("collections", [])
|
||||
return []
|
||||
|
||||
@property
|
||||
def companies(self) -> list[str]:
|
||||
if self.igdb_metadata:
|
||||
return self.igdb_metadata.get("companies", [])
|
||||
elif self.ss_metadata:
|
||||
return self.ss_metadata.get("companies", [])
|
||||
return []
|
||||
|
||||
@property
|
||||
def game_modes(self) -> list[str]:
|
||||
if self.igdb_metadata:
|
||||
return self.igdb_metadata.get("game_modes", [])
|
||||
elif self.ss_metadata:
|
||||
return self.ss_metadata.get("game_modes", [])
|
||||
return []
|
||||
|
||||
@property
|
||||
def age_ratings(self) -> list[str]:
|
||||
if self.igdb_metadata:
|
||||
return [r["rating"] for r in self.igdb_metadata.get("age_ratings", [])]
|
||||
return []
|
||||
|
||||
@property
|
||||
def is_unidentified(self) -> bool:
|
||||
return not self.igdb_id and not self.moby_id and not self.ss_id
|
||||
|
||||
@@ -46,11 +46,17 @@ class User(BaseModel, SimpleUser):
|
||||
last_login: Mapped[datetime | None] = mapped_column(TIMESTAMP(timezone=True))
|
||||
last_active: Mapped[datetime | None] = mapped_column(TIMESTAMP(timezone=True))
|
||||
|
||||
saves: Mapped[list[Save]] = relationship(back_populates="user")
|
||||
states: Mapped[list[State]] = relationship(back_populates="user")
|
||||
screenshots: Mapped[list[Screenshot]] = relationship(back_populates="user")
|
||||
rom_users: Mapped[list[RomUser]] = relationship(back_populates="user")
|
||||
collections: Mapped[list[Collection]] = relationship(back_populates="user")
|
||||
saves: Mapped[list[Save]] = relationship(lazy="select", back_populates="user")
|
||||
states: Mapped[list[State]] = relationship(lazy="select", back_populates="user")
|
||||
screenshots: Mapped[list[Screenshot]] = relationship(
|
||||
lazy="select", back_populates="user"
|
||||
)
|
||||
rom_users: Mapped[list[RomUser]] = relationship(
|
||||
lazy="select", back_populates="user"
|
||||
)
|
||||
collections: Mapped[list[Collection]] = relationship(
|
||||
lazy="select", back_populates="user"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def kiosk_mode_user(cls) -> User:
|
||||
|
||||
17
frontend/package-lock.json
generated
17
frontend/package-lock.json
generated
@@ -14,7 +14,7 @@
|
||||
"cronstrue": "^2.57.0",
|
||||
"js-cookie": "^3.0.5",
|
||||
"lodash": "^4.17.21",
|
||||
"md-editor-v3": "^5.4.5",
|
||||
"md-editor-v3": "^5.5.0",
|
||||
"mitt": "^3.0.1",
|
||||
"nanoid": "^5.1.4",
|
||||
"pinia": "^3.0.1",
|
||||
@@ -43,7 +43,7 @@
|
||||
"openapi-typescript-codegen": "^0.29.0",
|
||||
"typescript": "^5.7.3",
|
||||
"typescript-eslint": "^8.28.0",
|
||||
"vite": "^6.2.5",
|
||||
"vite": "^6.2.6",
|
||||
"vite-plugin-pwa": "^0.21.1",
|
||||
"vite-plugin-vuetify": "^2.0.4",
|
||||
"vue-tsc": "^2.2.8"
|
||||
@@ -6314,10 +6314,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/md-editor-v3": {
|
||||
"version": "5.4.5",
|
||||
"resolved": "https://registry.npmjs.org/md-editor-v3/-/md-editor-v3-5.4.5.tgz",
|
||||
"integrity": "sha512-Vw0mjlhGArlCt5aG15a2/W3BoQJLCACUGROgR64uVvRzepsh/26Pj1C3oGlU2lis4FrlnX7rzAN+m8g76eVFRA==",
|
||||
"license": "MIT",
|
||||
"version": "5.5.0",
|
||||
"resolved": "https://registry.npmjs.org/md-editor-v3/-/md-editor-v3-5.5.0.tgz",
|
||||
"integrity": "sha512-+YVHwbcUh7nPn5i+tD2QLQBuDlShJAuEzkhkFMJpN+UYMjfQG27rE3+cMfArP1C0xodpf4POn32jr7MlOfFHdA==",
|
||||
"dependencies": {
|
||||
"@codemirror/lang-markdown": "^6.3.0",
|
||||
"@codemirror/language-data": "^6.5.1",
|
||||
@@ -8082,9 +8081,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "6.2.5",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-6.2.5.tgz",
|
||||
"integrity": "sha512-j023J/hCAa4pRIUH6J9HemwYfjB5llR2Ps0CWeikOtdR8+pAURAk0DoJC5/mm9kd+UgdnIy7d6HE4EAvlYhPhA==",
|
||||
"version": "6.2.6",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-6.2.6.tgz",
|
||||
"integrity": "sha512-9xpjNl3kR4rVDZgPNdTL0/c6ao4km69a/2ihNQbcANz8RuCOK3hQBmLSJf3bRKVQjVMda+YvizNE8AwvogcPbw==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"cronstrue": "^2.57.0",
|
||||
"js-cookie": "^3.0.5",
|
||||
"lodash": "^4.17.21",
|
||||
"md-editor-v3": "^5.4.5",
|
||||
"md-editor-v3": "^5.5.0",
|
||||
"mitt": "^3.0.1",
|
||||
"nanoid": "^5.1.4",
|
||||
"pinia": "^3.0.1",
|
||||
@@ -61,7 +61,7 @@
|
||||
"openapi-typescript-codegen": "^0.29.0",
|
||||
"typescript": "^5.7.3",
|
||||
"typescript-eslint": "^8.28.0",
|
||||
"vite": "^6.2.5",
|
||||
"vite": "^6.2.6",
|
||||
"vite-plugin-pwa": "^0.21.1",
|
||||
"vite-plugin-vuetify": "^2.0.4",
|
||||
"vue-tsc": "^2.2.8"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import languageStore from "@/stores/language";
|
||||
import MainAppBar from "@/components/common/Navigation/MainAppBar.vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
@@ -20,7 +19,7 @@ storeLanguage.setLanguage(selectedLanguage.value);
|
||||
|
||||
<template>
|
||||
<v-app>
|
||||
<v-main height="100dvh">
|
||||
<v-main>
|
||||
<router-view />
|
||||
</v-main>
|
||||
</v-app>
|
||||
|
||||
4
frontend/src/__generated__/index.ts
generated
4
frontend/src/__generated__/index.ts
generated
@@ -12,6 +12,7 @@ export type { Body_update_rom_api_roms__id__put } from './models/Body_update_rom
|
||||
export type { Body_update_user_api_users__id__put } from './models/Body_update_user_api_users__id__put';
|
||||
export type { CollectionSchema } from './models/CollectionSchema';
|
||||
export type { ConfigResponse } from './models/ConfigResponse';
|
||||
export type { CustomLimitOffsetPage_SimpleRomSchema_ } from './models/CustomLimitOffsetPage_SimpleRomSchema_';
|
||||
export type { DetailedRomSchema } from './models/DetailedRomSchema';
|
||||
export type { EmulationDict } from './models/EmulationDict';
|
||||
export type { FilesystemDict } from './models/FilesystemDict';
|
||||
@@ -31,8 +32,8 @@ export type { Role } from './models/Role';
|
||||
export type { RomFileCategory } from './models/RomFileCategory';
|
||||
export type { RomFileSchema } from './models/RomFileSchema';
|
||||
export type { RomIGDBMetadata } from './models/RomIGDBMetadata';
|
||||
export type { RomMetadataSchema } from './models/RomMetadataSchema';
|
||||
export type { RomMobyMetadata } from './models/RomMobyMetadata';
|
||||
export type { RomSchema } from './models/RomSchema';
|
||||
export type { RomSSMetadata } from './models/RomSSMetadata';
|
||||
export type { RomUserSchema } from './models/RomUserSchema';
|
||||
export type { RomUserStatus } from './models/RomUserStatus';
|
||||
@@ -41,6 +42,7 @@ export type { SchedulerDict } from './models/SchedulerDict';
|
||||
export type { ScreenshotSchema } from './models/ScreenshotSchema';
|
||||
export type { SearchCoverSchema } from './models/SearchCoverSchema';
|
||||
export type { SearchRomSchema } from './models/SearchRomSchema';
|
||||
export type { SiblingRomSchema } from './models/SiblingRomSchema';
|
||||
export type { SimpleRomSchema } from './models/SimpleRomSchema';
|
||||
export type { StateSchema } from './models/StateSchema';
|
||||
export type { StatsReturn } from './models/StatsReturn';
|
||||
|
||||
13
frontend/src/__generated__/models/CustomLimitOffsetPage_SimpleRomSchema_.ts
generated
Normal file
13
frontend/src/__generated__/models/CustomLimitOffsetPage_SimpleRomSchema_.ts
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
/* generated using openapi-typescript-codegen -- do not edit */
|
||||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type { SimpleRomSchema } from './SimpleRomSchema';
|
||||
export type CustomLimitOffsetPage_SimpleRomSchema_ = {
|
||||
items: Array<SimpleRomSchema>;
|
||||
total: (number | null);
|
||||
limit: (number | null);
|
||||
offset: (number | null);
|
||||
char_index: Record<string, number>;
|
||||
};
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
import type { CollectionSchema } from './CollectionSchema';
|
||||
import type { RomFileSchema } from './RomFileSchema';
|
||||
import type { RomIGDBMetadata } from './RomIGDBMetadata';
|
||||
import type { RomMetadataSchema } from './RomMetadataSchema';
|
||||
import type { RomMobyMetadata } from './RomMobyMetadata';
|
||||
import type { RomSchema } from './RomSchema';
|
||||
import type { RomSSMetadata } from './RomSSMetadata';
|
||||
import type { RomUserSchema } from './RomUserSchema';
|
||||
import type { SaveSchema } from './SaveSchema';
|
||||
import type { ScreenshotSchema } from './ScreenshotSchema';
|
||||
import type { SiblingRomSchema } from './SiblingRomSchema';
|
||||
import type { StateSchema } from './StateSchema';
|
||||
import type { UserNotesSchema } from './UserNotesSchema';
|
||||
export type DetailedRomSchema = {
|
||||
@@ -34,16 +35,9 @@ export type DetailedRomSchema = {
|
||||
name: (string | null);
|
||||
slug: (string | null);
|
||||
summary: (string | null);
|
||||
first_release_date: (number | null);
|
||||
youtube_video_id: (string | null);
|
||||
average_rating: (number | null);
|
||||
alternative_names: Array<string>;
|
||||
genres: Array<string>;
|
||||
franchises: Array<string>;
|
||||
meta_collections: Array<string>;
|
||||
companies: Array<string>;
|
||||
game_modes: Array<string>;
|
||||
age_ratings: Array<string>;
|
||||
youtube_video_id: (string | null);
|
||||
metadatum: RomMetadataSchema;
|
||||
igdb_metadata: (RomIGDBMetadata | null);
|
||||
moby_metadata: (RomMobyMetadata | null);
|
||||
ss_metadata: (RomSSMetadata | null);
|
||||
@@ -67,13 +61,12 @@ export type DetailedRomSchema = {
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
merged_screenshots: Array<string>;
|
||||
sibling_roms: Array<RomSchema>;
|
||||
siblings: Array<SiblingRomSchema>;
|
||||
rom_user: RomUserSchema;
|
||||
user_saves: Array<SaveSchema>;
|
||||
user_states: Array<StateSchema>;
|
||||
user_screenshots: Array<ScreenshotSchema>;
|
||||
user_notes: Array<UserNotesSchema>;
|
||||
user_collections: Array<CollectionSchema>;
|
||||
readonly sort_comparator: string;
|
||||
};
|
||||
|
||||
|
||||
16
frontend/src/__generated__/models/RomMetadataSchema.ts
generated
Normal file
16
frontend/src/__generated__/models/RomMetadataSchema.ts
generated
Normal file
@@ -0,0 +1,16 @@
|
||||
/* generated using openapi-typescript-codegen -- do not edit */
|
||||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type RomMetadataSchema = {
|
||||
rom_id: number;
|
||||
genres: Array<string>;
|
||||
franchises: Array<string>;
|
||||
collections: Array<string>;
|
||||
companies: Array<string>;
|
||||
game_modes: Array<string>;
|
||||
age_ratings: Array<string>;
|
||||
first_release_date: (number | null);
|
||||
average_rating: (number | null);
|
||||
};
|
||||
|
||||
64
frontend/src/__generated__/models/RomSchema.ts
generated
64
frontend/src/__generated__/models/RomSchema.ts
generated
@@ -1,64 +0,0 @@
|
||||
/* generated using openapi-typescript-codegen -- do not edit */
|
||||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type { RomFileSchema } from './RomFileSchema';
|
||||
import type { RomIGDBMetadata } from './RomIGDBMetadata';
|
||||
import type { RomMobyMetadata } from './RomMobyMetadata';
|
||||
import type { RomSSMetadata } from './RomSSMetadata';
|
||||
export type RomSchema = {
|
||||
id: number;
|
||||
igdb_id: (number | null);
|
||||
sgdb_id: (number | null);
|
||||
moby_id: (number | null);
|
||||
ss_id: (number | null);
|
||||
platform_id: number;
|
||||
platform_slug: string;
|
||||
platform_fs_slug: string;
|
||||
platform_name: string;
|
||||
platform_custom_name: (string | null);
|
||||
platform_display_name: string;
|
||||
fs_name: string;
|
||||
fs_name_no_tags: string;
|
||||
fs_name_no_ext: string;
|
||||
fs_extension: string;
|
||||
fs_path: string;
|
||||
fs_size_bytes: number;
|
||||
name: (string | null);
|
||||
slug: (string | null);
|
||||
summary: (string | null);
|
||||
first_release_date: (number | null);
|
||||
youtube_video_id: (string | null);
|
||||
average_rating: (number | null);
|
||||
alternative_names: Array<string>;
|
||||
genres: Array<string>;
|
||||
franchises: Array<string>;
|
||||
meta_collections: Array<string>;
|
||||
companies: Array<string>;
|
||||
game_modes: Array<string>;
|
||||
age_ratings: Array<string>;
|
||||
igdb_metadata: (RomIGDBMetadata | null);
|
||||
moby_metadata: (RomMobyMetadata | null);
|
||||
ss_metadata: (RomSSMetadata | null);
|
||||
path_cover_small: (string | null);
|
||||
path_cover_large: (string | null);
|
||||
url_cover: (string | null);
|
||||
has_manual: boolean;
|
||||
path_manual: (string | null);
|
||||
url_manual: (string | null);
|
||||
is_unidentified: boolean;
|
||||
revision: (string | null);
|
||||
regions: Array<string>;
|
||||
languages: Array<string>;
|
||||
tags: Array<string>;
|
||||
crc_hash: (string | null);
|
||||
md5_hash: (string | null);
|
||||
sha1_hash: (string | null);
|
||||
multi: boolean;
|
||||
files: Array<RomFileSchema>;
|
||||
full_path: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
readonly sort_comparator: string;
|
||||
};
|
||||
|
||||
12
frontend/src/__generated__/models/SiblingRomSchema.ts
generated
Normal file
12
frontend/src/__generated__/models/SiblingRomSchema.ts
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
/* generated using openapi-typescript-codegen -- do not edit */
|
||||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type SiblingRomSchema = {
|
||||
id: number;
|
||||
name: (string | null);
|
||||
fs_name_no_tags: string;
|
||||
fs_name_no_ext: string;
|
||||
readonly sort_comparator: string;
|
||||
};
|
||||
|
||||
17
frontend/src/__generated__/models/SimpleRomSchema.ts
generated
17
frontend/src/__generated__/models/SimpleRomSchema.ts
generated
@@ -4,10 +4,11 @@
|
||||
/* eslint-disable */
|
||||
import type { RomFileSchema } from './RomFileSchema';
|
||||
import type { RomIGDBMetadata } from './RomIGDBMetadata';
|
||||
import type { RomMetadataSchema } from './RomMetadataSchema';
|
||||
import type { RomMobyMetadata } from './RomMobyMetadata';
|
||||
import type { RomSchema } from './RomSchema';
|
||||
import type { RomSSMetadata } from './RomSSMetadata';
|
||||
import type { RomUserSchema } from './RomUserSchema';
|
||||
import type { SiblingRomSchema } from './SiblingRomSchema';
|
||||
export type SimpleRomSchema = {
|
||||
id: number;
|
||||
igdb_id: (number | null);
|
||||
@@ -29,16 +30,9 @@ export type SimpleRomSchema = {
|
||||
name: (string | null);
|
||||
slug: (string | null);
|
||||
summary: (string | null);
|
||||
first_release_date: (number | null);
|
||||
youtube_video_id: (string | null);
|
||||
average_rating: (number | null);
|
||||
alternative_names: Array<string>;
|
||||
genres: Array<string>;
|
||||
franchises: Array<string>;
|
||||
meta_collections: Array<string>;
|
||||
companies: Array<string>;
|
||||
game_modes: Array<string>;
|
||||
age_ratings: Array<string>;
|
||||
youtube_video_id: (string | null);
|
||||
metadatum: RomMetadataSchema;
|
||||
igdb_metadata: (RomIGDBMetadata | null);
|
||||
moby_metadata: (RomMobyMetadata | null);
|
||||
ss_metadata: (RomSSMetadata | null);
|
||||
@@ -61,8 +55,7 @@ export type SimpleRomSchema = {
|
||||
full_path: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
sibling_roms: Array<RomSchema>;
|
||||
siblings: Array<SiblingRomSchema>;
|
||||
rom_user: RomUserSchema;
|
||||
readonly sort_comparator: string;
|
||||
};
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ watch(
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row
|
||||
v-if="rom.sibling_roms.length > 0"
|
||||
v-if="rom.siblings.length > 0"
|
||||
class="align-center my-3"
|
||||
no-gutters
|
||||
>
|
||||
@@ -171,16 +171,19 @@ watch(
|
||||
class="ml-2 text-grey-lighten-2"
|
||||
style="padding: 10px 14px"
|
||||
@click="toggleMainSibling"
|
||||
><v-icon
|
||||
>
|
||||
<v-icon
|
||||
:class="romUser.is_main_sibling ? '' : 'mr-1'"
|
||||
:color="romUser.is_main_sibling ? 'primary' : ''"
|
||||
>{{
|
||||
>
|
||||
{{
|
||||
romUser.is_main_sibling
|
||||
? "mdi-checkbox-outline"
|
||||
: "mdi-checkbox-blank-outline"
|
||||
}}</v-icon
|
||||
>{{ romUser.is_main_sibling ? "" : t("rom.default") }}</v-btn
|
||||
>
|
||||
}}
|
||||
</v-icon>
|
||||
{{ romUser.is_main_sibling ? "" : t("rom.default") }}
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-tooltip>
|
||||
</v-row>
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useRouter } from "vue-router";
|
||||
import { useDisplay, useTheme } from "vuetify";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { MdPreview } from "md-editor-v3";
|
||||
import { get } from "lodash";
|
||||
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
@@ -19,12 +20,20 @@ const show = ref(false);
|
||||
const carousel = ref(0);
|
||||
const router = useRouter();
|
||||
const filters = [
|
||||
{ value: "regions", name: t("rom.regions") },
|
||||
{ value: "languages", name: t("rom.languages") },
|
||||
{ value: "genres", name: t("rom.genres") },
|
||||
{ value: "franchises", name: t("rom.franchises") },
|
||||
{ value: "meta_collections", name: t("rom.collections") },
|
||||
{ value: "companies", name: t("rom.companies") },
|
||||
{ key: "regions", path: "regions", name: t("rom.regions") },
|
||||
{ key: "languages", path: "languages", name: t("rom.languages") },
|
||||
{ key: "genres", path: "metadatum.genres", name: t("rom.genres") },
|
||||
{
|
||||
key: "franchises",
|
||||
path: "metadatum.franchises",
|
||||
name: t("rom.franchises"),
|
||||
},
|
||||
{
|
||||
key: "collections",
|
||||
path: "metadatum.collections",
|
||||
name: t("rom.collections"),
|
||||
},
|
||||
{ key: "companies", path: "metadatum.companies", name: t("rom.companies") },
|
||||
] as const;
|
||||
|
||||
// Functions
|
||||
@@ -70,7 +79,7 @@ function onFilterClick(filter: FilterType, value: string) {
|
||||
</v-row>
|
||||
<template v-for="filter in filters" :key="filter">
|
||||
<v-row
|
||||
v-if="rom[filter.value].length > 0"
|
||||
v-if="get(rom, filter.path).length > 0"
|
||||
class="align-center my-3"
|
||||
no-gutters
|
||||
>
|
||||
@@ -79,9 +88,9 @@ function onFilterClick(filter: FilterType, value: string) {
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-chip
|
||||
v-for="value in rom[filter.value]"
|
||||
v-for="value in get(rom, filter.path)"
|
||||
:key="value"
|
||||
@click="onFilterClick(filter.value, value)"
|
||||
@click="onFilterClick(filter.key, value)"
|
||||
size="small"
|
||||
variant="outlined"
|
||||
class="my-1 mr-2"
|
||||
@@ -120,6 +129,7 @@ function onFilterClick(filter: FilterType, value: string) {
|
||||
<v-row no-gutters class="mt-4">
|
||||
<v-col class="text-caption">
|
||||
<MdPreview
|
||||
class="px-6"
|
||||
:model-value="rom.summary ?? ''"
|
||||
:theme="theme.name.value == 'dark' ? 'dark' : 'light'"
|
||||
preview-theme="vuepress"
|
||||
|
||||
@@ -75,7 +75,7 @@ function onCardClick(save: SaveSchema, event: MouseEvent) {
|
||||
size="small"
|
||||
@click="emitter?.emit('addSavesDialog', rom)"
|
||||
>
|
||||
<v-icon>mdi-upload</v-icon>
|
||||
<v-icon>mdi-cloud-upload-outline</v-icon>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
drawer
|
||||
@@ -179,9 +179,9 @@ function onCardClick(save: SaveSchema, event: MouseEvent) {
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-hover>
|
||||
<v-col v-else class="text-center mt-6">
|
||||
<v-icon size="x-large">mdi-help-rhombus-outline</v-icon>
|
||||
<p class="text-h4 mt-2">{{ t("rom.no-saves-found") }}</p>
|
||||
<v-col v-else class="text-center mt-2">
|
||||
<v-icon size="large">mdi-help-rhombus-outline</v-icon>
|
||||
<p class="text-h6 mt-2">{{ t("rom.no-saves-found") }}</p>
|
||||
</v-col>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -77,7 +77,7 @@ function onCardClick(state: StateSchema, event: MouseEvent) {
|
||||
size="small"
|
||||
@click="emitter?.emit('addStatesDialog', rom)"
|
||||
>
|
||||
<v-icon>mdi-upload</v-icon>
|
||||
<v-icon>mdi-cloud-upload-outline</v-icon>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
drawer
|
||||
@@ -181,9 +181,9 @@ function onCardClick(state: StateSchema, event: MouseEvent) {
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-hover>
|
||||
<v-col v-else class="text-center mt-6">
|
||||
<v-icon size="x-large">mdi-help-rhombus-outline</v-icon>
|
||||
<p class="text-h4 mt-2">{{ t("rom.no-states-found") }}</p>
|
||||
<v-col v-else class="text-center mt-2">
|
||||
<v-icon size="large">mdi-help-rhombus-outline</v-icon>
|
||||
<p class="text-h6 mt-2">{{ t("rom.no-states-found") }}</p>
|
||||
</v-col>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -11,13 +11,13 @@ import { useDisplay } from "vuetify";
|
||||
const props = defineProps<{ rom: DetailedRom }>();
|
||||
const { smAndDown } = useDisplay();
|
||||
const releaseDate = new Date(
|
||||
Number(props.rom.first_release_date),
|
||||
Number(props.rom.metadatum.first_release_date),
|
||||
).toLocaleDateString("en-US", {
|
||||
day: "2-digit",
|
||||
month: "short",
|
||||
year: "numeric",
|
||||
});
|
||||
const hasReleaseDate = Number(props.rom.first_release_date) > 0;
|
||||
const hasReleaseDate = Number(props.rom.metadatum.first_release_date) > 0;
|
||||
</script>
|
||||
<template>
|
||||
<div>
|
||||
@@ -61,7 +61,7 @@ const hasReleaseDate = Number(props.rom.first_release_date) > 0;
|
||||
{{ releaseDate }}
|
||||
</v-chip>
|
||||
<v-chip
|
||||
v-if="Number(rom.first_release_date) > 0 && smAndDown"
|
||||
v-if="Number(rom.metadatum.first_release_date) > 0 && smAndDown"
|
||||
class="font-italic ml-1"
|
||||
size="small"
|
||||
>
|
||||
|
||||
@@ -27,7 +27,7 @@ function updateVersion() {
|
||||
max-width="fit-content"
|
||||
hide-details
|
||||
:items="
|
||||
[rom, ...rom.sibling_roms].map((i) => ({
|
||||
[rom, ...rom.siblings].map((i) => ({
|
||||
title: i.fs_name_no_ext,
|
||||
value: i.id,
|
||||
}))
|
||||
|
||||
56
frontend/src/components/Gallery/AppBar/Base.vue
Normal file
56
frontend/src/components/Gallery/AppBar/Base.vue
Normal file
@@ -0,0 +1,56 @@
|
||||
<script setup lang="ts">
|
||||
import SearchTextField from "@/components/Gallery/AppBar/Search/SearchTextField.vue";
|
||||
import FilterTextField from "@/components/Gallery/AppBar/common/FilterTextField.vue";
|
||||
import SearchBtn from "@/components/Gallery/AppBar/Search/SearchBtn.vue";
|
||||
import FilterBtn from "@/components/Gallery/AppBar/common/FilterBtn.vue";
|
||||
import FilterDrawer from "@/components/Gallery/AppBar/common/FilterDrawer/Base.vue";
|
||||
import SelectingBtn from "@/components/Gallery/AppBar/common/SelectingBtn.vue";
|
||||
import GalleryViewBtn from "@/components/Gallery/AppBar/common/GalleryViewBtn.vue";
|
||||
import CharIndexBar from "@/components/Gallery/AppBar/common/CharIndexBar.vue";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { calculateMainLayoutWidth } from "@/utils";
|
||||
|
||||
// Props
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
showPlatformsFilter?: boolean;
|
||||
showFilterBar?: boolean;
|
||||
showSearchBar?: boolean;
|
||||
}>(),
|
||||
{
|
||||
showPlatformsFilter: false,
|
||||
showFilterBar: false,
|
||||
showSearchBar: false,
|
||||
},
|
||||
);
|
||||
const { xs } = useDisplay();
|
||||
const { calculatedWidth } = calculateMainLayoutWidth();
|
||||
</script>
|
||||
<template>
|
||||
<v-app-bar
|
||||
elevation="0"
|
||||
density="compact"
|
||||
class="ma-2"
|
||||
:style="{ width: calculatedWidth }"
|
||||
rounded
|
||||
>
|
||||
<template #prepend>
|
||||
<slot name="prepend" />
|
||||
<filter-btn />
|
||||
</template>
|
||||
<filter-text-field v-if="!xs && showFilterBar" />
|
||||
<search-text-field v-if="showSearchBar" />
|
||||
<slot name="content" />
|
||||
<template #append>
|
||||
<slot name="append" />
|
||||
<selecting-btn />
|
||||
<gallery-view-btn />
|
||||
</template>
|
||||
</v-app-bar>
|
||||
|
||||
<filter-drawer
|
||||
:show-platforms-filter="showPlatformsFilter"
|
||||
:show-filter-bar="showFilterBar"
|
||||
/>
|
||||
<char-index-bar />
|
||||
</template>
|
||||
@@ -1,62 +1,35 @@
|
||||
<script setup lang="ts">
|
||||
import FilterBtn from "@/components/Gallery/AppBar/common/FilterBtn.vue";
|
||||
import BaseGalleryAppBar from "@/components/Gallery/AppBar/Base.vue";
|
||||
import CollectionInfoDrawer from "@/components/Gallery/AppBar/Collection/CollectionInfoDrawer.vue";
|
||||
import FilterDrawer from "@/components/Gallery/AppBar/common/FilterDrawer/Base.vue";
|
||||
import FilterTextField from "@/components/Gallery/AppBar/common/FilterTextField.vue";
|
||||
import GalleryViewBtn from "@/components/Gallery/AppBar/common/GalleryViewBtn.vue";
|
||||
import RAvatar from "@/components/common/Collection/RAvatar.vue";
|
||||
import SelectingBtn from "@/components/Gallery/AppBar/common/SelectingBtn.vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import storeNavigation from "@/stores/navigation";
|
||||
import storeRoms from "@/stores/roms";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed } from "vue";
|
||||
|
||||
// Props
|
||||
const { xs, smAndDown } = useDisplay();
|
||||
const navigationStore = storeNavigation();
|
||||
const romsStore = storeRoms();
|
||||
const { currentCollection } = storeToRefs(romsStore);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-app-bar
|
||||
elevation="0"
|
||||
density="compact"
|
||||
class="ma-2"
|
||||
:class="{
|
||||
'gallery-app-bar-mobile': smAndDown,
|
||||
'gallery-app-bar-desktop': !smAndDown,
|
||||
}"
|
||||
rounded
|
||||
>
|
||||
<base-gallery-app-bar show-platforms-filter show-filter-bar>
|
||||
<template #prepend>
|
||||
<r-avatar
|
||||
v-if="currentCollection"
|
||||
@click="navigationStore.switchActiveCollectionInfoDrawer"
|
||||
class="collection-icon cursor-pointer"
|
||||
v-if="currentCollection"
|
||||
:size="45"
|
||||
:collection="currentCollection"
|
||||
/>
|
||||
<filter-btn />
|
||||
</template>
|
||||
<filter-text-field v-if="!xs" />
|
||||
<template #append>
|
||||
<selecting-btn />
|
||||
<gallery-view-btn />
|
||||
</template>
|
||||
</v-app-bar>
|
||||
</base-gallery-app-bar>
|
||||
|
||||
<collection-info-drawer />
|
||||
<filter-drawer />
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.gallery-app-bar-desktop {
|
||||
width: calc(100% - 91px) !important;
|
||||
}
|
||||
.gallery-app-bar-mobile {
|
||||
width: calc(100% - 16px) !important;
|
||||
}
|
||||
.collection-icon {
|
||||
transition:
|
||||
filter 0.15s ease-in-out,
|
||||
|
||||
@@ -136,14 +136,12 @@ async function updateCollection() {
|
||||
width="500"
|
||||
v-model="activeCollectionInfoDrawer"
|
||||
:class="{
|
||||
'mx-2 px-1': activeCollectionInfoDrawer,
|
||||
'ml-2': activeCollectionInfoDrawer,
|
||||
'drawer-mobile': smAndDown && activeCollectionInfoDrawer,
|
||||
'drawer-desktop': !smAndDown,
|
||||
}"
|
||||
class="bg-surface border-0 rounded my-2 py-1"
|
||||
style="height: unset"
|
||||
class="bg-surface rounded mt-4 mb-2 pa-1 unset-height"
|
||||
>
|
||||
<v-row no-gutters class="justify-center align-center pa-4">
|
||||
<v-row no-gutters class="justify-center align-center pa-2">
|
||||
<v-col style="max-width: 240px" cols="12">
|
||||
<div class="text-center justify-center align-center">
|
||||
<div class="position-absolute append-top-right">
|
||||
@@ -191,7 +189,7 @@ async function updateCollection() {
|
||||
:src="imagePreviewUrl"
|
||||
>
|
||||
<template v-if="isEditable" #append-inner>
|
||||
<v-btn-group divided density="compact">
|
||||
<v-btn-group rounded="0" divided density="compact">
|
||||
<v-btn
|
||||
title="Search for cover in SteamGridDB"
|
||||
:disabled="
|
||||
@@ -214,7 +212,7 @@ async function updateCollection() {
|
||||
class="translucent-dark"
|
||||
@click="triggerFileInput"
|
||||
>
|
||||
<v-icon size="large">mdi-upload</v-icon>
|
||||
<v-icon size="large">mdi-cloud-upload-outline</v-icon>
|
||||
<v-file-input
|
||||
id="file-input"
|
||||
v-model="updatedCollection.artwork"
|
||||
@@ -339,6 +337,7 @@ async function updateCollection() {
|
||||
elevation="0"
|
||||
titleDivider
|
||||
bgColor="bg-toplayer"
|
||||
class="mx-2"
|
||||
>
|
||||
<template #content>
|
||||
<div class="text-center">
|
||||
@@ -365,11 +364,4 @@ async function updateCollection() {
|
||||
right: 0.3rem;
|
||||
z-index: 1;
|
||||
}
|
||||
.drawer-desktop {
|
||||
top: 56px !important;
|
||||
}
|
||||
.drawer-mobile {
|
||||
top: 110px !important;
|
||||
width: calc(100% - 16px) !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,74 +1,49 @@
|
||||
<script setup lang="ts">
|
||||
import BaseGalleryAppBar from "@/components/Gallery/AppBar/Base.vue";
|
||||
import PlatformIcon from "@/components/common/Platform/Icon.vue";
|
||||
import FirmwareBtn from "@/components/Gallery/AppBar/Platform/FirmwareBtn.vue";
|
||||
import FirmwareDrawer from "@/components/Gallery/AppBar/Platform/FirmwareDrawer.vue";
|
||||
import PlatformInfoDrawer from "@/components/Gallery/AppBar/Platform/PlatformInfoDrawer.vue";
|
||||
import FilterBtn from "@/components/Gallery/AppBar/common/FilterBtn.vue";
|
||||
import FilterDrawer from "@/components/Gallery/AppBar/common/FilterDrawer/Base.vue";
|
||||
import FilterTextField from "@/components/Gallery/AppBar/common/FilterTextField.vue";
|
||||
import GalleryViewBtn from "@/components/Gallery/AppBar/common/GalleryViewBtn.vue";
|
||||
import SelectingBtn from "@/components/Gallery/AppBar/common/SelectingBtn.vue";
|
||||
import PlatformIcon from "@/components/common/Platform/Icon.vue";
|
||||
import storeNavigation from "@/stores/navigation";
|
||||
import storeRoms from "@/stores/roms";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { computed } from "vue";
|
||||
|
||||
// Props
|
||||
const { xs, smAndDown } = useDisplay();
|
||||
const romsStore = storeRoms();
|
||||
const { currentPlatform } = storeToRefs(romsStore);
|
||||
const navigationStore = storeNavigation();
|
||||
const { activePlatformInfoDrawer } = storeToRefs(navigationStore);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-app-bar
|
||||
elevation="0"
|
||||
density="compact"
|
||||
class="ma-2"
|
||||
:class="{
|
||||
'gallery-app-bar-mobile': smAndDown,
|
||||
'gallery-app-bar-desktop': !smAndDown,
|
||||
}"
|
||||
rounded
|
||||
>
|
||||
<platform-icon
|
||||
v-if="currentPlatform"
|
||||
:slug="currentPlatform.slug"
|
||||
:name="currentPlatform.name"
|
||||
:fs-slug="currentPlatform.fs_slug"
|
||||
:size="36"
|
||||
class="mx-3 cursor-pointer platform-icon"
|
||||
:class="{ active: activePlatformInfoDrawer }"
|
||||
@click="navigationStore.switchActivePlatformInfoDrawer"
|
||||
/>
|
||||
<firmware-btn />
|
||||
<filter-btn />
|
||||
<filter-text-field v-if="!xs" />
|
||||
<template #append>
|
||||
<selecting-btn />
|
||||
<gallery-view-btn />
|
||||
<base-gallery-app-bar :show-platforms-filter="false" show-filter-bar>
|
||||
<template #prepend>
|
||||
<platform-icon
|
||||
v-if="currentPlatform"
|
||||
:slug="currentPlatform.slug"
|
||||
:name="currentPlatform.name"
|
||||
:fs-slug="currentPlatform.fs_slug"
|
||||
:size="36"
|
||||
class="mx-3 cursor-pointer platform-icon"
|
||||
:class="{ active: activePlatformInfoDrawer }"
|
||||
@click="navigationStore.switchActivePlatformInfoDrawer"
|
||||
/>
|
||||
<firmware-btn />
|
||||
</template>
|
||||
</v-app-bar>
|
||||
</base-gallery-app-bar>
|
||||
|
||||
<platform-info-drawer />
|
||||
<filter-drawer hide-platforms />
|
||||
<firmware-drawer />
|
||||
<platform-info-drawer />
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.gallery-app-bar-desktop {
|
||||
width: calc(100% - 91px) !important;
|
||||
}
|
||||
.gallery-app-bar-mobile {
|
||||
width: calc(100% - 16px) !important;
|
||||
}
|
||||
.platform-icon {
|
||||
transition:
|
||||
filter 0.15s ease-in-out,
|
||||
transform 0.15s ease-in-out;
|
||||
filter: drop-shadow(0px 0px 1px rgba(var(--v-theme-primary)));
|
||||
}
|
||||
|
||||
.platform-icon:hover,
|
||||
.platform-icon.active {
|
||||
filter: drop-shadow(0px 0px 3px rgba(var(--v-theme-primary)));
|
||||
|
||||
@@ -6,7 +6,7 @@ import storeAuth from "@/stores/auth";
|
||||
import storeGalleryView from "@/stores/galleryView";
|
||||
import storeRoms from "@/stores/roms";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import { formatBytes } from "@/utils";
|
||||
import { formatBytes, calculateMainLayoutWidth } from "@/utils";
|
||||
import type { Emitter } from "mitt";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { inject, ref } from "vue";
|
||||
@@ -15,12 +15,13 @@ import { useI18n } from "vue-i18n";
|
||||
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
const { xs, mdAndUp, smAndDown } = useDisplay();
|
||||
const { xs, mdAndUp } = useDisplay();
|
||||
const auth = storeAuth();
|
||||
const romsStore = storeRoms();
|
||||
const { currentPlatform } = storeToRefs(romsStore);
|
||||
const galleryViewStore = storeGalleryView();
|
||||
const { activeFirmwareDrawer } = storeToRefs(galleryViewStore);
|
||||
const { calculatedWidth } = calculateMainLayoutWidth();
|
||||
const selectedFirmware = ref<FirmwareSchema[]>([]);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const HEADERS = [
|
||||
@@ -57,12 +58,12 @@ function deleteSelectedFirmware() {
|
||||
location="bottom"
|
||||
v-model="activeFirmwareDrawer"
|
||||
:class="{
|
||||
'my-2 px-1': activeFirmwareDrawer,
|
||||
'drawer-mobile': smAndDown,
|
||||
'drawer-desktop': !smAndDown,
|
||||
'my-2 px-1 max-h-50': activeFirmwareDrawer,
|
||||
}"
|
||||
class="bg-surface border-0 rounded mx-2 px-1"
|
||||
style="width: unset"
|
||||
:style="{
|
||||
width: calculatedWidth,
|
||||
}"
|
||||
>
|
||||
<v-data-table-virtual
|
||||
:items="currentPlatform?.firmware ?? []"
|
||||
@@ -79,7 +80,7 @@ function deleteSelectedFirmware() {
|
||||
size="small"
|
||||
@click="emitter?.emit('addFirmwareDialog', null)"
|
||||
>
|
||||
<v-icon>mdi-upload</v-icon>
|
||||
<v-icon>mdi-cloud-upload-outline</v-icon>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
:disabled="!selectedFirmware.length"
|
||||
@@ -183,11 +184,3 @@ function deleteSelectedFirmware() {
|
||||
<upload-firmware-dialog />
|
||||
<delete-firmware-dialog />
|
||||
</template>
|
||||
<style scoped>
|
||||
.drawer-desktop {
|
||||
width: calc(100% - 91px) !important;
|
||||
}
|
||||
.drawer-mobile {
|
||||
width: calc(100% - 16px) !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -191,14 +191,12 @@ watch(
|
||||
width="500"
|
||||
v-model="activePlatformInfoDrawer"
|
||||
:class="{
|
||||
'mx-2 px-1': activePlatformInfoDrawer,
|
||||
'ml-2': activePlatformInfoDrawer,
|
||||
'drawer-mobile': smAndDown && activePlatformInfoDrawer,
|
||||
'drawer-desktop': !smAndDown,
|
||||
}"
|
||||
class="bg-surface border-0 rounded my-2 py-1"
|
||||
style="height: unset"
|
||||
class="bg-surface rounded mt-4 mb-2 pa-1 unset-height"
|
||||
>
|
||||
<v-row no-gutters class="justify-center align-center pa-4">
|
||||
<v-row no-gutters class="justify-center align-center pa-2">
|
||||
<v-col cols="12">
|
||||
<div class="text-center justify-center align-center">
|
||||
<div class="position-absolute append-top-right">
|
||||
@@ -264,7 +262,9 @@ watch(
|
||||
class="bg-toplayer my-1"
|
||||
@click="emitter?.emit('showUploadRomDialog', currentPlatform)"
|
||||
>
|
||||
<v-icon class="text-romm-green mr-2">mdi-upload</v-icon>
|
||||
<v-icon class="text-romm-green mr-2"
|
||||
>mdi-cloud-upload-outline</v-icon
|
||||
>
|
||||
{{ t("platform.upload-roms") }}
|
||||
</v-btn>
|
||||
<v-btn
|
||||
@@ -368,6 +368,7 @@ watch(
|
||||
elevation="0"
|
||||
titleDivider
|
||||
bgColor="bg-toplayer"
|
||||
class="mx-2"
|
||||
>
|
||||
<template #content>
|
||||
<v-chip
|
||||
@@ -431,6 +432,7 @@ watch(
|
||||
elevation="0"
|
||||
titleDivider
|
||||
bgColor="bg-toplayer"
|
||||
class="mt-2 mx-2"
|
||||
>
|
||||
<template #content>
|
||||
<div class="text-center">
|
||||
@@ -458,14 +460,4 @@ watch(
|
||||
.platform-icon {
|
||||
filter: drop-shadow(0px 0px 1px rgba(var(--v-theme-primary)));
|
||||
}
|
||||
.greyscale {
|
||||
filter: grayscale(100%);
|
||||
}
|
||||
.drawer-desktop {
|
||||
top: 56px !important;
|
||||
}
|
||||
.drawer-mobile {
|
||||
top: 110px !important;
|
||||
width: calc(100% - 16px) !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,46 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import FilterBtn from "@/components/Gallery/AppBar/common/FilterBtn.vue";
|
||||
import FilterDrawer from "@/components/Gallery/AppBar/common/FilterDrawer/Base.vue";
|
||||
import GalleryViewBtn from "@/components/Gallery/AppBar/common/GalleryViewBtn.vue";
|
||||
import SearchTextField from "@/components/Gallery/AppBar/Search/SearchTextField.vue";
|
||||
import SelectingBtn from "@/components/Gallery/AppBar/common/SelectingBtn.vue";
|
||||
import SearchBtn from "@/components/Gallery/AppBar/Search/SearchBtn.vue";
|
||||
import { useDisplay } from "vuetify";
|
||||
|
||||
// Props
|
||||
const { xs, smAndDown } = useDisplay();
|
||||
import BaseGalleryAppBar from "@/components/Gallery/AppBar/Base.vue";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-app-bar
|
||||
elevation="0"
|
||||
density="compact"
|
||||
class="ma-2"
|
||||
:class="{
|
||||
'gallery-app-bar-mobile': smAndDown,
|
||||
'gallery-app-bar-desktop': !smAndDown,
|
||||
}"
|
||||
rounded
|
||||
>
|
||||
<filter-btn />
|
||||
<template v-if="!xs">
|
||||
<search-text-field />
|
||||
</template>
|
||||
<template #append>
|
||||
<search-btn v-if="!xs" />
|
||||
<selecting-btn />
|
||||
<gallery-view-btn />
|
||||
</template>
|
||||
</v-app-bar>
|
||||
|
||||
<filter-drawer />
|
||||
<base-gallery-app-bar show-platforms-filter show-search-bar />
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.gallery-app-bar-desktop {
|
||||
width: calc(100% - 91px) !important;
|
||||
}
|
||||
.gallery-app-bar-mobile {
|
||||
width: calc(100% - 16px) !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,66 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, inject } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import storeRoms from "@/stores/roms";
|
||||
import romApi from "@/services/api/rom";
|
||||
import storeGalleryFilter from "@/stores/galleryFilter";
|
||||
import { storeToRefs } from "pinia";
|
||||
import type { Platform } from "@/stores/platforms";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import type { Emitter } from "mitt";
|
||||
|
||||
const { t } = useI18n();
|
||||
const romsStore = storeRoms();
|
||||
const { gettingRoms } = storeToRefs(romsStore);
|
||||
const searched = ref(false);
|
||||
const selectedPlatform = ref<Platform | null>(null);
|
||||
const { fetchingRoms, initialSearch } = storeToRefs(romsStore);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const galleryFilterStore = storeGalleryFilter();
|
||||
const { searchText } = storeToRefs(galleryFilterStore);
|
||||
const { searchTerm } = storeToRefs(galleryFilterStore);
|
||||
|
||||
function fetchRoms() {
|
||||
if (searchText.value !== null) {
|
||||
gettingRoms.value = true;
|
||||
const inputElement = document.getElementById("search-text-field");
|
||||
inputElement?.blur();
|
||||
searched.value = true;
|
||||
romApi
|
||||
.getRoms({ searchTerm: searchText.value })
|
||||
.then(({ data }) => {
|
||||
data = data.sort((a, b) => {
|
||||
return a.platform_name.localeCompare(b.platform_name);
|
||||
});
|
||||
romsStore.set(data);
|
||||
romsStore.setFiltered(data, galleryFilterStore);
|
||||
})
|
||||
.catch((error) => {
|
||||
emitter?.emit("snackbarShow", {
|
||||
msg: `Couldn't fetch roms: ${error}`,
|
||||
icon: "mdi-close-circle",
|
||||
color: "red",
|
||||
timeout: 4000,
|
||||
});
|
||||
console.error(`Couldn't fetch roms: ${error}`);
|
||||
})
|
||||
.finally(() => {
|
||||
gettingRoms.value = false;
|
||||
});
|
||||
filterRoms();
|
||||
galleryFilterStore.activeFilterDrawer = false;
|
||||
}
|
||||
}
|
||||
if (searchTerm.value == null) return;
|
||||
|
||||
function filterRoms() {
|
||||
if (selectedPlatform.value) {
|
||||
romsStore.setFiltered(
|
||||
romsStore.allRoms.filter(
|
||||
(rom) => rom.platform_id === selectedPlatform.value?.id,
|
||||
),
|
||||
galleryFilterStore,
|
||||
);
|
||||
} else {
|
||||
romsStore.setFiltered(romsStore.allRoms, galleryFilterStore);
|
||||
}
|
||||
const inputElement = document.getElementById("search-text-field");
|
||||
inputElement?.blur();
|
||||
initialSearch.value = true;
|
||||
romsStore.fetchRoms(galleryFilterStore).catch((error) => {
|
||||
emitter?.emit("snackbarShow", {
|
||||
msg: `Couldn't fetch roms: ${error}`,
|
||||
icon: "mdi-close-circle",
|
||||
color: "red",
|
||||
timeout: 4000,
|
||||
});
|
||||
});
|
||||
|
||||
galleryFilterStore.activeFilterDrawer = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -73,6 +40,6 @@ function filterRoms() {
|
||||
class="bg-toplayer"
|
||||
variant="text"
|
||||
icon="mdi-magnify"
|
||||
:disabled="gettingRoms || !searchText"
|
||||
:disabled="fetchingRoms || !searchTerm"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -1,61 +1,75 @@
|
||||
<script setup lang="ts">
|
||||
import romApi from "@/services/api/rom";
|
||||
import storeRoms from "@/stores/roms";
|
||||
import storeGalleryFilter, { type FilterType } from "@/stores/galleryFilter";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import type { Emitter } from "mitt";
|
||||
import { inject, onMounted, watch } from "vue";
|
||||
import { inject, nextTick, onMounted, watch } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { debounce } from "lodash";
|
||||
|
||||
// Props
|
||||
const { xs } = useDisplay();
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
const romsStore = storeRoms();
|
||||
const { gettingRoms } = storeToRefs(romsStore);
|
||||
const { fetchingRoms, initialSearch } = storeToRefs(romsStore);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const galleryFilterStore = storeGalleryFilter();
|
||||
const { searchText } = storeToRefs(galleryFilterStore);
|
||||
const { searchTerm } = storeToRefs(galleryFilterStore);
|
||||
|
||||
async function fetchRoms() {
|
||||
if (searchText.value !== null) {
|
||||
// Auto hide android keyboard
|
||||
const inputElement = document.getElementById("search-text-field");
|
||||
inputElement?.blur();
|
||||
gettingRoms.value = true;
|
||||
if (searchTerm.value === null) return;
|
||||
|
||||
// Update URL with search term
|
||||
router.replace({ query: { search: searchText.value } });
|
||||
|
||||
try {
|
||||
const { data } = await romApi.getRoms({ searchTerm: searchText.value });
|
||||
const sortedData = data.sort((a, b) => {
|
||||
return a.platform_name.localeCompare(b.platform_name);
|
||||
});
|
||||
romsStore.set(sortedData);
|
||||
romsStore.setFiltered(sortedData, galleryFilterStore);
|
||||
} catch (error) {
|
||||
initialSearch.value = true;
|
||||
romsStore
|
||||
.fetchRoms(galleryFilterStore)
|
||||
.catch((error) => {
|
||||
emitter?.emit("snackbarShow", {
|
||||
msg: `Couldn't fetch roms: ${error}`,
|
||||
icon: "mdi-close-circle",
|
||||
color: "red",
|
||||
timeout: 4000,
|
||||
});
|
||||
console.error(`Couldn't fetch roms: ${error}`);
|
||||
} finally {
|
||||
gettingRoms.value = false;
|
||||
})
|
||||
.finally(() => {
|
||||
galleryFilterStore.activeFilterDrawer = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const refetchRoms = debounce(async () => {
|
||||
if (searchTerm.value === null) return;
|
||||
|
||||
// Update URL with search term
|
||||
router.replace({ query: { search: searchTerm.value } });
|
||||
|
||||
romsStore.resetPagination();
|
||||
initialSearch.value = true;
|
||||
romsStore
|
||||
.fetchRoms(galleryFilterStore, false)
|
||||
.catch((error) => {
|
||||
emitter?.emit("snackbarShow", {
|
||||
msg: `Couldn't fetch roms: ${error}`,
|
||||
icon: "mdi-close-circle",
|
||||
color: "red",
|
||||
timeout: 4000,
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
galleryFilterStore.activeFilterDrawer = false;
|
||||
});
|
||||
}, 500);
|
||||
|
||||
function clearInput() {
|
||||
searchTerm.value = null;
|
||||
}
|
||||
|
||||
const filterToSetFilter: Record<FilterType, Function> = {
|
||||
genres: galleryFilterStore.setSelectedFilterGenre,
|
||||
franchises: galleryFilterStore.setSelectedFilterFranchise,
|
||||
meta_collections: galleryFilterStore.setSelectedFilterCollection,
|
||||
collections: galleryFilterStore.setSelectedFilterCollection,
|
||||
companies: galleryFilterStore.setSelectedFilterCompany,
|
||||
age_ratings: galleryFilterStore.setSelectedFilterAgeRating,
|
||||
status: galleryFilterStore.setSelectedFilterStatus,
|
||||
@@ -69,8 +83,8 @@ onMounted(() => {
|
||||
filter: filterParam,
|
||||
value: valueParam,
|
||||
} = router.currentRoute.value.query;
|
||||
if (searchParam !== undefined && searchParam !== searchText.value) {
|
||||
searchText.value = searchParam as string;
|
||||
if (searchParam !== undefined && searchParam !== searchTerm.value) {
|
||||
searchTerm.value = searchParam as string;
|
||||
}
|
||||
|
||||
// Check for query params to set filters
|
||||
@@ -82,14 +96,17 @@ onMounted(() => {
|
||||
router.replace({ query: {} }); // Clear query params
|
||||
}
|
||||
|
||||
fetchRoms();
|
||||
// Check if search term is set in the URL (empty string is ok)
|
||||
if (searchTerm.value !== null) {
|
||||
fetchRoms();
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
router.currentRoute.value.query,
|
||||
() => router.currentRoute.value.query,
|
||||
(query) => {
|
||||
if (query.search !== undefined && query.search !== searchText.value) {
|
||||
searchText.value = query.search as string;
|
||||
if (query.search !== undefined && query.search !== searchTerm.value) {
|
||||
searchTerm.value = query.search as string;
|
||||
fetchRoms();
|
||||
}
|
||||
},
|
||||
@@ -99,14 +116,15 @@ watch(
|
||||
|
||||
<template>
|
||||
<v-text-field
|
||||
:density="xs ? 'comfortable' : 'default'"
|
||||
density="default"
|
||||
clearable
|
||||
autofocus
|
||||
@keyup.enter="fetchRoms"
|
||||
v-model="searchText"
|
||||
:disabled="gettingRoms"
|
||||
:label="t('common.search')"
|
||||
hide-details
|
||||
class="bg-toplayer"
|
||||
rounded="0"
|
||||
:label="t('common.search')"
|
||||
v-model="searchTerm"
|
||||
@keyup.enter="refetchRoms"
|
||||
@click:clear="clearInput"
|
||||
@update:model-value="nextTick(refetchRoms)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
125
frontend/src/components/Gallery/AppBar/common/CharIndexBar.vue
Normal file
125
frontend/src/components/Gallery/AppBar/common/CharIndexBar.vue
Normal file
@@ -0,0 +1,125 @@
|
||||
<script setup lang="ts">
|
||||
import storeRoms from "@/stores/roms";
|
||||
import storeGalleryFilter from "@/stores/galleryFilter";
|
||||
import storeGalleryView from "@/stores/galleryView";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import type { Emitter } from "mitt";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { inject, watch, computed } from "vue";
|
||||
import { useDisplay } from "vuetify";
|
||||
|
||||
// Props
|
||||
const { smAndDown } = useDisplay();
|
||||
const romsStore = storeRoms();
|
||||
const galleryFilterStore = storeGalleryFilter();
|
||||
const galleryViewStore = storeGalleryView();
|
||||
const { selectedRoms } = storeToRefs(romsStore);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
|
||||
const { characterIndex, selectedCharacter, fetchingRoms } =
|
||||
storeToRefs(romsStore);
|
||||
|
||||
const { scrolledToTop } = storeToRefs(galleryViewStore);
|
||||
|
||||
async function fetchRoms() {
|
||||
if (fetchingRoms.value) return;
|
||||
|
||||
emitter?.emit("showLoadingDialog", {
|
||||
loading: true,
|
||||
scrim: false,
|
||||
});
|
||||
|
||||
romsStore
|
||||
.fetchRoms(galleryFilterStore, false)
|
||||
.then(() => {
|
||||
emitter?.emit("showLoadingDialog", {
|
||||
loading: false,
|
||||
scrim: false,
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
emitter?.emit("snackbarShow", {
|
||||
msg: `Couldn't fetch roms: ${error}`,
|
||||
icon: "mdi-close-circle",
|
||||
color: "red",
|
||||
timeout: 4000,
|
||||
});
|
||||
emitter?.emit("showLoadingDialog", {
|
||||
loading: false,
|
||||
scrim: false,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const calculatedHeight = computed(() => {
|
||||
if (smAndDown.value) {
|
||||
if (!scrolledToTop.value && selectedRoms.value.length > 0) {
|
||||
return "calc(100dvh - 276px)";
|
||||
} else if (!scrolledToTop.value || selectedRoms.value.length > 0) {
|
||||
return "calc(100dvh - 225px)";
|
||||
} else {
|
||||
return "calc(100dvh - 174px)";
|
||||
}
|
||||
} else {
|
||||
if (!scrolledToTop.value && selectedRoms.value.length > 0) {
|
||||
return "calc(100dvh - 176px)";
|
||||
} else if (!scrolledToTop.value || selectedRoms.value.length > 0) {
|
||||
return "calc(100dvh - 125px)";
|
||||
} else {
|
||||
return "calc(100dvh - 74px)";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
selectedCharacter,
|
||||
() => {
|
||||
if (!selectedCharacter.value) return;
|
||||
romsStore.resetPagination();
|
||||
romsStore.fetchOffset = characterIndex.value[selectedCharacter.value];
|
||||
fetchRoms();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-toolbar
|
||||
elevation="0"
|
||||
density="compact"
|
||||
rounded
|
||||
height="100%"
|
||||
class="position-fixed bg-surface mt-4 char-index-toolbar"
|
||||
:style="{
|
||||
'max-height': calculatedHeight,
|
||||
}"
|
||||
>
|
||||
<v-tabs
|
||||
v-model="selectedCharacter"
|
||||
:mandatory="false"
|
||||
slider-color="primary"
|
||||
bg-color="surface"
|
||||
direction="vertical"
|
||||
>
|
||||
<v-tab
|
||||
v-for="char in Object.keys(characterIndex)"
|
||||
:key="char"
|
||||
:value="char"
|
||||
class="py-3"
|
||||
>
|
||||
{{ char }}
|
||||
</v-tab>
|
||||
</v-tabs>
|
||||
</v-toolbar>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.char-index-toolbar {
|
||||
right: 8px;
|
||||
transform: translateY(0px);
|
||||
height: fit-content;
|
||||
width: 44px;
|
||||
overflow-y: scroll;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
</style>
|
||||
@@ -1,29 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import PlatformIcon from "@/components/common/Platform/Icon.vue";
|
||||
import FilterUnmatchedBtn from "@/components/Gallery/AppBar/common/FilterDrawer/FilterUnmatchedBtn.vue";
|
||||
import FilterMatchedBtn from "@/components/Gallery/AppBar/common/FilterDrawer/FilterMatchedBtn.vue";
|
||||
import FilterFavouritesBtn from "@/components/Gallery/AppBar/common/FilterDrawer/FilterFavouritesBtn.vue";
|
||||
import FilterDuplicatesBtn from "@/components/Gallery/AppBar/common/FilterDrawer/FilterDuplicatesBtn.vue";
|
||||
import FilterTextField from "@/components/Gallery/AppBar/common/FilterTextField.vue";
|
||||
import SearchTextField from "@/components/Gallery/AppBar/Search/SearchTextField.vue";
|
||||
import SearchBtn from "@/components/Gallery/AppBar/Search/SearchBtn.vue";
|
||||
import storeGalleryFilter from "@/stores/galleryFilter";
|
||||
import storeRoms from "@/stores/roms";
|
||||
import storePlatforms from "@/stores/platforms";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import type { Emitter } from "mitt";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { inject, nextTick, onMounted, ref, watch } from "vue";
|
||||
import { inject, nextTick, onMounted, watch } from "vue";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
// Props
|
||||
withDefaults(defineProps<{ hidePlatforms?: boolean }>(), {
|
||||
hidePlatforms: false,
|
||||
});
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
showPlatformsFilter?: boolean;
|
||||
showFilterBar?: boolean;
|
||||
}>(),
|
||||
{
|
||||
showPlatformsFilter: false,
|
||||
showFilterBar: false,
|
||||
},
|
||||
);
|
||||
|
||||
const { t } = useI18n();
|
||||
const { xs, smAndDown } = useDisplay();
|
||||
const viewportWidth = ref(window.innerWidth);
|
||||
const galleryFilterStore = storeGalleryFilter();
|
||||
const romsStore = storeRoms();
|
||||
const platformsStore = storePlatforms();
|
||||
@@ -48,13 +53,14 @@ const {
|
||||
selectedLanguage,
|
||||
filterLanguages,
|
||||
} = storeToRefs(galleryFilterStore);
|
||||
const { allRoms, filteredRoms } = storeToRefs(romsStore);
|
||||
const { filteredRoms } = storeToRefs(romsStore);
|
||||
const { allPlatforms } = storeToRefs(platformsStore);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
emitter?.on("filter", onFilterChange);
|
||||
|
||||
async function onFilterChange() {
|
||||
romsStore.setFiltered(allRoms.value, galleryFilterStore);
|
||||
romsStore.resetPagination();
|
||||
romsStore.fetchRoms(galleryFilterStore, false);
|
||||
emitter?.emit("updateDataTablePages", null);
|
||||
}
|
||||
|
||||
@@ -103,18 +109,7 @@ const filters = [
|
||||
|
||||
// Functions
|
||||
function resetFilters() {
|
||||
selectedPlatform.value = null;
|
||||
selectedGenre.value = null;
|
||||
selectedFranchise.value = null;
|
||||
selectedCollection.value = null;
|
||||
selectedCompany.value = null;
|
||||
selectedAgeRating.value = null;
|
||||
selectedRegion.value = null;
|
||||
selectedLanguage.value = null;
|
||||
selectedStatus.value = null;
|
||||
galleryFilterStore.disableFilterUnmatched();
|
||||
galleryFilterStore.disableFilterMatched();
|
||||
galleryFilterStore.disableFilterFavourites();
|
||||
galleryFilterStore.resetFilters();
|
||||
nextTick(() => emitter?.emit("filter", null));
|
||||
}
|
||||
|
||||
@@ -128,21 +123,29 @@ function setFilters() {
|
||||
),
|
||||
]);
|
||||
galleryFilterStore.setFilterGenres([
|
||||
...new Set(romsStore.filteredRoms.flatMap((rom) => rom.genres).sort()),
|
||||
...new Set(
|
||||
romsStore.filteredRoms.flatMap((rom) => rom.metadatum.genres).sort(),
|
||||
),
|
||||
]);
|
||||
galleryFilterStore.setFilterFranchises([
|
||||
...new Set(romsStore.filteredRoms.flatMap((rom) => rom.franchises).sort()),
|
||||
...new Set(
|
||||
romsStore.filteredRoms.flatMap((rom) => rom.metadatum.franchises).sort(),
|
||||
),
|
||||
]);
|
||||
galleryFilterStore.setFilterCompanies([
|
||||
...new Set(romsStore.filteredRoms.flatMap((rom) => rom.companies).sort()),
|
||||
...new Set(
|
||||
romsStore.filteredRoms.flatMap((rom) => rom.metadatum.companies).sort(),
|
||||
),
|
||||
]);
|
||||
galleryFilterStore.setFilterCollections([
|
||||
...new Set(
|
||||
romsStore.filteredRoms.flatMap((rom) => rom.meta_collections).sort(),
|
||||
romsStore.filteredRoms.flatMap((rom) => rom.metadatum.collections).sort(),
|
||||
),
|
||||
]);
|
||||
galleryFilterStore.setFilterAgeRatings([
|
||||
...new Set(romsStore.filteredRoms.flatMap((rom) => rom.age_ratings).sort()),
|
||||
...new Set(
|
||||
romsStore.filteredRoms.flatMap((rom) => rom.metadatum.age_ratings).sort(),
|
||||
),
|
||||
]);
|
||||
galleryFilterStore.setFilterRegions([
|
||||
...new Set(romsStore.filteredRoms.flatMap((rom) => rom.regions).sort()),
|
||||
@@ -171,36 +174,19 @@ onMounted(async () => {
|
||||
<v-navigation-drawer
|
||||
mobile
|
||||
floating
|
||||
:width="xs ? viewportWidth : '350'"
|
||||
width="400"
|
||||
v-model="activeFilterDrawer"
|
||||
@update:model-value="galleryFilterStore.switchActiveFilterDrawer()"
|
||||
:class="{
|
||||
'mx-2 px-1': activeFilterDrawer,
|
||||
'ml-2': activeFilterDrawer,
|
||||
'drawer-mobile': smAndDown && activeFilterDrawer,
|
||||
'drawer-desktop': !smAndDown,
|
||||
}"
|
||||
class="bg-surface border-0 rounded my-2 py-1"
|
||||
style="height: unset"
|
||||
class="bg-surface rounded mt-4 mb-2 pa-1 unset-height"
|
||||
>
|
||||
<v-list>
|
||||
<template v-if="xs">
|
||||
<template v-if="$route.name != 'search'">
|
||||
<v-list-item>
|
||||
<filter-text-field />
|
||||
</v-list-item>
|
||||
</template>
|
||||
<template v-if="$route.name == 'search'">
|
||||
<v-list-item>
|
||||
<v-row no-gutters>
|
||||
<v-col>
|
||||
<search-text-field />
|
||||
</v-col>
|
||||
<v-col cols="auto">
|
||||
<search-btn />
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-list-item>
|
||||
</template>
|
||||
<template v-if="showFilterBar && xs">
|
||||
<v-list-item>
|
||||
<filter-text-field />
|
||||
</v-list-item>
|
||||
</template>
|
||||
<v-list-item>
|
||||
<filter-unmatched-btn />
|
||||
@@ -208,17 +194,55 @@ onMounted(async () => {
|
||||
<filter-favourites-btn class="mt-2" />
|
||||
<filter-duplicates-btn class="mt-2" />
|
||||
</v-list-item>
|
||||
<v-list-item v-if="!hidePlatforms">
|
||||
<v-list-item v-if="showPlatformsFilter">
|
||||
<v-autocomplete
|
||||
v-model="selectedPlatform"
|
||||
hide-details
|
||||
prepend-inner-icon="mdi-controller"
|
||||
clearable
|
||||
:label="t('common.platform')"
|
||||
variant="solo-filled"
|
||||
variant="outlined"
|
||||
density="comfortable"
|
||||
:items="filterPlatforms.map((p) => ({ title: p.name, value: p }))"
|
||||
:items="filterPlatforms"
|
||||
@update:model-value="nextTick(() => emitter?.emit('filter', null))"
|
||||
/>
|
||||
>
|
||||
<template #item="{ props, item }">
|
||||
<v-list-item
|
||||
v-bind="props"
|
||||
class="py-4"
|
||||
:title="item.raw.name ?? ''"
|
||||
:subtitle="item.raw.fs_slug"
|
||||
>
|
||||
<template #prepend>
|
||||
<platform-icon
|
||||
:key="item.raw.slug"
|
||||
:size="35"
|
||||
:slug="item.raw.slug"
|
||||
:name="item.raw.name"
|
||||
:fs-slug="item.raw.fs_slug"
|
||||
/>
|
||||
</template>
|
||||
<template #append>
|
||||
<v-chip class="ml-2" size="x-small" label>
|
||||
{{ item.raw.rom_count }}
|
||||
</v-chip>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</template>
|
||||
<template #chip="{ item }">
|
||||
<v-chip>
|
||||
<platform-icon
|
||||
:key="item.raw.slug"
|
||||
:slug="item.raw.slug"
|
||||
:name="item.raw.name"
|
||||
:fs-slug="item.raw.fs_slug"
|
||||
:size="20"
|
||||
class="mr-2"
|
||||
/>
|
||||
{{ item.raw.name }}
|
||||
</v-chip>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
</v-list-item>
|
||||
<v-list-item v-for="filter in filters">
|
||||
<v-autocomplete
|
||||
@@ -240,12 +264,3 @@ onMounted(async () => {
|
||||
</v-list>
|
||||
</v-navigation-drawer>
|
||||
</template>
|
||||
<style scoped>
|
||||
.drawer-desktop {
|
||||
top: 56px !important;
|
||||
}
|
||||
.drawer-mobile {
|
||||
top: 110px !important;
|
||||
width: calc(100% - 16px) !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import storeGalleryFilter from "@/stores/galleryFilter";
|
||||
import storeRoms from "@/stores/roms";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import type { Emitter } from "mitt";
|
||||
import { storeToRefs } from "pinia";
|
||||
@@ -8,7 +9,9 @@ import { useI18n } from "vue-i18n";
|
||||
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
const romsStore = storeRoms();
|
||||
const galleryFilterStore = storeGalleryFilter();
|
||||
const { fetchTotalRoms } = storeToRefs(romsStore);
|
||||
const { filterDuplicates } = storeToRefs(galleryFilterStore);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
function setDuplicates() {
|
||||
@@ -23,15 +26,17 @@ function setDuplicates() {
|
||||
variant="tonal"
|
||||
:color="filterDuplicates ? 'primary' : ''"
|
||||
@click="setDuplicates()"
|
||||
:disabled="fetchTotalRoms > 10000"
|
||||
>
|
||||
<v-icon :color="filterDuplicates ? 'primary' : ''"
|
||||
>mdi-content-duplicate</v-icon
|
||||
><span
|
||||
<v-icon :color="filterDuplicates ? 'primary' : ''">
|
||||
mdi-content-duplicate
|
||||
</v-icon>
|
||||
<span
|
||||
class="ml-2"
|
||||
:class="{
|
||||
'text-primary': filterDuplicates,
|
||||
}"
|
||||
>{{ t("platform.show-duplicates") }}</span
|
||||
></v-btn
|
||||
>
|
||||
>{{ t("platform.show-duplicates") }}
|
||||
</span>
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import storeGalleryFilter from "@/stores/galleryFilter";
|
||||
import storeRoms from "@/stores/roms";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import { debounce } from "lodash";
|
||||
import type { Emitter } from "mitt";
|
||||
@@ -7,28 +8,32 @@ import { storeToRefs } from "pinia";
|
||||
import { inject, nextTick, onMounted, watch } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useDisplay } from "vuetify";
|
||||
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
const { xs } = useDisplay();
|
||||
const router = useRouter();
|
||||
const galleryFilterStore = storeGalleryFilter();
|
||||
const { filterText } = storeToRefs(galleryFilterStore);
|
||||
const romsStore = storeRoms();
|
||||
const { searchTerm } = storeToRefs(galleryFilterStore);
|
||||
const { fetchingRoms } = storeToRefs(romsStore);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
|
||||
const filterRoms = debounce(() => {
|
||||
// Update URL with search term
|
||||
router.replace({ query: { search: filterText.value } });
|
||||
router.replace({ query: { search: searchTerm.value } });
|
||||
emitter?.emit("filter", null);
|
||||
}, 500);
|
||||
|
||||
function clear() {
|
||||
filterText.value = null;
|
||||
function clearInput() {
|
||||
searchTerm.value = null;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const { search: searchTerm } = router.currentRoute.value.query;
|
||||
if (searchTerm !== undefined && searchTerm !== filterText.value) {
|
||||
filterText.value = searchTerm as string;
|
||||
const { search } = router.currentRoute.value.query;
|
||||
if (search !== undefined && search !== searchTerm.value) {
|
||||
searchTerm.value = search as string;
|
||||
filterRoms();
|
||||
}
|
||||
});
|
||||
@@ -36,8 +41,8 @@ onMounted(() => {
|
||||
watch(
|
||||
() => router.currentRoute.value.query,
|
||||
(query) => {
|
||||
if (query.search !== undefined && query.search !== filterText.value) {
|
||||
filterText.value = query.search as string;
|
||||
if (query.search !== undefined && query.search !== searchTerm.value) {
|
||||
searchTerm.value = query.search as string;
|
||||
filterRoms();
|
||||
}
|
||||
},
|
||||
@@ -47,13 +52,17 @@ watch(
|
||||
|
||||
<template>
|
||||
<v-text-field
|
||||
v-model="filterText"
|
||||
prepend-inner-icon="mdi-filter-outline"
|
||||
:label="t('common.filter')"
|
||||
:density="xs ? 'comfortable' : 'default'"
|
||||
clearable
|
||||
autofocus
|
||||
hide-details
|
||||
rounded="0"
|
||||
clearable
|
||||
@click:clear="clear"
|
||||
:label="t('common.filter')"
|
||||
v-model="searchTerm"
|
||||
:disabled="fetchingRoms"
|
||||
@keyup.enter="filterRoms"
|
||||
prepend-inner-icon="mdi-filter-outline"
|
||||
@click:clear="clearInput"
|
||||
@update:model-value="nextTick(filterRoms)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -17,12 +17,12 @@ const romsStore = storeRoms();
|
||||
>
|
||||
<template #activator="{ props }">
|
||||
<v-btn
|
||||
:color="romsStore.selecting ? 'primary' : ''"
|
||||
:color="romsStore.selectingRoms ? 'primary' : ''"
|
||||
variant="text"
|
||||
rounded="0"
|
||||
v-bind="props"
|
||||
class="mr-0"
|
||||
icon="mdi-select-group"
|
||||
@click="romsStore.isSelecting()" /></template
|
||||
@click="romsStore.setSelecting()" /></template
|
||||
></v-tooltip>
|
||||
</template>
|
||||
|
||||
@@ -13,11 +13,13 @@ import type { Emitter } from "mitt";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { inject, ref } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
import { useDisplay } from "vuetify";
|
||||
|
||||
// Props
|
||||
const { smAndDown } = useDisplay();
|
||||
const romsStore = storeRoms();
|
||||
const galleryViewStore = storeGalleryView();
|
||||
const { scrolledToTop, currentView } = storeToRefs(galleryViewStore);
|
||||
const { scrolledToTop } = storeToRefs(galleryViewStore);
|
||||
const { selectedRoms } = storeToRefs(romsStore);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const fabMenu = ref(false);
|
||||
@@ -58,7 +60,7 @@ async function onScan() {
|
||||
}
|
||||
|
||||
function selectAllRoms() {
|
||||
romsStore.setSelection(romsStore.filteredRoms);
|
||||
romsStore.setSelection(romsStore.allRoms);
|
||||
}
|
||||
|
||||
function resetSelection() {
|
||||
@@ -139,74 +141,101 @@ function onDownload() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="text-right pa-2 sticky-bottom">
|
||||
<v-scroll-y-reverse-transition>
|
||||
<v-btn
|
||||
icon
|
||||
v-show="!scrolledToTop && currentView != 2"
|
||||
class="border-selected"
|
||||
color="background"
|
||||
elevation="8"
|
||||
size="large"
|
||||
@click="scrollToTop()"
|
||||
><v-icon color="primary">mdi-chevron-up</v-icon></v-btn
|
||||
>
|
||||
</v-scroll-y-reverse-transition>
|
||||
|
||||
<v-speed-dial v-model="fabMenu" transition="slide-y-transition">
|
||||
<template #activator="{ props: menuProps }">
|
||||
<div
|
||||
id="multi-select-overlay"
|
||||
class="text-right sticky-bottom"
|
||||
:class="{
|
||||
'bottom-0': !smAndDown,
|
||||
'bottom-50': smAndDown,
|
||||
}"
|
||||
>
|
||||
<v-speed-dial
|
||||
location="left bottom"
|
||||
transition="fade-transition"
|
||||
v-model="fabMenu"
|
||||
>
|
||||
<template #activator="{ props }">
|
||||
<v-fab-transition>
|
||||
<v-btn
|
||||
v-show="selectedRoms.length > 0"
|
||||
class="ml-2"
|
||||
class="rounded border-selected"
|
||||
color="primary"
|
||||
v-bind="menuProps"
|
||||
v-bind="props"
|
||||
elevation="8"
|
||||
icon
|
||||
size="large"
|
||||
:size="40"
|
||||
rounded="0"
|
||||
>{{ selectedRoms.length }}</v-btn
|
||||
>
|
||||
</v-fab-transition>
|
||||
</template>
|
||||
|
||||
<v-btn
|
||||
title="Delete roms"
|
||||
title="Unselect all"
|
||||
key="1"
|
||||
v-if="auth.scopes.includes('roms.write')"
|
||||
color="toplayer"
|
||||
elevation="8"
|
||||
icon
|
||||
size="default"
|
||||
@click="emitter?.emit('showDeleteRomDialog', romsStore.selectedRoms)"
|
||||
>
|
||||
<v-icon color="romm-red"> mdi-delete </v-icon>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
title="Refresh metadata"
|
||||
key="2"
|
||||
v-if="auth.scopes.includes('roms.write')"
|
||||
color="toplayer"
|
||||
elevation="8"
|
||||
icon="mdi-magnify-scan"
|
||||
size="default"
|
||||
@click="onScan"
|
||||
icon="mdi-select"
|
||||
class="rounded"
|
||||
:size="35"
|
||||
rounded="0"
|
||||
@click.stop="resetSelection"
|
||||
/>
|
||||
<v-btn
|
||||
title="Download roms"
|
||||
title="Select all"
|
||||
key="2"
|
||||
color="toplayer"
|
||||
elevation="8"
|
||||
icon="mdi-select-all"
|
||||
class="rounded"
|
||||
:size="35"
|
||||
rounded="0"
|
||||
@click.stop="selectAllRoms"
|
||||
/>
|
||||
<v-btn
|
||||
title="Add to favourites"
|
||||
key="3"
|
||||
color="toplayer"
|
||||
elevation="8"
|
||||
icon="mdi-download"
|
||||
size="default"
|
||||
@click="onDownload"
|
||||
icon="mdi-star"
|
||||
class="rounded"
|
||||
:size="35"
|
||||
rounded="0"
|
||||
@click="addToFavourites"
|
||||
/>
|
||||
<v-btn
|
||||
title="Remove from collection"
|
||||
title="Remove from favourites"
|
||||
key="4"
|
||||
color="toplayer"
|
||||
elevation="8"
|
||||
icon="mdi-star-remove-outline"
|
||||
class="rounded"
|
||||
:size="35"
|
||||
rounded="0"
|
||||
@click="removeFromFavourites"
|
||||
/>
|
||||
<v-btn
|
||||
title="Add to collection"
|
||||
key="5"
|
||||
color="toplayer"
|
||||
elevation="8"
|
||||
icon="mdi-bookmark-plus"
|
||||
class="rounded"
|
||||
:size="35"
|
||||
rounded="0"
|
||||
@click="
|
||||
emitter?.emit('showAddToCollectionDialog', romsStore.selectedRoms)
|
||||
"
|
||||
/>
|
||||
<v-btn
|
||||
title="Remove from collection"
|
||||
key="6"
|
||||
color="toplayer"
|
||||
elevation="8"
|
||||
icon="mdi-bookmark-remove-outline"
|
||||
size="default"
|
||||
class="rounded"
|
||||
:size="35"
|
||||
rounded="0"
|
||||
@click="
|
||||
emitter?.emit(
|
||||
'showRemoveFromCollectionDialog',
|
||||
@@ -215,63 +244,81 @@ function onDownload() {
|
||||
"
|
||||
/>
|
||||
<v-btn
|
||||
title="Add to collection"
|
||||
key="5"
|
||||
color="toplayer"
|
||||
elevation="8"
|
||||
icon="mdi-bookmark-plus"
|
||||
size="default"
|
||||
@click="
|
||||
emitter?.emit('showAddToCollectionDialog', romsStore.selectedRoms)
|
||||
"
|
||||
/>
|
||||
<v-btn
|
||||
title="Remove from favourites"
|
||||
key="6"
|
||||
color="toplayer"
|
||||
elevation="8"
|
||||
icon="mdi-star-remove-outline"
|
||||
size="default"
|
||||
@click="removeFromFavourites"
|
||||
/>
|
||||
<v-btn
|
||||
title="Add to favourites"
|
||||
title="Download roms"
|
||||
key="7"
|
||||
color="toplayer"
|
||||
elevation="8"
|
||||
icon="mdi-star"
|
||||
size="default"
|
||||
@click="addToFavourites"
|
||||
icon="mdi-download"
|
||||
class="rounded"
|
||||
:size="35"
|
||||
rounded="0"
|
||||
@click="onDownload"
|
||||
/>
|
||||
<v-btn
|
||||
title="Select all"
|
||||
title="Refresh metadata"
|
||||
key="8"
|
||||
v-if="auth.scopes.includes('roms.write')"
|
||||
color="toplayer"
|
||||
elevation="8"
|
||||
icon="mdi-select-all"
|
||||
size="default"
|
||||
@click.stop="selectAllRoms"
|
||||
icon="mdi-magnify-scan"
|
||||
class="rounded"
|
||||
:size="35"
|
||||
rounded="0"
|
||||
@click="onScan"
|
||||
/>
|
||||
<v-btn
|
||||
title="Unselect all"
|
||||
title="Delete roms"
|
||||
key="9"
|
||||
v-if="auth.scopes.includes('roms.write')"
|
||||
color="toplayer"
|
||||
elevation="8"
|
||||
icon="mdi-select"
|
||||
size="default"
|
||||
@click.stop="resetSelection"
|
||||
/>
|
||||
icon
|
||||
class="rounded"
|
||||
:size="35"
|
||||
rounded="0"
|
||||
@click="emitter?.emit('showDeleteRomDialog', romsStore.selectedRoms)"
|
||||
>
|
||||
<v-icon color="romm-red"> mdi-delete </v-icon>
|
||||
</v-btn>
|
||||
</v-speed-dial>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="text-right sticky-bottom"
|
||||
:class="{
|
||||
'bottom-0': !smAndDown,
|
||||
'bottom-50': smAndDown,
|
||||
}"
|
||||
:style="{
|
||||
'padding-bottom': selectedRoms.length > 0 ? '62px' : '10px',
|
||||
}"
|
||||
>
|
||||
<v-scroll-y-reverse-transition>
|
||||
<v-btn
|
||||
icon
|
||||
v-show="!scrolledToTop"
|
||||
class="border-selected rounded ml-2"
|
||||
color="background"
|
||||
elevation="8"
|
||||
:size="40"
|
||||
rounded="0"
|
||||
@click="scrollToTop()"
|
||||
><v-icon color="primary">mdi-chevron-up</v-icon></v-btn
|
||||
>
|
||||
</v-scroll-y-reverse-transition>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.sticky-bottom {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: 1000;
|
||||
z-index: 9999;
|
||||
pointer-events: none;
|
||||
padding-right: 10px !important;
|
||||
}
|
||||
#multi-select-overlay {
|
||||
padding-bottom: 10px !important;
|
||||
}
|
||||
.sticky-bottom * {
|
||||
pointer-events: auto; /* Re-enables pointer events for all child elements */
|
||||
|
||||
47
frontend/src/components/Gallery/LoadMoreBtn.vue
Normal file
47
frontend/src/components/Gallery/LoadMoreBtn.vue
Normal file
@@ -0,0 +1,47 @@
|
||||
<script setup lang="ts">
|
||||
import storeRoms from "@/stores/roms";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
defineProps<{
|
||||
fetchRoms: () => void;
|
||||
}>();
|
||||
const { t } = useI18n();
|
||||
const romsStore = storeRoms();
|
||||
const { fetchingRoms, fetchTotalRoms, fetchLimit, fetchOffset } =
|
||||
storeToRefs(romsStore);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-row
|
||||
v-if="fetchTotalRoms > fetchLimit"
|
||||
class="justify-center my-2"
|
||||
no-gutters
|
||||
>
|
||||
<v-col cols="6" md="4" lg="2" class="text-center">
|
||||
<template v-if="fetchTotalRoms > fetchOffset">
|
||||
<v-btn
|
||||
@click="fetchRoms"
|
||||
:loading="fetchingRoms"
|
||||
:disabled="fetchingRoms"
|
||||
variant="flat"
|
||||
>
|
||||
<template #loader>
|
||||
<v-progress-circular
|
||||
color="primary"
|
||||
:width="2"
|
||||
:size="20"
|
||||
indeterminate
|
||||
/>
|
||||
</template>
|
||||
{{ t("gallery.load-more") }}
|
||||
</v-btn>
|
||||
</template>
|
||||
<template v-else>
|
||||
<v-alert dense outlined color="surface" class="text-caption pa-2">
|
||||
{{ t("gallery.all-loaded") }}
|
||||
</v-alert>
|
||||
</template>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
@@ -11,7 +11,7 @@ const { currentView } = storeToRefs(galleryViewStore);
|
||||
<template>
|
||||
<v-row no-gutters>
|
||||
<v-col>
|
||||
<v-row v-if="currentView != 2" no-gutters class="mx-1 mt-3">
|
||||
<v-row v-if="currentView != 2" no-gutters class="mx-1 mt-3 mr-14">
|
||||
<v-col
|
||||
v-for="_ in 60"
|
||||
class="pa-1 align-self-end"
|
||||
@@ -25,11 +25,11 @@ const { currentView } = storeToRefs(galleryViewStore);
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-row class="h-100" v-if="currentView == 2" no-gutters>
|
||||
<v-row class="h-100 mr-13" v-if="currentView == 2" no-gutters>
|
||||
<v-col class="h-100 pt-4 pb-2">
|
||||
<v-skeleton-loader
|
||||
class="mx-2"
|
||||
type="table-heading, table-tbody, table-tbody, table-row, table-row, table-row, table-row, table-row"
|
||||
type="table-heading, table-tbody, table-tbody, table-row"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
@@ -5,22 +5,38 @@ import storeCollections from "@/stores/collections";
|
||||
import { views } from "@/utils";
|
||||
import { isNull } from "lodash";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { ref } from "vue";
|
||||
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
const collections = storeCollections();
|
||||
const gridCollections = isNull(localStorage.getItem("settings.gridCollections"))
|
||||
? true
|
||||
: localStorage.getItem("settings.gridCollections") === "true";
|
||||
const storedCollections = localStorage.getItem("settings.gridCollections");
|
||||
const gridCollections = ref(
|
||||
isNull(storedCollections) ? false : storedCollections === "true",
|
||||
);
|
||||
function toggleGridCollections() {
|
||||
gridCollections.value = !gridCollections.value;
|
||||
localStorage.setItem(
|
||||
"settings.gridCollections",
|
||||
gridCollections.value.toString(),
|
||||
);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<r-section icon="mdi-bookmark-box-multiple" :title="t('common.collections')">
|
||||
<template #toolbar-append>
|
||||
<v-btn icon rounded="0" @click="toggleGridCollections"
|
||||
><v-icon>{{
|
||||
gridCollections ? "mdi-view-comfy" : "mdi-view-column"
|
||||
}}</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
<template #content>
|
||||
<v-row
|
||||
class="py-2"
|
||||
:class="{
|
||||
'flex-nowrap overflow-x-auto': !gridCollections,
|
||||
}"
|
||||
class="pa-1"
|
||||
no-gutters
|
||||
>
|
||||
<v-col
|
||||
|
||||
@@ -6,25 +6,41 @@ import { views } from "@/utils";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { isNull } from "lodash";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { ref } from "vue";
|
||||
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
const romsStore = storeRoms();
|
||||
const { continuePlayingRoms } = storeToRefs(romsStore);
|
||||
const gridContinuePlayingRoms = isNull(
|
||||
localStorage.getItem("settings.gridContinuePlayingRoms"),
|
||||
)
|
||||
? false
|
||||
: localStorage.getItem("settings.gridContinuePlayingRoms") === "true";
|
||||
const storedContinuePlaying = localStorage.getItem(
|
||||
"settings.gridContinuePlayingRoms",
|
||||
);
|
||||
const gridContinuePlayingRoms = ref(
|
||||
isNull(storedContinuePlaying) ? false : storedContinuePlaying === "true",
|
||||
);
|
||||
function toggleGridContinuePlaying() {
|
||||
gridContinuePlayingRoms.value = !gridContinuePlayingRoms.value;
|
||||
localStorage.setItem(
|
||||
"settings.gridContinuePlayingRoms",
|
||||
gridContinuePlayingRoms.value.toString(),
|
||||
);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<r-section icon="mdi-play" :title="t('home.continue-playing')">
|
||||
<template #toolbar-append>
|
||||
<v-btn icon rounded="0" @click="toggleGridContinuePlaying"
|
||||
><v-icon>{{
|
||||
gridContinuePlayingRoms ? "mdi-view-comfy" : "mdi-view-column"
|
||||
}}</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
<template #content>
|
||||
<v-row
|
||||
:class="{
|
||||
'flex-nowrap overflow-x-auto': !gridContinuePlayingRoms,
|
||||
'py-2': true,
|
||||
}"
|
||||
class="pa-1"
|
||||
no-gutters
|
||||
>
|
||||
<v-col
|
||||
|
||||
@@ -6,20 +6,39 @@ import { isNull } from "lodash";
|
||||
import { views } from "@/utils";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { ref } from "vue";
|
||||
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
const platformsStore = storePlatforms();
|
||||
const { filledPlatforms } = storeToRefs(platformsStore);
|
||||
const gridPlatforms = isNull(localStorage.getItem("settings.gridPlatforms"))
|
||||
? true
|
||||
: localStorage.getItem("settings.gridPlatforms") === "true";
|
||||
const storedPlatforms = localStorage.getItem("settings.gridPlatforms");
|
||||
const gridPlatforms = ref(
|
||||
isNull(storedPlatforms) ? false : storedPlatforms === "true",
|
||||
);
|
||||
function toggleGridPlatforms() {
|
||||
gridPlatforms.value = !gridPlatforms.value;
|
||||
localStorage.setItem(
|
||||
"settings.gridPlatforms",
|
||||
gridPlatforms.value.toString(),
|
||||
);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<r-section icon="mdi-controller" :title="t('common.platforms')">
|
||||
<template #toolbar-append>
|
||||
<v-btn icon rounded="0" @click="toggleGridPlatforms"
|
||||
><v-icon>{{
|
||||
gridPlatforms ? "mdi-view-comfy" : "mdi-view-column"
|
||||
}}</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
<template #content>
|
||||
<v-row
|
||||
:class="{ 'flex-nowrap overflow-x-auto': !gridPlatforms, 'py-1': true }"
|
||||
:class="{
|
||||
'flex-nowrap overflow-x-auto': !gridPlatforms,
|
||||
}"
|
||||
class="pa-1"
|
||||
no-gutters
|
||||
>
|
||||
<v-col
|
||||
|
||||
@@ -6,23 +6,39 @@ import { views } from "@/utils";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { isNull } from "lodash";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { ref } from "vue";
|
||||
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
const romsStore = storeRoms();
|
||||
const { recentRoms } = storeToRefs(romsStore);
|
||||
const gridRecentRoms = isNull(localStorage.getItem("settings.gridRecentRoms"))
|
||||
? false
|
||||
: localStorage.getItem("settings.gridRecentRoms") === "true";
|
||||
const storedGridRecentRoms = localStorage.getItem("settings.gridRecentRoms");
|
||||
const gridRecentRoms = ref(
|
||||
isNull(storedGridRecentRoms) ? false : storedGridRecentRoms === "true",
|
||||
);
|
||||
function toggleGridRecentRoms() {
|
||||
gridRecentRoms.value = !gridRecentRoms.value;
|
||||
localStorage.setItem(
|
||||
"settings.gridRecentRoms",
|
||||
gridRecentRoms.value.toString(),
|
||||
);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<r-section icon="mdi-shimmer" :title="t('home.recently-added')">
|
||||
<template #toolbar-append>
|
||||
<v-btn icon rounded="0" @click="toggleGridRecentRoms"
|
||||
><v-icon>{{
|
||||
gridRecentRoms ? "mdi-view-comfy" : "mdi-view-column"
|
||||
}}</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
<template #content>
|
||||
<v-row
|
||||
:class="{
|
||||
'flex-nowrap overflow-x-auto': !gridRecentRoms,
|
||||
'py-2': true,
|
||||
}"
|
||||
class="pa-1"
|
||||
no-gutters
|
||||
>
|
||||
<v-col
|
||||
|
||||
@@ -8,10 +8,10 @@ defineProps<{ title: string }>();
|
||||
<template>
|
||||
<r-section icon="mdi-shimmer" :title="title">
|
||||
<template #content>
|
||||
<v-row class="flex-nowrap overflow-x-auto" no-gutters>
|
||||
<v-row class="flex-nowrap overflow-x-auto pa-1" no-gutters>
|
||||
<v-col
|
||||
v-for="_ in 15"
|
||||
class="pa-1 align-self-end"
|
||||
class="align-self-end pa-1"
|
||||
:cols="views[0]['size-cols']"
|
||||
:sm="views[0]['size-sm']"
|
||||
:md="views[0]['size-md']"
|
||||
|
||||
@@ -23,7 +23,7 @@ onBeforeMount(() => {
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<v-card class="ma-2">
|
||||
<v-card>
|
||||
<v-card-text class="pa-1">
|
||||
<v-row no-gutters class="flex-nowrap overflow-x-auto text-center">
|
||||
<v-col>
|
||||
|
||||
@@ -4,6 +4,7 @@ import RSection from "@/components/common/RSection.vue";
|
||||
import storeCollections from "@/stores/collections";
|
||||
import { views } from "@/utils";
|
||||
import { isNull } from "lodash";
|
||||
import { onBeforeUnmount, onMounted, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
// Props
|
||||
@@ -12,6 +13,24 @@ const collections = storeCollections();
|
||||
const gridCollections = isNull(localStorage.getItem("settings.gridCollections"))
|
||||
? true
|
||||
: localStorage.getItem("settings.gridCollections") === "true";
|
||||
const visibleCollections = ref(72);
|
||||
|
||||
function onScroll() {
|
||||
if (
|
||||
window.innerHeight + window.scrollY >= document.body.offsetHeight - 60 &&
|
||||
visibleCollections.value < collections.virtualCollections.length
|
||||
) {
|
||||
visibleCollections.value += 72;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener("scroll", onScroll);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener("scroll", onScroll);
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<r-section
|
||||
@@ -20,12 +39,17 @@ const gridCollections = isNull(localStorage.getItem("settings.gridCollections"))
|
||||
>
|
||||
<template #content>
|
||||
<v-row
|
||||
class="py-2"
|
||||
:class="{ 'flex-nowrap overflow-x-auto': !gridCollections }"
|
||||
:class="{
|
||||
'flex-nowrap overflow-x-auto': !gridCollections,
|
||||
}"
|
||||
class="pa-1"
|
||||
no-gutters
|
||||
>
|
||||
<v-col
|
||||
v-for="collection in collections.virtualCollections"
|
||||
v-for="collection in collections.virtualCollections.slice(
|
||||
0,
|
||||
visibleCollections,
|
||||
)"
|
||||
:key="collection.name"
|
||||
class="pa-1"
|
||||
:cols="views[0]['size-cols']"
|
||||
|
||||
@@ -67,7 +67,7 @@ const runAllTasks = async () => {
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<r-section icon="mdi-pulse" title="Tasks">
|
||||
<r-section icon="mdi-pulse" title="Tasks" class="ma-2">
|
||||
<template #toolbar-append>
|
||||
<v-btn
|
||||
:disabled="runningTasks.value"
|
||||
|
||||
@@ -5,9 +5,11 @@ import storeUsers from "@/stores/users";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import type { Emitter } from "mitt";
|
||||
import { inject, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useDisplay } from "vuetify";
|
||||
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
const user = ref({
|
||||
username: "",
|
||||
password: "",
|
||||
@@ -60,7 +62,7 @@ function closeDialog() {
|
||||
<v-text-field
|
||||
v-model="user.username"
|
||||
variant="outlined"
|
||||
label="username"
|
||||
:label="t('settings.username')"
|
||||
required
|
||||
hide-details
|
||||
clearable
|
||||
@@ -72,7 +74,7 @@ function closeDialog() {
|
||||
<v-text-field
|
||||
v-model="user.password"
|
||||
variant="outlined"
|
||||
label="Password"
|
||||
:label="t('settings.password')"
|
||||
required
|
||||
hide-details
|
||||
clearable
|
||||
@@ -84,7 +86,7 @@ function closeDialog() {
|
||||
<v-text-field
|
||||
v-model="user.email"
|
||||
variant="outlined"
|
||||
label="email"
|
||||
:label="t('settings.email')"
|
||||
required
|
||||
hide-details
|
||||
clearable
|
||||
@@ -97,7 +99,7 @@ function closeDialog() {
|
||||
v-model="user.role"
|
||||
variant="outlined"
|
||||
:items="['viewer', 'editor', 'admin']"
|
||||
label="Role"
|
||||
:label="t('settings.role')"
|
||||
required
|
||||
hide-details
|
||||
/>
|
||||
@@ -109,14 +111,16 @@ function closeDialog() {
|
||||
<template #append>
|
||||
<v-row class="justify-center mb-2" no-gutters>
|
||||
<v-btn-group divided density="compact">
|
||||
<v-btn class="bg-toplayer" @click="closeDialog"> Cancel </v-btn>
|
||||
<v-btn class="bg-toplayer" @click="closeDialog">
|
||||
{{ t("common.cancel") }}
|
||||
</v-btn>
|
||||
<v-btn
|
||||
:disabled="!user.username || !user.password"
|
||||
:variant="!user.username || !user.password ? 'plain' : 'flat'"
|
||||
class="text-romm-green bg-toplayer"
|
||||
@click="createUser()"
|
||||
>
|
||||
Create
|
||||
{{ t("common.create") }}
|
||||
</v-btn>
|
||||
</v-btn-group>
|
||||
</v-row>
|
||||
|
||||
@@ -5,7 +5,7 @@ import storeAuth from "@/stores/auth";
|
||||
import storeUsers from "@/stores/users";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import type { UserItem } from "@/types/user";
|
||||
import { defaultAvatarPath } from "@/utils";
|
||||
import { defaultAvatarPath, getRoleIcon } from "@/utils";
|
||||
import type { Emitter } from "mitt";
|
||||
import { inject, ref } from "vue";
|
||||
import { useDisplay } from "vuetify";
|
||||
@@ -120,7 +120,7 @@ function closeDialog() {
|
||||
<v-text-field
|
||||
v-model="user.email"
|
||||
variant="outlined"
|
||||
label="email"
|
||||
:label="t('settings.email')"
|
||||
required
|
||||
hide-details
|
||||
clearable
|
||||
@@ -136,7 +136,21 @@ function closeDialog() {
|
||||
:label="t('settings.role')"
|
||||
required
|
||||
hide-details
|
||||
/>
|
||||
>
|
||||
<template #selection="{ item }">
|
||||
<v-list-item class="pa-0">
|
||||
<v-icon class="mr-2">{{ getRoleIcon(item.title) }}</v-icon>
|
||||
{{ item.title }}
|
||||
</v-list-item>
|
||||
</template>
|
||||
<template #item="{ item }">
|
||||
<v-list-item :title="item.title">
|
||||
<template #prepend>
|
||||
<v-icon>{{ getRoleIcon(item.title) }}</v-icon>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</template>
|
||||
</v-select>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
|
||||
@@ -6,7 +6,8 @@ import userApi from "@/services/api/user";
|
||||
import storeAuth from "@/stores/auth";
|
||||
import storeUsers, { type User } from "@/stores/users";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import { defaultAvatarPath, formatTimestamp } from "@/utils";
|
||||
import { defaultAvatarPath, formatTimestamp, getRoleIcon } from "@/utils";
|
||||
import { ROUTES } from "@/plugins/router";
|
||||
import type { Emitter } from "mitt";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { inject, onMounted, ref } from "vue";
|
||||
@@ -78,7 +79,7 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<r-section icon="mdi-account" title="Users">
|
||||
<r-section icon="mdi-account" title="Users" class="ma-2">
|
||||
<template #content>
|
||||
<v-text-field
|
||||
v-model="userSearch"
|
||||
@@ -121,6 +122,17 @@ onMounted(() => {
|
||||
/>
|
||||
</v-avatar>
|
||||
</template>
|
||||
<template #item.username="{ item }">
|
||||
<v-list-item class="pa-0" min-width="120px">
|
||||
{{ item.username }}
|
||||
</v-list-item>
|
||||
</template>
|
||||
<template #item.role="{ item }">
|
||||
<v-list-item class="pa-0" min-width="100px">
|
||||
<v-icon class="mr-2">{{ getRoleIcon(item.role) }}</v-icon>
|
||||
{{ item.role }}
|
||||
</v-list-item>
|
||||
</template>
|
||||
<template #item.last_active="{ item }">
|
||||
{{ formatTimestamp(item.last_active) }}
|
||||
</template>
|
||||
|
||||
@@ -1,15 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import storeHeartbeat from "@/stores/heartbeat";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import storeNavigation from "@/stores/navigation";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed } from "vue";
|
||||
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
const { smAndDown } = useDisplay();
|
||||
const heartbeatStore = storeHeartbeat();
|
||||
const navigationStore = storeNavigation();
|
||||
const { mainBarCollapsed } = storeToRefs(navigationStore);
|
||||
// Computed property for dynamic width
|
||||
const computedWidth = computed(() => {
|
||||
return smAndDown.value
|
||||
? "100% !important"
|
||||
: mainBarCollapsed.value
|
||||
? "calc(100% - 60px) !important"
|
||||
: "calc(100% - 100px) !important";
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div :class="{ desktop: !smAndDown }" class="sticky-bottom">
|
||||
<div
|
||||
class="position-fixed"
|
||||
:class="{
|
||||
'bottom-0': !smAndDown,
|
||||
'bottom-50': smAndDown,
|
||||
}"
|
||||
:style="{ width: computedWidth }"
|
||||
>
|
||||
<v-card class="bg-toplayer ma-2 pa-2">
|
||||
<v-row class="align-center justify-center" no-gutters>
|
||||
<v-hover v-slot="{ isHovering, props }">
|
||||
@@ -17,15 +35,15 @@ const heartbeatStore = storeHeartbeat();
|
||||
:href="`https://github.com/rommapp/romm/releases/tag/${heartbeatStore.value.SYSTEM.VERSION}`"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="text-decoration-none text-body-2"
|
||||
class="text-decoration-none text-primary"
|
||||
v-bind="props"
|
||||
:class="{
|
||||
'text-secondary': isHovering,
|
||||
}"
|
||||
>
|
||||
<code class="px-2 py-1 rounded-sm bg-surface text-primary">
|
||||
{{ heartbeatStore.value.SYSTEM.VERSION }}
|
||||
</code>
|
||||
<!-- <code class="px-2 py-1 text-primary"> -->
|
||||
{{ heartbeatStore.value.SYSTEM.VERSION }}
|
||||
<!-- </code> -->
|
||||
</a>
|
||||
</v-hover>
|
||||
<v-icon>mdi-circle-small</v-icon>
|
||||
@@ -60,16 +78,3 @@ const heartbeatStore = storeHeartbeat();
|
||||
</v-card>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.sticky-bottom {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 1000;
|
||||
width: 100%;
|
||||
}
|
||||
.desktop {
|
||||
margin-left: 60px !important;
|
||||
width: calc(100% - 60px) !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -52,7 +52,11 @@ const exclusions = [
|
||||
const editable = ref(false);
|
||||
</script>
|
||||
<template>
|
||||
<r-section icon="mdi-cancel" :title="t('settings.excluded')" class="pb-1">
|
||||
<r-section
|
||||
icon="mdi-cancel"
|
||||
:title="t('settings.excluded')"
|
||||
class="pb-1 ma-2"
|
||||
>
|
||||
<template #toolbar-append>
|
||||
<v-btn
|
||||
v-if="authStore.scopes.includes('platforms.write')"
|
||||
|
||||
@@ -22,7 +22,11 @@ const editable = ref(false);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<r-section icon="mdi-controller" :title="t('settings.platforms-bindings')">
|
||||
<r-section
|
||||
icon="mdi-controller"
|
||||
:title="t('settings.platforms-bindings')"
|
||||
class="ma-2"
|
||||
>
|
||||
<template #toolbar-append>
|
||||
<v-btn
|
||||
v-if="authStore.scopes.includes('platforms.write')"
|
||||
|
||||
@@ -25,6 +25,7 @@ const editable = ref(false);
|
||||
<r-section
|
||||
icon="mdi-gamepad-variant"
|
||||
:title="t('settings.platforms-versions')"
|
||||
class="ma-2"
|
||||
>
|
||||
<template #toolbar-append>
|
||||
<v-btn
|
||||
|
||||
@@ -4,11 +4,13 @@ import RSection from "@/components/common/RSection.vue";
|
||||
import collectionApi from "@/services/api/collection";
|
||||
import storeCollections from "@/stores/collections";
|
||||
import { computed, ref } from "vue";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { isNull } from "lodash";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
const { smAndDown } = useDisplay();
|
||||
const collectionsStore = storeCollections();
|
||||
|
||||
// Initializing refs from localStorage
|
||||
@@ -16,10 +18,6 @@ const storedShowRecentRoms = localStorage.getItem("settings.showRecentRoms");
|
||||
const showRecentRomsRef = ref(
|
||||
isNull(storedShowRecentRoms) ? true : storedShowRecentRoms === "true",
|
||||
);
|
||||
const storedGridRecentRoms = localStorage.getItem("settings.gridRecentRoms");
|
||||
const gridRecentRomsRef = ref(
|
||||
isNull(storedGridRecentRoms) ? false : storedGridRecentRoms === "true",
|
||||
);
|
||||
const storedShowContinuePlaying = localStorage.getItem(
|
||||
"settings.showContinuePlaying",
|
||||
);
|
||||
@@ -28,30 +26,14 @@ const showContinuePlayingRef = ref(
|
||||
? true
|
||||
: storedShowContinuePlaying === "true",
|
||||
);
|
||||
const storedGridContinuePlaying = localStorage.getItem(
|
||||
"settings.gridContinuePlaying",
|
||||
);
|
||||
const gridContinuePlayingRef = ref(
|
||||
isNull(storedGridContinuePlaying)
|
||||
? false
|
||||
: storedGridContinuePlaying === "true",
|
||||
);
|
||||
const storedShowPlatforms = localStorage.getItem("settings.showPlatforms");
|
||||
const showPlatformsRef = ref(
|
||||
isNull(storedShowPlatforms) ? true : storedShowPlatforms === "true",
|
||||
);
|
||||
const storedGridPlatforms = localStorage.getItem("settings.gridPlatforms");
|
||||
const gridPlatformsRef = ref(
|
||||
isNull(storedGridPlatforms) ? true : storedGridPlatforms === "true",
|
||||
);
|
||||
const storedShowCollections = localStorage.getItem("settings.showCollections");
|
||||
const showCollectionsRef = ref(
|
||||
isNull(storedShowCollections) ? true : storedShowCollections === "true",
|
||||
);
|
||||
const storedGridCollections = localStorage.getItem("settings.gridCollections");
|
||||
const gridCollectionsRef = ref(
|
||||
isNull(storedGridCollections) ? true : storedGridCollections === "true",
|
||||
);
|
||||
const storedShowVirtualCollections = localStorage.getItem(
|
||||
"settings.showVirtualCollections",
|
||||
);
|
||||
@@ -95,15 +77,6 @@ const homeOptions = computed(() => [
|
||||
model: showRecentRomsRef,
|
||||
modelTrigger: toggleShowRecentRoms,
|
||||
},
|
||||
{
|
||||
title: t("settings.recently-added-as-grid"),
|
||||
description: t("settings.recently-added-as-grid-desc"),
|
||||
iconEnabled: "mdi-view-comfy",
|
||||
iconDisabled: "mdi-view-column",
|
||||
disabled: !showRecentRomsRef.value,
|
||||
model: gridRecentRomsRef,
|
||||
modelTrigger: toggleGridRecentRoms,
|
||||
},
|
||||
{
|
||||
title: t("settings.show-continue-playing"),
|
||||
description: t("settings.show-continue-playing-desc"),
|
||||
@@ -112,15 +85,6 @@ const homeOptions = computed(() => [
|
||||
model: showContinuePlayingRef,
|
||||
modelTrigger: toggleShowContinuePlaying,
|
||||
},
|
||||
{
|
||||
title: t("settings.continue-playing-as-grid"),
|
||||
description: t("settings.continue-playing-as-grid-desc"),
|
||||
iconEnabled: "mdi-view-comfy",
|
||||
iconDisabled: "mdi-view-column",
|
||||
disabled: !showContinuePlayingRef.value,
|
||||
model: gridContinuePlayingRef,
|
||||
modelTrigger: toggleGridContinuePlaying,
|
||||
},
|
||||
{
|
||||
title: t("settings.show-platforms"),
|
||||
description: t("settings.show-platforms-desc"),
|
||||
@@ -129,15 +93,6 @@ const homeOptions = computed(() => [
|
||||
model: showPlatformsRef,
|
||||
modelTrigger: toggleShowPlatforms,
|
||||
},
|
||||
{
|
||||
title: t("settings.show-platforms-as-grid"),
|
||||
description: t("settings.show-platforms-as-grid-desc"),
|
||||
iconEnabled: "mdi-view-comfy",
|
||||
iconDisabled: "mdi-view-column",
|
||||
disabled: !showPlatformsRef.value,
|
||||
model: gridPlatformsRef,
|
||||
modelTrigger: toggleGridPlatforms,
|
||||
},
|
||||
{
|
||||
title: t("settings.show-collections"),
|
||||
description: t("settings.show-collections-desc"),
|
||||
@@ -146,15 +101,6 @@ const homeOptions = computed(() => [
|
||||
model: showCollectionsRef,
|
||||
modelTrigger: toggleShowCollections,
|
||||
},
|
||||
{
|
||||
title: t("settings.show-collections-as-grid"),
|
||||
description: t("settings.show-collections-as-grid-desc"),
|
||||
iconEnabled: "mdi-view-comfy",
|
||||
iconDisabled: "mdi-view-column",
|
||||
disabled: !showCollectionsRef.value,
|
||||
model: gridCollectionsRef,
|
||||
modelTrigger: toggleGridCollections,
|
||||
},
|
||||
]);
|
||||
|
||||
const galleryOptions = computed(() => [
|
||||
@@ -206,34 +152,18 @@ const toggleShowRecentRoms = (value: boolean) => {
|
||||
showRecentRomsRef.value = value;
|
||||
localStorage.setItem("settings.showRecentRoms", value.toString());
|
||||
};
|
||||
const toggleGridRecentRoms = (value: boolean) => {
|
||||
gridRecentRomsRef.value = value;
|
||||
localStorage.setItem("settings.gridRecentRoms", value.toString());
|
||||
};
|
||||
const toggleShowContinuePlaying = (value: boolean) => {
|
||||
showContinuePlayingRef.value = value;
|
||||
localStorage.setItem("settings.showContinuePlaying", value.toString());
|
||||
};
|
||||
const toggleGridContinuePlaying = (value: boolean) => {
|
||||
gridContinuePlayingRef.value = value;
|
||||
localStorage.setItem("settings.gridContinuePlaying", value.toString());
|
||||
};
|
||||
const toggleShowPlatforms = (value: boolean) => {
|
||||
showPlatformsRef.value = value;
|
||||
localStorage.setItem("settings.showPlatforms", value.toString());
|
||||
};
|
||||
const toggleGridPlatforms = (value: boolean) => {
|
||||
gridPlatformsRef.value = value;
|
||||
localStorage.setItem("settings.gridPlatforms", value.toString());
|
||||
};
|
||||
const toggleShowCollections = (value: boolean) => {
|
||||
showCollectionsRef.value = value;
|
||||
localStorage.setItem("settings.showCollections", value.toString());
|
||||
};
|
||||
const toggleGridCollections = (value: boolean) => {
|
||||
gridCollectionsRef.value = value;
|
||||
localStorage.setItem("settings.gridCollections", value.toString());
|
||||
};
|
||||
const toggleShowVirtualCollections = (value: boolean) => {
|
||||
showVirtualCollectionsRef.value = value;
|
||||
localStorage.setItem("settings.showVirtualCollections", value.toString());
|
||||
@@ -275,7 +205,11 @@ const toggleStatus = (value: boolean) => {
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<r-section icon="mdi-palette-swatch-outline" :title="t('settings.interface')">
|
||||
<r-section
|
||||
icon="mdi-palette-swatch-outline"
|
||||
:title="t('settings.interface')"
|
||||
class="ma-2"
|
||||
>
|
||||
<template #content>
|
||||
<v-chip label variant="text" prepend-icon="mdi-home" class="ml-2 mt-1">{{
|
||||
t("settings.home")
|
||||
@@ -290,7 +224,6 @@ const toggleStatus = (value: boolean) => {
|
||||
>
|
||||
<interface-option
|
||||
class="ma-1"
|
||||
:disabled="option.disabled"
|
||||
:title="option.title"
|
||||
:description="option.description"
|
||||
:icon="
|
||||
@@ -365,6 +298,7 @@ const toggleStatus = (value: boolean) => {
|
||||
]"
|
||||
:label="t('settings.virtual-collection-type')"
|
||||
class="mx-2"
|
||||
:class="{ 'mt-4': smAndDown }"
|
||||
variant="outlined"
|
||||
hide-details
|
||||
:disabled="!showVirtualCollectionsRef"
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useI18n } from "vue-i18n";
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
<template>
|
||||
<r-section icon="mdi-translate" :title="t('settings.language')">
|
||||
<r-section icon="mdi-translate" :title="t('settings.language')" class="ma-2">
|
||||
<template #content>
|
||||
<language-selector />
|
||||
</template>
|
||||
|
||||
@@ -38,7 +38,7 @@ function toggleTheme() {
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<r-section icon="mdi-brush-variant" :title="t('settings.theme')">
|
||||
<r-section icon="mdi-brush-variant" :title="t('settings.theme')" class="ma-2">
|
||||
<template #content>
|
||||
<v-item-group
|
||||
v-model="selectedTheme"
|
||||
|
||||
@@ -147,8 +147,8 @@ const secondSmallCover = computed(() => memoizedCovers.value.small[1]);
|
||||
<template v-else>
|
||||
<v-img
|
||||
cover
|
||||
:src="collection.path_cover_large"
|
||||
:lazy-src="collection.path_cover_small?.toString()"
|
||||
:src="src || collection.path_cover_large"
|
||||
:lazy-src="src || collection.path_cover_small?.toString()"
|
||||
:aspect-ratio="galleryViewStore.defaultAspectRatioCollection"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -62,10 +62,10 @@ const playingStatus = computed(() => {
|
||||
{{ getEmojiForStatus(playingStatus) }}
|
||||
</v-chip>
|
||||
<v-chip
|
||||
v-if="rom.sibling_roms.length > 0 && showSiblings"
|
||||
v-if="rom.siblings.length > 0 && showSiblings"
|
||||
class="translucent-dark mr-1 mt-1"
|
||||
density="compact"
|
||||
>
|
||||
+{{ rom.sibling_roms.length }}
|
||||
+{{ rom.siblings.length }}
|
||||
</v-chip>
|
||||
</template>
|
||||
|
||||
@@ -87,7 +87,6 @@ const noMetadataMatch = computed(() => {
|
||||
async function handleRomUpdate(
|
||||
options: {
|
||||
rom: UpdateRom;
|
||||
renameAsSource?: boolean;
|
||||
removeCover?: boolean;
|
||||
unmatch?: boolean;
|
||||
},
|
||||
@@ -282,11 +281,11 @@ function closeDialog() {
|
||||
<v-btn
|
||||
@click="triggerFileInput('manual-file-input')"
|
||||
class="bg-toplayer ml-3"
|
||||
icon="mdi-upload"
|
||||
icon="mdi-cloud-upload-outline"
|
||||
rounded="0"
|
||||
size="small"
|
||||
>
|
||||
<v-icon size="large">mdi-upload</v-icon>
|
||||
<v-icon size="large">mdi-cloud-upload-outline</v-icon>
|
||||
<v-file-input
|
||||
id="manual-file-input"
|
||||
v-model="manualFiles"
|
||||
|
||||
@@ -31,13 +31,13 @@ const galleryViewStore = storeGalleryView();
|
||||
const platfotmsStore = storePlatforms();
|
||||
const searching = ref(false);
|
||||
const route = useRoute();
|
||||
const searchTerm = ref("");
|
||||
const searchText = ref("");
|
||||
const searchBy = ref("Name");
|
||||
const matchedRoms = ref<SearchRomSchema[]>([]);
|
||||
const filteredMatchedRoms = ref<SearchRomSchema[]>();
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const showSelectSource = ref(false);
|
||||
const renameAsSource = ref(false);
|
||||
const renameFromSource = ref(false);
|
||||
const selectedMatchRom = ref<SearchRomSchema>();
|
||||
const selectedCover = ref<MatchedSource>();
|
||||
const sources = ref<MatchedSource[]>([]);
|
||||
@@ -58,7 +58,7 @@ emitter?.on("showMatchRomDialog", (romToSearch) => {
|
||||
|
||||
// Use name as search term, only when it's matched
|
||||
// Otherwise use the filename without tags and extensions
|
||||
searchTerm.value =
|
||||
searchText.value =
|
||||
romToSearch.igdb_id || romToSearch.moby_id || romToSearch.ss_id
|
||||
? (romToSearch.name ?? "")
|
||||
: romToSearch.fs_name_no_tags;
|
||||
@@ -107,7 +107,7 @@ async function searchRom() {
|
||||
await romApi
|
||||
.searchRom({
|
||||
romId: rom.value.id,
|
||||
searchTerm: searchTerm.value,
|
||||
searchTerm: searchText.value,
|
||||
searchBy: searchBy.value,
|
||||
})
|
||||
.then((response) => {
|
||||
@@ -182,7 +182,7 @@ function confirm() {
|
||||
}
|
||||
|
||||
function toggleRenameAsSource() {
|
||||
renameAsSource.value = !renameAsSource.value;
|
||||
renameFromSource.value = !renameFromSource.value;
|
||||
}
|
||||
|
||||
function backToMatched() {
|
||||
@@ -190,7 +190,7 @@ function backToMatched() {
|
||||
selectedCover.value = undefined;
|
||||
selectedMatchRom.value = undefined;
|
||||
sources.value = [];
|
||||
renameAsSource.value = false;
|
||||
renameFromSource.value = false;
|
||||
}
|
||||
|
||||
async function updateRom(
|
||||
@@ -205,16 +205,23 @@ async function updateRom(
|
||||
// Set the properties from the selected rom
|
||||
rom.value = {
|
||||
...rom.value,
|
||||
fs_name:
|
||||
renameFromSource.value && selectedMatchRom.value
|
||||
? rom.value.fs_name.replace(
|
||||
rom.value.fs_name_no_ext,
|
||||
selectedMatchRom.value.name,
|
||||
)
|
||||
: rom.value.fs_name,
|
||||
igdb_id: selectedRom.igdb_id || null,
|
||||
moby_id: selectedRom.moby_id || null,
|
||||
ss_id: selectedRom.ss_id || null,
|
||||
name: selectedRom.name,
|
||||
slug: selectedRom.slug,
|
||||
summary: selectedRom.summary,
|
||||
name: selectedRom.name || null,
|
||||
slug: selectedRom.slug || null,
|
||||
summary: selectedRom.summary || null,
|
||||
url_cover:
|
||||
urlCover ||
|
||||
selectedRom.ss_url_cover ||
|
||||
selectedRom.igdb_url_cover ||
|
||||
selectedRom.ss_url_cover ||
|
||||
selectedRom.moby_url_cover ||
|
||||
null,
|
||||
};
|
||||
@@ -225,7 +232,7 @@ async function updateRom(
|
||||
}
|
||||
|
||||
await romApi
|
||||
.updateRom({ rom: rom.value, renameAsSource: renameAsSource.value })
|
||||
.updateRom({ rom: rom.value })
|
||||
.then(({ data }) => {
|
||||
emitter?.emit("snackbarShow", {
|
||||
msg: "Rom updated successfully!",
|
||||
@@ -256,7 +263,7 @@ function closeDialog() {
|
||||
showSelectSource.value = false;
|
||||
selectedCover.value = undefined;
|
||||
selectedMatchRom.value = undefined;
|
||||
renameAsSource.value = false;
|
||||
renameFromSource.value = false;
|
||||
}
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -370,9 +377,9 @@ onBeforeUnmount(() => {
|
||||
autofocus
|
||||
id="search-text-field"
|
||||
@keyup.enter="searchRom()"
|
||||
@click:clear="searchTerm = ''"
|
||||
@click:clear="searchText = ''"
|
||||
class="bg-toplayer"
|
||||
v-model="searchTerm"
|
||||
v-model="searchText"
|
||||
:disabled="searching"
|
||||
:label="t('common.search')"
|
||||
hide-details
|
||||
@@ -499,16 +506,16 @@ onBeforeUnmount(() => {
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-col cols="12" v-if="selectedMatchRom">
|
||||
<v-row class="mt-4 text-center" no-gutters>
|
||||
<v-col>
|
||||
<v-chip
|
||||
@click="toggleRenameAsSource"
|
||||
:variant="renameAsSource ? 'flat' : 'outlined'"
|
||||
:color="renameAsSource ? 'primary' : ''"
|
||||
:variant="renameFromSource ? 'flat' : 'outlined'"
|
||||
:color="renameFromSource ? 'primary' : ''"
|
||||
:disabled="selectedCover == undefined"
|
||||
><v-icon class="mr-1">{{
|
||||
selectedCover && renameAsSource
|
||||
selectedCover && renameFromSource
|
||||
? "mdi-checkbox-outline"
|
||||
: "mdi-checkbox-blank-outline"
|
||||
}}</v-icon
|
||||
@@ -516,18 +523,19 @@ onBeforeUnmount(() => {
|
||||
t("rom.rename-file-part1", { source: selectedCover?.name })
|
||||
}}</v-chip
|
||||
>
|
||||
<v-list-item v-if="renameAsSource" class="mt-2">
|
||||
<v-list-item v-if="rom && renameFromSource" class="mt-2">
|
||||
<span>{{ t("rom.rename-file-part2") }}</span>
|
||||
<br />
|
||||
<span>{{ t("rom.rename-file-part3") }}</span
|
||||
><span class="text-primary ml-1"
|
||||
>{{ rom?.fs_name_no_tags }}.{{ rom?.fs_extension }}</span
|
||||
>
|
||||
><span class="text-primary ml-1">{{ rom.fs_name }}</span>
|
||||
<br />
|
||||
<span class="mx-1">{{ t("rom.rename-file-part4") }}</span
|
||||
><span class="text-secondary"
|
||||
>{{ selectedMatchRom?.name }}.{{ rom?.fs_extension }}</span
|
||||
>
|
||||
><span class="text-secondary">{{
|
||||
rom.fs_name.replace(
|
||||
rom.fs_name_no_ext,
|
||||
selectedMatchRom.name,
|
||||
)
|
||||
}}</span>
|
||||
<br />
|
||||
<span class="text-caption font-italic font-weight-bold"
|
||||
>*{{ t("rom.rename-file-part5") }}</span
|
||||
|
||||
@@ -165,7 +165,7 @@ function closeDialog() {
|
||||
<r-dialog
|
||||
@close="closeDialog"
|
||||
v-model="show"
|
||||
icon="mdi-upload"
|
||||
icon="mdi-cloud-upload-outline"
|
||||
:width="mdAndUp ? '50vw' : '95vw'"
|
||||
scroll-content
|
||||
>
|
||||
|
||||
@@ -8,6 +8,7 @@ import storeConfig from "@/stores/config";
|
||||
import storeDownload from "@/stores/download";
|
||||
import storeHeartbeat from "@/stores/heartbeat";
|
||||
import storeAuth from "@/stores/auth";
|
||||
import storeGalleryFilter from "@/stores/galleryFilter";
|
||||
import storeRoms, { type SimpleRom } from "@/stores/roms";
|
||||
import {
|
||||
formatBytes,
|
||||
@@ -19,7 +20,7 @@ import {
|
||||
import { ROUTES } from "@/plugins/router";
|
||||
import { isNull } from "lodash";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, ref } from "vue";
|
||||
import { computed } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
// Props
|
||||
@@ -37,11 +38,13 @@ const showSiblings = isNull(localStorage.getItem("settings.showSiblings"))
|
||||
const router = useRouter();
|
||||
const downloadStore = storeDownload();
|
||||
const romsStore = storeRoms();
|
||||
const { filteredRoms, selectedRoms } = storeToRefs(romsStore);
|
||||
const { filteredRoms, selectedRoms, fetchingRoms, fetchTotalRoms } =
|
||||
storeToRefs(romsStore);
|
||||
const heartbeatStore = storeHeartbeat();
|
||||
const configStore = storeConfig();
|
||||
const { config } = storeToRefs(configStore);
|
||||
const auth = storeAuth();
|
||||
const galleryFilterStore = storeGalleryFilter();
|
||||
|
||||
const HEADERS = [
|
||||
{
|
||||
@@ -53,7 +56,7 @@ const HEADERS = [
|
||||
{
|
||||
title: "Size",
|
||||
align: "start",
|
||||
sortable: true,
|
||||
sortable: false,
|
||||
key: "fs_size_bytes",
|
||||
},
|
||||
{
|
||||
@@ -133,12 +136,26 @@ function updateSelectedRom(rom: SimpleRom) {
|
||||
romsStore.addToSelection(rom);
|
||||
}
|
||||
}
|
||||
|
||||
type SortBy = { key: keyof SimpleRom; order: "asc" | "desc" }[];
|
||||
|
||||
function updateOptions({ sortBy }: { sortBy: SortBy }) {
|
||||
if (!sortBy[0]) return;
|
||||
const { key, order } = sortBy[0];
|
||||
|
||||
romsStore.resetPagination();
|
||||
romsStore.setOrderBy(key);
|
||||
romsStore.setOrderDir(order);
|
||||
romsStore.fetchRoms(galleryFilterStore, false);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-data-table-virtual
|
||||
<v-data-table-server
|
||||
@update:options="updateOptions"
|
||||
@click:row="rowClick"
|
||||
:item-value="(item: SimpleRom) => item"
|
||||
:items-per-page="72"
|
||||
:items-length="fetchTotalRoms"
|
||||
:items="filteredRoms"
|
||||
:headers="HEADERS"
|
||||
v-model="selectedRomIDs"
|
||||
@@ -146,8 +163,11 @@ function updateSelectedRom(rom: SimpleRom) {
|
||||
fixed-header
|
||||
fixed-footer
|
||||
hide-default-footer
|
||||
:loading="fetchingRoms"
|
||||
:disable-sort="fetchingRoms"
|
||||
hover
|
||||
class="rounded"
|
||||
density="compact"
|
||||
class="rounded bg-background"
|
||||
>
|
||||
<template #header.data-table-select>
|
||||
<v-checkbox-btn
|
||||
@@ -168,16 +188,12 @@ function updateSelectedRom(rom: SimpleRom) {
|
||||
/>
|
||||
</template>
|
||||
<template #item.name="{ item }">
|
||||
<v-list-item
|
||||
:min-width="400"
|
||||
class="px-0 py-2"
|
||||
:to="{ name: ROUTES.ROM, params: { rom: item.id } }"
|
||||
>
|
||||
<v-list-item :min-width="400" class="px-0 py-2">
|
||||
<template #prepend>
|
||||
<platform-icon
|
||||
v-if="showPlatformIcon"
|
||||
class="mr-4"
|
||||
:size="30"
|
||||
v-if="showPlatformIcon"
|
||||
:slug="item.platform_slug"
|
||||
/>
|
||||
<r-avatar-rom :rom="item" />
|
||||
@@ -192,11 +208,11 @@ function updateSelectedRom(rom: SimpleRom) {
|
||||
</v-row>
|
||||
<template #append>
|
||||
<v-chip
|
||||
v-if="item.sibling_roms.length > 0 && showSiblings"
|
||||
v-if="item.siblings.length > 0 && showSiblings"
|
||||
class="translucent-dark ml-4"
|
||||
size="x-small"
|
||||
>
|
||||
<span class="text-caption">+{{ item.sibling_roms.length }}</span>
|
||||
<span class="text-caption">+{{ item.siblings.length }}</span>
|
||||
</v-chip>
|
||||
</template>
|
||||
</v-list-item>
|
||||
@@ -215,20 +231,23 @@ function updateSelectedRom(rom: SimpleRom) {
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template #item.first_release_date="{ item }">
|
||||
<span v-if="item.first_release_date" class="text-no-wrap">{{
|
||||
new Date(item.first_release_date).toLocaleDateString("en-US", {
|
||||
day: "2-digit",
|
||||
month: "short",
|
||||
year: "numeric",
|
||||
})
|
||||
<span v-if="item.metadatum.first_release_date" class="text-no-wrap">{{
|
||||
new Date(item.metadatum.first_release_date).toLocaleDateString(
|
||||
"en-US",
|
||||
{
|
||||
day: "2-digit",
|
||||
month: "short",
|
||||
year: "numeric",
|
||||
},
|
||||
)
|
||||
}}</span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template #item.average_rating="{ item }">
|
||||
<span v-if="item.average_rating" class="text-no-wrap">{{
|
||||
<span v-if="item.metadatum.average_rating" class="text-no-wrap">{{
|
||||
Intl.NumberFormat("en-US", {
|
||||
maximumSignificantDigits: 3,
|
||||
}).format(item.average_rating)
|
||||
}).format(item.metadatum.average_rating)
|
||||
}}</span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
@@ -262,11 +281,11 @@ function updateSelectedRom(rom: SimpleRom) {
|
||||
>
|
||||
{{ regionToEmoji(region) }}
|
||||
</span>
|
||||
<spa class="reglang-super">
|
||||
<span class="reglang-super">
|
||||
{{
|
||||
item.regions.length > 3 ? ` +${item.regions.length - 3}` : ""
|
||||
}}
|
||||
</spa>
|
||||
</span>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
@@ -276,6 +295,7 @@ function updateSelectedRom(rom: SimpleRom) {
|
||||
<v-btn
|
||||
:disabled="downloadStore.value.includes(item.id)"
|
||||
download
|
||||
variant="text"
|
||||
size="small"
|
||||
@click.stop="romApi.downloadRom({ rom: item })"
|
||||
>
|
||||
@@ -283,6 +303,7 @@ function updateSelectedRom(rom: SimpleRom) {
|
||||
</v-btn>
|
||||
<v-btn
|
||||
v-if="checkIfEJSEmulationSupported(item.platform_slug)"
|
||||
variant="text"
|
||||
size="small"
|
||||
@click.stop="
|
||||
$router.push({
|
||||
@@ -295,6 +316,7 @@ function updateSelectedRom(rom: SimpleRom) {
|
||||
</v-btn>
|
||||
<v-btn
|
||||
v-if="checkIfRuffleEmulationSupported(item.platform_slug)"
|
||||
variant="text"
|
||||
size="small"
|
||||
@click.stop="
|
||||
$router.push({
|
||||
@@ -314,7 +336,7 @@ function updateSelectedRom(rom: SimpleRom) {
|
||||
location="bottom"
|
||||
>
|
||||
<template #activator="{ props }">
|
||||
<v-btn v-bind="props" size="small">
|
||||
<v-btn v-bind="props" variant="text" size="small">
|
||||
<v-icon>mdi-dots-vertical</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
@@ -322,7 +344,7 @@ function updateSelectedRom(rom: SimpleRom) {
|
||||
</v-menu>
|
||||
</v-btn-group>
|
||||
</template>
|
||||
</v-data-table-virtual>
|
||||
</v-data-table-server>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import storeNavigation from "@/stores/navigation";
|
||||
import storePlatforms from "@/stores/platforms";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useDisplay } from "vuetify";
|
||||
|
||||
// Props
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
block?: boolean;
|
||||
height?: string;
|
||||
rounded?: boolean;
|
||||
withTag?: boolean;
|
||||
}>(),
|
||||
{
|
||||
block: false,
|
||||
height: "",
|
||||
rounded: false,
|
||||
withTag: false,
|
||||
},
|
||||
);
|
||||
const navigationStore = storeNavigation();
|
||||
@@ -21,12 +25,42 @@ const { activeCollectionsDrawer } = storeToRefs(navigationStore);
|
||||
icon
|
||||
:block="block"
|
||||
variant="flat"
|
||||
rounded="0"
|
||||
:height="height"
|
||||
class="py-4 bg-background custom-btn"
|
||||
:class="{ rounded: rounded }"
|
||||
:color="activeCollectionsDrawer ? 'toplayer' : 'background'"
|
||||
@click="navigationStore.switchActiveCollectionsDrawer"
|
||||
class="rounded my-1"
|
||||
><v-icon :color="$route.name == 'collection' ? 'primary' : ''"
|
||||
>mdi-bookmark-box-multiple</v-icon
|
||||
></v-btn
|
||||
>
|
||||
<div class="icon-container">
|
||||
<v-icon :color="$route.name == 'collection' ? 'primary' : ''"
|
||||
>mdi-bookmark-box-multiple</v-icon
|
||||
>
|
||||
<v-expand-transition>
|
||||
<span
|
||||
v-if="withTag"
|
||||
class="text-caption"
|
||||
:class="{ 'text-primary': $route.name == 'collection' }"
|
||||
>Collections</span
|
||||
>
|
||||
</v-expand-transition>
|
||||
</div>
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.custom-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.icon-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.icon-container span {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -6,7 +6,7 @@ import storeNavigation from "@/stores/navigation";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import type { Emitter } from "mitt";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { inject } from "vue";
|
||||
import { inject, onBeforeUnmount, onMounted, ref } from "vue";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { isNull } from "lodash";
|
||||
@@ -14,12 +14,13 @@ import { isNull } from "lodash";
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
const navigationStore = storeNavigation();
|
||||
const { smAndDown, mdAndUp } = useDisplay();
|
||||
const { mdAndUp, smAndDown } = useDisplay();
|
||||
const collectionsStore = storeCollections();
|
||||
const { filteredCollections, filteredVirtualCollections, searchText } =
|
||||
const { filteredCollections, filteredVirtualCollections, filterText } =
|
||||
storeToRefs(collectionsStore);
|
||||
const { activeCollectionsDrawer } = storeToRefs(navigationStore);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const visibleVirtualCollections = ref(72);
|
||||
|
||||
const showVirtualCollections = isNull(
|
||||
localStorage.getItem("settings.showVirtualCollections"),
|
||||
@@ -32,14 +33,44 @@ async function addCollection() {
|
||||
}
|
||||
|
||||
function clear() {
|
||||
searchText.value = "";
|
||||
filterText.value = "";
|
||||
}
|
||||
|
||||
function onScroll() {
|
||||
const collectionsDrawer = document.querySelector(
|
||||
"#collections-drawer .v-navigation-drawer__content",
|
||||
);
|
||||
if (!collectionsDrawer) return;
|
||||
|
||||
const rect = collectionsDrawer.getBoundingClientRect();
|
||||
if (
|
||||
collectionsDrawer.scrollTop + rect.height >=
|
||||
collectionsDrawer.scrollHeight - 60 &&
|
||||
visibleVirtualCollections.value < filteredVirtualCollections.value.length
|
||||
) {
|
||||
visibleVirtualCollections.value += 72;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const collectionsDrawer = document.querySelector(
|
||||
"#collections-drawer .v-navigation-drawer__content",
|
||||
);
|
||||
collectionsDrawer?.addEventListener("scroll", onScroll);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
const collectionsDrawer = document.querySelector(
|
||||
"#collections-drawer .v-navigation-drawer__content",
|
||||
);
|
||||
collectionsDrawer?.removeEventListener("scroll", onScroll);
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<v-navigation-drawer
|
||||
id="collections-drawer"
|
||||
mobile
|
||||
rounded
|
||||
:location="smAndDown ? 'top' : 'left'"
|
||||
:location="smAndDown ? 'bottom' : 'left'"
|
||||
@update:model-value="clear"
|
||||
width="500"
|
||||
v-model="activeCollectionsDrawer"
|
||||
@@ -47,15 +78,16 @@ function clear() {
|
||||
'my-2': mdAndUp || (smAndDown && activeCollectionsDrawer),
|
||||
'ml-2': (mdAndUp && activeCollectionsDrawer) || smAndDown,
|
||||
'drawer-mobile': smAndDown,
|
||||
'drawer-desktop': !smAndDown,
|
||||
'unset-height': mdAndUp,
|
||||
'max-h-70': smAndDown && activeCollectionsDrawer,
|
||||
}"
|
||||
class="bg-surface pa-1"
|
||||
:style="mdAndUp ? 'height: unset' : ''"
|
||||
rounded
|
||||
:border="0"
|
||||
>
|
||||
<template #prepend>
|
||||
<v-text-field
|
||||
v-model="searchText"
|
||||
v-model="filterText"
|
||||
prepend-inner-icon="mdi-filter-outline"
|
||||
clearable
|
||||
hide-details
|
||||
@@ -81,7 +113,10 @@ function clear() {
|
||||
t("common.virtual-collections").toUpperCase()
|
||||
}}</v-list-subheader>
|
||||
<collection-list-item
|
||||
v-for="collection in filteredVirtualCollections"
|
||||
v-for="collection in filteredVirtualCollections.slice(
|
||||
0,
|
||||
visibleVirtualCollections,
|
||||
)"
|
||||
:collection="collection"
|
||||
with-link
|
||||
/>
|
||||
@@ -103,8 +138,3 @@ function clear() {
|
||||
|
||||
<create-collection-dialog />
|
||||
</template>
|
||||
<style scoped>
|
||||
.drawer-mobile {
|
||||
width: calc(100% - 16px) !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import RIsotipo from "@/components/common/RIsotipo.vue";
|
||||
import { ROUTES } from "@/plugins/router";
|
||||
import { useDisplay } from "vuetify";
|
||||
import RIsotipo from "@/components/common/RIsotipo.vue";
|
||||
|
||||
// Props
|
||||
const { smAndDown } = useDisplay();
|
||||
</script>
|
||||
<template>
|
||||
<r-isotipo :to="{ name: ROUTES.HOME }" class="cursor-pointer" :size="40" />
|
||||
<router-link :to="{ name: ROUTES.HOME }" class="cursor-pointer">
|
||||
<r-isotipo :size="smAndDown ? 35 : 40" />
|
||||
</router-link>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.v-avatar {
|
||||
transition: filter 0.15s ease-in-out;
|
||||
}
|
||||
.v-avatar:hover,
|
||||
.v-avatar.active {
|
||||
filter: drop-shadow(0px 0px 2px rgba(var(--v-theme-primary)));
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
<
|
||||
<script setup lang="ts">
|
||||
import HomeBtn from "@/components/common/Navigation/HomeBtn.vue";
|
||||
import PlatformsBtn from "@/components/common/Navigation/PlatformsBtn.vue";
|
||||
@@ -11,49 +10,64 @@ import PlatformsDrawer from "@/components/common/Navigation/PlatformsDrawer.vue"
|
||||
import CollectionsDrawer from "@/components/common/Navigation/CollectionsDrawer.vue";
|
||||
import UploadRomDialog from "@/components/common/Game/Dialog/UploadRom.vue";
|
||||
import SettingsDrawer from "@/components/common/Navigation/SettingsDrawer.vue";
|
||||
import storeNavigation from "@/stores/navigation";
|
||||
import navigationStore from "@/stores/navigation";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useDisplay } from "vuetify";
|
||||
|
||||
// Props
|
||||
const { smAndDown } = useDisplay();
|
||||
const navigationStore = storeNavigation();
|
||||
const storeNavigation = navigationStore();
|
||||
const { mainBarCollapsed } = storeToRefs(storeNavigation);
|
||||
|
||||
// Functions
|
||||
function collapse() {
|
||||
mainBarCollapsed.value = !mainBarCollapsed.value;
|
||||
localStorage.setItem(
|
||||
"settings.mainBarCollapsed",
|
||||
mainBarCollapsed.value.toString(),
|
||||
);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<!-- Mobile app bar -->
|
||||
<v-app-bar
|
||||
v-if="smAndDown"
|
||||
elevation="0"
|
||||
class="bg-background justify-center px-1"
|
||||
mode="shift"
|
||||
height="55"
|
||||
app
|
||||
fixed
|
||||
left
|
||||
>
|
||||
<template #prepend>
|
||||
<home-btn />
|
||||
</template>
|
||||
<!-- Mobile top bar -->
|
||||
<template v-if="smAndDown">
|
||||
<v-app-bar
|
||||
elevation="0"
|
||||
class="bg-background justify-center px-1"
|
||||
height="50"
|
||||
fixed
|
||||
left
|
||||
>
|
||||
<template #prepend>
|
||||
<home-btn class="ml-1" />
|
||||
</template>
|
||||
|
||||
<search-btn />
|
||||
<platforms-btn />
|
||||
<collections-btn />
|
||||
<v-divider opacity="0" class="mx-3" vertical />
|
||||
<upload-btn />
|
||||
<scan-btn />
|
||||
<template #append>
|
||||
<upload-btn class="mr-2" />
|
||||
<user-btn class="mr-1" />
|
||||
</template>
|
||||
</v-app-bar>
|
||||
|
||||
<template #append>
|
||||
<user-btn />
|
||||
</template>
|
||||
</v-app-bar>
|
||||
<!-- Mobile bottom bar -->
|
||||
<v-bottom-navigation
|
||||
grow
|
||||
elevation="0"
|
||||
class="bg-background align-center justify-center"
|
||||
>
|
||||
<search-btn withTag />
|
||||
<platforms-btn withTag />
|
||||
<collections-btn withTag />
|
||||
<scan-btn withTag />
|
||||
</v-bottom-navigation>
|
||||
</template>
|
||||
|
||||
<!-- Desktop app bar -->
|
||||
<!-- Desktop app side bar -->
|
||||
<v-navigation-drawer
|
||||
v-else
|
||||
permanent
|
||||
rail
|
||||
rail-width="60"
|
||||
class="bg-background pa-1"
|
||||
:rail-width="mainBarCollapsed ? 60 : 100"
|
||||
class="bg-background px-2 py-1"
|
||||
:border="0"
|
||||
>
|
||||
<template #prepend>
|
||||
@@ -62,13 +76,29 @@ const navigationStore = storeNavigation();
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
<v-divider opacity="0" class="my-4" />
|
||||
<search-btn block />
|
||||
<platforms-btn block />
|
||||
<collections-btn block />
|
||||
<v-divider opacity="0" class="my-3" />
|
||||
<upload-btn block />
|
||||
<scan-btn block />
|
||||
<v-row no-gutters class="justify-center mt-10">
|
||||
<v-divider class="mx-2" />
|
||||
<v-btn
|
||||
@click="collapse"
|
||||
id="collapseBtn"
|
||||
size="small"
|
||||
density="comfortable"
|
||||
variant="flat"
|
||||
rounded
|
||||
icon
|
||||
><v-icon>{{
|
||||
mainBarCollapsed
|
||||
? "mdi-chevron-double-right"
|
||||
: "mdi-chevron-double-left"
|
||||
}}</v-icon></v-btn
|
||||
>
|
||||
</v-row>
|
||||
<search-btn :withTag="!mainBarCollapsed" rounded class="mt-4" block />
|
||||
<platforms-btn :withTag="!mainBarCollapsed" rounded class="mt-2" block />
|
||||
<collections-btn :withTag="!mainBarCollapsed" rounded class="mt-2" block />
|
||||
<scan-btn :withTag="!mainBarCollapsed" rounded class="mt-2" block />
|
||||
<upload-btn :withTag="!mainBarCollapsed" rounded class="mt-2" block />
|
||||
|
||||
<template #append>
|
||||
<v-row no-gutters class="my-2 justify-center">
|
||||
<user-btn />
|
||||
@@ -81,4 +111,8 @@ const navigationStore = storeNavigation();
|
||||
<upload-rom-dialog />
|
||||
<settings-drawer />
|
||||
</template>
|
||||
>
|
||||
<style scoped>
|
||||
#collapseBtn {
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,12 +2,19 @@
|
||||
import storeNavigation from "@/stores/navigation";
|
||||
import { storeToRefs } from "pinia";
|
||||
|
||||
// Props
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
block?: boolean;
|
||||
height?: string;
|
||||
rounded?: boolean;
|
||||
withTag?: boolean;
|
||||
}>(),
|
||||
{
|
||||
block: false,
|
||||
height: "",
|
||||
rounded: false,
|
||||
withTag: false,
|
||||
},
|
||||
);
|
||||
const navigationStore = storeNavigation();
|
||||
@@ -15,14 +22,46 @@ const { activePlatformsDrawer } = storeToRefs(navigationStore);
|
||||
</script>
|
||||
<template>
|
||||
<v-btn
|
||||
icon
|
||||
:block="block"
|
||||
variant="flat"
|
||||
rounded="1"
|
||||
:height="height"
|
||||
class="py-4 bg-background custom-btn"
|
||||
:class="{ rounded: rounded }"
|
||||
:color="activePlatformsDrawer ? 'toplayer' : 'background'"
|
||||
icon
|
||||
@click="navigationStore.switchActivePlatformsDrawer"
|
||||
class="rounded my-1"
|
||||
><v-icon :color="$route.name == 'platform' ? 'primary' : ''"
|
||||
>mdi-controller</v-icon
|
||||
></v-btn
|
||||
>
|
||||
<div class="icon-container">
|
||||
<v-icon :color="$route.name == 'platform' ? 'primary' : ''"
|
||||
>mdi-controller</v-icon
|
||||
>
|
||||
<v-expand-transition>
|
||||
<span
|
||||
v-if="withTag"
|
||||
class="text-caption"
|
||||
:class="{ 'text-primary': $route.name == 'platform' }"
|
||||
>Platforms</span
|
||||
>
|
||||
</v-expand-transition>
|
||||
</div>
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.custom-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.icon-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.icon-container span {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -9,20 +9,19 @@ import { useI18n } from "vue-i18n";
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
const navigationStore = storeNavigation();
|
||||
const { smAndDown, mdAndUp } = useDisplay();
|
||||
const { mdAndUp, smAndDown } = useDisplay();
|
||||
const platformsStore = storePlatforms();
|
||||
const { filteredPlatforms, searchText } = storeToRefs(platformsStore);
|
||||
const { filteredPlatforms, filterText } = storeToRefs(platformsStore);
|
||||
const { activePlatformsDrawer } = storeToRefs(navigationStore);
|
||||
|
||||
function clear() {
|
||||
searchText.value = "";
|
||||
filterText.value = "";
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<v-navigation-drawer
|
||||
mobile
|
||||
rounded
|
||||
:location="smAndDown ? 'top' : 'left'"
|
||||
:location="smAndDown ? 'bottom' : 'left'"
|
||||
@update:model-value="clear"
|
||||
width="500"
|
||||
v-model="activePlatformsDrawer"
|
||||
@@ -30,15 +29,16 @@ function clear() {
|
||||
'my-2': mdAndUp || (smAndDown && activePlatformsDrawer),
|
||||
'ml-2': (mdAndUp && activePlatformsDrawer) || smAndDown,
|
||||
'drawer-mobile': smAndDown,
|
||||
'drawer-desktop': !smAndDown,
|
||||
'unset-height': mdAndUp,
|
||||
'max-h-70': smAndDown && activePlatformsDrawer,
|
||||
}"
|
||||
class="bg-surface pa-1"
|
||||
:style="mdAndUp ? 'height: unset' : ''"
|
||||
rounded
|
||||
:border="0"
|
||||
>
|
||||
<template #prepend>
|
||||
<v-text-field
|
||||
v-model="searchText"
|
||||
v-model="filterText"
|
||||
prepend-inner-icon="mdi-filter-outline"
|
||||
clearable
|
||||
hide-details
|
||||
@@ -59,8 +59,3 @@ function clear() {
|
||||
</v-list>
|
||||
</v-navigation-drawer>
|
||||
</template>
|
||||
<style scoped>
|
||||
.drawer-mobile {
|
||||
width: calc(100% - 16px) !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -14,14 +14,19 @@ import { inject, onBeforeUnmount } from "vue";
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
block?: boolean;
|
||||
height?: string;
|
||||
rounded?: boolean;
|
||||
withTag?: boolean;
|
||||
}>(),
|
||||
{
|
||||
block: false,
|
||||
height: "",
|
||||
rounded: false,
|
||||
withTag: false,
|
||||
},
|
||||
);
|
||||
const navigationStore = storeNavigation();
|
||||
const auth = storeAuth();
|
||||
const galleryFilter = storeGalleryFilter();
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const scanningStore = storeScanning();
|
||||
const { scanningPlatforms, scanning } = storeToRefs(scanningStore);
|
||||
@@ -55,7 +60,6 @@ socket.on("scan:scanning_rom", (rom: SimpleRom) => {
|
||||
romsStore.addToRecent(rom);
|
||||
if (romsStore.currentPlatform?.id === rom.platform_id) {
|
||||
romsStore.add([rom]);
|
||||
romsStore.setFiltered(romsStore.allRoms, galleryFilter);
|
||||
}
|
||||
|
||||
let scannedPlatform = scanningPlatforms.value.find(
|
||||
@@ -111,23 +115,52 @@ onBeforeUnmount(() => {
|
||||
<template>
|
||||
<v-btn
|
||||
v-if="auth.scopes.includes('platforms.write')"
|
||||
icon
|
||||
:block="block"
|
||||
variant="flat"
|
||||
rounded="0"
|
||||
icon
|
||||
color="background"
|
||||
class="rounded my-1"
|
||||
:height="height"
|
||||
:class="{ rounded: rounded }"
|
||||
class="py-4 bg-background custom-btn"
|
||||
@click="navigationStore.goScan"
|
||||
>
|
||||
<v-progress-circular
|
||||
v-if="scanning"
|
||||
color="primary"
|
||||
:width="2"
|
||||
:size="20"
|
||||
indeterminate
|
||||
/>
|
||||
<v-icon v-else :color="$route.name == 'scan' ? 'primary' : ''"
|
||||
>mdi-magnify-scan</v-icon
|
||||
>
|
||||
<div class="icon-container">
|
||||
<v-progress-circular
|
||||
v-if="scanning"
|
||||
color="primary"
|
||||
:width="2"
|
||||
:size="20"
|
||||
indeterminate
|
||||
/>
|
||||
<v-icon v-else :color="$route.name == 'scan' ? 'primary' : ''"
|
||||
>mdi-magnify-scan</v-icon
|
||||
>
|
||||
<v-expand-transition>
|
||||
<span
|
||||
v-if="withTag"
|
||||
class="text-caption"
|
||||
:class="{ 'text-primary': $route.name == 'scan' }"
|
||||
>Scan</span
|
||||
>
|
||||
</v-expand-transition>
|
||||
</div>
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.custom-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.icon-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.icon-container span {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,24 +1,64 @@
|
||||
<script setup lang="ts">
|
||||
import type { Events } from "@/types/emitter";
|
||||
import storeNavigation from "@/stores/navigation";
|
||||
import type { Emitter } from "mitt";
|
||||
import { inject } from "vue";
|
||||
|
||||
// Props
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
block?: boolean;
|
||||
height?: string;
|
||||
rounded?: boolean;
|
||||
withTag?: boolean;
|
||||
}>(),
|
||||
{
|
||||
block: false,
|
||||
height: "",
|
||||
rounded: false,
|
||||
withTag: false,
|
||||
},
|
||||
);
|
||||
const navigationStore = storeNavigation();
|
||||
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
</script>
|
||||
<template>
|
||||
<v-btn
|
||||
icon
|
||||
:block="block"
|
||||
variant="flat"
|
||||
rounded="0"
|
||||
color="background"
|
||||
class="rounded my-1"
|
||||
:height="height"
|
||||
:class="{ rounded: rounded }"
|
||||
class="py-4 bg-background custom-btn"
|
||||
@click="navigationStore.goSearch"
|
||||
>
|
||||
<v-icon :color="$route.name == 'search' ? 'primary' : ''"
|
||||
>mdi-magnify</v-icon
|
||||
>
|
||||
<div class="icon-container">
|
||||
<v-icon :color="$route.name == 'search' ? 'primary' : ''"
|
||||
>mdi-magnify</v-icon
|
||||
>
|
||||
<v-expand-transition>
|
||||
<span
|
||||
v-if="withTag"
|
||||
class="text-caption"
|
||||
:class="{ 'text-primary': $route.name == 'search' }"
|
||||
>Search</span
|
||||
>
|
||||
</v-expand-transition>
|
||||
</div>
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.custom-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.icon-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.icon-container span {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -5,7 +5,7 @@ import { refetchCSRFToken } from "@/services/api/index";
|
||||
import storeAuth from "@/stores/auth";
|
||||
import storeNavigation from "@/stores/navigation";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import { defaultAvatarPath } from "@/utils";
|
||||
import { defaultAvatarPath, getRoleIcon } from "@/utils";
|
||||
import { ROUTES } from "@/plugins/router";
|
||||
import type { Emitter } from "mitt";
|
||||
import { storeToRefs, getActivePinia, type StateTree } from "pinia";
|
||||
@@ -22,7 +22,7 @@ const auth = storeAuth();
|
||||
const { user, scopes } = storeToRefs(auth);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const { activeSettingsDrawer } = storeToRefs(navigationStore);
|
||||
const { smAndDown } = useDisplay();
|
||||
const { smAndDown, mdAndUp } = useDisplay();
|
||||
|
||||
// Functions
|
||||
async function logout() {
|
||||
@@ -54,12 +54,11 @@ async function logout() {
|
||||
width="450"
|
||||
v-model="activeSettingsDrawer"
|
||||
:class="{
|
||||
'mx-2': smAndDown || activeSettingsDrawer,
|
||||
'my-2': !smAndDown || activeSettingsDrawer,
|
||||
'my-2': mdAndUp || (smAndDown && activeSettingsDrawer),
|
||||
'ml-2': (mdAndUp && activeSettingsDrawer) || smAndDown,
|
||||
'drawer-mobile': smAndDown,
|
||||
}"
|
||||
class="bg-surface pa-1"
|
||||
style="height: unset"
|
||||
class="bg-surface pa-1 unset-height"
|
||||
rounded
|
||||
:border="0"
|
||||
>
|
||||
@@ -76,18 +75,20 @@ async function logout() {
|
||||
>
|
||||
</v-img>
|
||||
</v-list-img>
|
||||
<v-list-item
|
||||
:title="user?.username"
|
||||
:subtitle="user?.role"
|
||||
class="mb-1 text-shadow text-white"
|
||||
>
|
||||
<v-list-item :title="user?.username" class="mb-1 text-shadow text-white">
|
||||
<template #subtitle>
|
||||
<v-list-item-subtitle v-if="user?.role">
|
||||
{{ user.role }}
|
||||
<v-icon size="x-small">{{ getRoleIcon(user.role) }}</v-icon>
|
||||
</v-list-item-subtitle>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
<v-list class="py-1 px-0">
|
||||
<v-list-item
|
||||
v-if="scopes.includes('me.write')"
|
||||
rounded
|
||||
@click="emitter?.emit('showEditUserDialog', user as UserSchema)"
|
||||
:to="{ name: ROUTES.USER_PROFILE, params: { user: user?.id } }"
|
||||
append-icon="mdi-account"
|
||||
>{{ t("common.profile") }}</v-list-item
|
||||
>
|
||||
@@ -126,8 +127,3 @@ async function logout() {
|
||||
</template>
|
||||
</v-navigation-drawer>
|
||||
</template>
|
||||
<style scoped>
|
||||
.drawer-mobile {
|
||||
width: calc(100% - 16px) !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -5,17 +5,58 @@ import type { Emitter } from "mitt";
|
||||
import { inject } from "vue";
|
||||
|
||||
// Props
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
block?: boolean;
|
||||
height?: string;
|
||||
rounded?: boolean;
|
||||
withTag?: boolean;
|
||||
}>(),
|
||||
{
|
||||
block: false,
|
||||
height: "",
|
||||
rounded: false,
|
||||
withTag: false,
|
||||
},
|
||||
);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const auth = storeAuth();
|
||||
</script>
|
||||
<template>
|
||||
<v-btn
|
||||
v-if="auth.scopes.includes('roms.write')"
|
||||
icon="mdi-upload"
|
||||
icon
|
||||
:block="block"
|
||||
variant="flat"
|
||||
rounded="0"
|
||||
color="background"
|
||||
class="rounded my-1"
|
||||
:height="height"
|
||||
:class="{ rounded: rounded }"
|
||||
class="bg-background custom-btn"
|
||||
@click="emitter?.emit('showUploadRomDialog', null)"
|
||||
/>
|
||||
>
|
||||
<div class="icon-container">
|
||||
<v-icon>mdi-cloud-upload-outline</v-icon>
|
||||
<v-expand-transition>
|
||||
<span v-if="withTag" class="text-caption">Upload</span>
|
||||
</v-expand-transition>
|
||||
</div>
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.custom-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.icon-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.icon-container span {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -3,17 +3,19 @@ import storeAuth from "@/stores/auth";
|
||||
import storeNavigation from "@/stores/navigation";
|
||||
import { defaultAvatarPath } from "@/utils";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useDisplay } from "vuetify";
|
||||
|
||||
// Props
|
||||
const navigationStore = storeNavigation();
|
||||
const auth = storeAuth();
|
||||
const { user } = storeToRefs(auth);
|
||||
const { smAndDown } = useDisplay();
|
||||
</script>
|
||||
<template>
|
||||
<v-avatar
|
||||
@click="navigationStore.switchActiveSettingsDrawer"
|
||||
class="pointer"
|
||||
:size="40"
|
||||
:size="smAndDown ? 35 : 40"
|
||||
:class="{ active: navigationStore.activeSettingsDrawer }"
|
||||
>
|
||||
<v-img
|
||||
|
||||
@@ -74,7 +74,7 @@ onMounted(async () => {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: 1000;
|
||||
z-index: 9999;
|
||||
pointer-events: none;
|
||||
}
|
||||
.sticky-bottom * {
|
||||
|
||||
@@ -38,7 +38,7 @@ function closeDialog() {
|
||||
<template #text>
|
||||
<v-row class="d-flex align-center px-2">
|
||||
<v-icon :icon="snackbarStatus.icon" class="mx-2" />
|
||||
<span class="text-subtitle-1 font-weight-bold">
|
||||
<span class="text-subtitle-1 font-weight-regular">
|
||||
{{ snackbarStatus.msg }}
|
||||
</span>
|
||||
</v-row>
|
||||
|
||||
@@ -62,7 +62,7 @@ onMounted(() => {
|
||||
scroll-strategy="block"
|
||||
no-click-animation
|
||||
persistent
|
||||
z-index="10000"
|
||||
z-index="9999"
|
||||
:scrim="theme.name.value == 'dark' ? 'black' : 'white'"
|
||||
>
|
||||
<v-card :min-height="height" :max-height="height">
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import type { RouteLocationRaw } from "vue-router";
|
||||
|
||||
withDefaults(defineProps<{ size?: number; to?: RouteLocationRaw }>(), {
|
||||
withDefaults(defineProps<{ size?: number }>(), {
|
||||
size: 40,
|
||||
});
|
||||
|
||||
@@ -29,17 +28,17 @@ const randomLogo = ref<string>(getRandomLogo());
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-btn
|
||||
:to="to"
|
||||
icon
|
||||
variant="flat"
|
||||
color="background"
|
||||
class="rounded-50"
|
||||
:height="size"
|
||||
:width="size"
|
||||
>
|
||||
<v-avatar :size="size">
|
||||
<img :src="`/assets/logos/${randomLogo}`" alt="Romm Logo" :width="size" />
|
||||
</v-avatar>
|
||||
</v-btn>
|
||||
<v-avatar :size="size">
|
||||
<img :src="`/assets/logos/${randomLogo}`" alt="Romm Logo" :width="size" />
|
||||
</v-avatar>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.v-avatar {
|
||||
transition: filter 0.15s ease-in-out;
|
||||
}
|
||||
.v-avatar:hover,
|
||||
.v-avatar.active {
|
||||
filter: drop-shadow(0px 0px 2px rgba(var(--v-theme-primary)));
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -18,7 +18,7 @@ withDefaults(
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-card class="ma-2 bg-background" elevation="0">
|
||||
<v-card class="bg-background" elevation="0">
|
||||
<v-toolbar class="bg-toplayer px-1" density="compact">
|
||||
<v-toolbar-title class="text-button">
|
||||
<v-icon :color="iconColor" class="mr-2">{{ icon }}</v-icon>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user