mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 10:01:00 +01:00
multifile selector added to front
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
Revision ID: 1.6.3
|
||||
Revises: 1.6.2
|
||||
Create Date: 2023-04-10 11:54:23.748175
|
||||
Create Date: 2023-04-10 16:21:34.680282
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
@@ -19,10 +19,12 @@ depends_on = None
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('roms', sa.Column('multi', sa.Boolean(), nullable=True))
|
||||
op.add_column('roms', sa.Column('files', sa.JSON(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('roms', 'files')
|
||||
op.drop_column('roms', 'multi')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import sys
|
||||
import subprocess
|
||||
from subprocess import CalledProcessError
|
||||
from fastapi import FastAPI, Request
|
||||
@@ -22,6 +23,7 @@ async def startup() -> None:
|
||||
subprocess.run(['alembic', 'upgrade', 'head'], check=True)
|
||||
except CalledProcessError as e:
|
||||
log.critical(f"Could not apply migrations: {e}")
|
||||
sys.exit(4)
|
||||
|
||||
|
||||
@app.put("/scan")
|
||||
|
||||
@@ -17,7 +17,7 @@ class Rom(BaseModel):
|
||||
file_name_no_tags = Column(String(length=450), default="")
|
||||
file_extension = Column(String(length=10), default="")
|
||||
file_path = Column(String(length=1000), default="")
|
||||
file_size = Column(Float, default="")
|
||||
file_size = Column(Float, default=0.0)
|
||||
|
||||
name = Column(String(length=350), default="")
|
||||
r_slug = Column(String(length=100), default="")
|
||||
@@ -33,6 +33,7 @@ class Rom(BaseModel):
|
||||
tags = Column(JSON, default=[])
|
||||
|
||||
multi = Column(Boolean, default=False)
|
||||
files = Column(JSON, default=[])
|
||||
|
||||
@property
|
||||
def full_path(self) -> str:
|
||||
@@ -47,4 +48,5 @@ class Rom(BaseModel):
|
||||
f"file_name: {self.file_name},"
|
||||
f"file_path: {self.file_path},"
|
||||
f"multi: {self.multi},"
|
||||
f"files: {self.files}"
|
||||
)
|
||||
|
||||
@@ -95,26 +95,31 @@ def get_roms(p_slug: str, full_scan: bool, only_amount: bool = False) -> list[di
|
||||
only_amount: flag to return only amount of roms instead of all info
|
||||
Returns: list with all the filesystem roms for a platform found in the LIBRARY_BASE_PATH. Just the amount of them if only_amount=True
|
||||
"""
|
||||
roms: list[dict] = []
|
||||
roms_path = _check_folder_structure(p_slug)
|
||||
roms_files: list = list(os.walk(roms_path))[0][2] + list(os.walk(roms_path))[0][1]
|
||||
roms_multi: list = []
|
||||
for rom_folder in list(os.walk(roms_path))[0][1]:
|
||||
roms_multi.append(list(os.walk(f"{roms_path}/{rom_folder}"))[0][2])
|
||||
roms_files = _exclude_files(roms_files)
|
||||
roms: list[dict] = []
|
||||
|
||||
if only_amount: return len(roms_files)
|
||||
roms_files: list = _exclude_files(list(os.walk(roms_path))[0][2])
|
||||
roms_files_multi: list = list(os.walk(roms_path))[0][1]
|
||||
|
||||
if only_amount: return len(roms_files) + len(roms_files_multi)
|
||||
|
||||
not_new_roms: list[str] = [rom.file_name for rom in dbh.get_roms(p_slug)]
|
||||
|
||||
excluded_roms: list[str] = [rom.file_name for rom in dbh.get_roms(p_slug)]
|
||||
for rom in roms_files:
|
||||
if rom in excluded_roms and not full_scan: continue
|
||||
if rom in not_new_roms and not full_scan: continue
|
||||
file_size: str = str(round(os.stat(f"{roms_path}/{rom}").st_size / (1024 * 1024), 2))
|
||||
file_extension: str = rom.split('.')[-1] if '.' in rom else ""
|
||||
reg, rev, other_tags = parse_tags(rom)
|
||||
roms.append({'file_name': rom, 'file_path': roms_path, 'file_size': file_size, 'file_extension': file_extension,
|
||||
'region': reg, 'revision': rev, 'tags': other_tags})
|
||||
|
||||
for rom_multi in roms_files_multi:
|
||||
if rom_multi in not_new_roms and not full_scan: continue
|
||||
reg, rev, other_tags = parse_tags(rom_multi)
|
||||
roms.append({'file_name': rom_multi, 'file_path': roms_path, 'multi': True, 'files': list(os.walk(f"{roms_path}/{rom_multi}"))[0][2],
|
||||
'region': reg, 'revision': rev, 'tags': other_tags, 'multi': True})
|
||||
|
||||
log.info(f"Roms found for {p_slug}: {roms}")
|
||||
if only_amount: return 0
|
||||
return roms
|
||||
|
||||
|
||||
@@ -209,4 +214,3 @@ def get_cover_details(overwrite: bool, p_slug: str, file_name: str, url_cover: s
|
||||
path_cover_l = _get_cover_path(p_slug, file_name, 'l')
|
||||
has_cover = 1
|
||||
return path_cover_s, path_cover_l, has_cover
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "romm",
|
||||
"version": "1.6.1",
|
||||
"version": "1.6.3",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite --host",
|
||||
|
||||
@@ -104,7 +104,7 @@ getPlatforms()
|
||||
<v-divider class="border-opacity-100" :thickness="2"/>
|
||||
<v-list>
|
||||
<!-- Settings drawer - scan button -->
|
||||
<v-select label="Platforms" item-title="name" v-model="platformsToScan" :items="platforms" class="pl-5 pr-5 mt-2" density="comfortable" variant="outlined" multiple return-object clearable/>
|
||||
<v-select label="Platforms" item-title="name" v-model="platformsToScan" :items="platforms" class="pl-5 pr-5 mt-2 mb-1" density="comfortable" variant="outlined" multiple return-object clearable hide-details/>
|
||||
<v-list-item class="pa-0">
|
||||
<v-row class="align-center">
|
||||
<v-col class="d-flex justify-center">
|
||||
|
||||
@@ -134,17 +134,20 @@ async function deleteRom() {
|
||||
<v-col cols="15" xs="15" sm="12" md="6" lg="10">
|
||||
<v-table density="comfortable">
|
||||
<tbody>
|
||||
<tr><td>IGDB id</td><td><a :href="'https://www.igdb.com/games/'+rom.r_slug">{{ rom.r_igdb_id }}</a></td></tr>
|
||||
<tr><td>Name</td><td>{{ rom.name }}</td></tr>
|
||||
<tr><td>File</td><td>{{ rom.file_name }}</td></tr>
|
||||
<tr><td>Path</td><td>{{ rom.file_path }}</td></tr>
|
||||
<tr v-show="!rom.multi"><td>File</td><td>{{ rom.file_name }}</td></tr>
|
||||
<tr v-show="rom.multi"><td>Files</td><td>
|
||||
<v-select item-title="file_name" :items="rom.files" class="mt-2 mb-2" density="compact" variant="outlined" max-width="300" return-object hide-details/>
|
||||
</td></tr>
|
||||
<tr><td>Platform</td><td>{{ rom.p_slug }}</td></tr>
|
||||
<tr><td>Size</td><td>{{ rom.file_size }} MB</td></tr>
|
||||
<!-- <tr><td>Path</td><td>{{ rom.file_path }}</td></tr> -->
|
||||
<tr><td>IGDB id</td><td><a :href="'https://www.igdb.com/games/'+rom.r_slug">{{ rom.r_igdb_id }}</a></td></tr>
|
||||
<tr v-show="rom.region"><td>Region</td><td>{{ rom.region }}</td></tr>
|
||||
<tr v-show="rom.revision"><td>Revision</td><td>{{ rom.revision }}</td></tr>
|
||||
<tr v-show="rom.tags.length>0"><td>Tags</td><td><v-chip-group><v-chip v-for="tag in rom.tags" label>{{ tag }}</v-chip></v-chip-group></td></tr>
|
||||
<tr><td>Size</td><td>{{ rom.file_size }} MB</td></tr>
|
||||
<tr><td>Slug</td><td>{{ rom.r_slug }}</td></tr>
|
||||
<tr><td>Platform</td><td>{{ rom.p_slug }}</td></tr>
|
||||
<tr><td>Cover</td><td>{{ rom.path_cover_l }}</td></tr>
|
||||
<!-- <tr><td>Slug</td><td>{{ rom.r_slug }}</td></tr> -->
|
||||
<!-- <tr><td>Cover</td><td>{{ rom.path_cover_l }}</td></tr> -->
|
||||
<tr><td>Summary</td><td class="pt-3">{{ rom.summary }}</td></tr>
|
||||
</tbody>
|
||||
</v-table>
|
||||
|
||||
Reference in New Issue
Block a user