mirror of
https://github.com/rommapp/romm.git
synced 2026-02-18 00:27:41 +01:00
Merge pull request #1762 from rommapp/romm-1761
[ROMM-1761] Show platform disk size in sidebar
This commit is contained in:
@@ -29,6 +29,7 @@ class PlatformSchema(BaseModel):
|
||||
aspect_ratio: str = DEFAULT_COVER_ASPECT_RATIO
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
filesystem_size_bytes: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
@@ -43,3 +43,16 @@ class DBStatsHandler(DBBaseHandler):
|
||||
)
|
||||
or 0
|
||||
)
|
||||
|
||||
@begin_session
|
||||
def get_platform_filesize(self, platform_id: int, session: Session = None) -> int:
|
||||
"""Get the total filesize of all roms in the database, in bytes."""
|
||||
return (
|
||||
session.scalar(
|
||||
select(func.sum(RomFile.file_size_bytes))
|
||||
.select_from(RomFile)
|
||||
.join(Rom)
|
||||
.filter(Rom.platform_id == platform_id)
|
||||
)
|
||||
or 0
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from functools import cached_property
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from models.base import BaseModel
|
||||
@@ -50,3 +51,9 @@ class Platform(BaseModel):
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return self.name
|
||||
|
||||
@cached_property
|
||||
def filesystem_size_bytes(self) -> int:
|
||||
from handler.database import db_stats_handler
|
||||
|
||||
return db_stats_handler.get_platform_filesize(self.id)
|
||||
|
||||
@@ -25,6 +25,7 @@ export type PlatformSchema = {
|
||||
aspect_ratio?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
filesystem_size_bytes: number;
|
||||
readonly display_name: string;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,11 +12,13 @@ import storePlatforms from "@/stores/platforms";
|
||||
import storeRoms from "@/stores/roms";
|
||||
import storeScanning from "@/stores/scanning";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import { formatBytes } from "@/utils";
|
||||
import type { Emitter } from "mitt";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, inject, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { identity } from "lodash";
|
||||
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
@@ -28,7 +30,6 @@ const platformsStore = storePlatforms();
|
||||
const scanningStore = storeScanning();
|
||||
const { scanning } = storeToRefs(scanningStore);
|
||||
const { currentPlatform } = storeToRefs(romsStore);
|
||||
const { allPlatforms } = storeToRefs(platformsStore);
|
||||
const auth = storeAuth();
|
||||
const navigationStore = storeNavigation();
|
||||
const { activePlatformInfoDrawer } = storeToRefs(navigationStore);
|
||||
@@ -55,14 +56,25 @@ const aspectRatioOptions = computed(() => [
|
||||
source: t("platform.old-horizontal-cases"),
|
||||
},
|
||||
]);
|
||||
const platformInfoFields = [
|
||||
{ key: "name", label: t("common.name") },
|
||||
{ key: "slug", label: "Slug" },
|
||||
{ key: "fs_slug", label: t("platform.filesystem-folder-name") },
|
||||
{ key: "category", label: t("platform.category") },
|
||||
{ key: "generation", label: t("platform.generation") },
|
||||
{ key: "family_name", label: t("platform.family") },
|
||||
|
||||
const PLATFORM_INFO_FIELDS: {
|
||||
key: keyof Platform;
|
||||
label: string;
|
||||
format: (value: any) => string;
|
||||
}[] = [
|
||||
{ key: "name", label: t("common.name"), format: identity },
|
||||
{ key: "slug", label: t("common.slug"), format: identity },
|
||||
{ key: "fs_slug", label: t("settings.folder-name"), format: identity },
|
||||
{ key: "category", label: t("platform.category"), format: identity },
|
||||
{ key: "generation", label: t("platform.generation"), format: identity },
|
||||
{ key: "family_name", label: t("platform.family"), format: identity },
|
||||
{
|
||||
key: "filesystem_size_bytes",
|
||||
label: t("common.size-on-disk"),
|
||||
format: (fs: number) => formatBytes(fs, 2),
|
||||
},
|
||||
];
|
||||
|
||||
const updating = ref(false);
|
||||
const updatedPlatform = ref({ ...currentPlatform.value });
|
||||
const isEditable = ref(false);
|
||||
@@ -334,22 +346,13 @@ watch(
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-card class="mt-4 bg-toplayer fill-width" elevation="0">
|
||||
<v-card-text class="pa-4">
|
||||
<template
|
||||
v-for="(field, index) in platformInfoFields"
|
||||
:key="field.key"
|
||||
>
|
||||
<div :class="{ 'mt-4': index !== 0 }">
|
||||
<v-chip size="small" class="mr-2 px-0" label>
|
||||
<v-chip label>{{ field.label }}</v-chip
|
||||
><span class="px-2">{{
|
||||
currentPlatform[
|
||||
field.key as keyof typeof currentPlatform
|
||||
]?.toString()
|
||||
? currentPlatform[
|
||||
field.key as keyof typeof currentPlatform
|
||||
]
|
||||
: "N/A"
|
||||
<v-card-text class="pa-4 d-flex flex-wrap ga-2">
|
||||
<template v-for="field in PLATFORM_INFO_FIELDS" :key="field.key">
|
||||
<div>
|
||||
<v-chip size="small" class="px-0" label>
|
||||
<v-chip label>{{ field.label }}</v-chip>
|
||||
<span class="px-2">{{
|
||||
field.format(currentPlatform[field.key]) || "N/A"
|
||||
}}</span>
|
||||
</v-chip>
|
||||
</div>
|
||||
|
||||
@@ -32,5 +32,6 @@
|
||||
"library-management": "Bibliothek verwalten",
|
||||
"administration": "Administration",
|
||||
"logout": "Ausloggen",
|
||||
"name": "Name"
|
||||
"name": "Name",
|
||||
"slug": "Slug"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"search-platform": "Plattform suchen",
|
||||
"upload-roms": "Roms hochladen",
|
||||
"filesystem-folder-name": "Verzeichnisname im Dateisystem",
|
||||
"category": "Kategorie",
|
||||
"generation": "Generation",
|
||||
"family": "Familie",
|
||||
|
||||
@@ -32,5 +32,6 @@
|
||||
"library-management": "Library management",
|
||||
"administration": "Administration",
|
||||
"logout": "Logout",
|
||||
"name": "Name"
|
||||
"name": "Name",
|
||||
"slug": "Slug"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"search-platform": "Search platform",
|
||||
"upload-roms": "Upload Roms",
|
||||
"filesystem-folder-name": "Filesystem folder name",
|
||||
"category": "Category",
|
||||
"generation": "Generation",
|
||||
"family": "Family",
|
||||
|
||||
@@ -32,5 +32,6 @@
|
||||
"library-management": "Library management",
|
||||
"administration": "Administration",
|
||||
"logout": "Logout",
|
||||
"name": "Name"
|
||||
"name": "Name",
|
||||
"slug": "Slug"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"search-platform": "Search platform",
|
||||
"upload-roms": "Upload Roms",
|
||||
"filesystem-folder-name": "Filesystem folder name",
|
||||
"category": "Category",
|
||||
"generation": "Generation",
|
||||
"family": "Family",
|
||||
|
||||
@@ -32,5 +32,6 @@
|
||||
"library-management": "Gestionar biblioteca",
|
||||
"administration": "Administración",
|
||||
"logout": "Cerrar sesión",
|
||||
"name": "Nombre"
|
||||
"name": "Nombre",
|
||||
"slug": "Slug"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"search-platform": "Buscar plataforma",
|
||||
"upload-roms": "Subir Roms",
|
||||
"filesystem-folder-name": "Nombre de carpeta",
|
||||
"category": "Categoría",
|
||||
"generation": "Generación",
|
||||
"family": "Familia",
|
||||
|
||||
@@ -33,5 +33,6 @@
|
||||
"library-management": "Gestion de la bibliothèque",
|
||||
"administration": "Administration",
|
||||
"logout": "Se déconnecter",
|
||||
"name": "Nom"
|
||||
"name": "Nom",
|
||||
"slug": "Slug"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"search-platform": "Recherche dans la plateforme",
|
||||
"upload-roms": "Télécharger des ROMs",
|
||||
"filesystem-folder-name": "Nom du dossier du système de fichiers",
|
||||
"category": "Catégorie",
|
||||
"generation": "Génération",
|
||||
"family": "Famille",
|
||||
|
||||
@@ -32,5 +32,6 @@
|
||||
"library-management": "ライブラリ管理",
|
||||
"administration": "管理者メニュー",
|
||||
"logout": "ログアウト",
|
||||
"name": "名前"
|
||||
"name": "名前",
|
||||
"slug": "スラッグ"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"search-platform": "プラットフォームを検索",
|
||||
"upload-roms": "Romをアップロード",
|
||||
"filesystem-folder-name": "ファイルシステム参照先",
|
||||
"category": "カテゴリ",
|
||||
"generation": "生成",
|
||||
"family": "ファミリー",
|
||||
|
||||
@@ -32,5 +32,6 @@
|
||||
"library-management": "라이브러리 관리",
|
||||
"administration": "유저 관리",
|
||||
"logout": "로그아웃",
|
||||
"name": "이름"
|
||||
"name": "이름",
|
||||
"slug": "슬러그"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"search-platform": "플랫폼 검색",
|
||||
"upload-roms": "롬 업로드",
|
||||
"filesystem-folder-name": "저장소 폴더 이름",
|
||||
"category": "분류",
|
||||
"generation": "세대",
|
||||
"family": "계열",
|
||||
|
||||
@@ -32,5 +32,6 @@
|
||||
"library-management": "Gerenciamento de biblioteca",
|
||||
"administration": "Administração",
|
||||
"logout": "Sair",
|
||||
"name": "Nome"
|
||||
"name": "Nome",
|
||||
"slug": "Slug"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"search-platform": "Buscar plataforma",
|
||||
"upload-roms": "Carregar ROMs",
|
||||
"filesystem-folder-name": "Nome da pasta do sistema de arquivos",
|
||||
"category": "Categoria",
|
||||
"generation": "Geração",
|
||||
"family": "Família",
|
||||
|
||||
@@ -32,5 +32,6 @@
|
||||
"library-management": "Управление библиотекой",
|
||||
"administration": "Администрирование",
|
||||
"logout": "Выйти",
|
||||
"name": "Имя"
|
||||
"name": "Имя",
|
||||
"slug": "Слаг"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"search-platform": "Поиск платформы",
|
||||
"upload-roms": "Загрузить ромы",
|
||||
"filesystem-folder-name": "Имя папки файловой системы",
|
||||
"category": "Категория",
|
||||
"generation": "Поколение",
|
||||
"family": "Семейство",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"search-platform": "搜索平台",
|
||||
"upload-roms": "上传 Roms",
|
||||
"filesystem-folder-name": "实际文件夹名称",
|
||||
"category": "分类",
|
||||
"generation": "世代",
|
||||
"family": "家族",
|
||||
|
||||
Reference in New Issue
Block a user