Compare commits

...
24 changed files with 153 additions and 70 deletions

No files matched your search

@@ -1,6 +1,6 @@
--- ---
title: 'Immich Album Carousel' title: 'Immich Album Carousel'
description: 'Shows a slideshow of your album pictures from Immich' description: 'Shows a slideshow of pictures from an Immich album or your full library'
hide_title: true hide_title: true
--- ---
@@ -37,4 +37,3 @@ import screen from './img/screen.png';
### Configuration ### Configuration
<WidgetConfig configuration={immichAlbumCarouselWidget.configuration} /> <WidgetConfig configuration={immichAlbumCarouselWidget.configuration} />
@@ -4,15 +4,16 @@ import { IconPhoto } from "@tabler/icons-react";
export const immichAlbumCarouselWidget: WidgetDefinition = { export const immichAlbumCarouselWidget: WidgetDefinition = {
icon: IconPhoto, icon: IconPhoto,
name: "Immich Album", name: "Immich Album",
description: "Shows a slideshow of your album pictures from Immich", description: "Shows a slideshow of pictures from an Immich album or your full library",
path: "../../widgets/immich-album-carousel", path: "../../widgets/immich-album-carousel",
configuration: { configuration: {
items: [ items: [
{ {
name: "Album", name: "Album",
description: "Select the Immich album to show in the slideshow.", description:
"Select an Immich album or All photos. An empty selection also shows random photos from your full library.",
values: { type: "string" }, values: { type: "string" },
defaultValue: "", defaultValue: "All photos",
}, },
{ {
name: "Interval in seconds", name: "Interval in seconds",
@@ -16,7 +16,10 @@ export default async function AppEditPage(props: AppEditPageProps) {
const params = await props.params; const params = await props.params;
const session = await auth(); const session = await auth();
if (!session?.user.permissions.includes("app-modify-all")) { if (
!session?.user.permissions.includes("board-modify-all") ||
!session?.user.permissions.includes("app-modify-all")
) {
notFound(); notFound();
} }
const app = await api.app.byId({ id: params.id }); const app = await api.app.byId({ id: params.id });
@@ -10,7 +10,7 @@ import { DynamicBreadcrumb } from "~/components/navigation/dynamic-breadcrumb";
export default async function AppNewPage() { export default async function AppNewPage() {
const session = await auth(); const session = await auth();
if (!session?.user.permissions.includes("app-create")) { if (!session?.user.permissions.includes("board-modify-all") || !session?.user.permissions.includes("app-create")) {
notFound(); notFound();
} }
@@ -1,5 +1,5 @@
import { Fragment } from "react"; import { Fragment } from "react";
import { redirect } from "next/navigation"; import { notFound, redirect } from "next/navigation";
import { ActionIcon, ActionIconGroup, Anchor, Avatar, Card, Group, Stack, Text } from "@mantine/core"; import { ActionIcon, ActionIconGroup, Anchor, Avatar, Card, Group, Stack, Text } from "@mantine/core";
import { IconBox, IconPencil } from "@tabler/icons-react"; import { IconBox, IconPencil } from "@tabler/icons-react";
import { z } from "zod/v4"; import { z } from "zod/v4";
@@ -33,6 +33,9 @@ export default async function AppsPage(props: AppsPageProps) {
if (!session) { if (!session) {
redirect("/auth/login"); redirect("/auth/login");
} }
if (!session.user.permissions.includes("board-modify-all")) {
notFound();
}
const searchParams = searchParamsSchema.parse(await props.searchParams); const searchParams = searchParamsSchema.parse(await props.searchParams);
@@ -61,7 +61,7 @@ export default async function ManageLayout({ children }: PropsWithChildren) {
icon: IconBox, icon: IconBox,
href: "/manage/apps", href: "/manage/apps",
label: t("items.apps"), label: t("items.apps"),
hidden: !session, hidden: !session?.user.permissions.includes("board-modify-all"),
iconProps: { iconProps: {
strokeWidth: 2.5, strokeWidth: 2.5,
}, },
+2 -1
View File
@@ -18,7 +18,8 @@ import { AppAccessControl } from "./app/app-access-control";
const defaultIcon = "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/homarr.svg"; const defaultIcon = "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/homarr.svg";
export const appRouter = createTRPCRouter({ export const appRouter = createTRPCRouter({
getPaginated: protectedProcedure getPaginated: permissionRequiredProcedure
.requiresPermission("board-modify-all")
.input(paginatedSchema) .input(paginatedSchema)
.output(z.object({ items: z.array(selectAppSchema), totalCount: z.number() })) .output(z.object({ items: z.array(selectAppSchema), totalCount: z.number() }))
.meta({ .meta({
+1 -1
View File
@@ -101,7 +101,7 @@ export const homeRouter = createTRPCRouter({
}); });
} }
if (ctx.session?.user) { if (ctx.session?.user.permissions.includes("board-modify-all")) {
statistics.push({ statistics.push({
titleKey: "app", titleKey: "app",
subtitleKey: "resources", subtitleKey: "resources",
+27
View File
@@ -76,6 +76,33 @@ describe("all should return all apps", () => {
}); });
}); });
describe("getPaginated should require board modification access", () => {
test("should throw FORBIDDEN without board-modify-all", async () => {
const caller = appRouter.createCaller({
db: createDb(),
deviceType: undefined,
session: createDefaultSession(),
});
await expect(caller.getPaginated({ page: 1, pageSize: 10 })).rejects.toThrow("Permission denied");
});
test("should return apps with board-modify-all", async () => {
const db = createDb();
const caller = appRouter.createCaller({
db,
deviceType: undefined,
session: createDefaultSession(["board-modify-all"]),
});
await db.insert(apps).values({ id: "1", name: "Homarr", iconUrl: "https://homarr.dev/icon.svg" });
await expect(caller.getPaginated({ page: 1, pageSize: 10 })).resolves.toMatchObject({
totalCount: 1,
items: [{ id: "1" }],
});
});
});
describe("byId should return an app by id", () => { describe("byId should return an app by id", () => {
test("should return an app by id when canUserSeeAppAsync returns true", async () => { test("should return an app by id when canUserSeeAppAsync returns true", async () => {
// Arrange // Arrange
+1 -1
View File
@@ -25,7 +25,7 @@ export const immichRouter = createTRPCRouter({
.concat(createImmichIntegrationMiddleware("query")) .concat(createImmichIntegrationMiddleware("query"))
.input( .input(
z.object({ z.object({
albumId: z.string(), albumId: z.string().optional(),
}), }),
) )
.query(async ({ ctx, input }) => { .query(async ({ ctx, input }) => {
@@ -1,11 +1,14 @@
import { import {
AssetMediaSize, AssetMediaSize,
AssetTypeEnum,
AssetVisibility,
getAlbumInfo, getAlbumInfo,
getAllAlbums, getAllAlbums,
getMyUser, getMyUser,
getServerStatistics, getServerStatistics,
init, init,
searchAssets, searchAssets,
searchRandom,
searchUsers, searchUsers,
} from "@immich/sdk"; } from "@immich/sdk";
import type { AssetResponseDto, MetadataSearchDto } from "@immich/sdk"; import type { AssetResponseDto, MetadataSearchDto } from "@immich/sdk";
@@ -43,6 +46,7 @@ export interface ImmichAsset {
} }
const logger = createLogger({ module: "immich-integration" }); const logger = createLogger({ module: "immich-integration" });
const randomPhotoCount = 50;
export class ImmichIntegration extends Integration { export class ImmichIntegration extends Integration {
constructor(integration: IntegrationInput) { constructor(integration: IntegrationInput) {
@@ -63,38 +67,36 @@ export class ImmichIntegration extends Integration {
}; };
} }
public async getAlbumAsync(albumId: string): Promise<ImmichAlbum> { public async getAlbumAsync(albumId?: string): Promise<ImmichAlbum> {
this.initClient(); this.initClient();
const requestOptions = this.getRequestOptions(); const requestOptions = this.getRequestOptions();
if (!albumId) {
const assets = await searchRandom(
{
randomSearchDto: {
size: randomPhotoCount,
type: AssetTypeEnum.Image,
visibility: AssetVisibility.Timeline,
},
},
requestOptions,
);
return {
id: "",
albumName: "",
assets: await this.createAssetsAsync(assets),
};
}
const [album, albumAssets] = await Promise.all([ const [album, albumAssets] = await Promise.all([
getAlbumInfo({ id: albumId }, requestOptions), getAlbumInfo({ id: albumId }, requestOptions),
this.searchAlbumAssetsAsync(albumId), this.searchAlbumAssetsAsync(albumId),
]); ]);
const imageProxy = new ImageProxy();
return { return {
albumName: album.albumName, albumName: album.albumName,
assets: await Promise.all( assets: await this.createAssetsAsync(albumAssets),
albumAssets.map(async (asset) => {
const publicLink = await imageProxy.createImageAsync(
// This is the URL generated by the SDK's viewAsset call. Preview images are
// browser-compatible while avoiding the large original asset download.
this.url(`/api/assets/${asset.id}/thumbnail`, { size: AssetMediaSize.Preview }).toString(),
{
"x-api-key": this.getSecretValue("apiKey"),
},
);
return {
id: asset.id,
type: asset.type,
thumbhash: asset.thumbhash,
fileCreatedAt: asset.fileCreatedAt,
fileModifiedAt: asset.fileModifiedAt,
originalPath: asset.originalPath,
updatedAt: asset.updatedAt,
publicLink,
};
}),
),
id: album.id, id: album.id,
}; };
} }
@@ -136,6 +138,32 @@ export class ImmichIntegration extends Integration {
return assets; return assets;
} }
private async createAssetsAsync(assets: AssetResponseDto[]): Promise<ImmichAsset[]> {
const imageProxy = new ImageProxy();
return await Promise.all(
assets.map(async (asset) => {
const publicLink = await imageProxy.createImageAsync(
// This is the URL generated by the SDK's viewAsset call. Preview images are
// browser-compatible while avoiding the large original asset download.
this.url(`/api/assets/${asset.id}/thumbnail`, { size: AssetMediaSize.Preview }).toString(),
{
"x-api-key": this.getSecretValue("apiKey"),
},
);
return {
id: asset.id,
type: asset.type,
thumbhash: asset.thumbhash,
fileCreatedAt: asset.fileCreatedAt,
fileModifiedAt: asset.fileModifiedAt,
originalPath: asset.originalPath,
updatedAt: asset.updatedAt,
publicLink,
};
}),
);
}
private getRequestOptions(fetchAsync = fetchWithTrustedCertificatesAsync) { private getRequestOptions(fetchAsync = fetchWithTrustedCertificatesAsync) {
return { return {
// Undici and node types are not the same // Undici and node types are not the same
+1 -1
View File
@@ -33,7 +33,7 @@ export const immichAlbumsRequestHandler = createIntegrationRequestHandler<
export const immichAlbumRequestHandler = createIntegrationRequestHandler< export const immichAlbumRequestHandler = createIntegrationRequestHandler<
ImmichAlbum, ImmichAlbum,
IntegrationKindByCategory<"photoService">, IntegrationKindByCategory<"photoService">,
{ albumId: string } { albumId?: string }
>({ >({
async requestAsync(integration, input) { async requestAsync(integration, input) {
const integrationInstance = await createIntegrationAsync(integration); const integrationInstance = await createIntegrationAsync(integration);
@@ -16,4 +16,6 @@ export const mediaRequestStatsRequestHandler = createIntegrationRequestHandler<
users: await integrationInstance.getUsersAsync(), users: await integrationInstance.getUsersAsync(),
}; };
}, },
cacheTtlMs: 60_000,
fallbackToStaleOnError: true,
}); });
+4 -1
View File
@@ -9,7 +9,7 @@ export const weatherRequestHandler = createWidgetRequestHandler({
async requestAsync(input: { latitude: number; longitude: number }) { async requestAsync(input: { latitude: number; longitude: number }) {
const res = await withTimeoutAsync(async (signal) => { const res = await withTimeoutAsync(async (signal) => {
return await fetchWithTrustedCertificatesAsync( return await fetchWithTrustedCertificatesAsync(
`https://api.open-meteo.com/v1/forecast?latitude=${input.latitude}&longitude=${input.longitude}&daily=weathercode,temperature_2m_max,temperature_2m_min,sunrise,sunset,wind_speed_10m_max,wind_gusts_10m_max&current_weather=true&timezone=auto`, `https://api.open-meteo.com/v1/forecast?latitude=${input.latitude}&longitude=${input.longitude}&daily=weathercode,temperature_2m_max,temperature_2m_min,sunrise,sunset,wind_speed_10m_max,wind_gusts_10m_max,relative_humidity_2m_mean&current_weather=true&timezone=auto`,
{ signal }, { signal },
); );
}); });
@@ -27,6 +27,7 @@ export const weatherRequestHandler = createWidgetRequestHandler({
sunset: weather.daily.sunset[index], sunset: weather.daily.sunset[index],
maxWindSpeed: weather.daily.wind_speed_10m_max[index], maxWindSpeed: weather.daily.wind_speed_10m_max[index],
maxWindGusts: weather.daily.wind_gusts_10m_max[index], maxWindGusts: weather.daily.wind_gusts_10m_max[index],
humidity: weather.daily.relative_humidity_2m_mean[index],
}; };
}), }),
} satisfies Weather; } satisfies Weather;
@@ -48,6 +49,7 @@ const atLocationOutput = z.object({
sunset: z.array(z.string()), sunset: z.array(z.string()),
wind_speed_10m_max: z.array(z.number()), wind_speed_10m_max: z.array(z.number()),
wind_gusts_10m_max: z.array(z.number()), wind_gusts_10m_max: z.array(z.number()),
relative_humidity_2m_mean: z.array(z.number()),
}), }),
}); });
@@ -66,5 +68,6 @@ export interface Weather {
sunset: string | undefined; sunset: string | undefined;
maxWindSpeed: number | undefined; maxWindSpeed: number | undefined;
maxWindGusts: number | undefined; maxWindGusts: number | undefined;
humidity: number | undefined;
}[]; }[];
} }
@@ -17,6 +17,10 @@ export const appIntegrationBoardMode = {
return groups; return groups;
} }
return groups.concat([appsSearchGroup, integrationsSearchGroup]); return groups.concat(
session.user.permissions.includes("board-modify-all")
? [appsSearchGroup, integrationsSearchGroup]
: [integrationsSearchGroup],
);
}, },
} satisfies SearchMode; } satisfies SearchMode;
@@ -87,7 +87,8 @@ export const globalCommandGroup = createGroup<Command>({
icon: IconBox, icon: IconBox,
name: tOption("newApp.label"), name: tOption("newApp.label"),
useInteraction: interaction.link(() => ({ href: "/manage/apps/new" })), useInteraction: interaction.link(() => ({ href: "/manage/apps/new" })),
hidden: !session?.user.permissions.includes("app-create"), hidden:
!session?.user.permissions.includes("board-modify-all") || !session?.user.permissions.includes("app-create"),
}, },
{ {
commandKey: "newIntegration", commandKey: "newIntegration",
@@ -76,7 +76,7 @@ export const pagesSearchGroup = createGroup<{
icon: IconBox, icon: IconBox,
path: "/manage/apps", path: "/manage/apps",
name: t("manageApp.label"), name: t("manageApp.label"),
hidden: !session, hidden: !session?.user.permissions.includes("board-modify-all"),
}, },
{ {
icon: IconPlug, icon: IconPlug,
+6 -5
View File
@@ -2257,7 +2257,8 @@
"sunrise": "Sunrise", "sunrise": "Sunrise",
"sunset": "Sunset", "sunset": "Sunset",
"maxWindSpeed": "Max wind speed: {maxWindSpeed} {unit}", "maxWindSpeed": "Max wind speed: {maxWindSpeed} {unit}",
"maxWindGusts": "Max wind gusts: {maxWindGusts} {unit}" "maxWindGusts": "Max wind gusts: {maxWindGusts} {unit}",
"humidity": "Humidity: {humidity}%"
}, },
"kind": { "kind": {
"clear": "Clear", "clear": "Clear",
@@ -3006,10 +3007,11 @@
}, },
"immich-albumCarousel": { "immich-albumCarousel": {
"name": "Immich Album", "name": "Immich Album",
"allPhotos": "All photos",
"option": { "option": {
"albumId": { "albumId": {
"label": "Album", "label": "Album",
"description": "Select the Immich album to show in the slideshow." "description": "Select an Immich album or All photos. An empty selection also shows random photos from your full library."
}, },
"rotationIntervalSeconds": { "rotationIntervalSeconds": {
"label": "Interval in seconds", "label": "Interval in seconds",
@@ -3024,9 +3026,8 @@
"description": "Show photos in a random order instead of always starting with the same album order." "description": "Show photos in a random order instead of always starting with the same album order."
} }
}, },
"description": "Slideshow of pictures in your Immich album", "description": "Slideshow of pictures from an Immich album or your full library",
"noAlbumSelected": "No album selected, edit widget and choose an album", "noPhotos": "No photos found"
"noPhotos": "No photos in this album"
}, },
"downloads": { "downloads": {
"name": "Download Client", "name": "Download Client",
@@ -11,6 +11,7 @@ import { useI18n } from "@homarr/translation/client";
import { WidgetEmptyState } from "../../common/empty-state"; import { WidgetEmptyState } from "../../common/empty-state";
import type { WidgetComponentProps } from "../../definition"; import type { WidgetComponentProps } from "../../definition";
import classes from "./component.module.css"; import classes from "./component.module.css";
import { ALL_PHOTOS_ALBUM_ID } from "./constants";
export default function ImmichAlbumCarouselWidget({ export default function ImmichAlbumCarouselWidget({
integrationIds, integrationIds,
@@ -21,9 +22,9 @@ export default function ImmichAlbumCarouselWidget({
const { data: album } = clientApi.widget.immich.getAlbum.useQuery( const { data: album } = clientApi.widget.immich.getAlbum.useQuery(
{ {
integrationId: integrationIds[0] ?? "", integrationId: integrationIds[0] ?? "",
albumId: options.albumId ?? "", albumId: options.albumId && options.albumId !== ALL_PHOTOS_ALBUM_ID ? options.albumId : undefined,
}, },
{ enabled: Boolean(options.albumId) }, { enabled: integrationIds.length > 0 },
); );
const photoAssets = useMemo(() => { const photoAssets = useMemo(() => {
@@ -35,10 +36,6 @@ export default function ImmichAlbumCarouselWidget({
setCurrentPhotoIndex(0); setCurrentPhotoIndex(0);
}, [photoAssets]); }, [photoAssets]);
if (!options.albumId) {
return <NoAlbumSelected />;
}
if (!album) return <WidgetEmptyState />; if (!album) return <WidgetEmptyState />;
if (album.assets.length === 0) { if (album.assets.length === 0) {
@@ -117,20 +114,6 @@ function Carousel({ assets, currentIndex, setCurrentIndex, rotationInterval, sho
); );
} }
function NoAlbumSelected() {
const t = useI18n();
return (
<Center h="100%">
<Stack align="center" gap="xs">
<IconAlertCircle size={32} />
<Text size="sm" fw={500}>
{t("widget.immich-albumCarousel.noAlbumSelected")}
</Text>
</Stack>
</Center>
);
}
function NoPhotosInAlbum() { function NoPhotosInAlbum() {
const t = useI18n(); const t = useI18n();
return ( return (
@@ -0,0 +1 @@
export const ALL_PHOTOS_ALBUM_ID = "all";
@@ -2,9 +2,11 @@ import { IconPhoto } from "@tabler/icons-react";
import z from "zod"; import z from "zod";
import { clientApi } from "@homarr/api/client"; import { clientApi } from "@homarr/api/client";
import { useScopedI18n } from "@homarr/translation/client";
import { createWidgetDefinition } from "../../definition"; import { createWidgetDefinition } from "../../definition";
import { optionsBuilder } from "../../options"; import { optionsBuilder } from "../../options";
import { ALL_PHOTOS_ALBUM_ID } from "./constants";
export const { definition, componentLoader } = createWidgetDefinition("immich-albumCarousel", { export const { definition, componentLoader } = createWidgetDefinition("immich-albumCarousel", {
icon: IconPhoto, icon: IconPhoto,
@@ -15,9 +17,11 @@ export const { definition, componentLoader } = createWidgetDefinition("immich-al
createOptions() { createOptions() {
return optionsBuilder.from((factory) => ({ return optionsBuilder.from((factory) => ({
albumId: factory.integrationSelect({ albumId: factory.integrationSelect({
defaultValue: ALL_PHOTOS_ALBUM_ID,
withDescription: true, withDescription: true,
clearable: true, clearable: true,
useOptions: (integrationIds: string[]) => { useOptions: (integrationIds: string[]) => {
const t = useScopedI18n("widget.immich-albumCarousel");
const { const {
data = [], data = [],
isPending, isPending,
@@ -26,7 +30,14 @@ export const { definition, componentLoader } = createWidgetDefinition("immich-al
{ integrationId: integrationIds[0] ?? "" }, { integrationId: integrationIds[0] ?? "" },
{ enabled: integrationIds.length > 0, staleTime: 15 * 60 * 1000 }, { enabled: integrationIds.length > 0, staleTime: 15 * 60 * 1000 },
); );
return { data: data.map((album) => ({ value: album.id, label: album.albumName })), isPending, isError }; return {
data: [
{ value: ALL_PHOTOS_ALBUM_ID, label: t("allPhotos") },
...data.map((album) => ({ value: album.id, label: album.albumName })),
],
isPending,
isError,
};
}, },
}), }),
rotationIntervalSeconds: factory.number({ rotationIntervalSeconds: factory.number({
@@ -66,10 +66,12 @@ export default function MediaServerWidget({ options, integrationIds }: WidgetCom
const currentlyPlaying = row.original.currentlyPlaying; const currentlyPlaying = row.original.currentlyPlaying;
if (!currentlyPlaying) return null; if (!currentlyPlaying) return null;
const isPaused = currentlyPlaying.playback.state === "paused"; const playback = currentlyPlaying.playback;
const isPaused = playback?.state === "paused";
const Icon = isPaused ? IconPlayerPause : mediaTypeIconMap[currentlyPlaying.type]; const Icon = isPaused ? IconPlayerPause : mediaTypeIconMap[currentlyPlaying.type];
const { positionMs, durationMs } = currentlyPlaying.playback; const positionMs = playback?.positionMs ?? null;
const durationMs = playback?.durationMs ?? null;
const progressPercent = const progressPercent =
positionMs !== null && durationMs !== null && durationMs > 0 positionMs !== null && durationMs !== null && durationMs > 0
? Math.min(100, Math.round((positionMs / durationMs) * 100)) ? Math.min(100, Math.round((positionMs / durationMs) * 100))
+8 -1
View File
@@ -1,7 +1,7 @@
"use client"; "use client";
import { Box, Group, HoverCard, Stack, Text } from "@mantine/core"; import { Box, Group, HoverCard, Stack, Text } from "@mantine/core";
import { IconArrowDownRight, IconArrowUpRight, IconMapPin, IconWind } from "@tabler/icons-react"; import { IconArrowDownRight, IconArrowUpRight, IconDroplets, IconMapPin, IconWind } from "@tabler/icons-react";
import combineClasses from "clsx"; import combineClasses from "clsx";
import dayjs from "dayjs"; import dayjs from "dayjs";
@@ -87,6 +87,12 @@ const DailyWeather = ({ options, weather }: WeatherProps) => {
</Text> </Text>
</Group> </Group>
)} )}
{weather.daily[0]?.humidity !== undefined && (
<Group className="weather-humidity-group" wrap="nowrap" gap="xs">
<IconDroplets size={16} />
<Text fz={16}>{t("dailyForecast.humidity", { humidity: weather.daily[0].humidity })}</Text>
</Group>
)}
<Group className="weather-max-min-temp-group" wrap="nowrap" gap="sm"> <Group className="weather-max-min-temp-group" wrap="nowrap" gap="sm">
<Group gap="xs" wrap="nowrap"> <Group gap="xs" wrap="nowrap">
<IconArrowUpRight size={16} /> <IconArrowUpRight size={16} />
@@ -204,6 +210,7 @@ function Forecast({ weather, options }: WeatherProps) {
sunset={dayjs(dayWeather.sunset).format("HH:mm")} sunset={dayjs(dayWeather.sunset).format("HH:mm")}
maxWindSpeed={dayWeather.maxWindSpeed} maxWindSpeed={dayWeather.maxWindSpeed}
maxWindGusts={dayWeather.maxWindGusts} maxWindGusts={dayWeather.maxWindGusts}
humidity={dayWeather.humidity}
/> />
</HoverCard.Dropdown> </HoverCard.Dropdown>
</HoverCard> </HoverCard>
+6
View File
@@ -5,6 +5,7 @@ import {
IconCloudRain, IconCloudRain,
IconCloudSnow, IconCloudSnow,
IconCloudStorm, IconCloudStorm,
IconDroplets,
IconMoon, IconMoon,
IconQuestionMark, IconQuestionMark,
IconSnowflake, IconSnowflake,
@@ -51,6 +52,7 @@ interface WeatherDescriptionProps {
sunset?: string; sunset?: string;
maxWindSpeed?: number; maxWindSpeed?: number;
maxWindGusts?: number; maxWindGusts?: number;
humidity?: number;
} }
/** /**
@@ -78,6 +80,7 @@ export const WeatherDescription = ({
sunset, sunset,
maxWindSpeed, maxWindSpeed,
maxWindGusts, maxWindGusts,
humidity,
}: WeatherDescriptionProps) => { }: WeatherDescriptionProps) => {
const t = useScopedI18n("widget.weather"); const t = useScopedI18n("widget.weather");
const tCommon = useScopedI18n("common"); const tCommon = useScopedI18n("common");
@@ -97,6 +100,9 @@ export const WeatherDescription = ({
<List.Item icon={<IconTemperatureMinus size={15} />}>{`${tCommon("information.min")}: ${minTemp}`}</List.Item> <List.Item icon={<IconTemperatureMinus size={15} />}>{`${tCommon("information.min")}: ${minTemp}`}</List.Item>
<List.Item icon={<IconSun size={15} />}>{`${t("dailyForecast.sunrise")}: ${sunrise}`}</List.Item> <List.Item icon={<IconSun size={15} />}>{`${t("dailyForecast.sunrise")}: ${sunrise}`}</List.Item>
<List.Item icon={<IconMoon size={15} />}>{`${t("dailyForecast.sunset")}: ${sunset}`}</List.Item> <List.Item icon={<IconMoon size={15} />}>{`${t("dailyForecast.sunset")}: ${sunset}`}</List.Item>
{humidity !== undefined && (
<List.Item icon={<IconDroplets size={15} />}>{t("dailyForecast.humidity", { humidity })}</List.Item>
)}
{maxWindSpeed !== undefined && ( {maxWindSpeed !== undefined && (
<List.Item icon={<IconWind size={15} />}> <List.Item icon={<IconWind size={15} />}>
{t("dailyForecast.maxWindSpeed", { {t("dailyForecast.maxWindSpeed", {