mirror of
https://github.com/rommapp/romm.git
synced 2026-12-03 10:33:22 +01:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -26,7 +26,7 @@ from handler import dbh
|
||||
from starlette.middleware.authentication import AuthenticationMiddleware
|
||||
from starlette.middleware.sessions import SessionMiddleware
|
||||
from typing_extensions import TypedDict
|
||||
from utils import get_version
|
||||
from utils import check_new_version, get_version
|
||||
from utils.auth import (
|
||||
CustomCSRFMiddleware,
|
||||
HybridAuthBackend,
|
||||
@@ -34,7 +34,7 @@ from utils.auth import (
|
||||
)
|
||||
from utils.socket import socket_app
|
||||
|
||||
app = FastAPI(title="RomM API", version="0.1.0")
|
||||
app = FastAPI(title="RomM API", version=get_version())
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
@@ -95,6 +95,7 @@ class SchedulerDict(TypedDict):
|
||||
|
||||
class HeartbeatReturn(TypedDict):
|
||||
VERSION: str
|
||||
NEW_VERSION: str | None
|
||||
ROMM_AUTH_ENABLED: bool
|
||||
WATCHER: WatcherDict
|
||||
SCHEDULER: SchedulerDict
|
||||
@@ -110,6 +111,7 @@ def heartbeat() -> HeartbeatReturn:
|
||||
"""
|
||||
return {
|
||||
"VERSION": get_version(),
|
||||
"NEW_VERSION": check_new_version(),
|
||||
"ROMM_AUTH_ENABLED": ROMM_AUTH_ENABLED,
|
||||
"WATCHER": {
|
||||
"ENABLED": ENABLE_RESCAN_ON_FILESYSTEM_CHANGE,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import re
|
||||
import subprocess as sp
|
||||
|
||||
import requests
|
||||
from __version__ import __version__
|
||||
from packaging.version import InvalidVersion, parse
|
||||
|
||||
LANGUAGES = [
|
||||
("Ar", "Arabic"),
|
||||
@@ -126,11 +128,11 @@ def normalize_search_term(search_term: str) -> str:
|
||||
|
||||
|
||||
def get_file_extension(rom: dict) -> str:
|
||||
return (
|
||||
re.search(EXTENSION_REGEX, rom["file_name"]).group(1)
|
||||
if not rom["multi"]
|
||||
else ""
|
||||
)
|
||||
if rom["multi"]:
|
||||
return ""
|
||||
|
||||
match = re.search(EXTENSION_REGEX, rom["file_name"])
|
||||
return match.group(1) if match else ""
|
||||
|
||||
|
||||
def get_version() -> str | None:
|
||||
@@ -144,3 +146,19 @@ def get_version() -> str | None:
|
||||
return None
|
||||
branch = [a for a in output.split("\n") if a.find("*") >= 0][0]
|
||||
return branch[branch.find("*") + 2 :]
|
||||
|
||||
|
||||
def check_new_version() -> str | None:
|
||||
response = requests.get(
|
||||
"https://api.github.com/repos/zurdi15/romm/releases/latest", timeout=0.5
|
||||
)
|
||||
try:
|
||||
last_version = response.json()["name"][1:] # remove leading 'v' from 'vX.X.X'
|
||||
except KeyError: # rate limit reached
|
||||
return None
|
||||
try:
|
||||
if parse(get_version()) < parse(last_version):
|
||||
return last_version
|
||||
except InvalidVersion:
|
||||
pass
|
||||
return None
|
||||
|
||||
@@ -23,7 +23,6 @@ from config import (
|
||||
)
|
||||
from config.config_loader import config
|
||||
from exceptions.fs_exceptions import (
|
||||
PlatformNotFoundException,
|
||||
PlatformsNotFoundException,
|
||||
RomAlreadyExistsException,
|
||||
RomNotFoundError,
|
||||
@@ -31,6 +30,8 @@ from exceptions.fs_exceptions import (
|
||||
)
|
||||
from PIL import Image
|
||||
|
||||
from . import get_file_extension
|
||||
|
||||
|
||||
# ========= Resources utils =========
|
||||
class CoverSize(Enum):
|
||||
@@ -230,26 +231,26 @@ def get_roms_structure(fs_slug: str):
|
||||
def _exclude_files(files, filetype) -> list[str]:
|
||||
excluded_extensions = config[f"EXCLUDED_{filetype.upper()}_EXT"]
|
||||
excluded_names = config[f"EXCLUDED_{filetype.upper()}_FILES"]
|
||||
filtered_files: list = []
|
||||
excluded_files: list = []
|
||||
|
||||
for file in files:
|
||||
# Split the file name to get the extension.
|
||||
parts = file.split(".")
|
||||
ext = get_file_extension({"file_name": file, "multi": False})
|
||||
|
||||
# Exclude the file if it has no extension or the extension is in the excluded list.
|
||||
if len(parts) == 1 or parts[-1] in excluded_extensions:
|
||||
filtered_files.append(file)
|
||||
if not ext or ext in excluded_extensions:
|
||||
excluded_files.append(file)
|
||||
|
||||
# Additionally, check if the file name mathes a pattern in the excluded list.
|
||||
if len(excluded_names) > 0:
|
||||
[
|
||||
filtered_files.append(file)
|
||||
excluded_files.append(file)
|
||||
for name in excluded_names
|
||||
if file == name or fnmatch.fnmatch(file, name)
|
||||
]
|
||||
|
||||
# Return files that are not in the filtered list.
|
||||
return [f for f in files if f not in filtered_files]
|
||||
return [f for f in files if f not in excluded_files]
|
||||
|
||||
|
||||
def _exclude_multi_roms(roms) -> list[str]:
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { inject } from "vue";
|
||||
import { inject, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import type { Emitter } from "mitt";
|
||||
import type { Events } from "@/types/emitter";
|
||||
|
||||
import storeAuth from "@/stores/auth";
|
||||
import { defaultAvatarPath } from "@/utils"
|
||||
import storeHeartbeat from "@/stores/heartbeat";
|
||||
import { defaultAvatarPath } from "@/utils";
|
||||
import { api } from "@/services/api";
|
||||
|
||||
// Props
|
||||
@@ -13,8 +13,17 @@ defineProps<{ rail?: boolean }>();
|
||||
const router = useRouter();
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const auth = storeAuth();
|
||||
const heartbeat = storeHeartbeat();
|
||||
const newVersion = heartbeat.data.NEW_VERSION;
|
||||
localStorage.setItem("newVersion", newVersion)
|
||||
const newVersionDismissed = ref(localStorage.getItem("dismissNewVersion") === newVersion);
|
||||
|
||||
// Functions
|
||||
function dismissNewVersion() {
|
||||
localStorage.setItem("dismissNewVersion", newVersion);
|
||||
newVersionDismissed.value = true;
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
api
|
||||
.post("/logout", {})
|
||||
@@ -38,8 +47,12 @@ async function logout() {
|
||||
<template>
|
||||
<v-list-item height="60" class="bg-primary text-button" rounded="0">
|
||||
<template v-if="!rail">
|
||||
<div class="text-no-wrap text-truncate text-subtitle-1">{{ auth.user?.username }}</div>
|
||||
<div class="text-no-wrap text-truncate text-caption text-romm-accent-1">{{ auth.user?.role }}</div>
|
||||
<div class="text-no-wrap text-truncate text-subtitle-1">
|
||||
{{ auth.user?.username }}
|
||||
</div>
|
||||
<div class="text-no-wrap text-truncate text-caption text-romm-accent-1">
|
||||
{{ auth.user?.role }}
|
||||
</div>
|
||||
</template>
|
||||
<template v-slot:prepend>
|
||||
<v-avatar :class="{ 'my-2': rail }">
|
||||
@@ -69,4 +82,30 @@ async function logout() {
|
||||
block
|
||||
@click="logout()"
|
||||
></v-btn>
|
||||
<v-list-item
|
||||
class="bg-terciary py-1 px-1 text-subtitle-2"
|
||||
v-if="newVersion && !newVersionDismissed && !rail"
|
||||
>
|
||||
<v-card>
|
||||
<v-card-text class="py-2 px-4">
|
||||
<v-row no-gutters>
|
||||
<v-col class="py-1">
|
||||
<span
|
||||
>New version available <span class="text-romm-accent-1">{{ newVersion }}</span></span
|
||||
>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters>
|
||||
<v-col class="py-1">
|
||||
<span @click="dismissNewVersion()" class="pointer text-grey">Dismiss</span><span class="ml-4"><a target="_blank" :href="`https://github.com/zurdi15/romm/releases/tag/v${newVersion}`">See what's new!</a></span>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-list-item>
|
||||
</template>
|
||||
<style scoped>
|
||||
.pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
@@ -11,23 +11,23 @@ defineProps<{ watcher: Heartbeat["WATCHER"] }>();
|
||||
lg="4"
|
||||
:class="{
|
||||
'status-item d-flex': true,
|
||||
disabled: !watcher.ENABLED,
|
||||
disabled: !watcher?.ENABLED,
|
||||
}"
|
||||
>
|
||||
<v-icon
|
||||
:class="watcher.ENABLED ? 'text-romm-accent-1' : ''"
|
||||
:class="watcher?.ENABLED ? 'text-romm-accent-1' : ''"
|
||||
:icon="
|
||||
watcher.ENABLED ? 'mdi-file-check-outline' : 'mdi-file-remove-outline'
|
||||
watcher?.ENABLED ? 'mdi-file-check-outline' : 'mdi-file-remove-outline'
|
||||
"
|
||||
/>
|
||||
<div class="ml-3">
|
||||
<span
|
||||
class="font-weight-bold text-body-1"
|
||||
:class="watcher.ENABLED ? 'text-romm-accent-1' : ''"
|
||||
>{{ watcher.TITLE }}</span
|
||||
:class="watcher?.ENABLED ? 'text-romm-accent-1' : ''"
|
||||
>{{ watcher?.TITLE }}</span
|
||||
>
|
||||
<p class="mt-1">
|
||||
{{ watcher.MESSAGE }}
|
||||
{{ watcher?.MESSAGE }}
|
||||
</p>
|
||||
</div>
|
||||
</v-col>
|
||||
|
||||
Reference in New Issue
Block a user