mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-09 15:05:48 +01:00
Merge branch 'dev' into next-13
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "homarr",
|
"name": "homarr",
|
||||||
"version": "0.11.3",
|
"version": "0.11.4",
|
||||||
"description": "Homarr - A homepage for your server.",
|
"description": "Homarr - A homepage for your server.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
},
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"label": "Dash. URL"
|
"label": "Dash. URL"
|
||||||
|
},
|
||||||
|
"usePercentages": {
|
||||||
|
"label": "Display percentages"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
createStyles,
|
createStyles,
|
||||||
Divider,
|
Divider,
|
||||||
|
Grid,
|
||||||
Group,
|
Group,
|
||||||
HoverCard,
|
HoverCard,
|
||||||
Modal,
|
Modal,
|
||||||
@@ -94,35 +95,45 @@ export const AboutModal = ({ opened, closeModal, newVersionAvailable }: AboutMod
|
|||||||
{t('layout/modals/about:contact')}
|
{t('layout/modals/about:contact')}
|
||||||
</Title>
|
</Title>
|
||||||
|
|
||||||
<Group grow>
|
<Grid grow>
|
||||||
<Button
|
<Grid.Col md={4} xs={12}>
|
||||||
component="a"
|
<Button
|
||||||
href="https://github.com/ajnart/homarr"
|
component="a"
|
||||||
target="_blank"
|
href="https://github.com/ajnart/homarr"
|
||||||
leftIcon={<IconBrandGithub size={20} />}
|
target="_blank"
|
||||||
variant="default"
|
leftIcon={<IconBrandGithub size={20} />}
|
||||||
>
|
variant="default"
|
||||||
GitHub
|
fullWidth
|
||||||
</Button>
|
>
|
||||||
<Button
|
GitHub
|
||||||
component="a"
|
</Button>
|
||||||
href="https://homarr.dev/"
|
</Grid.Col>
|
||||||
target="_blank"
|
<Grid.Col md={4} xs={12}>
|
||||||
leftIcon={<IconWorldWww size={20} />}
|
<Button
|
||||||
variant="default"
|
component="a"
|
||||||
>
|
href="https://homarr.dev/"
|
||||||
Documentation
|
target="_blank"
|
||||||
</Button>
|
leftIcon={<IconWorldWww size={20} />}
|
||||||
<Button
|
variant="default"
|
||||||
component="a"
|
fullWidth
|
||||||
href="https://discord.gg/aCsmEV5RgA"
|
>
|
||||||
target="_blank"
|
Documentation
|
||||||
leftIcon={<IconBrandDiscord size={20} />}
|
</Button>
|
||||||
variant="default"
|
</Grid.Col>
|
||||||
>
|
|
||||||
Discord
|
<Grid.Col md={4} xs={12}>
|
||||||
</Button>
|
<Button
|
||||||
</Group>
|
component="a"
|
||||||
|
href="https://discord.gg/aCsmEV5RgA"
|
||||||
|
target="_blank"
|
||||||
|
leftIcon={<IconBrandDiscord size={20} />}
|
||||||
|
variant="default"
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
Discord
|
||||||
|
</Button>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
<Credits />
|
<Credits />
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
@@ -16,7 +16,7 @@ export const AppPing = ({ app }: AppPingProps) => {
|
|||||||
(config?.settings.customization.layout.enabledPing && app.network.enabledStatusChecker) ??
|
(config?.settings.customization.layout.enabledPing && app.network.enabledStatusChecker) ??
|
||||||
false;
|
false;
|
||||||
const { data, isLoading } = useQuery({
|
const { data, isLoading } = useQuery({
|
||||||
queryKey: [`ping/${app.id}`],
|
queryKey: ['ping', { id: app.id, name: app.name }],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const response = await fetch(`/api/modules/ping?url=${encodeURI(app.url)}`);
|
const response = await fetch(`/api/modules/ping?url=${encodeURI(app.url)}`);
|
||||||
const isOk = app.network.okStatus.includes(response.status);
|
const isOk = app.network.okStatus.includes(response.status);
|
||||||
|
|||||||
@@ -16,17 +16,15 @@ export function Header(props: any) {
|
|||||||
const { classes: cardClasses } = useCardStyles(false);
|
const { classes: cardClasses } = useCardStyles(false);
|
||||||
const { attributes } = usePackageAttributesStore();
|
const { attributes } = usePackageAttributesStore();
|
||||||
|
|
||||||
const [newVersionAvailable, setNewVersionAvailable] = useState<string>('');
|
const { isLoading, error, data } = useQuery({
|
||||||
useEffect(() => {
|
queryKey: ['github/latest'],
|
||||||
// Fetch Data here when component first mounted
|
cacheTime: 1000 * 60 * 60 * 24,
|
||||||
fetch(`https://api.github.com/repos/${REPO_URL}/releases/latest`).then((res) => {
|
staleTime: 1000 * 60 * 60 * 5,
|
||||||
res.json().then((data) => {
|
queryFn: () =>
|
||||||
if (data.tag_name > `v${attributes.packageVersion}`) {
|
fetch(`https://api.github.com/repos/${REPO_URL}/releases/latest`).then((res) => res.json()),
|
||||||
setNewVersionAvailable(data.tag_name);
|
});
|
||||||
}
|
const newVersionAvailable =
|
||||||
});
|
data?.tag_name > `v${attributes.packageVersion}` ? data?.tag_name : undefined;
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MantineHeader height="auto" className={cardClasses.card}>
|
<MantineHeader height="auto" className={cardClasses.card}>
|
||||||
@@ -38,7 +36,13 @@ export function Header(props: any) {
|
|||||||
<Search />
|
<Search />
|
||||||
<ToggleEditModeAction />
|
<ToggleEditModeAction />
|
||||||
<DockerMenuButton />
|
<DockerMenuButton />
|
||||||
<Indicator size={15} color="blue" withBorder processing disabled={!newVersionAvailable}>
|
<Indicator
|
||||||
|
size={15}
|
||||||
|
color="blue"
|
||||||
|
withBorder
|
||||||
|
processing
|
||||||
|
disabled={newVersionAvailable === undefined}
|
||||||
|
>
|
||||||
<SettingsMenu newVersionAvailable={newVersionAvailable} />
|
<SettingsMenu newVersionAvailable={newVersionAvailable} />
|
||||||
</Indicator>
|
</Indicator>
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@@ -148,13 +148,14 @@ export function Search() {
|
|||||||
} = useQuery(
|
} = useQuery(
|
||||||
['overseerr', debounced],
|
['overseerr', debounced],
|
||||||
async () => {
|
async () => {
|
||||||
if (debounced !== '' && selectedSearchEngine.value === 'overseerr' && debounced.length > 3) {
|
const res = await axios.get(`/api/modules/overseerr?query=${debounced}`);
|
||||||
const res = await axios.get(`/api/modules/overseerr?query=${debounced}`);
|
return res.data.results ?? [];
|
||||||
return res.data.results ?? [];
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
enabled:
|
||||||
|
isOverseerrEnabled === true &&
|
||||||
|
selectedSearchEngine.value === 'overseerr' &&
|
||||||
|
debounced.length > 3,
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
refetchOnMount: false,
|
refetchOnMount: false,
|
||||||
refetchInterval: false,
|
refetchInterval: false,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Badge, Button, Menu } from '@mantine/core';
|
|||||||
import { useDisclosure } from '@mantine/hooks';
|
import { useDisclosure } from '@mantine/hooks';
|
||||||
import { IconInfoCircle, IconMenu2, IconSettings } from '@tabler/icons';
|
import { IconInfoCircle, IconMenu2, IconSettings } from '@tabler/icons';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
import { AboutModal } from '../../About/AboutModal';
|
import { AboutModal } from '../../Dashboard/Modals/AboutModal/AboutModal';
|
||||||
import { SettingsDrawer } from '../../Settings/SettingsDrawer';
|
import { SettingsDrawer } from '../../Settings/SettingsDrawer';
|
||||||
import { useCardStyles } from '../useCardStyles';
|
import { useCardStyles } from '../useCardStyles';
|
||||||
import { ColorSchemeSwitch } from './SettingsMenu/ColorSchemeSwitch';
|
import { ColorSchemeSwitch } from './SettingsMenu/ColorSchemeSwitch';
|
||||||
|
|||||||
@@ -68,6 +68,15 @@ export default function DockerMenuButton(props: any) {
|
|||||||
position="right"
|
position="right"
|
||||||
size="full"
|
size="full"
|
||||||
title={<ContainerActionBar selected={selection} reload={reload} />}
|
title={<ContainerActionBar selected={selection} reload={reload} />}
|
||||||
|
styles={{
|
||||||
|
drawer: {
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
minHeight: 0,
|
||||||
|
},
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<DockerTable containers={containers} selection={selection} setSelection={setSelection} />
|
<DockerTable containers={containers} selection={selection} setSelection={setSelection} />
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ export default function DockerTable({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollArea style={{ height: '90vh' }} offsetScrollbars>
|
<ScrollArea style={{ height: '100%' }} offsetScrollbars>
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={t('search.placeholder')}
|
placeholder={t('search.placeholder')}
|
||||||
mr="md"
|
mr="md"
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ export function MediaDisplay({ media }: { media: IMedia }) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{media.type === 'tvshow' && (
|
{media.type === 'tvshow' && (
|
||||||
<Badge variant="dot" size="xs" radius="md" color="blue">
|
<Badge variant="dot" size="xs" radius="md" color="blue" style={{ maxWidth: 200 }}>
|
||||||
s{media.seasonNumber}e{media.episodeNumber} - {media.episodetitle}
|
s{media.seasonNumber}e{media.episodeNumber} - {media.episodetitle}
|
||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ function App(
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
||||||
</Head>
|
</Head>
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<ColorSchemeProvider colorScheme={colorScheme} toggleColorScheme={toggleColorScheme}>
|
<ColorSchemeProvider colorScheme={colorScheme} toggleColorScheme={toggleColorScheme}>
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
import { QueryClient } from '@tanstack/react-query';
|
import { QueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
export const queryClient = new QueryClient();
|
export const queryClient = new QueryClient({
|
||||||
|
defaultOptions: {
|
||||||
|
queries: {
|
||||||
|
staleTime: 5 * 60 * 1000, // 5 mins
|
||||||
|
cacheTime: 10 * 60 * 1000, // 10 mins
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ function CalendarTile({ widget }: CalendarTileProps) {
|
|||||||
|
|
||||||
const { data: medias } = useQuery({
|
const { data: medias } = useQuery({
|
||||||
queryKey: ['calendar/medias', { month: month.getMonth(), year: month.getFullYear() }],
|
queryKey: ['calendar/medias', { month: month.getMonth(), year: month.getFullYear() }],
|
||||||
|
staleTime: 1000 * 60 * 60 * 5,
|
||||||
queryFn: async () =>
|
queryFn: async () =>
|
||||||
(await (
|
(await (
|
||||||
await fetch(
|
await fetch(
|
||||||
|
|||||||
@@ -18,16 +18,10 @@ export const MediaList = ({ medias }: MediaListProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollArea
|
<ScrollArea
|
||||||
|
style={{ height: '80vh', maxWidth: '90vw' }}
|
||||||
offsetScrollbars
|
offsetScrollbars
|
||||||
scrollbarSize={5}
|
|
||||||
pt={5}
|
pt={5}
|
||||||
className={classes.scrollArea}
|
className={classes.scrollArea}
|
||||||
styles={{
|
|
||||||
viewport: {
|
|
||||||
maxHeight: 450,
|
|
||||||
minHeight: 210,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{mapMedias(medias.tvShows, SonarrMediaDisplay, lastMediaType === 'tv-show')}
|
{mapMedias(medias.tvShows, SonarrMediaDisplay, lastMediaType === 'tv-show')}
|
||||||
{mapMedias(medias.movies, RadarrMediaDisplay, lastMediaType === 'movie')}
|
{mapMedias(medias.movies, RadarrMediaDisplay, lastMediaType === 'movie')}
|
||||||
|
|||||||
@@ -5,9 +5,15 @@ interface DashDotGraphProps {
|
|||||||
graph: GraphType;
|
graph: GraphType;
|
||||||
isCompact: boolean;
|
isCompact: boolean;
|
||||||
dashDotUrl: string;
|
dashDotUrl: string;
|
||||||
|
usePercentages: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DashDotGraph = ({ graph, isCompact, dashDotUrl }: DashDotGraphProps) => {
|
export const DashDotGraph = ({
|
||||||
|
graph,
|
||||||
|
isCompact,
|
||||||
|
dashDotUrl,
|
||||||
|
usePercentages,
|
||||||
|
}: DashDotGraphProps) => {
|
||||||
const { classes } = useStyles();
|
const { classes } = useStyles();
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
@@ -25,13 +31,18 @@ export const DashDotGraph = ({ graph, isCompact, dashDotUrl }: DashDotGraphProps
|
|||||||
className={classes.iframe}
|
className={classes.iframe}
|
||||||
key={graph.name}
|
key={graph.name}
|
||||||
title={graph.name}
|
title={graph.name}
|
||||||
src={useIframeSrc(dashDotUrl, graph, isCompact)}
|
src={useIframeSrc(dashDotUrl, graph, isCompact, usePercentages)}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const useIframeSrc = (dashDotUrl: string, graph: GraphType, isCompact: boolean) => {
|
const useIframeSrc = (
|
||||||
|
dashDotUrl: string,
|
||||||
|
graph: GraphType,
|
||||||
|
isCompact: boolean,
|
||||||
|
usePercentages: boolean
|
||||||
|
) => {
|
||||||
const { colorScheme, colors, radius } = useMantineTheme();
|
const { colorScheme, colors, radius } = useMantineTheme();
|
||||||
const surface = (colorScheme === 'dark' ? colors.dark[7] : colors.gray[0]).substring(1); // removes # from hex value
|
const surface = (colorScheme === 'dark' ? colors.dark[7] : colors.gray[0]).substring(1); // removes # from hex value
|
||||||
|
|
||||||
@@ -45,7 +56,8 @@ const useIframeSrc = (dashDotUrl: string, graph: GraphType, isCompact: boolean)
|
|||||||
`&surface=${surface}` +
|
`&surface=${surface}` +
|
||||||
`&gap=${isCompact ? 10 : 5}` +
|
`&gap=${isCompact ? 10 : 5}` +
|
||||||
`&innerRadius=${radius.lg}` +
|
`&innerRadius=${radius.lg}` +
|
||||||
`&multiView=${graph.isMultiView}`
|
`&multiView=${graph.isMultiView}` +
|
||||||
|
`&showPercentage=${usePercentages ? 'true' : 'false'}`
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ const definition = defineWidget({
|
|||||||
type: 'switch',
|
type: 'switch',
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
},
|
},
|
||||||
|
usePercentages: {
|
||||||
|
type: 'switch',
|
||||||
|
defaultValue: false,
|
||||||
|
},
|
||||||
graphs: {
|
graphs: {
|
||||||
type: 'multi-select',
|
type: 'multi-select',
|
||||||
defaultValue: ['cpu', 'memory'],
|
defaultValue: ['cpu', 'memory'],
|
||||||
@@ -88,6 +92,8 @@ function DashDotTile({ widget }: DashDotTileProps) {
|
|||||||
|
|
||||||
const isCompactNetworkVisible = graphs?.some((g) => g.id === 'network' && isCompact);
|
const isCompactNetworkVisible = graphs?.some((g) => g.id === 'network' && isCompact);
|
||||||
|
|
||||||
|
const usePercentages = widget?.properties.usePercentages ?? false;
|
||||||
|
|
||||||
const displayedGraphs = graphs?.filter(
|
const displayedGraphs = graphs?.filter(
|
||||||
(g) => !isCompact || !['network', 'storage'].includes(g.id)
|
(g) => !isCompact || !['network', 'storage'].includes(g.id)
|
||||||
);
|
);
|
||||||
@@ -109,6 +115,7 @@ function DashDotTile({ widget }: DashDotTileProps) {
|
|||||||
graph={graph}
|
graph={graph}
|
||||||
dashDotUrl={dashDotUrl}
|
dashDotUrl={dashDotUrl}
|
||||||
isCompact={isCompact}
|
isCompact={isCompact}
|
||||||
|
usePercentages={usePercentages}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@@ -11,12 +11,18 @@ export const useWeatherForCity = (cityName: string) => {
|
|||||||
data: city,
|
data: city,
|
||||||
isLoading,
|
isLoading,
|
||||||
isError,
|
isError,
|
||||||
} = useQuery({ queryKey: ['weatherCity', { cityName }], queryFn: () => fetchCity(cityName) });
|
} = useQuery({
|
||||||
|
queryKey: ['weatherCity', { cityName }],
|
||||||
|
queryFn: () => fetchCity(cityName),
|
||||||
|
cacheTime: 1000 * 60 * 60 * 24, // the city is cached for 24 hours
|
||||||
|
staleTime: Infinity, // the city is never considered stale
|
||||||
|
});
|
||||||
const weatherQuery = useQuery({
|
const weatherQuery = useQuery({
|
||||||
queryKey: ['weather', { cityName }],
|
queryKey: ['weather', { cityName }],
|
||||||
queryFn: () => fetchWeather(city?.results[0]),
|
queryFn: () => fetchWeather(city?.results[0]),
|
||||||
enabled: !!city,
|
enabled: !!city,
|
||||||
refetchInterval: 1000 * 60 * 5, // requests the weather every 5 minutes
|
cacheTime: 1000 * 60 * 60 * 6, // the weather is cached for 6 hours
|
||||||
|
staleTime: 1000 * 60 * 5, // the weather is considered stale after 5 minutes
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -41,14 +47,14 @@ const fetchCity = async (cityName: string) => {
|
|||||||
* @param coordinates of the location the weather should be fetched
|
* @param coordinates of the location the weather should be fetched
|
||||||
* @returns weather of specified coordinates
|
* @returns weather of specified coordinates
|
||||||
*/
|
*/
|
||||||
const fetchWeather = async (coordinates?: Coordinates) => {
|
async function fetchWeather(coordinates?: Coordinates) {
|
||||||
if (!coordinates) return;
|
if (!coordinates) return null;
|
||||||
const { longitude, latitude } = coordinates;
|
const { longitude, latitude } = coordinates;
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&daily=weathercode,temperature_2m_max,temperature_2m_min¤t_weather=true&timezone=Europe%2FLondon`
|
`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&daily=weathercode,temperature_2m_max,temperature_2m_min¤t_weather=true&timezone=Europe%2FLondon`
|
||||||
);
|
);
|
||||||
// eslint-disable-next-line consistent-return
|
// eslint-disable-next-line consistent-return
|
||||||
return (await res.json()) as WeatherResponse;
|
return (await res.json()) as WeatherResponse;
|
||||||
};
|
}
|
||||||
|
|
||||||
type Coordinates = { latitude: number; longitude: number };
|
type Coordinates = { latitude: number; longitude: number };
|
||||||
|
|||||||
Reference in New Issue
Block a user