✏️ Fix locales, button order and add reload state

This commit is contained in:
ajnart
2022-08-31 15:52:16 +02:00
parent 313367a8b8
commit 4bdfcce060
4 changed files with 46 additions and 29 deletions

View File

@@ -1,6 +1,5 @@
module.exports = { module.exports = {
// https://www.i18next.com/overview/configuration-options#logging // https://www.i18next.com/overview/configuration-options#logging
debug: process.env.NODE_ENV === 'development',
i18n: { i18n: {
defaultLocale: 'en', defaultLocale: 'en',
locales: ['en', 'de', 'es', 'fr', 'it', 'ja', 'nl', 'ru', 'sv', 'zh'], locales: ['en', 'de', 'es', 'fr', 'it', 'ja', 'nl', 'ru', 'sv', 'zh'],

View File

@@ -11,7 +11,8 @@
"name": "Name", "name": "Name",
"image": "Image", "image": "Image",
"ports": "Ports", "ports": "Ports",
"state": "State" "state": "State",
"addToHomarr": "Add to homarr"
}, },
"body": { "body": {
"portCollapse": "{{ports}} more" "portCollapse": "{{ports}} more"
@@ -37,9 +38,8 @@
"start": { "start": {
"title": "Start" "title": "Start"
}, },
"refreshData": "Refresh data", "refreshData": {
"addToHomarr": { "title": "Refresh data"
"title": "Add to Homarr"
}, },
"remove": { "remove": {
"title": "Remove" "title": "Remove"

View File

@@ -11,6 +11,7 @@ import {
import axios from 'axios'; import axios from 'axios';
import Dockerode from 'dockerode'; import Dockerode from 'dockerode';
import { useTranslation } from 'next-i18next'; import { useTranslation } from 'next-i18next';
import { useState } from 'react';
import { TFunction } from 'react-i18next'; import { TFunction } from 'react-i18next';
let t: TFunction<'modules/docker', undefined>; let t: TFunction<'modules/docker', undefined>;
@@ -61,9 +62,25 @@ export interface ContainerActionBarProps {
export default function ContainerActionBar({ selected, reload }: ContainerActionBarProps) { export default function ContainerActionBar({ selected, reload }: ContainerActionBarProps) {
t = useTranslation('modules/docker').t; t = useTranslation('modules/docker').t;
const [isLoading, setisLoading] = useState(false);
return ( return (
<Group> <Group>
<Button
leftIcon={<IconRefresh />}
onClick={() => {
setisLoading(true);
setTimeout(() => {
reload();
setisLoading(false);
}, 750);
}}
variant="light"
color="violet"
loading={isLoading}
radius="md"
>
{t('actionBar.refreshData.title')}
</Button>
<Button <Button
leftIcon={<IconRotateClockwise />} leftIcon={<IconRotateClockwise />}
onClick={() => onClick={() =>
@@ -112,9 +129,6 @@ export default function ContainerActionBar({ selected, reload }: ContainerAction
> >
{t('actionBar.start.title')} {t('actionBar.start.title')}
</Button> </Button>
<Button leftIcon={<IconRefresh />} onClick={() => reload()} variant="light" color="violet" radius="md">
{t('actionBar.refreshData.title')}
</Button>
<Button <Button
leftIcon={<IconTrash />} leftIcon={<IconTrash />}
color="red" color="red"

View File

@@ -1,4 +1,14 @@
import { Table, Checkbox, Group, Badge, createStyles, ScrollArea, TextInput, Modal, ActionIcon, Tooltip } from '@mantine/core'; import {
Table,
Checkbox,
Group,
Badge,
createStyles,
ScrollArea,
TextInput,
Modal,
ActionIcon,
} from '@mantine/core';
import { IconPlus, IconSearch } from '@tabler/icons'; import { IconPlus, IconSearch } from '@tabler/icons';
import Dockerode from 'dockerode'; import Dockerode from 'dockerode';
import { useTranslation } from 'next-i18next'; import { useTranslation } from 'next-i18next';
@@ -71,9 +81,7 @@ export default function DockerTable({
/> />
</td> </td>
<td>{element.Names[0].replace('/', '')}</td> <td>{element.Names[0].replace('/', '')}</td>
<td> <td>{element.Image}</td>
{element.Image}
</td>
<td> <td>
<Group> <Group>
{element.Ports.sort((a, b) => a.PrivatePort - b.PrivatePort) {element.Ports.sort((a, b) => a.PrivatePort - b.PrivatePort)
@@ -99,8 +107,6 @@ export default function DockerTable({
<ContainerState state={element.State} /> <ContainerState state={element.State} />
</td> </td>
<td> <td>
<Group>
<Tooltip label={t('table.body.action.addToHomarr')}>
<ActionIcon <ActionIcon
color="indigo" color="indigo"
variant="light" variant="light"
@@ -112,8 +118,6 @@ export default function DockerTable({
> >
<IconPlus /> <IconPlus />
</ActionIcon> </ActionIcon>
</Tooltip>
</Group>
</td> </td>
</tr> </tr>
); );
@@ -158,7 +162,7 @@ export default function DockerTable({
<th>{t('table.header.image')}</th> <th>{t('table.header.image')}</th>
<th>{t('table.header.ports')}</th> <th>{t('table.header.ports')}</th>
<th>{t('table.header.state')}</th> <th>{t('table.header.state')}</th>
<th>{t('table.header.action')}</th> <th>{t('table.header.addToHomarr')}</th>
</tr> </tr>
</thead> </thead>
<tbody>{rows}</tbody> <tbody>{rows}</tbody>