mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-15 17:56:21 +01:00
Merge branch 'dev' into feature/add-basic-authentication
This commit is contained in:
@@ -22,6 +22,8 @@
|
|||||||
"test:ui": "vitest --ui",
|
"test:ui": "vitest --ui",
|
||||||
"test:run": "vitest run",
|
"test:run": "vitest run",
|
||||||
"test:coverage": "vitest run --coverage",
|
"test:coverage": "vitest run --coverage",
|
||||||
|
"docker:build": "turbo build && docker build . -t homarr:dev",
|
||||||
|
"docker:start": "docker run --env-file ./.env -p 7575:7575 homarr:dev ",
|
||||||
"postinstall": "prisma generate"
|
"postinstall": "prisma generate"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -3,7 +3,10 @@
|
|||||||
"name": "Media request stats",
|
"name": "Media request stats",
|
||||||
"description": "Statistics about your media requests",
|
"description": "Statistics about your media requests",
|
||||||
"settings": {
|
"settings": {
|
||||||
"title": "Media requests stats"
|
"title": "Media requests stats",
|
||||||
|
"direction": {
|
||||||
|
"label": "Direction of the layout."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"stats": {
|
"stats": {
|
||||||
|
|||||||
@@ -5,8 +5,12 @@ function Post(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
const { tried, type = 'password' } = req.body;
|
const { tried, type = 'password' } = req.body;
|
||||||
// If the type of password is "edit", we run this branch to check the edit password
|
// If the type of password is "edit", we run this branch to check the edit password
|
||||||
if (type === 'edit') {
|
if (type === 'edit') {
|
||||||
if (tried === process.env.EDIT_MODE_PASSWORD) {
|
if ((tried === process.env.EDIT_MODE_PASSWORD) !== undefined) {
|
||||||
process.env.DISABLE_EDIT_MODE = process.env.DISABLE_EDIT_MODE === 'true' ? 'false' : 'true';
|
if (process.env.DISABLE_EDIT_MODE?.toLowerCase() === 'true') {
|
||||||
|
process.env.DISABLE_EDIT_MODE = 'false';
|
||||||
|
} else {
|
||||||
|
process.env.DISABLE_EDIT_MODE = 'true';
|
||||||
|
}
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Card, Center, Flex, Stack, Text } from '@mantine/core';
|
import { Card, Flex, Stack, Text } from '@mantine/core';
|
||||||
import { IconChartBar } from '@tabler/icons-react';
|
import { IconChartBar } from '@tabler/icons-react';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
|
|
||||||
@@ -11,14 +11,23 @@ import { MediaRequestStatus } from './media-request-types';
|
|||||||
const definition = defineWidget({
|
const definition = defineWidget({
|
||||||
id: 'media-requests-stats',
|
id: 'media-requests-stats',
|
||||||
icon: IconChartBar,
|
icon: IconChartBar,
|
||||||
options: {},
|
options: {
|
||||||
component: MediaRequestStatsTile,
|
direction: {
|
||||||
|
type: 'select',
|
||||||
|
defaultValue: 'row' as 'row' | 'column',
|
||||||
|
data: [
|
||||||
|
{ label: 'Horizontal', value: 'row' },
|
||||||
|
{ label: 'Vertical', value: 'column' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
gridstack: {
|
gridstack: {
|
||||||
minWidth: 1,
|
minWidth: 1,
|
||||||
minHeight: 2,
|
minHeight: 1,
|
||||||
maxWidth: 12,
|
maxWidth: 12,
|
||||||
maxHeight: 12,
|
maxHeight: 12,
|
||||||
},
|
},
|
||||||
|
component: MediaRequestStatsTile,
|
||||||
});
|
});
|
||||||
|
|
||||||
export type MediaRequestStatsWidget = IWidget<(typeof definition)['id'], typeof definition>;
|
export type MediaRequestStatsWidget = IWidget<(typeof definition)['id'], typeof definition>;
|
||||||
@@ -36,41 +45,46 @@ function MediaRequestStatsTile({ widget }: MediaRequestStatsWidgetProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex gap="md" wrap="wrap">
|
<Flex
|
||||||
<Card w={100} h={100} withBorder>
|
w="100%"
|
||||||
<Center h="100%">
|
h="100%"
|
||||||
<Stack spacing={0} align="center">
|
gap="md"
|
||||||
<Text>
|
direction={ widget.properties.direction?? 'row' }
|
||||||
{data.filter((x) => x.status === MediaRequestStatus.PendingApproval).length}
|
>
|
||||||
</Text>
|
<StatCard
|
||||||
<Text color="dimmed" align="center" size="xs">
|
number={data.filter((x) => x.status === MediaRequestStatus.PendingApproval).length}
|
||||||
{t('stats.pending')}
|
label={t('stats.pending')}
|
||||||
</Text>
|
/>
|
||||||
</Stack>
|
<StatCard
|
||||||
</Center>
|
number={data.filter((x) => x.type === 'tv').length}
|
||||||
</Card>
|
label={t('stats.tvRequests')}
|
||||||
<Card w={100} h={100} withBorder>
|
/>
|
||||||
<Center h="100%">
|
<StatCard
|
||||||
<Stack spacing={0} align="center">
|
number={data.filter((x) => x.type === 'movie').length}
|
||||||
<Text align="center">{data.filter((x) => x.type === 'tv').length}</Text>
|
label={t('stats.movieRequests')}
|
||||||
<Text color="dimmed" align="center" size="xs">
|
/>
|
||||||
{t('stats.tvRequests')}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Center>
|
|
||||||
</Card>
|
|
||||||
<Card w={100} h={100} withBorder>
|
|
||||||
<Center h="100%">
|
|
||||||
<Stack spacing={0} align="center">
|
|
||||||
<Text align="center">{data.filter((x) => x.type === 'movie').length}</Text>
|
|
||||||
<Text color="dimmed" align="center" size="xs">
|
|
||||||
{t('stats.movieRequests')}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Center>
|
|
||||||
</Card>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface StatCardProps {
|
||||||
|
number: number;
|
||||||
|
label: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const StatCard = ({ number, label }: StatCardProps) => {
|
||||||
|
return (
|
||||||
|
<Card w="100%" h="100%" withBorder style={{flex:"1 1 auto"}}>
|
||||||
|
<Stack w="100%" h="100%" align="center" justify="center" spacing={0}>
|
||||||
|
<Text align="center">
|
||||||
|
{number}
|
||||||
|
</Text>
|
||||||
|
<Text color="dimmed" align="center" size="xs">
|
||||||
|
{label}
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default definition;
|
export default definition;
|
||||||
Reference in New Issue
Block a user