Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.15.8 #2216

Merged
merged 3 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"layout.manage.navigation.**",
],
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
},
"typescript.tsdk": "node_modules/typescript/lib",
"explorer.fileNesting.patterns": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homarr",
"version": "0.15.7",
"version": "0.15.8",
"description": "Homarr - A homepage for your server.",
"license": "MIT",
"repository": {
Expand Down
64 changes: 37 additions & 27 deletions src/server/api/routers/board.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
import { TRPCError } from '@trpc/server';
import Consola from 'consola';
import fs from 'fs';
import { z } from 'zod';
import Consola from 'consola';
import { getDefaultBoardAsync } from '~/server/db/queries/userSettings';
import { configExists } from '~/tools/config/configExists';
import { getConfig } from '~/tools/config/getConfig';
import { getFrontendConfig } from '~/tools/config/getFrontendConfig';
import { writeConfig } from '~/tools/config/writeConfig';
import { generateDefaultApp } from '~/tools/shared/app';
import { configNameSchema } from '~/validations/boards';

import { adminProcedure, createTRPCRouter, protectedProcedure } from '../trpc';
import { writeConfig } from '~/tools/config/writeConfig';
import { configNameSchema } from '~/validations/boards';

export const boardRouter = createTRPCRouter({
all: protectedProcedure
.meta({ openapi: { method: 'GET', path: '/boards/all', tags: ['board'] } })
.input(z.void())
.output(z.array(z.object({
name: z.string(),
allowGuests: z.boolean(),
countApps: z.number().min(0),
countWidgets: z.number().min(0),
countCategories: z.number().min(0),
isDefaultForUser: z.boolean(),
})))
.output(
z.array(
z.object({
name: z.string(),
allowGuests: z.boolean(),
countApps: z.number().min(0),
countWidgets: z.number().min(0),
countCategories: z.number().min(0),
isDefaultForUser: z.boolean(),
})
)
)
.query(async ({ ctx }) => {
const files = fs.readdirSync('./data/configs').filter((file) => file.endsWith('.json'));

Expand All @@ -44,7 +48,7 @@ export const boardRouter = createTRPCRouter({
countCategories: config.categories.length,
isDefaultForUser: name === defaultBoard,
};
}),
})
);
}),
addAppsForContainers: adminProcedure
Expand All @@ -58,9 +62,9 @@ export const boardRouter = createTRPCRouter({
name: z.string(),
icon: z.string().optional(),
port: z.number().optional(),
}),
})
),
}),
})
)
.mutation(async ({ input }) => {
if (!configExists(input.boardName)) {
Expand Down Expand Up @@ -101,12 +105,14 @@ export const boardRouter = createTRPCRouter({
const targetPath = `data/configs/${input.boardName}.json`;
fs.writeFileSync(targetPath, JSON.stringify(newConfig, null, 2), 'utf8');
}),
renameBoard: protectedProcedure
renameBoard: adminProcedure
.meta({ openapi: { method: 'PUT', path: '/boards/rename', tags: ['board'] } })
.input(z.object({
oldName: z.string(),
newName: z.string().min(1),
}))
.input(
z.object({
oldName: configNameSchema,
newName: configNameSchema,
})
)
.output(z.void())
.mutation(async ({ input }) => {
if (input.oldName === 'default') {
Expand Down Expand Up @@ -141,15 +147,19 @@ export const boardRouter = createTRPCRouter({
fs.unlinkSync(targetPath);
Consola.info(`Deleted ${input.oldName} from file system`);
}),
duplicateBoard: protectedProcedure
duplicateBoard: adminProcedure
.meta({ openapi: { method: 'POST', path: '/boards/duplicate', tags: ['board'] } })
.input(z.object({
boardName: z.string(),
}))
.input(
z.object({
boardName: z.string(),
})
)
.output(z.void())
.mutation(async ({ input }) => {
if (!configExists(input.boardName)) {
Consola.error(`Tried to duplicate ${input.boardName} but this configuration does not exist.`);
Consola.error(
`Tried to duplicate ${input.boardName} but this configuration does not exist.`
);
throw new TRPCError({
code: 'NOT_FOUND',
message: 'Board not found',
Expand All @@ -164,7 +174,7 @@ export const boardRouter = createTRPCRouter({
config.configProperties.name = targetName;
writeConfig(config);

Consola.info(`Wrote config to name '${targetName}'`)
Consola.info(`Wrote config to name '${targetName}'`);
}),
});

Expand All @@ -185,7 +195,7 @@ const attemptGenerateDuplicateName = (baseName: string, maxAttempts: number) =>
code: 'CONFLICT',
message: 'Board conflicts with an existing board',
});
}
};

const generateDuplicateName = (baseName: string, increment: number) => {
const result = duplicationName.exec(baseName);
Expand All @@ -197,4 +207,4 @@ const generateDuplicateName = (baseName: string, increment: number) => {
}

return `${baseName} (2)`;
}
};
6 changes: 4 additions & 2 deletions src/server/api/routers/media-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const mediaRequestsRouter = createTRPCRouter({
name: genericItem.name,
userName: item.requestedBy.displayName,
userProfilePicture: constructAvatarUrl(appUrl, item.requestedBy.avatar),
fallbackUserProfilePicture: constructAvatarUrl(appUrl, item.requestedBy.avatar,'avatarproxy'),
userLink: `${appUrl}/users/${item.requestedBy.id}`,
userRequestCount: item.requestedBy.requestCount,
airDate: genericItem.airDate,
Expand Down Expand Up @@ -119,6 +120,7 @@ export const mediaRequestsRouter = createTRPCRouter({
id: user.id,
userName: user.displayName,
userProfilePicture: constructAvatarUrl(appUrl, user.avatar),
fallbackUserProfilePicture: constructAvatarUrl(appUrl, user.avatar,'avatarproxy'),
userLink: `${appUrl}/users/${user.id}`,
userRequestCount: user.requestCount,
};
Expand All @@ -137,14 +139,14 @@ export const mediaRequestsRouter = createTRPCRouter({
}),
});

const constructAvatarUrl = (appUrl: string, avatar: string) => {
const constructAvatarUrl = (appUrl: string, avatar: string, path?: string) => {
const isAbsolute = avatar.startsWith('http://') || avatar.startsWith('https://');

if (isAbsolute) {
return avatar;
}

return `${appUrl}/${avatar}`;
return `${appUrl}/${path?.concat("/") ?? "" }${avatar}`;
};

const retrieveDetailsForItem = async (
Expand Down
11 changes: 9 additions & 2 deletions src/validations/boards.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { DEFAULT_THEME, MANTINE_COLORS, MantineColor } from '@mantine/core';
import { z } from 'zod';
import { BackgroundImageAttachment, BackgroundImageRepeat, BackgroundImageSize } from '~/types/settings';
import {
BackgroundImageAttachment,
BackgroundImageRepeat,
BackgroundImageSize,
} from '~/types/settings';

export const configNameSchema = z.string().regex(/^[a-zA-Z0-9-_\s()]+$/);
export const configNameSchema = z
.string()
.regex(/^[a-zA-Z0-9-_\s()]+$/)
.min(1);

export const createBoardSchemaValidation = z.object({
name: configNameSchema,
Expand Down
10 changes: 5 additions & 5 deletions src/widgets/dnshole/TimerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export function TimerModal({ toggleDns, getDnsStatus, opened, close, appId }: Ti
setHours(0);
setMinutes(0);
}}
title={t('modules/dns-hole-controls:durationModal.title')}
title={t('durationModal.title')}
>
<Flex direction="column" align="center" justify="center">
<Stack align="flex-end">
<Group spacing={5}>
<Text>{t('modules/dns-hole-controls:durationModal.hours')}</Text>
<Text>{t('durationModal.hours')}</Text>
<ActionIcon
size={35}
variant="default"
Expand All @@ -73,7 +73,7 @@ export function TimerModal({ toggleDns, getDnsStatus, opened, close, appId }: Ti
</ActionIcon>
</Group>
<Group spacing={5}>
<Text>{t('modules/dns-hole-controls:durationModal.minutes')}</Text>
<Text>{t('durationModal.minutes')}</Text>
<ActionIcon
size={35}
variant="default"
Expand Down Expand Up @@ -101,7 +101,7 @@ export function TimerModal({ toggleDns, getDnsStatus, opened, close, appId }: Ti
</Group>
</Stack>
<Text ta="center" c="dimmed" my={5}>
{t('modules/dns-hole-controls:durationModal.unlimited')}
{t('durationModal.unlimited')}
</Text>
<Button
variant="light"
Expand All @@ -116,7 +116,7 @@ export function TimerModal({ toggleDns, getDnsStatus, opened, close, appId }: Ti
close();
}}
>
{t('modules/dns-hole-controls:durationModal.set')}
{t('durationModal.set')}
</Button>
</Flex>
</Modal>
Expand Down
1 change: 1 addition & 0 deletions src/widgets/iframe/IFrameTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ function IFrameTile({ widget }: IFrameTileProps) {
return (
<Container h="100%" w="100%" maw="initial" mah="initial" p={0}>
<iframe
sandbox="" // Disables js execution see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#sandbox
className={classes.iframe}
src={widget.properties.embedUrl}
title="widget iframe"
Expand Down
14 changes: 9 additions & 5 deletions src/widgets/media-requests/MediaRequestListTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Stack,
Text,
Tooltip,
Avatar,
useMantineTheme,
} from '@mantine/core';
import { notifications } from '@mantine/notifications';
Expand Down Expand Up @@ -170,14 +171,17 @@ function MediaRequestListTile({ widget }: MediaRequestListWidgetProps) {
</Flex>
<Stack justify="center">
<Flex gap="xs">
<Image
<Avatar
src={item.userProfilePicture}
width={25}
height={25}
size={25}
alt="requester avatar"
radius="xl"
withPlaceholder
/>
>
<Image
src={item.fallbackUserProfilePicture}
alt="requester avatar"
/>
</Avatar>
<Anchor
href={item.userLink}
target={widget.properties.openInNewTab ? '_blank' : '_self'}
Expand Down
5 changes: 4 additions & 1 deletion src/widgets/media-requests/MediaRequestStatsTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Stack,
Text,
Tooltip,
Image,
useMantineTheme,
} from '@mantine/core';
import { useElementSize } from '@mantine/hooks';
Expand Down Expand Up @@ -163,7 +164,9 @@ function MediaRequestStatsTile({ widget }: MediaRequestStatsWidgetProps) {
/>
</Tooltip.Floating>
)}
<Avatar radius="xl" size={45} src={user.userProfilePicture} alt="user avatar" />
<Avatar radius="xl" size={45} src={user.userProfilePicture} alt="user avatar" >
<Image src={user.fallbackUserProfilePicture} alt="user avatar" />
</Avatar>
<Stack spacing={0} style={{ flex: 1 }}>
<Text>{user.userName}</Text>
<Text size="xs">
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/media-requests/media-request-types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type MediaRequest = {
name: string;
userName: string;
userProfilePicture: string;
fallbackUserProfilePicture: string;
userLink: string;
userRequestCount: number;
airDate?: string;
Expand All @@ -22,6 +23,7 @@ export type Users = {
id: number;
userName: string;
userProfilePicture: string;
fallbackUserProfilePicture: string;
userLink: string;
userRequestCount: number;
};
Expand Down
Loading