mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
Login form tweaks (#9005)
* Login form tweaks - Improve consistency - Add tooltips * Cleanup ServerInfo list * Slight layout tweaks
This commit is contained in:
parent
855afde4e5
commit
bef6270ff6
@ -1,4 +1,4 @@
|
|||||||
import { Center, Group, Text, Tooltip } from '@mantine/core';
|
import { ActionIcon, Center, Group, Text, Tooltip } from '@mantine/core';
|
||||||
import { IconServer } from '@tabler/icons-react';
|
import { IconServer } from '@tabler/icons-react';
|
||||||
|
|
||||||
import { useServerApiState } from '../../states/ApiState';
|
import { useServerApiState } from '../../states/ApiState';
|
||||||
@ -21,7 +21,13 @@ export function AuthFormOptions({
|
|||||||
<LanguageToggle />
|
<LanguageToggle />
|
||||||
{window.INVENTREE_SETTINGS.show_server_selector && (
|
{window.INVENTREE_SETTINGS.show_server_selector && (
|
||||||
<Tooltip label={hostname}>
|
<Tooltip label={hostname}>
|
||||||
<IconServer onClick={toggleHostEdit} />
|
<ActionIcon
|
||||||
|
size='lg'
|
||||||
|
variant='transparent'
|
||||||
|
onClick={toggleHostEdit}
|
||||||
|
>
|
||||||
|
<IconServer />
|
||||||
|
</ActionIcon>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
<Text c={'dimmed'}>
|
<Text c={'dimmed'}>
|
||||||
|
@ -1,12 +1,28 @@
|
|||||||
import { Trans } from '@lingui/macro';
|
import { Trans, t } from '@lingui/macro';
|
||||||
import { Divider, Group, Select, Text, Title } from '@mantine/core';
|
import {
|
||||||
|
ActionIcon,
|
||||||
|
Divider,
|
||||||
|
Group,
|
||||||
|
Paper,
|
||||||
|
Select,
|
||||||
|
Table,
|
||||||
|
Text
|
||||||
|
} from '@mantine/core';
|
||||||
import { useToggle } from '@mantine/hooks';
|
import { useToggle } from '@mantine/hooks';
|
||||||
import { IconCheck } from '@tabler/icons-react';
|
import {
|
||||||
|
IconApi,
|
||||||
|
IconCheck,
|
||||||
|
IconInfoCircle,
|
||||||
|
IconPlugConnected,
|
||||||
|
IconServer,
|
||||||
|
IconServerSpark
|
||||||
|
} from '@tabler/icons-react';
|
||||||
|
|
||||||
import { useServerApiState } from '../../states/ApiState';
|
import { useServerApiState } from '../../states/ApiState';
|
||||||
import { useLocalState } from '../../states/LocalState';
|
import { useLocalState } from '../../states/LocalState';
|
||||||
import type { HostList } from '../../states/states';
|
import type { HostList } from '../../states/states';
|
||||||
import { EditButton } from '../buttons/EditButton';
|
import { EditButton } from '../buttons/EditButton';
|
||||||
|
import { StylishText } from '../items/StylishText';
|
||||||
import { HostOptionsForm } from './HostOptionsForm';
|
import { HostOptionsForm } from './HostOptionsForm';
|
||||||
|
|
||||||
export function InstanceOptions({
|
export function InstanceOptions({
|
||||||
@ -39,11 +55,10 @@ export function InstanceOptions({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Title order={3}>
|
<Paper p='xl' withBorder>
|
||||||
<Trans>Select destination instance</Trans>
|
<StylishText size='xl'>{t`Select Server`}</StylishText>
|
||||||
</Title>
|
<Divider p='xs' />
|
||||||
<Group>
|
<Group gap='xs' wrap='nowrap'>
|
||||||
<Group>
|
|
||||||
<Select
|
<Select
|
||||||
value={hostKey}
|
value={hostKey}
|
||||||
onChange={ChangeHost}
|
onChange={ChangeHost}
|
||||||
@ -55,29 +70,29 @@ export function InstanceOptions({
|
|||||||
editing={HostListEdit}
|
editing={HostListEdit}
|
||||||
disabled={HostListEdit}
|
disabled={HostListEdit}
|
||||||
/>
|
/>
|
||||||
|
<EditButton
|
||||||
|
setEditing={setHostEdit}
|
||||||
|
editing={true}
|
||||||
|
disabled={HostListEdit}
|
||||||
|
saveIcon={<IconCheck />}
|
||||||
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
<EditButton
|
|
||||||
setEditing={setHostEdit}
|
|
||||||
editing={true}
|
|
||||||
disabled={HostListEdit}
|
|
||||||
saveIcon={<IconCheck />}
|
|
||||||
/>
|
|
||||||
</Group>
|
|
||||||
|
|
||||||
{HostListEdit ? (
|
{HostListEdit ? (
|
||||||
<>
|
<>
|
||||||
<Divider my={'sm'} />
|
<Divider my={'sm'} />
|
||||||
<Text>
|
<Text>
|
||||||
<Trans>Edit possible host options</Trans>
|
<Trans>Edit host options</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
<HostOptionsForm data={hostList} saveOptions={SaveOptions} />
|
<HostOptionsForm data={hostList} saveOptions={SaveOptions} />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Divider my={'sm'} />
|
<Divider my={'sm'} />
|
||||||
<ServerInfo hostList={hostList} hostKey={hostKey} />
|
<ServerInfo hostList={hostList} hostKey={hostKey} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
</Paper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -91,27 +106,66 @@ function ServerInfo({
|
|||||||
}>) {
|
}>) {
|
||||||
const [server] = useServerApiState((state) => [state.server]);
|
const [server] = useServerApiState((state) => [state.server]);
|
||||||
|
|
||||||
|
const items: any[] = [
|
||||||
|
{
|
||||||
|
key: 'server',
|
||||||
|
label: t`Server`,
|
||||||
|
value: hostList[hostKey]?.host,
|
||||||
|
icon: <IconServer />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'name',
|
||||||
|
label: t`Name`,
|
||||||
|
value: server.instance,
|
||||||
|
icon: <IconInfoCircle />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'version',
|
||||||
|
label: t`Version`,
|
||||||
|
value: server.version,
|
||||||
|
icon: <IconInfoCircle />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'api',
|
||||||
|
label: t`API Version`,
|
||||||
|
value: server.apiVersion,
|
||||||
|
icon: <IconApi />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'plugins',
|
||||||
|
label: t`Plugins`,
|
||||||
|
value: server.plugins_enabled ? t`Enabled` : t`Disabled`,
|
||||||
|
icon: <IconPlugConnected />,
|
||||||
|
color: server.plugins_enabled ? 'green' : 'red'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'worker',
|
||||||
|
label: t`Worker`,
|
||||||
|
value: server.worker_running ? t`Running` : t`Stopped`,
|
||||||
|
icon: <IconServerSpark />,
|
||||||
|
color: server.worker_running ? 'green' : 'red'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text>
|
<Table striped p='xs'>
|
||||||
{hostList[hostKey]?.host}
|
<Table.Tbody>
|
||||||
<br />
|
{items.map((item) => (
|
||||||
<Trans>Version: {server.version}</Trans>
|
<Table.Tr key={item.key} p={2}>
|
||||||
<br />
|
<Table.Td>
|
||||||
<Trans>API:{server.apiVersion}</Trans>
|
<ActionIcon size='xs' variant='transparent' color={item.color}>
|
||||||
<br />
|
{item.icon}
|
||||||
<Trans>Name: {server.instance}</Trans>
|
</ActionIcon>
|
||||||
<br />
|
</Table.Td>
|
||||||
<Trans>
|
<Table.Td>
|
||||||
State:{' '}
|
<Text size='sm'>{item.label}</Text>
|
||||||
<Text span c={server.worker_running ? 'green' : 'red'}>
|
</Table.Td>
|
||||||
worker
|
<Table.Td>
|
||||||
</Text>{' '}
|
<Text size='sm'>{item.value}</Text>
|
||||||
({server.worker_pending_tasks}),{' '}
|
</Table.Td>
|
||||||
<Text span c={server.plugins_enabled ? 'green' : 'red'}>
|
</Table.Tr>
|
||||||
plugins
|
))}
|
||||||
</Text>
|
</Table.Tbody>
|
||||||
{server.plugins_enabled ? ` (${server.active_plugins.length})` : null}
|
</Table>
|
||||||
</Trans>
|
|
||||||
</Text>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
import { ActionIcon, Group, useMantineColorScheme } from '@mantine/core';
|
import {
|
||||||
|
ActionIcon,
|
||||||
|
Group,
|
||||||
|
Tooltip,
|
||||||
|
useMantineColorScheme
|
||||||
|
} from '@mantine/core';
|
||||||
import { IconMoonStars, IconSun } from '@tabler/icons-react';
|
import { IconMoonStars, IconSun } from '@tabler/icons-react';
|
||||||
|
|
||||||
|
import { t } from '@lingui/macro';
|
||||||
import { vars } from '../../theme';
|
import { vars } from '../../theme';
|
||||||
|
|
||||||
export function ColorToggle() {
|
export function ColorToggle() {
|
||||||
@ -8,17 +14,21 @@ export function ColorToggle() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Group justify='center'>
|
<Group justify='center'>
|
||||||
<ActionIcon
|
<Tooltip label={t`Toggle color scheme`}>
|
||||||
onClick={toggleColorScheme}
|
<ActionIcon
|
||||||
size='lg'
|
onClick={toggleColorScheme}
|
||||||
style={{
|
size='lg'
|
||||||
color:
|
style={{
|
||||||
colorScheme === 'dark' ? vars.colors.yellow[4] : vars.colors.blue[6]
|
color:
|
||||||
}}
|
colorScheme === 'dark'
|
||||||
variant='transparent'
|
? vars.colors.yellow[4]
|
||||||
>
|
: vars.colors.blue[6]
|
||||||
{colorScheme === 'dark' ? <IconSun /> : <IconMoonStars />}
|
}}
|
||||||
</ActionIcon>
|
variant='transparent'
|
||||||
|
>
|
||||||
|
{colorScheme === 'dark' ? <IconSun /> : <IconMoonStars />}
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
</Group>
|
</Group>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { ActionIcon, Group } from '@mantine/core';
|
import { ActionIcon, Group, Tooltip } from '@mantine/core';
|
||||||
import { useDisclosure } from '@mantine/hooks';
|
import { useDisclosure } from '@mantine/hooks';
|
||||||
import { IconLanguage } from '@tabler/icons-react';
|
import { IconLanguage } from '@tabler/icons-react';
|
||||||
|
|
||||||
|
import { t } from '@lingui/macro';
|
||||||
import { LanguageSelect } from './LanguageSelect';
|
import { LanguageSelect } from './LanguageSelect';
|
||||||
|
|
||||||
export function LanguageToggle() {
|
export function LanguageToggle() {
|
||||||
@ -16,13 +17,15 @@ export function LanguageToggle() {
|
|||||||
padding: open === true ? 8 : 0
|
padding: open === true ? 8 : 0
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ActionIcon
|
<Tooltip label={t`Select language`}>
|
||||||
onClick={() => toggle.toggle()}
|
<ActionIcon
|
||||||
size='lg'
|
onClick={() => toggle.toggle()}
|
||||||
variant='transparent'
|
size='lg'
|
||||||
>
|
variant='transparent'
|
||||||
<IconLanguage />
|
>
|
||||||
</ActionIcon>
|
<IconLanguage />
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
{open && (
|
{open && (
|
||||||
<Group>
|
<Group>
|
||||||
<LanguageSelect />
|
<LanguageSelect />
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Trans, t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import {
|
import {
|
||||||
BackgroundImage,
|
BackgroundImage,
|
||||||
Center,
|
Center,
|
||||||
@ -18,6 +18,7 @@ import {
|
|||||||
RegistrationForm
|
RegistrationForm
|
||||||
} from '../../components/forms/AuthenticationForm';
|
} from '../../components/forms/AuthenticationForm';
|
||||||
import { InstanceOptions } from '../../components/forms/InstanceOptions';
|
import { InstanceOptions } from '../../components/forms/InstanceOptions';
|
||||||
|
import { StylishText } from '../../components/items/StylishText';
|
||||||
import { defaultHostKey } from '../../defaults/defaultHostList';
|
import { defaultHostKey } from '../../defaults/defaultHostList';
|
||||||
import {
|
import {
|
||||||
checkLoginState,
|
checkLoginState,
|
||||||
@ -128,14 +129,11 @@ export default function Login() {
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Paper radius='md' p='xl' withBorder>
|
<Paper p='xl' withBorder>
|
||||||
<Text size='lg' fw={500}>
|
<StylishText size='xl'>
|
||||||
{loginMode ? (
|
{loginMode ? t`Login` : t`Register`}
|
||||||
<Trans>Welcome, log in below</Trans>
|
</StylishText>
|
||||||
) : (
|
<Divider p='xs' />
|
||||||
<Trans>Register below</Trans>
|
|
||||||
)}
|
|
||||||
</Text>
|
|
||||||
{loginMode ? <AuthenticationForm /> : <RegistrationForm />}
|
{loginMode ? <AuthenticationForm /> : <RegistrationForm />}
|
||||||
<ModeSelector loginMode={loginMode} setMode={setMode} />
|
<ModeSelector loginMode={loginMode} setMode={setMode} />
|
||||||
{LoginMessage}
|
{LoginMessage}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user