Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d204c9aaa | ||
|
|
070e186b57 |
No files matched your search
@@ -271,7 +271,6 @@ 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({
|
||||||
@@ -316,7 +315,6 @@ export const onboardRouter = createTRPCRouter({
|
|||||||
layoutId: layout.id,
|
layoutId: layout.id,
|
||||||
columnCount: layout.columnCount,
|
columnCount: layout.columnCount,
|
||||||
},
|
},
|
||||||
allIntegrations,
|
|
||||||
allApps,
|
allApps,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -698,13 +698,11 @@ 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,19 +1,11 @@
|
|||||||
import superjson from "superjson";
|
import { stringify } from "superjson";
|
||||||
|
|
||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import {
|
import { defaultBookmarkApps, defaultWidgetConfigs, emptySuperJSON } from "@homarr/definitions";
|
||||||
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;
|
||||||
@@ -77,12 +69,7 @@ interface App {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const placeAllWidgetsAsync = async (
|
export const placeAllWidgetsAsync = async (db: Database, target: BoardTarget, allApps: App[]) => {
|
||||||
db: Database,
|
|
||||||
target: BoardTarget,
|
|
||||||
allIntegrations: Integration[],
|
|
||||||
allApps: App[],
|
|
||||||
) => {
|
|
||||||
const ctx: PlacementContext = {
|
const ctx: PlacementContext = {
|
||||||
...target,
|
...target,
|
||||||
xOffset: 0,
|
xOffset: 0,
|
||||||
@@ -92,38 +79,11 @@ export const placeAllWidgetsAsync = async (
|
|||||||
|
|
||||||
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(
|
await placeWidgetAsync(db, ctx, "app", [], stringify({ appId: app.id, openInNewTab: true, showTitle: true }), {
|
||||||
db,
|
width: 1,
|
||||||
ctx,
|
height: 1,
|
||||||
"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));
|
||||||
@@ -138,7 +98,7 @@ export const placeAllWidgetsAsync = async (
|
|||||||
options = { ...options, items: bookmarkAppIds };
|
options = { ...options, items: bookmarkAppIds };
|
||||||
}
|
}
|
||||||
|
|
||||||
await placeWidgetAsync(db, ctx, config.kind, [], options ? superjson.stringify(options) : undefined, {
|
await placeWidgetAsync(db, ctx, config.kind, [], options ? stringify(options) : undefined, {
|
||||||
width: config.width,
|
width: config.width,
|
||||||
height: config.height,
|
height: config.height,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -467,7 +467,6 @@ export const integrationDefs = {
|
|||||||
iconUrl: "https://cdn.jsdelivr.net/gh/selfhst/icons/png/archiveteam-warrior.png",
|
iconUrl: "https://cdn.jsdelivr.net/gh/selfhst/icons/png/archiveteam-warrior.png",
|
||||||
category: ["archiving"],
|
category: ["archiving"],
|
||||||
documentationUrl: null,
|
documentationUrl: null,
|
||||||
defaultUrl: "http://localhost:8001",
|
|
||||||
},
|
},
|
||||||
// This integration only returns mock data, it is used during development (but can also be used in production by directly going to the create page)
|
// This integration only returns mock data, it is used during development (but can also be used in production by directly going to the create page)
|
||||||
mock: {
|
mock: {
|
||||||
|
|||||||
Reference in new issue
Block a user