Merge pull request #184 from zurdi15/refactor/code_base

Refactor/code base
This commit is contained in:
Zurdi
2023-04-17 13:13:47 +02:00
committed by GitHub
32 changed files with 320 additions and 291 deletions

View File

@@ -1,11 +1,11 @@
<div align="center">
<h1 style="padding:20px;"><img src="romm.svg" height="220px" width="auto" alt="RomM Logo"></h1>
<img alt="GitHub" src="https://img.shields.io/github/license/zurdi15/romm">
<img alt="GitHub release (latest SemVer)" src="https://img.shields.io/github/v/release/zurdi15/romm">
<img alt="GitHub Workflow Status (with branch)" src="https://img.shields.io/github/actions/workflow/status/zurdi15/romm/image.yml?branch=master">
<img alt="GitHub" src="https://img.shields.io/github/license/zurdi15/romm?style=flat-square">
<img alt="GitHub release (latest SemVer)" src="https://img.shields.io/github/v/release/zurdi15/romm?style=flat-square">
<img alt="GitHub Workflow Status (with branch)" src="https://img.shields.io/github/actions/workflow/status/zurdi15/romm/image.yml?style=flat-square&branch=master">
<a href="https://hub.docker.com/r/zurdi15/romm">
<img alt="Docker Pulls" src="https://img.shields.io/docker/pulls/zurdi15/romm">
<img alt="Docker Image Size (latest by date)" src="https://img.shields.io/docker/image-size/zurdi15/romm">
<img alt="Docker Pulls" src="https://img.shields.io/docker/pulls/zurdi15/romm?style=flat-square">
<img alt="Docker Image Size (latest by date)" src="https://img.shields.io/docker/image-size/zurdi15/romm?style=flat-square">
</div>
<br>
<div align="center">

View File

@@ -1,4 +1,4 @@
"""empty message
"""add size units
Revision ID: 1.7.1
Revises: 1.6.3

View File

