mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-14 09:25:47 +01:00
🌐 Cache settings
This commit is contained in:
24
public/locales/en/settings/general/cache-buttons.json
Normal file
24
public/locales/en/settings/general/cache-buttons.json
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"title": "Cache cleaning",
|
||||||
|
"selector": {
|
||||||
|
"label": "Select the cache(s) to clear",
|
||||||
|
"data": {
|
||||||
|
"ping": "Ping queries",
|
||||||
|
"repositoryIcons": "Remote/Local icons",
|
||||||
|
"calendar&medias": "Medias from the Calendar",
|
||||||
|
"weather": "Weather data"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"buttons": {
|
||||||
|
"notificationTitle": "Cache Cleared",
|
||||||
|
"clearAll":{
|
||||||
|
"text": "Clear all cache",
|
||||||
|
"notificationMessage": "All cache has been cleared"
|
||||||
|
},
|
||||||
|
"clearSelect":{
|
||||||
|
"text": "Clear selected queries",
|
||||||
|
"notificationMessageSingle": "Cache for {{value}} has been cleared",
|
||||||
|
"notificationMessageMulti": "Cache for {{values}} have been cleared"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,25 +4,29 @@ import { IconTrash } from '@tabler/icons-react';
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
import { queryClient } from '../../../tools/server/configurations/tanstack/queryClient.tool';
|
import { queryClient } from '../../../tools/server/configurations/tanstack/queryClient.tool';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
const data = [
|
|
||||||
{ value: 'ping', label: 'Ping queries' },
|
|
||||||
{ value: 'repository-icons', label: 'Remote/Local icons' },
|
|
||||||
{ value: 'calendar/medias', label: 'Medais from the Calendar' },
|
|
||||||
{ value: 'weather', label: 'Weather data' },
|
|
||||||
];
|
|
||||||
|
|
||||||
export function CacheButtons() {
|
export function CacheButtons() {
|
||||||
const [value, setValue] = useState<string[]>([]);
|
const [value, setValue] = useState<string[]>([]);
|
||||||
|
|
||||||
|
const { t } = useTranslation('settings/general/cache-buttons')
|
||||||
|
|
||||||
|
const data = [
|
||||||
|
{ value: 'ping', label: t('selector.data.ping') },
|
||||||
|
{ value: 'repository-icons', label: t('selector.data.repositoryIcons') },
|
||||||
|
{ value: 'calendar/medias', label: t('selector.data.calendar&medias') },
|
||||||
|
{ value: 'weather', label: t('selector.data.weather') },
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack spacing="xs">
|
<Stack spacing="xs">
|
||||||
<Title order={4}>Cache cleaning</Title>
|
<Title order={4}>{t('title')}</Title>
|
||||||
<MultiSelect
|
<MultiSelect
|
||||||
value={value}
|
value={value}
|
||||||
searchable
|
searchable
|
||||||
onChange={setValue}
|
onChange={setValue}
|
||||||
data={data}
|
data={data}
|
||||||
label="Select the cache(s) to clear"
|
label={t('selector.label')}
|
||||||
/>
|
/>
|
||||||
<Group>
|
<Group>
|
||||||
<Button
|
<Button
|
||||||
@@ -31,8 +35,11 @@ export function CacheButtons() {
|
|||||||
onClick={() =>
|
onClick={() =>
|
||||||
queryClient.invalidateQueries(value).then(() =>
|
queryClient.invalidateQueries(value).then(() =>
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: 'Cache cleared',
|
title: t('buttons.notificationTitle'),
|
||||||
message: `Cache for ${value.join(', ')} has been cleared`,
|
message:
|
||||||
|
value.length > 1 ?
|
||||||
|
t('buttons.clearSelect.notificationMessageMulti', {values: value.join(', ')}) :
|
||||||
|
t('buttons.clearSelect.notificationMessageSingle', {value: value[0]}),
|
||||||
color: 'teal',
|
color: 'teal',
|
||||||
icon: <IconTrash />,
|
icon: <IconTrash />,
|
||||||
autoClose: 5000,
|
autoClose: 5000,
|
||||||
@@ -40,14 +47,14 @@ export function CacheButtons() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
Clear selected queries
|
{t('buttons.clearSelect.text')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
queryClient.invalidateQueries().then(() =>
|
queryClient.invalidateQueries().then(() =>
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: 'Cache cleared',
|
title: t('buttons.notificationTitle'),
|
||||||
message: 'All cache has been cleared',
|
message: t('buttons.clearAll.notificationMessage'),
|
||||||
color: 'teal',
|
color: 'teal',
|
||||||
icon: <IconTrash />,
|
icon: <IconTrash />,
|
||||||
autoClose: 5000,
|
autoClose: 5000,
|
||||||
@@ -55,7 +62,7 @@ export function CacheButtons() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
Clear all cache
|
{t('buttons.clearAll.text')}
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -8,11 +8,12 @@ export const dashboardNamespaces = [
|
|||||||
'layout/header/actions/toggle-edit-mode',
|
'layout/header/actions/toggle-edit-mode',
|
||||||
'layout/mobile/drawer',
|
'layout/mobile/drawer',
|
||||||
'settings/common',
|
'settings/common',
|
||||||
'settings/general/theme-selector',
|
'settings/general/cache-buttons',
|
||||||
'settings/general/config-changer',
|
'settings/general/config-changer',
|
||||||
'settings/general/edit-mode-toggle',
|
'settings/general/edit-mode-toggle',
|
||||||
'settings/general/internationalization',
|
'settings/general/internationalization',
|
||||||
'settings/general/search-engine',
|
'settings/general/search-engine',
|
||||||
|
'settings/general/theme-selector',
|
||||||
'settings/general/widget-positions',
|
'settings/general/widget-positions',
|
||||||
'settings/customization/accessibility',
|
'settings/customization/accessibility',
|
||||||
'settings/customization/general',
|
'settings/customization/general',
|
||||||
|
|||||||
Reference in New Issue
Block a user