feat: add import for config files from oldmarr (#1019)
* wip: add oldmarr config import
* wip: add support for wrong amount of categories / sections with autofix, color mapping, position adjustments of wrappers
* fix: lockfile broken
* feat: add support for form data trpc requests
* wip: improve file upload
* refactor: restructure import, add import configuration
* wip: add configurations for import to modal
* refactor: move oldmarr import to old-import package
* fix: column count not respects screen size for board
* feat: add beta badge for oldmarr config import
* chore: address pull request feedback
* fix: format issues
* fix: inconsistent versions
* fix: deepsource issues
* fix: revert {} to Record<string, never> convertion to prevent typecheck issue
* fix: inconsistent zod version
* fix: format issue
* chore: address pull request feedback
* fix: wrong import
* fix: broken lock file
* fix: inconsistent versions
* fix: format issues
This commit is contained in:
35
packages/old-import/src/import-board.ts
Normal file
35
packages/old-import/src/import-board.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { Database } from "@homarr/db";
|
||||
import { createId } from "@homarr/db";
|
||||
import { boards } from "@homarr/db/schema/sqlite";
|
||||
import { logger } from "@homarr/log";
|
||||
import type { OldmarrConfig } from "@homarr/old-schema";
|
||||
import type { OldmarrImportConfiguration } from "@homarr/validation";
|
||||
|
||||
import { mapColor } from "./mappers/map-colors";
|
||||
import { mapColumnCount } from "./mappers/map-column-count";
|
||||
|
||||
export const insertBoardAsync = async (db: Database, old: OldmarrConfig, configuration: OldmarrImportConfiguration) => {
|
||||
logger.info(`Importing old homarr board configuration=${old.configProperties.name}`);
|
||||
const boardId = createId();
|
||||
await db.insert(boards).values({
|
||||
id: boardId,
|
||||
name: configuration.name,
|
||||
backgroundImageAttachment: old.settings.customization.backgroundImageAttachment,
|
||||
backgroundImageUrl: old.settings.customization.backgroundImageUrl,
|
||||
backgroundImageRepeat: old.settings.customization.backgroundImageRepeat,
|
||||
backgroundImageSize: old.settings.customization.backgroundImageSize,
|
||||
columnCount: mapColumnCount(old, configuration.screenSize),
|
||||
faviconImageUrl: old.settings.customization.faviconUrl,
|
||||
isPublic: old.settings.access.allowGuests,
|
||||
logoImageUrl: old.settings.customization.logoImageUrl,
|
||||
pageTitle: old.settings.customization.pageTitle,
|
||||
metaTitle: old.settings.customization.metaTitle,
|
||||
opacity: old.settings.customization.appOpacity,
|
||||
primaryColor: mapColor(old.settings.customization.colors.primary, "#fa5252"),
|
||||
secondaryColor: mapColor(old.settings.customization.colors.secondary, "#fd7e14"),
|
||||
});
|
||||
|
||||
logger.info(`Imported board id=${boardId}`);
|
||||
|
||||
return boardId;
|
||||
};
|
||||
Reference in New Issue
Block a user