Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d04c8c437f | ||
|
|
28fefcd23f | ||
|
|
c08054736e | ||
|
|
2e20fd7da5 | ||
|
|
1856d20a47 | ||
|
|
6df2f92268 | ||
|
|
c30f525a83 | ||
|
|
dd23de7aaa | ||
|
|
f1602f67d4 |
No files matched your search
@@ -6,7 +6,7 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24.18.0",
|
"node": ">=24.18.0",
|
||||||
"pnpm": ">=11.11.0"
|
"pnpm": ">=11.13.1"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@11.11.0"
|
"packageManager": "pnpm@11.13.1"
|
||||||
}
|
}
|
||||||
+2
-2
@@ -69,7 +69,7 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24.18.0",
|
"node": ">=24.18.0",
|
||||||
"pnpm": ">=11.11.0"
|
"pnpm": ">=11.13.1"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@11.11.0"
|
"packageManager": "pnpm@11.13.1"
|
||||||
}
|
}
|
||||||
@@ -271,6 +271,7 @@ export const onboardRouter = createTRPCRouter({
|
|||||||
setupIntegrations: onboardingProcedure.requiresStep("integrations").mutation(async ({ ctx }) => {
|
setupIntegrations: onboardingProcedure.requiresStep("integrations").mutation(async ({ ctx }) => {
|
||||||
const db = ctx.db;
|
const db = ctx.db;
|
||||||
|
|
||||||
|
const allIntegrations = await db.query.integrations.findMany();
|
||||||
const allApps = await db.query.apps.findMany();
|
const allApps = await db.query.apps.findMany();
|
||||||
|
|
||||||
const board = await db.query.boards.findFirst({
|
const board = await db.query.boards.findFirst({
|
||||||
@@ -315,6 +316,7 @@ export const onboardRouter = createTRPCRouter({
|
|||||||
layoutId: layout.id,
|
layoutId: layout.id,
|
||||||
columnCount: layout.columnCount,
|
columnCount: layout.columnCount,
|
||||||
},
|
},
|
||||||
|
allIntegrations,
|
||||||
allApps,
|
allApps,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -698,11 +698,13 @@ const seedBoardWidgetsAsync = async (db: Database) => {
|
|||||||
const layout = board.layouts[0];
|
const layout = board.layouts[0];
|
||||||
if (!section || !layout) return;
|
if (!section || !layout) return;
|
||||||
|
|
||||||
|
const allIntegrations = await db.query.integrations.findMany();
|
||||||
const allApps = await db.query.apps.findMany();
|
const allApps = await db.query.apps.findMany();
|
||||||
|
|
||||||
const count = await placeAllWidgetsAsync(
|
const count = await placeAllWidgetsAsync(
|
||||||
db,
|
db,
|
||||||
{ boardId: board.id, sectionId: section.id, layoutId: layout.id, columnCount: layout.columnCount },
|
{ boardId: board.id, sectionId: section.id, layoutId: layout.id, columnCount: layout.columnCount },
|
||||||
|
allIntegrations,
|
||||||
allApps,
|
allApps,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,19 @@
|
|||||||
import { stringify } from "superjson";
|
import superjson from "superjson";
|
||||||
|
|
||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import { defaultBookmarkApps, defaultWidgetConfigs, emptySuperJSON } from "@homarr/definitions";
|
import {
|
||||||
|
defaultBookmarkApps,
|
||||||
|
defaultWidgetConfigs,
|
||||||
|
emptySuperJSON,
|
||||||
|
getWidgetKindsForIntegration,
|
||||||
|
} from "@homarr/definitions";
|
||||||
import type { WidgetKind } from "@homarr/definitions";
|
import type { WidgetKind } from "@homarr/definitions";
|
||||||
|
|
||||||
import type { Database } from "..";
|
import type { Database } from "..";
|
||||||
import { integrationItems, itemLayouts, items } from "../schema";
|
import { integrationItems, itemLayouts, items } from "../schema";
|
||||||
|
import type { Integration } from "../schema";
|
||||||
|
|
||||||
|
const widgetConfigMap = new Map(defaultWidgetConfigs.map((config) => [config.kind, config]));
|
||||||
|
|
||||||
interface BoardTarget {
|
interface BoardTarget {
|
||||||
boardId: string;
|
boardId: string;
|
||||||
@@ -69,7 +77,12 @@ interface App {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const placeAllWidgetsAsync = async (db: Database, target: BoardTarget, allApps: App[]) => {
|
export const placeAllWidgetsAsync = async (
|
||||||
|
db: Database,
|
||||||
|
target: BoardTarget,
|
||||||
|
allIntegrations: Integration[],
|
||||||
|
allApps: App[],
|
||||||
|
) => {
|
||||||
const ctx: PlacementContext = {
|
const ctx: PlacementContext = {
|
||||||
...target,
|
...target,
|
||||||
xOffset: 0,
|
xOffset: 0,
|
||||||
@@ -79,11 +92,38 @@ export const placeAllWidgetsAsync = async (db: Database, target: BoardTarget, al
|
|||||||
|
|
||||||
const placedWidgets = new Set<WidgetKind>();
|
const placedWidgets = new Set<WidgetKind>();
|
||||||
|
|
||||||
|
for (const integration of allIntegrations) {
|
||||||
|
for (const widgetKind of getWidgetKindsForIntegration(integration.kind)) {
|
||||||
|
if (placedWidgets.has(widgetKind)) continue;
|
||||||
|
const config = widgetConfigMap.get(widgetKind);
|
||||||
|
if (config?.skip) continue;
|
||||||
|
placedWidgets.add(widgetKind);
|
||||||
|
|
||||||
|
const matchingIds = allIntegrations
|
||||||
|
.filter((row) => getWidgetKindsForIntegration(row.kind).includes(widgetKind))
|
||||||
|
.map((row) => row.id);
|
||||||
|
|
||||||
|
const options = config?.options ? superjson.stringify(config.options) : undefined;
|
||||||
|
await placeWidgetAsync(
|
||||||
|
db,
|
||||||
|
ctx,
|
||||||
|
widgetKind,
|
||||||
|
matchingIds,
|
||||||
|
options,
|
||||||
|
config && { width: config.width, height: config.height },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const app of allApps) {
|
for (const app of allApps) {
|
||||||
await placeWidgetAsync(db, ctx, "app", [], stringify({ appId: app.id, openInNewTab: true, showTitle: true }), {
|
await placeWidgetAsync(
|
||||||
width: 1,
|
db,
|
||||||
height: 1,
|
ctx,
|
||||||
});
|
"app",
|
||||||
|
[],
|
||||||
|
superjson.stringify({ appId: app.id, openInNewTab: true, showTitle: true }),
|
||||||
|
{ width: 1, height: 1 },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bookmarkAppNames = new Set(defaultBookmarkApps.map((bookmark) => bookmark.name));
|
const bookmarkAppNames = new Set(defaultBookmarkApps.map((bookmark) => bookmark.name));
|
||||||
@@ -98,7 +138,7 @@ export const placeAllWidgetsAsync = async (db: Database, target: BoardTarget, al
|
|||||||
options = { ...options, items: bookmarkAppIds };
|
options = { ...options, items: bookmarkAppIds };
|
||||||
}
|
}
|
||||||
|
|
||||||
await placeWidgetAsync(db, ctx, config.kind, [], options ? stringify(options) : undefined, {
|
await placeWidgetAsync(db, ctx, config.kind, [], options ? superjson.stringify(options) : undefined, {
|
||||||
width: config.width,
|
width: config.width,
|
||||||
height: config.height,
|
height: config.height,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import { useCallback, useState } from "react";
|
import { Box, Container, Flex, HoverCard, Text, useMantineTheme } from "@mantine/core";
|
||||||
import { Box, Container, Flex, Popover, Text, useMantineTheme } from "@mantine/core";
|
|
||||||
import { useElementSize } from "@mantine/hooks";
|
|
||||||
|
|
||||||
import { useRequiredBoard } from "@homarr/boards/context";
|
import { useRequiredBoard } from "@homarr/boards/context";
|
||||||
import type { CalendarEvent } from "@homarr/integrations/types";
|
import type { CalendarEvent } from "@homarr/integrations/types";
|
||||||
@@ -13,14 +11,9 @@ interface CalendarDayProps {
|
|||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
rootWidth: number;
|
rootWidth: number;
|
||||||
rootHeight: number;
|
rootHeight: number;
|
||||||
onOpen: (close: () => void) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CalendarDay = ({ date, events, disabled, rootHeight, rootWidth, onOpen }: CalendarDayProps) => {
|
export const CalendarDay = ({ date, events, disabled, rootHeight, rootWidth }: CalendarDayProps) => {
|
||||||
const [opened, setOpened] = useState(false);
|
|
||||||
const [pinned, setPinned] = useState(false);
|
|
||||||
const { primaryColor } = useMantineTheme();
|
|
||||||
const { ref, height } = useElementSize();
|
|
||||||
const board = useRequiredBoard();
|
const board = useRequiredBoard();
|
||||||
const mantineTheme = useMantineTheme();
|
const mantineTheme = useMantineTheme();
|
||||||
const actualItemRadius = mantineTheme.radius[board.itemRadius];
|
const actualItemRadius = mantineTheme.radius[board.itemRadius];
|
||||||
@@ -29,39 +22,19 @@ export const CalendarDay = ({ date, events, disabled, rootHeight, rootWidth, onO
|
|||||||
const shouldScaleDown = minAxisSize < 350;
|
const shouldScaleDown = minAxisSize < 350;
|
||||||
const isSmall = rootHeight < 256;
|
const isSmall = rootHeight < 256;
|
||||||
|
|
||||||
const isTooSmallForIndicators = height < 30;
|
|
||||||
|
|
||||||
const handleMouseEnter = useCallback(() => {
|
|
||||||
if (disabled) return;
|
|
||||||
onOpen(() => {
|
|
||||||
setOpened(false);
|
|
||||||
setPinned(false);
|
|
||||||
});
|
|
||||||
setOpened(true);
|
|
||||||
}, [disabled, onOpen]);
|
|
||||||
|
|
||||||
const handleMouseLeave = useCallback(() => {
|
|
||||||
if (!pinned) setOpened(false);
|
|
||||||
}, [pinned]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover
|
<HoverCard
|
||||||
position="bottom"
|
position="bottom"
|
||||||
withArrow
|
withArrow
|
||||||
withinPortal
|
withinPortal
|
||||||
radius="lg"
|
radius="lg"
|
||||||
shadow="sm"
|
shadow="sm"
|
||||||
transitionProps={{
|
transitionProps={{ transition: "pop" }}
|
||||||
transition: "pop",
|
openDelay={350}
|
||||||
}}
|
closeDelay={400}
|
||||||
onChange={(value) => {
|
|
||||||
setOpened(value);
|
|
||||||
if (!value) setPinned(false);
|
|
||||||
}}
|
|
||||||
opened={opened}
|
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
<Popover.Target>
|
<HoverCard.Target>
|
||||||
<Container
|
<Container
|
||||||
h="100%"
|
h="100%"
|
||||||
w="100%"
|
w="100%"
|
||||||
@@ -69,38 +42,23 @@ export const CalendarDay = ({ date, events, disabled, rootHeight, rootWidth, onO
|
|||||||
pt={isSmall ? 0 : 10}
|
pt={isSmall ? 0 : 10}
|
||||||
pb={isSmall ? 0 : 10}
|
pb={isSmall ? 0 : 10}
|
||||||
m={0}
|
m={0}
|
||||||
ref={ref}
|
pos="relative"
|
||||||
bd={`2px solid ${opened && !disabled ? primaryColor : "transparent"}`}
|
|
||||||
style={{
|
style={{
|
||||||
alignContent: "center",
|
alignContent: "center",
|
||||||
borderRadius: actualItemRadius,
|
borderRadius: actualItemRadius,
|
||||||
cursor: disabled ? "default" : "pointer",
|
cursor: disabled ? "default" : "pointer",
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
|
||||||
if (!disabled) setPinned((prev) => !prev);
|
|
||||||
}}
|
|
||||||
onMouseEnter={handleMouseEnter}
|
|
||||||
onMouseLeave={handleMouseLeave}
|
|
||||||
>
|
>
|
||||||
<Text ta={"center"} size={shouldScaleDown ? "xs" : "md"} lh={1}>
|
<Text ta={"center"} size={shouldScaleDown ? "xs" : "md"} lh={1}>
|
||||||
{date.getDate()}
|
{date.getDate()}
|
||||||
</Text>
|
</Text>
|
||||||
{!isTooSmallForIndicators && <NotificationIndicator events={events} isSmall={isSmall} />}
|
<NotificationIndicator events={events} isSmall={isSmall} />
|
||||||
</Container>
|
</Container>
|
||||||
</Popover.Target>
|
</HoverCard.Target>
|
||||||
{/* Popover has some offset on the left side, padding is removed because of scrollarea paddings */}
|
<HoverCard.Dropdown maw="calc(100vw - 24px)" w={512} pe={4} pb={0} style={{ overflow: "hidden" }}>
|
||||||
<Popover.Dropdown
|
|
||||||
maw="calc(100vw - 24px)"
|
|
||||||
w={512}
|
|
||||||
pe={4}
|
|
||||||
pb={0}
|
|
||||||
style={{ overflow: "hidden" }}
|
|
||||||
onMouseEnter={() => setOpened(true)}
|
|
||||||
onMouseLeave={handleMouseLeave}
|
|
||||||
>
|
|
||||||
<CalendarEventList events={events} />
|
<CalendarEventList events={events} />
|
||||||
</Popover.Dropdown>
|
</HoverCard.Dropdown>
|
||||||
</Popover>
|
</HoverCard>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -111,7 +69,6 @@ interface NotificationIndicatorProps {
|
|||||||
|
|
||||||
const NotificationIndicator = ({ events, isSmall }: NotificationIndicatorProps) => {
|
const NotificationIndicator = ({ events, isSmall }: NotificationIndicatorProps) => {
|
||||||
const notificationEvents = [...new Set(events.map((event) => event.indicatorColor))].filter(String);
|
const notificationEvents = [...new Set(events.map((event) => event.indicatorColor))].filter(String);
|
||||||
/* position bottom is lower when small to not be on top of number*/
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
w="75%"
|
w="75%"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useCallback, useMemo, useRef, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
import { useMantineTheme } from "@mantine/core";
|
import { useMantineTheme } from "@mantine/core";
|
||||||
import { Calendar } from "@mantine/dates";
|
import { Calendar } from "@mantine/dates";
|
||||||
@@ -65,11 +65,6 @@ const CalendarBase = ({ isEditMode, events, month, setMonth, options }: Calendar
|
|||||||
const isSmall = width < 256;
|
const isSmall = width < 256;
|
||||||
|
|
||||||
const normalizedEvents = useMemo(() => splitEvents(events), [events]);
|
const normalizedEvents = useMemo(() => splitEvents(events), [events]);
|
||||||
const activeCloseRef = useRef<(() => void) | null>(null);
|
|
||||||
const onDayOpen = useCallback((close: () => void) => {
|
|
||||||
activeCloseRef.current?.();
|
|
||||||
activeCloseRef.current = close;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Calendar
|
<Calendar
|
||||||
@@ -146,7 +141,6 @@ const CalendarBase = ({ isEditMode, events, month, setMonth, options }: Calendar
|
|||||||
disabled={isEditMode || eventsForDate.length === 0}
|
disabled={isEditMode || eventsForDate.length === 0}
|
||||||
rootWidth={width}
|
rootWidth={width}
|
||||||
rootHeight={height}
|
rootHeight={height}
|
||||||
onOpen={onDayOpen}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in new issue
Block a user