WIP: Create new start page

This commit is contained in:
grimsi
2025-04-30 20:46:13 +02:00
parent 610abc69ee
commit 410172fee2
8 changed files with 38 additions and 89 deletions
@@ -42,7 +42,7 @@ function LogManagementLayout({getConfig, formik}: any) {
}
return (
<div className="flex flex-col">
<div className="flex flex-col mt-4">
<div className="flex flex-row gap-4">
<ConfigFormField configElement={getConfig("logs.folder")}/>
<ConfigFormField configElement={getConfig("logs.max-history-days")}/>
@@ -113,10 +113,10 @@ export default function ProfileManagement() {
<div className="flex flex-row gap-2">
<NextUiInput type="file" accept="image/*" onChange={onFileSelected}
isDisabled={auth.state.user?.managedBySso}/>
<Button onClick={() => uploadAvatar(avatar)} isDisabled={avatar == null}
<Button onPress={() => uploadAvatar(avatar)} isDisabled={avatar == null}
color="success">Upload</Button>
<Tooltip content="Remove your current avatar">
<Button onClick={removeAvatar} isIconOnly color="danger"
<Button onPress={removeAvatar} isIconOnly color="danger"
isDisabled={auth.state.user?.managedBySso}><Trash/></Button>
</Tooltip>
</div>
@@ -0,0 +1,14 @@
import React from "react";
import {SystemEndpoint} from "Frontend/generated/endpoints";
import withConfigPage from "Frontend/components/administration/withConfigPage";
import {Button} from "@heroui/react";
function SystemManagementLayout() {
return (
<div className="flex flex-col mt-4">
<Button onPress={() => SystemEndpoint.restart()}>Restart</Button>
</div>
);
}
export const SystemManagement = withConfigPage(SystemManagementLayout, "System", "system", null);
+5 -3
View File
@@ -2,7 +2,7 @@ import {protectRoutes} from '@vaadin/hilla-react-auth';
import {createBrowserRouter, RouteObject} from 'react-router';
import LoginView from "Frontend/views/LoginView";
import MainLayout from "Frontend/views/MainLayout";
import TestView from "Frontend/views/TestView";
import HomeView from "Frontend/views/HomeView";
import SetupView from "Frontend/views/SetupView";
import {ThemeSelector} from "Frontend/components/theming/ThemeSelector";
import App from "Frontend/App";
@@ -18,6 +18,7 @@ import PasswordResetView from "Frontend/views/PasswordResetView";
import EmailConfirmationView from "Frontend/views/EmailConfirmationView";
import InvitationRegistrationView from "Frontend/views/InvitationRegistrationView";
import PluginManagement from "Frontend/components/administration/PluginManagement";
import {SystemManagement} from "Frontend/components/administration/SystemManagement";
export const routes = protectRoutes([
{
@@ -29,7 +30,7 @@ export const routes = protectRoutes([
handle: {requiresLogin: true},
children: [
{
index: true, element: <TestView/>
index: true, element: <HomeView/>
},
{
path: 'settings',
@@ -48,7 +49,8 @@ export const routes = protectRoutes([
{path: 'sso', element: <SsoManagement/>},
{path: 'messages', element: <MessageManagement/>},
{path: 'plugins', element: <PluginManagement/>},
{path: 'logs', element: <LogManagement/>}
{path: 'logs', element: <LogManagement/>},
{path: 'system', element: <SystemManagement/>}
]
}
]
@@ -1,4 +1,4 @@
import {Envelope, GameController, LockKey, Log, Plug, Users} from "@phosphor-icons/react";
import {Envelope, GameController, LockKey, Log, Plug, Users, Wrench} from "@phosphor-icons/react";
import withSideMenu, {MenuItem} from "Frontend/components/general/withSideMenu";
const menuItems: MenuItem[] = [
@@ -31,6 +31,11 @@ const menuItems: MenuItem[] = [
title: "Logs",
url: "logs",
icon: <Log/>
},
{
title: "System",
url: "system",
icon: <Wrench/>
}
]
@@ -0,0 +1,9 @@
export default function HomeView() {
return (
<div className="grow justify-center mt-12">
<div className="flex flex-col items-center gap-6">
<p>Welcome to Gameyfin!</p>
</div>
</div>
);
}
@@ -1,78 +0,0 @@
import {Link} from "react-router";
import {addToast, Button, Input} from "@heroui/react";
import {LibraryEndpoint, SystemEndpoint} from "Frontend/generated/endpoints";
import {useState} from "react";
import GameDto from "Frontend/generated/de/grimsi/gameyfin/games/dto/GameDto";
import {GameOverviewCard} from "Frontend/components/general/cards/GameOverviewCard";
export default function TestView() {
const [gameTitle, setGameTitle] = useState("");
const [game, setGame] = useState<GameDto>();
function getGame() {
LibraryEndpoint.test(gameTitle).then(game => {
if (game == undefined) return;
setGame(game);
});
}
function removeGames() {
LibraryEndpoint.removeGames().then(() => {
setGame(undefined);
addToast({
title: "Success",
description: "Games removed",
color: "success"
})
});
}
function removeLibraries() {
LibraryEndpoint.removeLibraries().then(() => {
addToast({
title: "Success",
description: "Libraries removed",
color: "success"
})
});
}
return (
<div className="grow justify-center mt-12">
<div className="flex flex-col items-center gap-6">
<Link to="/setup">Setup</Link>
<div className="flex flex-row gap-4">
<Button onPress={
() => addToast({
title: "Primary",
description: "Description"
})
}>Toast (Normal)</Button>
<Button onPress={
() => addToast({
title: "Success",
description: "Description",
color: "success"
})
}>Toast (Success)</Button>
<Button onPress={
() => addToast({
title: "Error",
description: "Description",
color: "danger"
})
}>Toast (Error)</Button>
</div>
<Button onPress={() => SystemEndpoint.restart()}>Restart</Button>
<div className="flex flex-row gap-4 items-center">
<Input label="Game title" onValueChange={setGameTitle}/>
<Button onPress={getGame} size="lg">Match</Button>
<Button onPress={removeGames} size="lg">Clear DB</Button>
<Button onPress={removeLibraries} size="lg">Clear Libs</Button>
</div>
{game && <GameOverviewCard game={game}></GameOverviewCard>}
{game && <>{JSON.stringify(game, null, 2)}</>}
</div>
</div>
);
}
@@ -41,14 +41,11 @@ class PasswordResetService(
* - The user is not managed externally
*/
fun generate(username: String): TokenDto {
if (messageService.enabled) {
throw IllegalStateException("Cannot create password reset token for user '$username' because self-service is enabled")
}
val user = userService.getByUsername(username)
?: throw IllegalArgumentException("Cannot create password reset token for user '$username' because user does not exist")
if (user.emailConfirmed) {
if (messageService.enabled && user.emailConfirmed) {
throw IllegalStateException("Cannot create password reset token for user '$username' because self-service is enabled")
}