/** * Identification Settings Page * Server name, description, and basic settings */ import { Alert, Button, Card, Container, Divider, Group, Loader, Stack, Switch, Text, TextInput, Textarea, ThemeIcon, Title, } from '@mantine/core'; import { useForm } from '@mantine/form'; import { notifications } from '@mantine/notifications'; import { IconServer, IconAlertCircle, IconCheck, IconDeviceFloppy, } from '@tabler/icons-react'; import { GetServerSidePropsContext } from 'next'; import { UnraidLayout } from '~/components/Unraid/Layout'; import { getServerAuthSession } from '~/server/auth'; import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations'; import { checkForSessionOrAskForLogin } from '~/tools/server/loginBuilder'; import { api } from '~/utils/api'; export default function IdentificationSettingsPage() { const { data: vars, isLoading, error, } = api.unraid.vars.useQuery(); const { data: info, } = api.unraid.info.useQuery(); const form = useForm({ initialValues: { name: '', description: '', model: '', timezone: '', }, }); // Update form when data loads if (vars && !form.isTouched()) { form.setValues({ name: vars.name || '', description: vars.description || '', model: vars.model || '', timezone: vars.timezone || '', }); } if (isLoading) { return ( Loading settings... ); } if (error) { return ( } title="Error" color="red"> {error.message} ); } return ( {/* Header */} Identification Server name and basic settings {/* Server Identity */} Server Identity {/* System Information */} System Information Unraid Version {info?.versions.unraid || 'Unknown'} Linux Kernel {info?.os.kernel || 'Unknown'} CPU {info?.cpu.brand || 'Unknown'} Motherboard {info?.baseboard?.model || 'Unknown'} Total RAM {info?.memory?.total ? `${Math.round(info.memory.total / 1024 / 1024 / 1024)} GB` : 'Unknown'} Timezone {vars?.timezone || 'Unknown'} {/* Server Model */} Hardware Model {vars?.model || 'Unknown'} Protocol {vars?.protocol || 'Unknown'} Port {vars?.port || 'Unknown'} {/* Save Button (disabled for now) */} } disabled > Save Changes ); } export const getServerSideProps = async (context: GetServerSidePropsContext) => { const session = await getServerAuthSession(context); const translations = await getServerSideTranslations( ['common'], context.locale, context.req, context.res ); const result = checkForSessionOrAskForLogin( context, session, () => session?.user != undefined ); if (result) { return result; } return { props: { ...translations, }, }; };