@@ -0,0 +1,32 @@
"""empty message
Revision ID: 1.7.2
Revises: 1.7.1
Create Date: 2023-04-17 12:03:19.163501
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '1.7.2'
down_revision = '1.7.1'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('roms', sa.Column('p_name', sa.String(length=150), nullable=True))
op.add_column('roms', sa.Column('url_cover', sa.Text(), nullable=True))
op.alter_column('roms', 'name', new_column_name='r_name')
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('roms', 'p_name')
op.drop_column('roms', 'url_cover')
op.alter_column('roms', 'r_name', new_column_name='name')
# ### end Alembic commands ###

View File

@@ -0,0 +1,12 @@
from fastapi import APIRouter
from handler import dbh
router = APIRouter()
@router.get("/platforms")
def platforms() -> dict:
"""Returns platforms data"""
return {'data': dbh.get_platforms()}

View File

@@ -0,0 +1,56 @@
from fastapi import APIRouter, Request
from logger.logger import log, COLORS
from handler import igdbh, dbh
from utils import fs
router = APIRouter()
@router.get("/platforms/{p_slug}/roms/{file_name}")
def rom(p_slug: str, file_name: str) -> dict:
"""Returns one rom data of the desired platform"""
return {'data': dbh.get_rom(p_slug, file_name)}
@router.get("/platforms/{p_slug}/roms")
def roms(p_slug: str) -> dict:
"""Returns all roms of the desired platform"""
return {'data': dbh.get_roms(p_slug)}
@router.patch("/platforms/{p_slug}/roms")
async def updateRom(req: Request, p_slug: str) -> dict:
"""Updates rom details"""
data: dict = await req.json()
rom: dict = data['rom']
updatedRom: dict = data['updatedRom']
log.info(f"Updating {COLORS['orange']}{updatedRom['file_name']}{COLORS['reset']} details")
updatedRom.update(igdbh.get_rom_details(updatedRom['file_name'], rom['p_igdb_id'], updatedRom['r_igdb_id']))
updatedRom.update(fs.get_cover_details(True, p_slug, updatedRom['file_name'], updatedRom['url_cover']))
updatedRom['p_igdb_id'] = rom['p_igdb_id']
updatedRom['p_slug'] = p_slug
updatedRom['file_path'] = rom['file_path']
updatedRom['file_size'] = rom['file_size']
updatedRom['multi'] = rom['multi']
updatedRom['file_extension'] = fs.get_file_extension(updatedRom)
reg, rev, other_tags = fs.parse_tags(updatedRom['file_name'])
updatedRom.update({'region': reg, 'revision': rev, 'tags': other_tags})
fs.rename_rom(p_slug, rom['file_name'], updatedRom['file_name'])
dbh.update_rom(p_slug, rom['file_name'], updatedRom)
return {'data': updatedRom}
@router.delete("/platforms/{p_slug}/roms/{file_name}")
def remove_rom(p_slug: str, file_name: str, filesystem: bool=False) -> dict:
"""Detele rom from filesystem and database"""
log.info(f"Deleting {file_name} from database")
dbh.delete_rom(p_slug, file_name)
if filesystem:
log.info(f"Removing {file_name} from filesystem")
fs.remove_rom(p_slug, file_name)
return {'msg': 'success'}

View File

@@ -0,0 +1,37 @@
from fastapi import APIRouter
import emoji
import json
from logger.logger import log, COLORS
from utils import fs, fastapi
from handler import dbh
from models.platform import Platform
router = APIRouter()
@router.get("/scan")
def scan(platforms: str, full_scan: bool=False) -> dict:
"""Scan platforms and roms and write them in database."""
log.info(emoji.emojize(":magnifying_glass_tilted_right: Scanning "))
fs.store_default_resources()
fs_platforms: list[str] = fs.get_platforms()
platforms: list[str] = json.loads(platforms) if len(json.loads(platforms)) > 0 else fs_platforms
log.info(f"Platforms to be scanned: {', '.join(platforms)}")
for p_slug in platforms:
log.info(emoji.emojize(f":video_game: {p_slug} {COLORS['reset']}"))
platform: Platform = fastapi.scan_platform(p_slug)
if p_slug != str(platform): log.info(f"Identified as {COLORS['blue']}{platform}{COLORS['reset']}")
dbh.add_platform(platform)
log.info(f"Searching new roms")
roms: list[dict] = fs.get_roms(p_slug, full_scan)
for rom in roms:
log.info(f"Getting {COLORS['orange']}{rom['file_name']}{COLORS['reset']} details")
if rom['multi']: [log.info(f"\t - {COLORS['orange_i']}{file}{COLORS['reset']}") for file in rom['files']]
rom = fastapi.scan_rom(platform, rom)
dbh.add_rom(rom)
log.info(emoji.emojize(":wastebasket: Purging database"))
[dbh.purge_roms(p_slug, fs.get_roms(p_slug, True)) for p_slug in platforms]
dbh.purge_platforms(fs_platforms)
return {'msg': 'success'}

View File

@@ -0,0 +1,24 @@
from fastapi import APIRouter, Request
import emoji
from logger.logger import log, COLORS
from handler import igdbh
router = APIRouter()
@router.put("/search/roms/igdb")
async def search_rom_igdb(req: Request, igdb_id: str = None) -> dict:
"""Get all the roms matched from igdb."""
data: dict = await req.json()
log.info(emoji.emojize(":magnifying_glass_tilted_right: IGDB Searching"))
if igdb_id:
log.info(f"Searching by id: {igdb_id}")
matched_roms = igdbh.get_matched_roms_by_id(igdb_id)
else:
log.info(emoji.emojize(f":video_game: {data['rom']['p_slug']}: {COLORS['orange']}{data['rom']['file_name']}{COLORS['reset']}"))
matched_roms = igdbh.get_matched_roms(data['rom']['file_name'], data['rom']['p_igdb_id'], data['rom']['p_slug'])
log.info("Results:")
[log.info(f"\t - {COLORS['blue']}{rom['r_name']}{COLORS['reset']}") for rom in matched_roms]
return {'data': matched_roms}

View File

@@ -48,8 +48,8 @@ class IGDBHandler():
def get_rom_details(self, file_name: str, p_igdb_id: int, r_igdb_id_search: str) -> dict:
file_name_no_tags: str = re.sub('[\(\[].*?[\)\]]', '', file_name.split('.')[0])
r_igdb_id: str = ""
slug: str = ""
name: str = ""
r_slug: str = ""
r_name: str = ""
summary: str = ""
url_cover: str = ""
@@ -57,8 +57,8 @@ class IGDBHandler():
res_details: dict = requests.post("https://api.igdb.com/v4/games/", headers=self.headers,
data=f"fields id, slug, name, summary; where id={r_igdb_id_search};").json()[0]
r_igdb_id = res_details['id']
slug = res_details['slug']
name = res_details['name']
r_slug = res_details['slug']
r_name = res_details['name']
try:
summary = res_details['summary']
except KeyError:
@@ -72,8 +72,8 @@ class IGDBHandler():
res_details: dict = requests.post("https://api.igdb.com/v4/games/", headers=self.headers,
data=f"search \"{search_term}\";fields id, slug, name, summary; where platforms=[{p_igdb_id}] & category=0;").json()[0]
r_igdb_id = res_details['id']
slug = res_details['slug']
name = res_details['name']
r_slug = res_details['slug']
r_name = res_details['name']
try:
summary = res_details['summary']
except KeyError:
@@ -83,8 +83,8 @@ class IGDBHandler():
res_details: dict = requests.post("https://api.igdb.com/v4/games/", headers=self.headers,
data=f"search \"{search_term}\";fields name, id, slug, summary; where platforms=[{p_igdb_id}] & category=10;").json()[0]
r_igdb_id = res_details['id']
slug = res_details['slug']
name = res_details['name']
r_slug = res_details['slug']
r_name = res_details['name']
try:
summary = res_details['summary']
except KeyError:
@@ -94,8 +94,8 @@ class IGDBHandler():
res_details: dict = requests.post("https://api.igdb.com/v4/games/", headers=self.headers,
data=f"search \"{search_term}\";fields name, id, slug, summary; where platforms=[{p_igdb_id}];").json()[0]
r_igdb_id = res_details['id']
slug = res_details['slug']
name = res_details['name']
r_slug = res_details['slug']
r_name = res_details['name']
try:
summary = res_details['summary']
except KeyError:
@@ -108,9 +108,9 @@ class IGDBHandler():
data=f"fields url; where game={r_igdb_id};").json()[0]
url_cover: str = f"https:{res_details['url']}"
except IndexError:
log.warning(f"{name} cover not found in IGDB")
if not name: name = file_name_no_tags
return (r_igdb_id, file_name_no_tags, slug, name, summary, url_cover)
log.warning(f"{r_name} cover not found in IGDB")
if not r_name: r_name = file_name_no_tags
return {'r_igdb_id': r_igdb_id, 'file_name_no_tags': file_name_no_tags, 'r_slug': r_slug, 'r_name': r_name, 'summary': summary, 'url_cover': url_cover}
@check_twitch_token
@@ -129,23 +129,28 @@ class IGDBHandler():
rom['url_cover'] = DEFAULT_URL_COVER_L
rom['r_igdb_id'] = rom.pop('id')
rom['r_slug'] = rom.pop('slug')
rom['r_name'] = rom.pop('name')
else:
log.warning(f"{p_slug} is not supported!")
return matched_roms
def get_matched_roms_by_id(self, igdb_id: str) -> list:
matched_roms: list[dict] = []
matched_roms: list = requests.post("https://api.igdb.com/v4/games/", headers=self.headers,
data=f"fields name, id, slug, summary; where id={igdb_id};").json()
for rom in matched_roms:
try:
res_details: dict = requests.post("https://api.igdb.com/v4/covers/", headers=self.headers,
data=f"fields url; where game={rom['id']};").json()[0]
rom['url_cover'] = f"https:{res_details['url']}".replace('t_thumb', f't_cover_big')
except IndexError:
rom['url_cover'] = DEFAULT_URL_COVER_L
rom['r_igdb_id'] = rom.pop('id')
rom['r_slug'] = rom.pop('slug')
res: list = requests.post("https://api.igdb.com/v4/games/", headers=self.headers,
data=f"fields name, id, slug, summary; where id={igdb_id};")
if res.status_code == 200:
matched_roms = res.json()
for rom in matched_roms:
try:
res_details: dict = requests.post("https://api.igdb.com/v4/covers/", headers=self.headers,
data=f"fields url; where game={rom['id']};").json()[0]
rom['url_cover'] = f"https:{res_details['url']}".replace('t_thumb', f't_cover_big')
except IndexError:
rom['url_cover'] = DEFAULT_URL_COVER_L
rom['r_igdb_id'] = rom.pop('id')
rom['r_slug'] = rom.pop('slug')
rom['r_name'] = rom.pop('name')
else:
matched_roms: list = []
return matched_roms

View File

@@ -1,17 +1,24 @@
from fastapi import FastAPI, Request
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
import json
import emoji
from logger.logger import log, COLORS
from handler import igdbh, dbh
from config import DEV_PORT, DEV_HOST
from models.platform import Platform
from utils import fs, fastapi
from utils import fastapi
from endpoints import scan, search, platform, rom
app = FastAPI()
fastapi.allow_cors(app)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(scan.router)
app.include_router(search.router)
app.include_router(platform.router)
app.include_router(rom.router)
@app.on_event("startup")
@@ -20,116 +27,5 @@ def startup() -> None:
pass
@app.get("/scan")
def scan(platforms: str, full_scan: bool=False) -> dict:
"""Scan platforms and roms and write them in database."""
log.info(emoji.emojize(":magnifying_glass_tilted_right: Scanning "))
fs.store_default_resources()
fs_platforms: list[str] = fs.get_platforms()
platforms: list[str] = json.loads(platforms) if len(json.loads(platforms)) > 0 else fs_platforms
log.info(f"Platforms to be scanned: {', '.join(platforms)}")
for p_slug in platforms:
log.info(emoji.emojize(f":video_game: {p_slug} {COLORS['reset']}"))
platform: Platform = fastapi.scan_platform(p_slug)
if p_slug != str(platform): log.info(f"Identified as {COLORS['blue']}{platform}{COLORS['reset']}")
dbh.add_platform(platform)
log.info(f"Searching new roms")
roms: list[dict] = fs.get_roms(p_slug, full_scan)
for rom in roms:
log.info(f"Getting {COLORS['orange']}{rom['file_name']}{COLORS['reset']} details")
if rom['multi']: [log.info(f"\t - {COLORS['orange_i']}{file}{COLORS['reset']}") for file in rom['files']]
rom = fastapi.scan_rom(platform, rom)
dbh.add_rom(rom)
log.info(emoji.emojize(":wastebasket: Purging database"))
[dbh.purge_roms(p_slug, fs.get_roms(p_slug, True)) for p_slug in platforms]
dbh.purge_platforms(fs_platforms)
return {'msg': 'success'}
@app.get("/platforms")
def platforms() -> dict:
"""Returns platforms data"""
return {'data': dbh.get_platforms()}
@app.get("/platforms/{p_slug}/roms/{file_name}")
def rom(p_slug: str, file_name: str) -> dict:
"""Returns one rom data of the desired platform"""
return {'data': {
**dbh.get_rom(p_slug, file_name).__dict__,
'platform': dbh.get_platform(p_slug)
}}
@app.get("/platforms/{p_slug}/roms")
def roms(p_slug: str) -> dict:
"""Returns all roms of the desired platform"""
return {'data': dbh.get_roms(p_slug)}
@app.patch("/platforms/{p_slug}/roms")
async def updateRom(req: Request, p_slug: str) -> dict:
"""Updates rom details"""
data: dict = await req.json()
rom: dict = data['rom']
updatedRom: dict = data['updatedRom']
log.info(f"Updating {COLORS['orange']}{updatedRom['file_name']}{COLORS['reset']} details")
r_igdb_id, file_name_no_tags, r_slug, r_name, summary, url_cover = igdbh.get_rom_details(updatedRom['file_name'], rom['p_igdb_id'], updatedRom['r_igdb_id'])
path_cover_s, path_cover_l, has_cover = fs.get_cover_details(True, p_slug, updatedRom['file_name'], url_cover)
updatedRom['file_name_no_tags'] = file_name_no_tags
updatedRom['r_igdb_id'] = r_igdb_id
updatedRom['p_igdb_id'] = rom['p_igdb_id']
updatedRom['r_slug'] = r_slug
updatedRom['p_slug'] = p_slug
updatedRom['name'] = r_name
updatedRom['summary'] = summary
updatedRom['path_cover_s'] = path_cover_s
updatedRom['path_cover_l'] = path_cover_l
updatedRom['has_cover'] = has_cover
updatedRom['file_path'] = rom['file_path']
updatedRom['file_size'] = rom['file_size']
updatedRom['file_extension'] = updatedRom['file_name'].split('.')[-1] if '.' in updatedRom['file_name'] else ""
reg, rev, other_tags = fs.parse_tags(updatedRom['file_name'])
updatedRom.update({'region': reg, 'revision': rev, 'tags': other_tags})
if 'url_cover' in updatedRom.keys(): del updatedRom['url_cover']
fs.rename_rom(p_slug, rom['file_name'], updatedRom['file_name'])
dbh.update_rom(p_slug, rom['file_name'], updatedRom)
return {'data': updatedRom}
@app.delete("/platforms/{p_slug}/roms/{file_name}")
def remove_rom(p_slug: str, file_name: str, filesystem: bool=False) -> dict:
"""Detele rom from filesystem and database"""
log.info(f"Deleting {file_name} from database")
dbh.delete_rom(p_slug, file_name)
if filesystem:
log.info(f"Removing {file_name} from filesystem")
fs.remove_rom(p_slug, file_name)
return {'msg': 'success'}
@app.put("/search/roms/igdb")
async def search_rom_igdb(req: Request, igdb_id: str=None) -> dict:
"""Get all the roms matched from igdb."""
data: dict = await req.json()
log.info(emoji.emojize(":magnifying_glass_tilted_right: IGDB Searching"))
if igdb_id:
log.info(f"Searching by id: {igdb_id}")
matched_roms = igdbh.get_matched_roms_by_id(igdb_id)
else:
log.info(emoji.emojize(f":video_game: {data['rom']['p_slug']}: {COLORS['orange']}{data['rom']['file_name']}{COLORS['reset']}"))
matched_roms = igdbh.get_matched_roms(data['rom']['file_name'], data['rom']['p_igdb_id'], data['rom']['p_slug'])
log.info("Results:")
[log.info(f"\t - {COLORS['blue']}{rom['name']}{COLORS['reset']}") for rom in matched_roms]
return {'data': matched_roms}
if __name__ == '__main__':
uvicorn.run("main:app", host=DEV_HOST, port=DEV_PORT, reload=True)

View File

@@ -12,6 +12,7 @@ class Rom(BaseModel):
p_sgdb_id = Column(String(length=10), default="")
p_slug = Column(String(length=50), primary_key=True)
p_name = Column(String(length=150))
file_name = Column(String(length=450), primary_key=True)
file_name_no_tags = Column(String(length=450), default="")
@@ -20,7 +21,7 @@ class Rom(BaseModel):
file_size = Column(Float, default=0.0)
file_size_units = Column(String(length=10), default="")
name = Column(String(length=350), default="")
r_name = Column(String(length=350), default="")
r_slug = Column(String(length=100), default="")
summary = Column(Text, default="")
@@ -28,6 +29,7 @@ class Rom(BaseModel):
path_cover_s = Column(Text, default=DEFAULT_PATH_COVER_S)
path_cover_l = Column(Text, default=DEFAULT_PATH_COVER_L)
has_cover = Column(Boolean, default=False)
url_cover = Column(Text, default=DEFAULT_PATH_COVER_L)
region = Column(String(20), default="")
revision = Column(String(20), default="")

View File

@@ -1,21 +1,7 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from handler import igdbh
from utils import fs
from models.platform import Platform
from models.rom import Rom
from logger.logger import log
def allow_cors(app: FastAPI) -> None:
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
def scan_platform(p_slug: str) -> Platform:
@@ -33,17 +19,10 @@ def scan_platform(p_slug: str) -> Platform:
def scan_rom(platform: Platform, rom: dict, r_igbd_id_search: str = '', overwrite: bool = False) -> None:
r_igdb_id, file_name_no_tags, r_slug, r_name, summary, url_cover = igdbh.get_rom_details(rom['file_name'], platform.igdb_id, r_igbd_id_search)
path_cover_s, path_cover_l, has_cover = fs.get_cover_details(overwrite, platform.slug, rom['file_name'], url_cover)
rom['file_name_no_tags'] = file_name_no_tags
rom['r_igdb_id'] = r_igdb_id
rom.update(igdbh.get_rom_details(rom['file_name'], platform.igdb_id, r_igbd_id_search))
rom.update(fs.get_cover_details(overwrite, platform.slug, rom['file_name'], rom['url_cover']))
rom['p_igdb_id'] = platform.igdb_id
rom['r_slug'] = r_slug
rom['p_slug'] = platform.slug
rom['name'] = r_name
rom['summary'] = summary
rom['path_cover_s'] = path_cover_s
rom['path_cover_l'] = path_cover_l
rom['has_cover'] = has_cover
rom['p_name'] = platform.name
rom = Rom(**rom)
return rom

View File

@@ -127,8 +127,8 @@ def parse_tags(file_name: str) -> tuple:
return reg, rev, other_tags
def _get_file_extension(rom: dict) -> str:
return rom['file'].split('.')[-1] if not rom['multi'] else ''
def get_file_extension(rom: dict) -> str:
return rom['file_name'].split('.')[-1] if not rom['multi'] else ''
def _get_rom_files(multi: bool, rom: str, roms_path: str) -> list[str]:
@@ -166,18 +166,18 @@ def get_roms(p_slug: str, full_scan: bool, only_amount: bool = False) -> list[di
fs_single_roms: list[str] = list(os.walk(roms_path))[0][2]
fs_multi_roms: list[str] = list(os.walk(roms_path))[0][1]
fs_roms: list[dict] = [{'multi': False, 'file': rom} for rom in _exclude_single_roms(fs_single_roms)] + \
[{'multi': True, 'file': rom} for rom in _exclude_multi_roms(fs_multi_roms)]
fs_roms: list[dict] = [{'multi': False, 'file_name': rom} for rom in _exclude_single_roms(fs_single_roms)] + \
[{'multi': True, 'file_name': rom} for rom in _exclude_multi_roms(fs_multi_roms)]
if only_amount: return len(fs_roms)
for rom in fs_roms:
if rom['file'] in db_roms and not full_scan and not rom['multi']: continue
reg, rev, other_tags = parse_tags(rom['file'])
file_extension: str = _get_file_extension(rom)
files: list = _get_rom_files(rom['multi'], rom['file'], roms_path)
file_size, file_size_units = _get_file_size(rom['multi'], rom['file'], files, roms_path)
roms.append({'file_name': rom['file'], 'file_path': roms_path, 'multi': rom['multi'],
if rom['file_name'] in db_roms and not full_scan and not rom['multi']: continue
reg, rev, other_tags = parse_tags(rom['file_name'])
file_extension: str = get_file_extension(rom)
files: list = _get_rom_files(rom['multi'], rom['file_name'], roms_path)
file_size, file_size_units = _get_file_size(rom['multi'], rom['file_name'], files, roms_path)
roms.append({'file_name': rom['file_name'], 'file_path': roms_path, 'multi': rom['multi'],
'files': files, 'file_size': file_size, 'file_size_units': file_size_units, 'file_extension': file_extension,
'region': reg, 'revision': rev, 'tags': other_tags})
return roms
@@ -278,4 +278,4 @@ def get_cover_details(overwrite: bool, p_slug: str, file_name: str, url_cover: s
if _cover_exists(p_slug, file_name, 'l'):
path_cover_l = _get_cover_path(p_slug, file_name, 'l')
has_cover = 1
return path_cover_s, path_cover_l, has_cover
return {'path_cover_s': path_cover_s, 'path_cover_l': path_cover_l, 'has_cover': has_cover}

View File

@@ -1 +1 @@
VITE_ROMM_VERSION=1.7.1
VITE_ROMM_VERSION=1.7.2

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/public/favicon.svg" />
<link rel="icon" href="/favicon.ico"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>RomM</title>
</head>

View File

@@ -1,12 +1,12 @@
{
"name": "romm",
"version": "1.7.1",
"version": "1.7.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "romm",
"version": "1.7.1",
"version": "1.7.2",
"dependencies": {
"@mdi/font": "7.0.96",
"axios": "^1.3.4",

View File

@@ -1,6 +1,6 @@
{
"name": "romm",
"version": "1.7.1",
"version": "1.7.2",
"private": true,
"scripts": {
"dev": "vite --host",

BIN
frontend/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -58,25 +58,4 @@ emitter.on('refresh', () => { refresh.value = !refresh.value })
background-color: #808080;
border-radius: 5px;
}
rommDark {
primary: #161b22;
secondary: #a452fe;
background: #0d1117;
notification: #0d1117;
surface: #161b22;
tooltip: #161b22;
chip: #161b22;
rommAccent1: #a452fe;
rommAccent2: #9a00ea;
rommAccent3: #7b00e1;
rommAccent4: #702bcf;
rommAccent5: #3808a4;
rommWhite: #fefdfe;
rommBlack: #000000;
rommRed: #da3633;
}
</style>

View File

@@ -23,9 +23,9 @@ async function goHome(){
<template>
<v-app-bar class="elevation-3">
<v-app-bar>
<v-progress-linear color="secondary" :active="scanning" :indeterminate="true" absolute/>
<v-progress-linear color="rommAccent1" :active="scanning" :indeterminate="true" absolute/>
<v-avatar size="100" class="ml-3 home-btn hidden-sm-and-down" @click="goHome()"><v-img src="/assets/romm_complete.svg"></v-img></v-avatar>

View File

@@ -18,7 +18,7 @@ const forceImgReload = Date.now()
cover>
<template v-slot:placeholder>
<div class="d-flex align-center justify-center fill-height">
<v-progress-circular color="secondary" indeterminate/>
<v-progress-circular color="rommAccent1" indeterminate/>
</div>
</template>
<v-expand-transition>

View File

@@ -18,7 +18,7 @@ const emitter = inject('emitter')
:key="rom.file_name"
class="pa-2">
<v-row class="text-subtitle-2">
<v-col md="3" lg="3"><p>{{ rom.name }}</p></v-col>
<v-col md="3" lg="3"><p>{{ rom.r_name }}</p></v-col>
<v-col md="3" lg="4" class="hidden-sm-and-down"><p>{{ rom.file_name }}</p></v-col>
<v-col class="hidden-sm-and-down"><p>{{ rom.p_slug }}</p></v-col>
<v-col class="hidden-sm-and-down"><p>{{ rom.file_size }} {{ rom.file_size_units }}</p></v-col>

View File

@@ -12,7 +12,7 @@ const props = defineProps(['platform', 'rail'])
<v-avatar :rounded="0"><v-img :src="'/assets/platforms/'+platform.slug+'.ico'"></v-img></v-avatar>
</template>
<template v-slot:append>
<v-chip class="ml-4" size="small">{{ platform.n_roms }}</v-chip>
<v-chip class="ml-4 bg-chip" size="small">{{ platform.n_roms }}</v-chip>
</template>
</v-list-item>
</template>

View File

@@ -12,6 +12,7 @@ const emitter = inject('emitter')
<v-btn
@click="emitter.emit('togglePlatformsRail')"
rounded="0"
color="primary"
block>
<v-icon v-if="rail">mdi-arrow-collapse-right</v-icon>
<v-icon v-if="!rail">mdi-arrow-collapse-left</v-icon>

View File

@@ -3,7 +3,7 @@ import { ref, inject } from "vue"
import SettingsHeader from '@/components/SettingsDrawer/Header.vue'
import Scan from '@/components/SettingsDrawer/Scan.vue'
import ThemeToggle from '@/components/SettingsDrawer/ThemeToggle.vue'
import VersionLabel from '@/components/SettingsDrawer/VersionLabel.vue'
import SettingsFooter from '@/components/SettingsDrawer/Footer.vue'
// Props
const settingsDrawer = ref(false)
@@ -19,7 +19,7 @@ emitter.on('toggleSettings', () => { settingsDrawer.value = !settingsDrawer.valu
v-model="settingsDrawer"
location="right"
width="270"
class="bg-background"
class="bg-secondary"
temporary
floating>
@@ -33,7 +33,7 @@ emitter.on('toggleSettings', () => { settingsDrawer.value = !settingsDrawer.valu
<v-divider class="border-opacity-25"/>
<theme-toggle/>
<v-divider class="border-opacity-25"/>
<version-label class="bg-primary"/>
<settings-footer class="bg-primary"/>
</template>
</v-navigation-drawer>

View File

@@ -4,6 +4,6 @@ const ROMM_VERSION = import.meta.env.VITE_ROMM_VERSION
<template>
<v-list-item class="d-flex justify-center alignt-center text-body-2">
<span class="text-secondary">RomM</span><span> v{{ ROMM_VERSION }}</span>
<span class="text-rommAccent1">RomM</span><span> v{{ ROMM_VERSION }}</span>
</v-list-item>
</template>

View File

@@ -54,14 +54,14 @@ async function scan() {
@click="scan()"
:disabled="scanning"
prepend-icon="mdi-magnify-scan"
class="ml-7 bg-scanBtn"
class="ml-7"
rounded="0"
inset>
<p v-if="!scanning">Scan</p>
<v-progress-circular
v-show="scanning"
class="ml-2"
color="secondary"
color="rommAccent1"
:width="2"
:size="20"
indeterminate/>

View File

@@ -7,53 +7,11 @@
// Styles
import '@mdi/font/css/materialdesignicons.css'
import 'vuetify/styles'
import { rommDark, rommLight } from '@/styles/themes.js'
// Composables
import { createVuetify } from 'vuetify'
const rommDark = {
dark: true,
colors: {
primary: '#161b22',
secondary: '#a452fe',
background: '#0d1117',
notification: '#0d1117',
surface: '#161b22',
tooltip: '#161b22',
chip: '#161b22',
rommAccent1: '#a452fe',
rommAccent2: '#c400f7',
rommAccent2: '#3808a4',
rommWhite: '#fefdfe',
rommBlack: '#000000',
rommRed: '#da3633',
rommGreen: '#3FB950'
}
}
const rommLight = {
dark: false,
colors: {
primary: '#fefdfe',
secondary: '#a452fe',
background: '#fefdfe',
notification: '#0d1117',
surface: '#fefdfe',
tooltip: '#fefdfe',
chip: '#161b22',
rommAccent1: '#a452fe',
rommAccent2: '#c400f7',
rommAccent2: '#3808a4',
rommWhite: '#fefdfe',
rommBlack: '#000000',
rommRed: '#da3633',
rommGreen: '#3FB950'
}
}
export default createVuetify({
icons: {
iconfont: 'mdi'

View File

@@ -0,0 +1,43 @@
export const rommDark = {
dark: true,
colors: {
primary: '#161b22',
secondary: '#0d1117',
background: '#0d1117',
surface: '#161b22',
tooltip: '#161b22',
chip: '#161b22',
rommAccent1: '#a452fe',
rommAccent2: '#c400f7',
rommAccent3: '#3808a4',
rommRed: '#da3633',
rommGreen: '#3FB950',
rommWhite: '#fefdfe',
rommBlack: '#000000',
}
}
export const rommLight = {
dark: false,
colors: {
primary: '#fefdfe',
secondary: '#fefdfe',
background: '#fefdfe',
surface: '#fefdfe',
tooltip: '#fefdfe',
chip: '#fefdfe',
rommAccent1: '#a452fe',
rommAccent2: '#c400f7',
rommAccent3: '#3808a4',
rommRed: '#da3633',
rommGreen: '#3FB950',
rommWhite: '#fefdfe',
rommBlack: '#000000',
}
}

View File

@@ -24,11 +24,13 @@ const dialogSearchRom = ref(false)
const dialogEditRom = ref(false)
const dialogDeleteRom = ref(false)
const deleteFromFs = ref(false)
const filesToDownload = ref([])
const tab = ref('info')
const { xs, sm, mdAndUp } = useDisplay()
// Event listeners bus
const emitter = inject('emitter')
// Functions
async function searchRomIGDB() {
searching.value = true
@@ -45,7 +47,7 @@ async function updateRom(updatedRom=Object.assign({},rom.value), newName=rom.val
updating.value = true
dialogSearchRom.value = false
if (renameAsIGDB.value) {
updatedRom.file_name = rom.value.file_name.replace(rom.value.file_name_no_tags.trim(), updatedRom.name)
updatedRom.file_name = rom.value.file_name.replace(rom.value.file_name_no_tags.trim(), updatedRom.r_name)
editedRomName.value = updatedRom.file_name
renameAsIGDB.value = false
}
@@ -58,6 +60,7 @@ async function updateRom(updatedRom=Object.assign({},rom.value), newName=rom.val
}).then((response) => {
emitter.emit('snackbarScan', {'msg': rom.value.file_name+" updated successfully!", 'icon': 'mdi-check-bold', 'color': 'green'})
rom.value = response.data.data
router.push('/'+rom.value.p_slug+'/roms/'+rom.value.file_name)
}).catch((error) => {
console.log(error)
emitter.emit('snackbarScan', {'msg': "Couldn't updated "+rom.value.file_name+". Something went wrong...", 'icon': 'mdi-close-circle', 'color': 'red'})
@@ -102,7 +105,7 @@ onMounted(() => {
<v-img :src="'/assets'+rom.path_cover_l+'?reload='+Date.now()" :lazy-src="'/assets'+rom.path_cover_s+'?reload='+Date.now()" cover>
<template v-slot:placeholder>
<div class="d-flex align-center justify-center fill-height">
<v-progress-circular color="secondary" :width="2" :size="20" indeterminate/>
<v-progress-circular color="rommAccent1" :width="2" :size="20" indeterminate/>
</div>
</template>
</v-img>
@@ -111,7 +114,7 @@ onMounted(() => {
<v-img :src="'/assets'+rom.path_cover_l+'?reload='+Date.now()" :lazy-src="'/assets'+rom.path_cover_s+'?reload='+Date.now()" cover>
<template v-slot:placeholder>
<div class="d-flex align-center justify-center fill-height">
<v-progress-circular color="secondary" :width="2" :size="20" indeterminate/>
<v-progress-circular color="rommAccent1" :width="2" :size="20" indeterminate/>
</div>
</template>
</v-img>
@@ -120,7 +123,7 @@ onMounted(() => {
</v-row>
<v-row class="pl-3 pr-3">
<v-col class="pa-0">
<v-btn @click="downloadRom(rom, emitter, filesToDownload)" rounded="0" block><v-icon icon="mdi-download" size="large"/></v-btn>
<v-btn @click="downloadRom(rom, emitter, filesToDownload)" rounded="0" color="primary" block><v-icon icon="mdi-download" size="large"/></v-btn>
</v-col>
<v-col class="pa-0">
<v-btn @click="downloadSave(rom, emitter)" rounded="0" block :disabled="!saveFiles"><v-icon icon="mdi-content-save-all" size="large"/></v-btn>
@@ -153,23 +156,23 @@ onMounted(() => {
<v-col class="mt-10" :class="{'info': mdAndUp, 'info-tablet': sm, 'info-mobile': xs}">
<div class="info-header text-white">
<v-row no-gutters>
<p class="text-h4 font-weight-bold">{{ rom.name }}</p>
<p class="text-h4 font-weight-bold rom-name">{{ rom.r_name }}</p>
<v-chip-group class="ml-3 mt-1 hidden-xs">
<v-chip v-show="rom.region" size="x-small" class="bg-chip text-white" label>{{ rom.region }}</v-chip>
<v-chip v-show="rom.revision" size="x-small" class="bg-chip text-white" label>{{ rom.revision }}</v-chip>
<v-chip v-show="rom.region" size="x-small" class="bg-chip" label>{{ rom.region }}</v-chip>
<v-chip v-show="rom.revision" size="x-small" class="bg-chip" label>{{ rom.revision }}</v-chip>
</v-chip-group>
</v-row>
<v-row no-gutters class="align-center">
<p class="font-italic mt-1">{{ rom.platform.name }}</p>
<p class="font-italic mt-1 rom-platform">{{ rom.p_name }}</p>
<v-chip-group class="ml-3 mt-1 hidden-sm-and-up">
<v-chip v-show="rom.region" size="x-small" class="bg-chip text-white" label>{{ rom.region }}</v-chip>
<v-chip v-show="rom.revision" size="x-small" class="bg-chip text-white" label>{{ rom.revision }}</v-chip>
<v-chip v-show="rom.region" size="x-small" class="bg-chip" label>{{ rom.region }}</v-chip>
<v-chip v-show="rom.revision" size="x-small" class="bg-chip" label>{{ rom.revision }}</v-chip>
</v-chip-group>
</v-row>
</div>
<div class="mb-10" :class="{'info-content': mdAndUp, 'info-content-tablet': sm, 'info-content-mobile': xs}">
<v-tabs v-model="tab" slider-color="secondary">
<v-tabs v-model="tab" slider-color="rommAccent1">
<v-tab value="info">Info</v-tab>
<v-tab value="saves" disabled>Saves</v-tab>
<v-tab value="screenshots" disabled>Screenshots</v-tab>
@@ -228,7 +231,7 @@ onMounted(() => {
<v-divider class="border-opacity-25" :thickness="1"/>
<v-card-text class="pa-3 scroll justify-center align-center bg-background">
<v-card-text class="pa-3 scroll justify-center align-center bg-secondary">
<v-row>
<v-text-field
@keyup.enter="searchRomIGDB()"
@@ -243,7 +246,7 @@ onMounted(() => {
hide-details
clearable/>
</v-row>
<v-row class="justify-center align-center loader-searching" v-show="searching"><v-progress-circular :width="2" :size="40" class="pa-3 ma-3" color="secondary" indeterminate/></v-row>
<v-row class="justify-center align-center loader-searching" v-show="searching"><v-progress-circular :width="2" :size="40" class="pa-3 ma-3" color="rommAccent1" indeterminate/></v-row>
<v-row class="justify-center align-center no-results-searching" v-show="!searching && matchedRoms.length==0" ><p>No results found</p></v-row>
<v-row class="pl-4 pr-4">
<v-col cols="6" xs="6" sm="4" md="3" lg="3" v-show="!searching" v-for="rom in matchedRoms" :key="rom.file_name">
@@ -252,7 +255,7 @@ onMounted(() => {
<v-img v-bind="props" :src="rom.url_cover" cover/>
<v-card-text>
<v-row class="pa-2">
<span class="d-inline-block text-truncate">{{ rom.name }}</span>
<span class="d-inline-block text-truncate">{{ rom.r_name }}</span>
</v-row>
</v-card-text>
</v-card>
@@ -279,12 +282,15 @@ onMounted(() => {
<v-divider class="border-opacity-25" :thickness="1"/>
<v-card-text class="pt-5 bg-background">
<v-card-text class="pt-5 bg-secondary">
<v-form @submit.prevent class="ma-4">
<v-text-field @keyup.enter="updateRom()" v-model="editedRomName" label="File name" variant="outlined" required/>
<v-file-input @keyup.enter="updateRom()" label="Custom cover" prepend-inner-icon="mdi-image" prepend-icon="" variant="outlined" disabled/>
<v-btn type="submit" @click="updateRom(undefined, editedRomName)" class="mt-2 bg-rommGreen" block>Apply</v-btn>
</v-form>
<v-row class="justify-center ma-2 mt-5">
<v-btn type="submit" @click="updateRom(undefined, editedRomName)" class="bg-rommGreen">Apply</v-btn>
<v-btn @click="dialogEditRom=false" class="ml-5" variant="tonal">Cancel</v-btn>
</v-row>
</v-card-text>
</v-card>
</v-dialog>
@@ -298,7 +304,7 @@ onMounted(() => {
<v-divider class="border-opacity-25" :thickness="1"/>
<v-card-text class="bg-background">
<v-card-text class="bg-secondary">
<v-row class="justify-center ma-2">
<span>Deleting from RomM. Do you confirm?</span>
</v-row>
@@ -317,7 +323,7 @@ onMounted(() => {
</v-dialog>
<v-dialog :model-value="updating || loading" scroll-strategy="none" width="auto" :scrim="updating" persistent>
<v-progress-circular :width="3" :size="70" color="secondary" indeterminate/>
<v-progress-circular :width="3" :size="70" color="rommAccent1" indeterminate/>
</v-dialog>
</template>
@@ -343,7 +349,7 @@ onMounted(() => {
padding-left: 25px;
padding-right: 25px;
}
.info-header{
.rom-name, .rom-platform {
text-shadow: 1px 1px 3px #000000, 0 0 3px #000000;
}
.info-content{

View File

@@ -68,16 +68,16 @@ onBeforeRouteUpdate(async (to, from) => {
</v-col>
</v-row>
<v-list v-show="currentView == 2" class="bg-background">
<v-list v-show="currentView == 2" class="bg-secondary">
<game-list-header/>
<v-divider class="border-opacity-100 ml-3 mb-4 mr-3" color="secondary" :thickness="1"/>
<v-divider class="border-opacity-100 ml-3 mb-4 mr-3" color="rommAccent1" :thickness="1"/>
<game-list-item v-for="rom in romsFiltered" :key="rom.file_name" :rom="rom"/>
</v-list>
<no-roms :noRoms="noRoms"/>
<v-dialog v-model="gettingRoms" scroll-strategy="none" width="auto" :scrim="false" persistent>
<v-progress-circular color="secondary" :width="3" :size="70" indeterminate/>
<v-progress-circular color="rommAccent1" :width="3" :size="70" indeterminate/>
</v-dialog>
</template>

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 51 KiB