Skip to content

📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

feat: new import system with more options (#492)

Smauge485200cf92f
diff --git a/frontend/app/components/AppDrop.vue b/frontend/app/components/AppDrop.vue
index a789b53d..dc323382 100644
--- a/frontend/app/components/AppDrop.vue
+++ b/frontend/app/components/AppDrop.vue
@@ -8,13 +8,17 @@
@dragleave.prevent="dragLeave"
@paste.prevent="handlePaste"
>
- <input ref="fileInput" type="file" :multiple="multiple" @change="handleFileSelect" />
+ <input ref="fileInput" type="file" :multiple="multiple" :webkitdirectory="allowFolders" @change="handleFileSelect" />
<div v-if="selectedFiles.length" class="files">
<div class="list">
- <div v-for="(file, index) in selectedFiles" :key="file.name + '-' + file.size + '-' + file.lastModified" class="item">
- <FileInline :file="file" :remove-file="() => removeFile(index)" class="file-card" />
- </div>
+ <FileInline
+ v-for="(file, index) in selectedFiles"
+ :key="file.name + '-' + file.size + '-' + file.lastModified"
+ :file="file"
+ :remove-file="() => removeFile(index)"
+ class="file-card"
+ />
</div>
<footer>
<span class="total">{{ selectedFiles.length }} file{{ selectedFiles.length > 1 ? 's' : '' }} • {{ readableFileSize(totalSize) }}</span>
@@ -48,11 +52,13 @@ import { readableFileSize } from '~/helpers/resources';
const props = withDefaults(
defineProps<{
multiple?: boolean;
+ allowFolders?: boolean;
maxFiles?: number;
}>(),
{
maxFiles: 10,
multiple: false,
+ allowFolders: false,
},
);
@@ -205,87 +211,6 @@ defineExpose({ reset });
overflow-y: auto;
}
-.item {
- display: flex;
- padding: 10px 12px;
- border: 1px solid var(--border);
- border-radius: var(--radius-sm);
- background: var(--surface-base);
- transition:
- border-color 0.15s ease,
- background-color 0.15s ease;
- align-items: center;
- gap: 12px;
-
- &:hover {
- border-color: var(--border-strong);
- background: var(--surface-raised);
-
- .remove {
- opacity: 1;
- }
- }
-}
-
-.icon {
- display: flex;
- width: 36px;
- height: 36px;
- border-radius: var(--radius-sm);
- color: var(--primary);
- align-items: center;
- flex-shrink: 0;
- justify-content: center;
-}
-
-.details {
- display: flex;
- min-width: 0;
- flex: 1;
- flex-direction: column;
- gap: 2px;
-}
-
-.name {
- font-size: 14px;
- font-weight: 500;
- color: var(--text-primary);
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.meta {
- font-size: 12px;
- color: var(--text-secondary);
-}
-
-.remove {
- display: flex;
- width: 28px;
- height: 28px;
- padding: 0;
- border: none;
- border-radius: var(--radius-xs);
- color: var(--text-secondary);
- background: transparent;
- opacity: 0.6;
- transition:
- color 0.15s ease,
- background-color 0.15s ease,
- opacity 0.15s ease;
- align-items: center;
- cursor: pointer;
- flex-shrink: 0;
- justify-content: center;
-
- &:hover {
- color: var(--red);
- background: var(--surface-transparent);
- opacity: 1;
- }
-}
-
footer {
display: flex;
align-items: center;
diff --git a/frontend/app/components/Node/Import/Preview.vue b/frontend/app/components/Node/Import/Preview.vue
new file mode 100644
index 00000000..b2453278
--- /dev/null
+++ b/frontend/app/components/Node/Import/Preview.vue
@@ -0,0 +1,128 @@
+<template>
+ <div class="node-item">
+ <AppCheck v-if="selectable" :checked="selected" @change="toggleSelection" />
+ <div class="doc-info">
+ <Icon :name="resolveIcon(node)" display="xl" :class="['icon', getAppAccent(node.color, true)]" />
+ <div class="doc-details">
+ <span class="doc-name">{{ node.name }}</span>
+ <span class="doc-meta">
+ {{ getRoleName(node.role) }}
+ <span v-if="node.description" class="separator">•</span>
+ {{ node.description || '' }}
+ </span>
+ </div>
+ </div>
+ <div class="comparison">
+ <div v-if="existingNode" class="version current">
+ <span class="version-label">{{ t('import.tabs.current') }}</span>
+ <span class="version-date">{{ numericDate(existingNode?.updated_timestamp) }}</span>
+ </div>
+ <div class="version backup">
+ <span class="version-label">{{ t('import.tabs.backup') }}</span>
+ <span class="version-date">{{ numericDate(node.updated_timestamp) }}</span>
+ </div>
+ </div>
+ <div class="doc-actions">
+ <AppButton type="primary" size="sm" :disabled="isImporting" @click="importSingle">
+ {{ t('import.tabs.importFromBackup') }}
+ </AppButton>
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { resolveIcon, getRoleName } from '~/helpers/node';
+import type { DB_Node } from '~/stores';
+
+const props = defineProps<{ node: DB_Node; selectable: boolean; selected?: boolean; isImporting?: boolean }>();
+
+const emit = defineEmits<{
+ (e: 'toggleSelection' | 'importSingle'): void;
+}>();
+
+const store = useNodesStore();
+const { t } = useI18nT();
+const { numericDate } = useDateFormatters();
+const { getAppAccent } = useAppColors();
+
+const existingNode = computed(() => store.getById(props.node.id));
+
+const toggleSelection = () => emit('toggleSelection');
+const importSingle = () => emit('importSingle');
+</script>
+
+<style scoped lang="scss">
+.node-item {
+ display: flex;
+ padding: 0.75rem;
+ border-radius: var(--radius-sm);
+ border: 1px solid var(--border);
+ align-items: center;
+ gap: 1rem;
+ flex-wrap: wrap;
+ width: 100%;
+}
+.doc-info {
+ display: flex;
+ min-width: 0;
+ align-items: center;
+ flex: 1;
+ gap: 0.75rem;
+}
+.icon {
+ padding: 4px;
+ border-radius: var(--radius-md);
+ margin-right: 10px;
+}
+.doc-details {
+ display: flex;
+ min-width: 0;
+ flex-direction: column;
+}
+
+.doc-name {
+ font-weight: 500;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.doc-meta {
+ font-size: 0.75rem;
+ color: var(--text-primary);
+
+ .separator {
+ margin: 0 0.25rem;
+ }
+}
+
+.comparison {
+ display: flex;
+ padding: 0.25rem 0.5rem;
+ border-radius: var(--radius-sm);
+ font-size: 0.75rem;
+ background: var(--surface-base);
+ align-items: center;
+ gap: 0.5rem;
+
+ .version {
+ display: flex;
+ align-items: center;
+ flex-direction: column;
+
+ .version-label {
+ font-size: 0.65rem;
+ font-weight: 500;
+ text-transform: uppercase;
+ }
+
+ .version-date {
+ color: var(--text-primary);
+ }
+
+ &.backup .version-date {
+ color: var(--primary);
+ }
+ }
+}
+</style>
diff --git a/frontend/app/helpers/backups/Importer.ts b/frontend/app/helpers/backups/Importer.ts
new file mode 100644
index 00000000..6241c7e8
--- /dev/null
+++ b/frontend/app/helpers/backups/Importer.ts
@@ -0,0 +1,134 @@
+import compile from '~/helpers/markdown';
+import { extractMetadataFromMarkdown } from '~/helpers/node';
+import type { DB_Node } from '~/stores';
+
+interface ImportOptions {
+ extractFrontMatter: boolean;
+ normalizeLineEndings: boolean;
+ preserveTimestamps: boolean;
+ defaultValues: {
+ defaultDescription: string;
+ defaultTags: string;
+ defaultColor: number;
+ defaultThumbnail: string;
+ defaultIcon: string;
+ defaultTheme: string;
+ };
+ user_id: string;
+}
+
+interface NormalizedEntry<T = 'folder' | 'text_based'> {
+ id: string; // path
+ filetype: T;
+ file: File;
+ filename?: string; // For folders, this will be the folder name
+ children?: NormalizedEntry[];
+ content: string | ArrayBuffer;
+}
+
+function isImportable(file: File) {
+ return file.type.startsWith('text/') || file.name.endsWith('.md') || file.name.endsWith('.json') || file.name.endsWith('.txt');
+}
+
+function normalizeName(name?: string) {
+ return name?.split('.').slice(0, -1).join('.') || name;
+}
+
+export class Importer {
+ options: ImportOptions;
+
+ normalized_files: NormalizedEntry[] = [];
+
+ nodes: DB_Node[] = [];
+
+ constructor(options: ImportOptions) {
+ this.options = options;
+ }
+
+ async handleFiles(files: File[] | File) {
+ const fileArray = Array.isArray(files) ? files : [files];
+ for (const file of fileArray) {
+ if (!isImportable(file)) continue;
+
+ const path = file.webkitRelativePath;
+ const parts = path.split('/');
+ const id = parts.slice(0, -1).join('/'); // Use folder path as ID
+
+ let parent = this.normalized_files.find(e => e.id === id);
+ if (!parent) {
+ parent = {
+ id,
+ filetype: 'folder',
+ file,
+ filename: parts[parts.length - 2] || '',
+ children: [],
+ content: '',
+ };
+ this.normalized_files.push(parent);
+ }
+
+ const content = await file.text();
+ parent.children!.push({
+ id: path,
+ filetype: 'text_based',
+ file,
+ filename: file.name,
+ content,
+ });
+ }
+ }
+ async normalizedToNodes() {
+ const to_process = [...this.normalized_files];
+ while (to_process.length) {
+ const entry = to_process.shift()!;
+
+ let tags = this.options.defaultValues.defaultTags;
+ let description = this.options.defaultValues.defaultDescription;
+ let content = '';
+ if (this.options.extractFrontMatter && entry.filetype === 'text_based') {
+ const data = extractMetadataFromMarkdown(entry.content as string);
+ tags = data.tags || this.options.defaultValues.defaultTags;
+ description = data.description || this.options.defaultValues.defaultDescription;
+ content = data.content_clean;
+ }
+ const parentId = entry.id.split('/').slice(0, -1).join('/') || undefined;
+ if (entry.filetype === 'text_based') {
+ this.nodes.push({
+ id: entry.id,
+ parent_id: parentId,
+ name: normalizeName(entry.filename) || 'Untitled',
+ description: description,
+ tags: tags,
+ color: this.options.defaultValues.defaultColor || -1,
+ role: 3,
+ icon: this.options.defaultValues.defaultIcon,
+ theme: this.options.defaultValues.defaultTheme,
+ user_id: this.options.user_id,
+ content: content,
+ content_compiled: compile(content),
+ accessibility: 1,
+ access: 1,
+ created_timestamp: this.options.preserveTimestamps ? entry.file.lastModified : Date.now(),
+ updated_timestamp: this.options.preserveTimestamps ? entry.file.lastModified : Date.now(),
+ });
+ }
+
+ if (entry.filetype === 'folder') {
+ this.nodes.push({
+ id: entry.id,
+ parent_id: parentId,
+ name: normalizeName(entry.filename) || 'Untitled',
+ role: 2,
+ user_id: this.options.user_id,
+ accessibility: 1,
+ access: 1,
+ created_timestamp: this.options.preserveTimestamps ? entry.file.lastModified : Date.now(),
+ updated_timestamp: this.options.preserveTimestamps ? entry.file.lastModified : Date.now(),
+ });
+ }
+
+ if (entry.children?.length) to_process.push(...entry.children);
+ }
+ return this.nodes;
+ }
+}
diff --git a/frontend/app/helpers/node.ts b/frontend/app/helpers/node.ts
index e2ed97f1..7c4fb36a 100644
--- a/frontend/app/helpers/node.ts
+++ b/frontend/app/helpers/node.ts
@@ -18,7 +18,7 @@ export const resolveIcon = (item: Node | DB_Node | NodeSearchResult): string =>
if (item.metadata?.filetype?.startsWith('image/')) return 'sidebar/image';
return 'sidebar/attachment';
}
- return 'sidebar/default';
+ return 'sidebar/attachment';
};
/** Get the dashboard route for a node */
@@ -50,3 +50,27 @@ export const generateMarkdownWithMetadata = (node: Node): string => {
metadataLines.push('---', '', '');
return metadataLines.join('\n') + (node.content || '');
};
+
+export const extractMetadataFromMarkdown = (markdown: string): { title: string; description?: string; tags?: string; content_clean: string } => {
+ const metadata: { title: string; description?: string; tags?: string } = { title: '' };
+ let contentClean = markdown;
+
+ const metadataMatch = markdown.match(/^---\n([\s\S]*?)\n---/);
+ if (metadataMatch && metadataMatch[1]) {
+ const metadataContent = metadataMatch[1];
+ const lines = metadataContent.split('\n');
+ for (const line of lines) {
+ const [key, ...rest] = line.split(':');
+ const value = rest
+ .join(':')
+ .trim()
+ .replace(/^"(.*)"$/, '$1'); // Remove surrounding quotes
+ if (key === 'title') metadata.title = value;
+ else if (key === 'description') metadata.description = value;
+ else if (key === 'tags') metadata.tags = value;
+ }
+ contentClean = markdown.slice(metadataMatch[0].length).trimStart();
+ }
+
+ return { ...metadata, content_clean: contentClean };
+};
diff --git a/frontend/app/pages/dashboard/import/_components/ImportProgress.vue b/frontend/app/pages/dashboard/import/_components/ImportProgress.vue
index cd1e588a..c97349e2 100644
--- a/frontend/app/pages/dashboard/import/_components/ImportProgress.vue
+++ b/frontend/app/pages/dashboard/import/_components/ImportProgress.vue
@@ -11,17 +11,21 @@
<div v-if="importJob.status === 'in_progress'" class="progress-bar-container">
<div class="progress-bar" :style="{ width: progress + '%' }"></div>
</div>
+
+ <small v-if="importJob.status === 'failed'">{{ importJob.error_message }}</small>
</div>
</template>
<script setup lang="ts">
import type { ImportJob } from '~/stores';
-const props = defineProps<{ importJob: ImportJob; toCreate: number; toUpdate: number }>();
+const props = defineProps<{ importJob: ImportJob; toCreate?: number; toUpdate?: number }>();
const { t } = useI18nT();
-const progress = computed(() => Math.floor(((props.importJob.created.length + props.importJob.updated.length) * 100) / (props.toCreate + props.toUpdate)));
+const progress = computed(() =>
+ Math.floor(((props.importJob.created.length + props.importJob.updated.length) * 100) / ((props.toCreate || 0) + (props.toUpdate || 0))),
+);
const statusLabel = computed(() => {
switch (props.importJob.status) {
case 'pending':
@@ -99,4 +103,8 @@ const statusLabel = computed(() => {
background: var(--primary);
transition: width $transition-medium ease;
}
+
+small {
+ color: var(--text-primary);
+}
</style>
diff --git a/frontend/app/pages/dashboard/import/_components/ImportTabs.vue b/frontend/app/pages/dashboard/import/_components/ImportTabs.vue
index acf551f3..1c57235b 100644
--- a/frontend/app/pages/dashboard/import/_components/ImportTabs.vue
+++ b/frontend/app/pages/dashboard/import/_components/ImportTabs.vue
@@ -22,23 +22,16 @@
</AppButton>
</div>
<div class="documents-list">
- <div v-for="doc in toCreate" :key="doc.id" class="document-item">
- <AppCheck :checked="selectedCreate.includes(doc.id)" @change="toggleSelection(doc.id, 'create')" />
- <div class="doc-info">
- <Icon :name="resolveIcon(doc)" :size="18" />
- <div class="doc-details">
- <span class="doc-name">{{ doc.name }}</span>
- <span class="doc-meta">
- {{ getRoleName(doc.role) }}
- <span v-if="doc.description" class="separator">•</span>
- {{ doc.description || '' }}
- </span>
- </div>
- </div>
- <div class="doc-actions">
- <AppButton type="primary" size="sm" :disabled="isImporting" @click="importSingle(doc, 'create')"> {{ t('import.tabs.import') }} </AppButton>
- </div>
- </div>
+ <NodeImportPreview
+ v-for="doc in toCreate"
+ :key="doc.id"
+ :node="doc"
+ selectable
+ :selected="selectedCreate.includes(doc.id)"
+ :is-importing="isImporting"
+ @toggle-selection="() => toggleSelection(doc.id, 'create')"
+ @import-single="() => importSingle(doc, 'create')"
+ />
</div>
</template>
</div>
@@ -58,34 +51,16 @@
</AppButton>
</div>
<div class="documents-list">
- <div v-for="doc in toUpdate" :key="doc.id" class="document-item update-item">
- <AppCheck :checked="selectedUpdate.includes(doc.id)" @change="toggleSelection(doc.id, 'update')" />
- <div class="doc-info">
- <Icon :name="resolveIcon(doc)" :size="18" />
- <div class="doc-details">
- <span class="doc-name">{{ doc.name }}</span>
- <span class="doc-meta">
- {{ getRoleName(doc.role) }}
- </span>
- </div>
- </div>
- <div class="comparison">
- <div class="version current">
- <span class="version-label">{{ t('import.tabs.current') }}</span>
- <span class="version-date">{{ numericDate(getExistingNode(doc.id)?.updated_timestamp) }}</span>
- </div>
- <Icon name="arrow-right" :size="14" class="arrow" />
- <div class="version backup">
- <span class="version-label">{{ t('import.tabs.backup') }}</span>
- <span class="version-date">{{ numericDate(doc.updated_timestamp) }}</span>
- </div>
- </div>
- <div class="doc-actions">
- <AppButton type="primary" size="sm" :disabled="isImporting" @click="importSingle(doc, 'update')">
- {{ t('import.tabs.importFromBackup') }}
- </AppButton>
- </div>
- </div>
+ <NodeImportPreview
+ v-for="doc in toUpdate"
+ :key="doc.id"
+ :node="doc"
+ selectable
+ :selected="selectedUpdate.includes(doc.id)"
+ :is-importing="isImporting"
+ @toggle-selection="() => toggleSelection(doc.id, 'update')"
+ @import-single="() => importSingle(doc, 'update')"
+ />
</div>
</template>
</div>
@@ -108,7 +83,6 @@
</template>
<script setup lang="ts">
-import { getRoleName, resolveIcon } from '~/helpers/node';
import type { DB_Node, ImportJob } from '~/stores';
import type { Manifest } from '~/helpers/backups/types';
@@ -119,10 +93,6 @@ const emit = defineEmits<{
(e: 'importLocalSettings'): void;
}>();
-const store = useNodesStore();
-
-const { numericDate } = useDateFormatters();
-
// Selection
const activeTab = ref<'create' | 'update' | 'local'>('create');
const selectedCreate = ref<string[]>([]);
@@ -157,9 +127,7 @@ function toggleSelectAllUpdate(value: boolean) {
selectedUpdate.value = [];
}
}
-function getExistingNode(id: string): DB_Node | undefined {
- return store.getById(id);
-}
+
function importSingle(doc: DB_Node, type: 'create' | 'update') {
emit('import', type, [doc.id]);
}
@@ -240,88 +208,6 @@ function importLocalSettings() {
overflow-y: auto;
}
-.document-item {
- display: flex;
- padding: 0.75rem;
- border-radius: var(--radius-sm);
- align-items: center;
- gap: 1rem;
-
- .doc-info {
- display: flex;
- min-width: 0;
- align-items: center;
- flex: 1;
- gap: 0.75rem;
- }
-
- .doc-details {
- display: flex;
- min-width: 0;
- flex-direction: column;
- }
-
- .doc-name {
- font-weight: 500;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- .doc-meta {
- font-size: 0.75rem;
- color: var(--text-primary);
-
- .separator {
- margin: 0 0.25rem;
- }
- }
-
- .doc-actions {
- display: flex;
- flex-shrink: 0;
- gap: 0.5rem;
- }
-
- &.update-item {
- flex-wrap: wrap;
-
- .comparison {
- display: flex;
- padding: 0.25rem 0.5rem;
- border-radius: var(--radius-sm);
- font-size: 0.75rem;
- background: var(--surface-base);
- align-items: center;
- gap: 0.5rem;
-
- .version {
- display: flex;
- align-items: center;
- flex-direction: column;
-
- .version-label {
- font-size: 0.65rem;
- font-weight: 500;
- text-transform: uppercase;
- }
-
- .version-date {
- color: var(--text-primary);
- }
-
- &.backup .version-date {
- color: var(--primary);
- }
- }
-
- .arrow {
- color: var(--text-primary);
- }
- }
- }
-}
-
.warning {
display: flex;
align-items: center;
diff --git a/frontend/app/pages/dashboard/import/advanced.vue b/frontend/app/pages/dashboard/import/advanced.vue
new file mode 100644
index 00000000..5c69d271
--- /dev/null
+++ b/frontend/app/pages/dashboard/import/advanced.vue
@@ -0,0 +1,218 @@
+<template>
+ <div class="page-card files-import">
+ <header>
+ <div>
+ <h1>{{ t('import.files.meta.title') }} <tag class="orange">Beta</tag></h1>
+ <p class="subtitle">
+ {{ t('import.files.meta.description') }}
+ </p>
+ </div>
+ </header>
+
+ <AppDrop ref="dropComponent" multiple allow-folders @select="selectFiles" />
+ <small>{{ t('import.files.importable') }}</small>
+
+ <h3>{{ t('import.advanced.options') }}</h3>
+
+ <div class="actions-row">
+ <AppToggle v-model="options.extractFrontMatter" />
+ <p>{{ t('import.actions.extractFrontMatter') }}</p>
+ </div>
+
+ <div class="actions-row">
+ <AppToggle v-model="options.normalizeLineEndings" />
+ <p>{{ t('import.actions.normalizeLineEndings') }}</p>
+ </div>
+
+ <div class="actions-row">
+ <AppToggle v-model="options.preserveTimestamps" />
+ <p>{{ t('import.actions.preserveTimestamps') }}</p>
+ </div>
+ <div>
+ <label for="default-description">
+ {{ t('import.advanced.defaultDescription') }}
+ </label>
+ <input id="default-description" v-model="options.defaultValues.defaultDescription" type="text" placeholder="Default description for imported nodes" />
+ <label for="default-tags">
+ {{ t('import.advanced.defaultTags') }}
+ </label>
+ <input id="default-tags" v-model="options.defaultValues.defaultTags" type="text" placeholder="tag1, tag2, tag3" />
+ <label for="default-color">
+ {{ t('import.advanced.defaultColor') }}
+ </label>
+ <AppColorPicker id="default-color" v-model="options.defaultValues.defaultColor" nullable />
+ <label for="default-thumbnail">
+ {{ t('import.advanced.defaultThumbnail') }}
+ </label>
+ <input id="default-thumbnail" v-model="options.defaultValues.defaultThumbnail" type="text" />
+ <label for="default-icon">
+ {{ t('import.advanced.defaultIcon') }}
+ </label>
+ <input id="default-icon" v-model="options.defaultValues.defaultIcon" type="text" />
+ <label for="default-theme">
+ {{ t('import.advanced.defaultTheme') }}
+ </label>
+ <AppSelect id="default-theme" v-model="options.defaultValues.defaultTheme" :items="DOCUMENT_THEMES" />
+ </div>
+ <section v-if="nodes.length" class="panel">
+ <div class="panel-head">
+ <h3>{{ t('import.files.toImport') }} ({{ nodes.length }})</h3>
+ <div class="actions-row">
+ <AppButton type="primary" size="sm" :disabled="selectedNodes.length === 0" @click="importSelected">
+ {{ t('import.tabs.importSelected', { count: selectedNodes.length }) }}
+ </AppButton>
+ <AppButton type="primary" @click="importAll">
+ <Icon name="download" :size="16" />
+ {{ t('import.actions.importAll') }}
+ </AppButton>
+ </div>
+ </div>
+ <ImportProgress :import-job="importJob" :to-create="toCreate" />
+ <div class="list">
+ <NodeImportPreview
+ v-for="node in nodes"
+ :key="node.id"
+ :node="node"
+ selectable
+ :selected="selectedNodes.includes(node.id)"
+ @toggle-selection="() => toggleSelection(node.id)"
+ @import-single="() => importSingle(node)"
+ />
+ </div>
+ </section>
+ </div>
+</template>
+
+<script setup lang="ts">
+import ImportProgress from './_components/ImportProgress.vue';
+import { Importer } from '~/helpers/backups/Importer';
+import { DOCUMENT_THEMES } from '~/helpers/constants';
+import type { DB_Node, ImportJob } from '~/stores';
+
+definePageMeta({ breadcrumb: { i18n: 'import.meta.breadcrumb' } });
+
+const user = useUserStore();
+const nodesStore = useNodesStore();
+const { t } = useI18nT();
+
+const selectedNodes = ref<string[]>([]);
+
+const toCreate = ref(0);
+
+const files = ref<File[]>([]);
+const nodes = ref<DB_Node[]>([]);
+
+const options = ref({
+ extractFrontMatter: true,
+ normalizeLineEndings: true,
+ preserveTimestamps: true,
+ defaultValues: {
+ defaultDescription: '',
+ defaultTags: '',
+ defaultColor: -1,
+ defaultThumbnail: '',
+ defaultIcon: '',
+ defaultTheme: '',
+ },
+});
+
+watch(
+ () => options.value,
+ _ => {
+ // Re-process files with new options
+ if (files.value.length) processImport();
+ },
+ { deep: true },
+);
+
+const importJob = ref<ImportJob>({
+ status: 'pending',
+ toCreate: 0,
+ toUpdate: 0,
+ created: [],
+ updated: [],
+ failures: 0,
+});
+
+function selectFiles(importedFiles: File | File[] | null) {
+ if (!importedFiles) return;
+ files.value = Array.isArray(importedFiles) ? importedFiles : [importedFiles];
+ processImport();
+}
+
+async function processImport() {
+ if (!files.value) return;
+ const imp = new Importer({
+ ...options.value,
+ user_id: user.user!.id,
+ });
+ await imp.handleFiles(files.value);
+ nodes.value = await imp.normalizedToNodes();
+}
+
+function toggleSelection(id: string) {
+ const idx = selectedNodes.value.indexOf(id);
+ if (idx === -1) selectedNodes.value.push(id);
+ else selectedNodes.value.splice(idx, 1);
+}
+
+const importSingle = (node: DB_Node) => importNodes([node]);
+const importSelected = () => {
+ const toImport = nodes.value.filter(n => selectedNodes.value.includes(n.id));
+ importNodes(toImport);
+};
+const importAll = () => importNodes(nodes.value);
+
+async function importNodes(importNodes: DB_Node[]) {
+ toCreate.value = importNodes.length;
+ importJob.value.toCreate = importNodes.length;
+ await nodesStore.importMultipleNodes({ toCreate: importNodes, toUpdate: [] }, importJob);
+ nodes.value = nodes.value.filter(n => !importJob.value.created.includes(n.id));
+}
+</script>
+
+<style scoped lang="scss">
+.files-import {
+ display: grid;
+ gap: 1rem;
+}
+
+.actions-row > p {
+ margin: 0.1rem;
+}
+
+label {
+ margin-top: 0.5rem;
+}
+
+.panel {
+ border: 1px solid var(--border);
+ border-radius: 10px;
+ padding: 0.85rem;
+}
+
+.panel h3 {
+ margin: 0 0 0.65rem;
+}
+
+.panel-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 0.7rem;
+ margin-bottom: 0.65rem;
+}
+
+.list {
+ display: grid;
+ gap: 0.35rem;
+ max-height: 250px;
+ overflow: auto;
+}
+
+@media (max-width: 900px) {
+ .grid {
+ grid-template-columns: 1fr;
+ }
+}
+</style>
diff --git a/frontend/app/pages/dashboard/import/backup.vue b/frontend/app/pages/dashboard/import/backup.vue
new file mode 100644
index 00000000..aafb454e
--- /dev/null
+++ b/frontend/app/pages/dashboard/import/backup.vue
@@ -0,0 +1,236 @@
+<template>
+ <div class="import-page page-card">
+ <!-- Step 1: File Selection -->
+ <div v-if="step === 'select'">
+ <header>
+ <h1 style="font-size: 20px">{{ t('import.meta.title') }}</h1>
+ </header>
+ <p>
+ {{ t('import.meta.description') }}
+ <NuxtLink to="/dashboard/settings?p=backup" style="color: var(--primary)">{{ t('import.meta.settingsLink') }}</NuxtLink
+ >.
+ </p>
+ <AppDrop ref="dropComponent" @select="handleFileSelect as (file: File) => void" />
+ <div class="submit">
+ <AppButton type="primary" :disabled="!selectedFile || isAnalyzing" @click="analyzeFile">
+ {{ isAnalyzing ? t('import.steps.select.analyzing') : t('import.steps.select.startImport') }}
+ </AppButton>
+ </div>
+ <p v-if="analyzeError" class="error-text">{{ analyzeError }}</p>
+ </div>
+
+ <!-- Step 2: Preview & Import -->
+ <template v-if="step === 'preview' && manifest">
+ <!-- Backup Info Card -->
+ <ImportHeader :manifest="manifest" :reset-import="resetImport" />
+
+ <!-- Import Summary -->
+ <SummaryCard :to-create="toCreate.length" :to-update="toUpdate.length" :unchanged-count="unchangedCount" :import-job="importJob" />
+
+ <!-- Tabs for New / Updates -->
+ <ImportTabs
+ :manifest="manifest"
+ :to-create="toCreate"
+ :to-update="toUpdate"
+ :import-job="importJob"
+ @import="importNodes"
+ @import-local-settings="importLocalSettings"
+ />
+
+ <!-- Import All Actions -->
+ <ImportActions
+ v-model:preserve-timestamps="importOptions.preserveTimestamps"
+ v-model:skip-existing="importOptions.skipExisting"
+ :to-create="toCreate"
+ :to-update="toUpdate"
+ :reset-import="resetImport"
+ :import-all="importAll"
+ :import-job="importJob"
+ />
+ </template>
+ </div>
+</template>
+
+<script setup lang="ts">
+import ImportHeader from './_components/ImportHeader.vue';
+import SummaryCard from './_components/ImportSummary.vue';
+import ImportTabs from './_components/ImportTabs.vue';
+import ImportActions from './_components/ImportActions.vue';
+import { handleBackupFile } from '~/helpers/backups';
+import type { Manifest } from '~/helpers/backups/types';
+import type { DB_Node, ImportJob } from '~/stores/db_strustures';
+
+definePageMeta({ breadcrumb: { i18n: 'import.meta.breadcrumb' } });
+
+const { t } = useI18nT();
+const nodesStore = useNodesStore();
+const notifications = useNotifications();
+
+// State
+const step = ref<'select' | 'preview'>('select');
+const selectedFile = ref<File>();
+const isAnalyzing = ref(false);
+const analyzeError = ref('');
+
+// Backup data
+const manifest = ref<Manifest | null>(null);
+const backupDocuments = ref<DB_Node[]>([]);
+const toCreate = ref<DB_Node[]>([]);
+const toUpdate = ref<DB_Node[]>([]);
+const localData = ref<object | null>(null);
+
+// Import state
+const importJob = ref<ImportJob>({
+ status: 'pending',
+ toCreate: 0,
+ toUpdate: 0,
+ created: [],
+ updated: [],
+ failures: 0,
+});
+
+// Options
+const importOptions = reactive({
+ preserveTimestamps: false,
+ skipExisting: false,
+});
+
+// Computed
+const unchangedCount = computed(() => {
+ if (!backupDocuments.value.length) return 0;
+ return backupDocuments.value.length - toCreate.value.length - toUpdate.value.length;
+});
+
+// Methods
+const handleFileSelect = (file?: File) => {
+ selectedFile.value = file;
+ analyzeError.value = '';
+};
+
+async function analyzeFile() {
+ if (!selectedFile.value) return;
+
+ isAnalyzing.value = true;
+ analyzeError.value = '';
+
+ try {
+ const result = await handleBackupFile(selectedFile.value);
+ manifest.value = result.manifest;
+ localData.value = result.localData;
+
+ if (result.documents?.length) {
+ backupDocuments.value = result.documents;
+ const { toCreate: create, toUpdate: update } = nodesStore.prepareImport(result.documents);
+ toCreate.value = create;
+ toUpdate.value = update;
+ } else {
+ backupDocuments.value = [];
+ toCreate.value = [];
+ toUpdate.value = [];
+ }
+
+ step.value = 'preview';
+ } catch (e) {
+ analyzeError.value = e instanceof Error ? e.message : 'Failed to analyze backup file';
+ } finally {
+ isAnalyzing.value = false;
+ }
+}
+
+function resetImport() {
+ step.value = 'select';
+ selectedFile.value = undefined;
+ manifest.value = null;
+ backupDocuments.value = [];
+ toCreate.value = [];
+ toUpdate.value = [];
+
+ importJob.value = {
+ status: 'pending',
+ toCreate: 0,
+ toUpdate: 0,
+ created: [],
+ updated: [],
+ failures: 0,
+ };
+}
+
+async function importNodes(type: 'create' | 'update', ids: string[]) {
+ const nodes: DB_Node[] = type === 'create' ? toCreate.value.filter(d => ids.includes(d.id)) : toUpdate.value.filter(d => ids.includes(d.id));
+
+ if (type === 'create') {
+ importJob.value.toCreate = nodes.length;
+ await nodesStore.importMultipleNodes({ toCreate: nodes, toUpdate: [] }, importJob);
+ toCreate.value = toCreate.value.filter(d => !importJob.value.created.includes(d.id));
+ } else if (type == 'update') {
+ importJob.value.toUpdate = nodes.length;
+ await nodesStore.importMultipleNodes({ toCreate: [], toUpdate: nodes }, importJob);
+ toUpdate.value = toUpdate.value.filter(d => !importJob.value.updated.includes(d.id));
+ }
+
+ notifications.add({
+ type: 'success',
+ title: 'Import complete',
+ message: `${importJob.value.created.length + importJob.value.updated.length} documents ${type === 'create' ? 'imported' : 'updated'}`,
+ });
+}
+
+function importLocalSettings() {
+ if (!manifest.value) return;
+
+ const preferences = usePreferencesStore();
+ if (localData.value) {
+ preferences.importPreferences(localData.value);
+ notifications.add({
+ type: 'success',
+ title: t('import.notifications.localImportedTitle'),
+ message: t('import.notifications.localImportedMessage'),
+ });
+ } else {
+ notifications.add({
+ type: 'error',
+ title: t('import.notifications.importFailedTitle'),
+ message: t('import.notifications.importFailedMessage'),
+ });
+ }
+}
+
+async function importAll() {
+ const createDocs = toCreate.value;
+ const updateDocs = importOptions.skipExisting ? [] : toUpdate.value;
+
+ importJob.value.toCreate = createDocs.length;
+ importJob.value.toUpdate = updateDocs.length;
+
+ await nodesStore.importMultipleNodes({ toCreate: createDocs, toUpdate: updateDocs }, importJob);
+ toCreate.value = toCreate.value.filter(d => !importJob.value.created.includes(d.id));
+ toUpdate.value = toUpdate.value.filter(d => !importJob.value.updated.includes(d.id));
+
+ notifications.add({
+ type: 'success',
+ title: t('import.notifications.importCompleteTitle'),
+ message: t('import.notifications.importCompleteMessage'),
+ });
+}
+</script>
+
+<style scoped lang="scss">
+.import-page {
+ display: flex;
+ flex-direction: column;
+ gap: 1.5rem;
+}
+
+.submit {
+ display: flex;
+ justify-content: center;
+ margin-top: 1rem;
+}
+
+.error-text {
+ font-size: 0.9rem;
+ color: var(--red);
+ text-align: center;
+ margin-top: 0.5rem;
+}
+</style>
diff --git a/frontend/app/pages/dashboard/import/files.vue b/frontend/app/pages/dashboard/import/files.vue
new file mode 100644
index 00000000..6c14bc2e
--- /dev/null
+++ b/frontend/app/pages/dashboard/import/files.vue
@@ -0,0 +1,146 @@
+<template>
+ <div class="page-card files-import">
+ <header>
+ <div>
+ <h1>{{ t('import.files.meta.title') }} <tag class="orange">Beta</tag></h1>
+ <p class="subtitle">
+ {{ t('import.files.meta.description') }}
+ </p>
+ </div>
+ </header>
+
+ <AppDrop ref="dropComponent" multiple allow-folders @select="selectFiles" />
+ <small>{{ t('import.files.importable') }}</small>
+ <section v-if="nodes.length" class="panel">
+ <div class="panel-head">
+ <h3>{{ t('import.files.toImport') }} ({{ nodes.length }})</h3>
+ <div class="actions-row">
+ <AppButton type="primary" size="sm" :disabled="selectedNodes.length === 0" @click="importSelected">
+ {{ t('import.tabs.importSelected', { count: selectedNodes.length }) }}
+ </AppButton>
+ <AppButton type="primary" @click="importAll">
+ <Icon name="download" :size="16" />
+ {{ t('import.actions.importAll') }}
+ </AppButton>
+ </div>
+ </div>
+ <ImportProgress :import-job="importJob" :to-create="toCreate" />
+ <div class="list">
+ <NodeImportPreview
+ v-for="node in nodes"
+ :key="node.id"
+ :node="node"
+ selectable
+ :selected="selectedNodes.includes(node.id)"
+ @toggle-selection="() => toggleSelection(node.id)"
+ @import-single="() => importSingle(node)"
+ />
+ </div>
+ </section>
+ </div>
+</template>
+
+<script setup lang="ts">
+import ImportProgress from './_components/ImportProgress.vue';
+import { Importer } from '~/helpers/backups/Importer';
+import type { DB_Node, ImportJob } from '~/stores';
+
+definePageMeta({ breadcrumb: { i18n: 'import.meta.breadcrumb' } });
+
+const user = useUserStore();
+const nodesStore = useNodesStore();
+const { t } = useI18nT();
+
+const selectedNodes = ref<string[]>([]);
+
+const toCreate = ref(0);
+
+const nodes = ref<DB_Node[]>([]);
+
+const importJob = ref<ImportJob>({
+ status: 'pending',
+ toCreate: 0,
+ toUpdate: 0,
+ created: [],
+ updated: [],
+ failures: 0,
+});
+
+async function selectFiles(files: File | File[] | null) {
+ if (!files) return;
+ const imp = new Importer({
+ extractFrontMatter: true,
+ normalizeLineEndings: true,
+ preserveTimestamps: false,
+ defaultValues: {
+ defaultColor: 0,
+ defaultDescription: '',
+ defaultTags: '',
+ defaultIcon: '',
+ defaultTheme: '',
+ defaultThumbnail: '',
+ },
+ user_id: user.user!.id,
+ });
+ await imp.handleFiles(files);
+ nodes.value = await imp.normalizedToNodes();
+}
+
+function toggleSelection(id: string) {
+ const idx = selectedNodes.value.indexOf(id);
+ if (idx === -1) selectedNodes.value.push(id);
+ else selectedNodes.value.splice(idx, 1);
+}
+
+const importSingle = (node: DB_Node) => importNodes([node]);
+const importSelected = () => {
+ const toImport = nodes.value.filter(n => selectedNodes.value.includes(n.id));
+ importNodes(toImport);
+};
+const importAll = () => importNodes(nodes.value);
+
+async function importNodes(importNodes: DB_Node[]) {
+ toCreate.value = importNodes.length;
+ importJob.value.toCreate = importNodes.length;
+ await nodesStore.importMultipleNodes({ toCreate: importNodes, toUpdate: [] }, importJob);
+ nodes.value = nodes.value.filter(n => !importJob.value.created.includes(n.id));
+}
+</script>
+
+<style scoped lang="scss">
+.files-import {
+ display: grid;
+ gap: 1rem;
+}
+
+.panel {
+ border: 1px solid var(--border);
+ border-radius: 10px;
+ padding: 0.85rem;
+}
+
+.panel h3 {
+ margin: 0 0 0.65rem;
+}
+
+.panel-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 0.7rem;
+ margin-bottom: 0.65rem;
+}
+
+.list {
+ display: grid;
+ gap: 0.35rem;
+ max-height: 250px;
+ overflow: auto;
+}
+
+@media (max-width: 900px) {
+ .grid {
+ grid-template-columns: 1fr;
+ }
+}
+</style>
diff --git a/frontend/app/pages/dashboard/import/index.vue b/frontend/app/pages/dashboard/import/index.vue
index 270ec15a..692aed65 100644
--- a/frontend/app/pages/dashboard/import/index.vue
+++ b/frontend/app/pages/dashboard/import/index.vue
@@ -1,236 +1,123 @@
<template>
<div class="import-page page-card">
- <!-- Step 1: File Selection -->
- <div v-if="step === 'select'">
- <header>
- <h1 style="font-size: 20px">{{ t('import.meta.title') }} <tag class="orange">Beta</tag></h1>
- </header>
- <p>
- {{ t('import.meta.description') }}
- <NuxtLink to="/dashboard/settings?p=backup" style="color: var(--primary)">{{ t('import.meta.settingsLink') }}</NuxtLink
- >.
- </p>
- <AppDrop ref="dropComponent" @select="handleFileSelect as (file: File) => void" />
- <div class="submit">
- <AppButton type="primary" :disabled="!selectedFile || isAnalyzing" @click="analyzeFile">
- {{ isAnalyzing ? t('import.steps.select.analyzing') : t('import.steps.select.startImport') }}
- </AppButton>
+ <header>
+ <div>
+ <h1>{{ t('import.meta.title') }} <tag class="orange">Beta</tag></h1>
+ <p class="subtitle">
+ {{ t('import.meta.description') }}
+ <NuxtLink to="/dashboard/settings?p=backup">{{ t('import.meta.settingsLink') }}</NuxtLink
+ >.
+ </p>
</div>
- <p v-if="analyzeError" class="error-text">{{ analyzeError }}</p>
- </div>
-
- <!-- Step 2: Preview & Import -->
- <template v-if="step === 'preview' && manifest">
- <!-- Backup Info Card -->
- <ImportHeader :manifest="manifest" :reset-import="resetImport" />
-
- <!-- Import Summary -->
- <SummaryCard :to-create="toCreate.length" :to-update="toUpdate.length" :unchanged-count="unchangedCount" :import-job="importJob" />
-
- <!-- Tabs for New / Updates -->
- <ImportTabs
- :manifest="manifest"
- :to-create="toCreate"
- :to-update="toUpdate"
- :import-job="importJob"
- @import="importNodes"
- @import-local-settings="importLocalSettings"
- />
-
- <!-- Import All Actions -->
- <ImportActions
- v-model:preserve-timestamps="importOptions.preserveTimestamps"
- v-model:skip-existing="importOptions.skipExisting"
- :to-create="toCreate"
- :to-update="toUpdate"
- :reset-import="resetImport"
- :import-all="importAll"
- :import-job="importJob"
- />
- </template>
+ </header>
+
+ <section class="cards-grid">
+ <NuxtLink class="import-card" to="/dashboard/import/backup">
+ <div class="top">
+ <h3>{{ t('import.categories.backup.title') }}</h3>
+ <tag class="green">{{ t('common.labels.basic') }}</tag>
+ </div>
+ <IconApp class="icon-app" />
+ <p>{{ t('import.categories.backup.description') }}</p>
+ <span class="cta">{{ t('common.actions.open') }}</span>
+ </NuxtLink>
+
+ <NuxtLink class="import-card" to="/dashboard/import/files">
+ <div class="top">
+ <h3>{{ t('import.categories.files.title') }}</h3>
+ <tag class="green">{{ t('common.labels.basic') }}</tag>
+ </div>
+ <Icon name="files" display="xxl" />
+ <p>{{ t('import.categories.files.description') }}</p>
+ <span class="cta">{{ t('common.actions.open') }}</span>
+ </NuxtLink>
+
+ <NuxtLink class="import-card" to="/dashboard/import/advanced">
+ <div class="top">
+ <h3>{{ t('import.categories.advanced.title') }}</h3>
+ <tag class="orange">{{ t('common.labels.advanced') }}</tag>
+ </div>
+ <Icon name="advanced" display="xxl" />
+ <p>{{ t('import.categories.advanced.description') }}</p>
+ <span class="cta">{{ t('common.actions.preview') }}</span>
+ </NuxtLink>
+ </section>
</div>
</template>
<script setup lang="ts">
-import ImportHeader from './_components/ImportHeader.vue';
-import SummaryCard from './_components/ImportSummary.vue';
-import ImportTabs from './_components/ImportTabs.vue';
-import ImportActions from './_components/ImportActions.vue';
-import { handleBackupFile } from '~/helpers/backups';
-import type { Manifest } from '~/helpers/backups/types';
-import type { DB_Node, ImportJob } from '~/stores/db_strustures';
-
definePageMeta({ breadcrumb: { i18n: 'import.meta.breadcrumb' } });
const { t } = useI18nT();
-const nodesStore = useNodesStore();
-const notifications = useNotifications();
-
-// State
-const step = ref<'select' | 'preview'>('select');
-const selectedFile = ref<File>();
-const isAnalyzing = ref(false);
-const analyzeError = ref('');
-
-// Backup data
-const manifest = ref<Manifest | null>(null);
-const backupDocuments = ref<DB_Node[]>([]);
-const toCreate = ref<DB_Node[]>([]);
-const toUpdate = ref<DB_Node[]>([]);
-const localData = ref<object | null>(null);
-
-// Import state
-const importJob = ref<ImportJob>({
- status: 'pending',
- toCreate: 0,
- toUpdate: 0,
- created: [],
- updated: [],
- failures: 0,
-});
-
-// Options
-const importOptions = reactive({
- preserveTimestamps: false,
- skipExisting: false,
-});
-
-// Computed
-const unchangedCount = computed(() => {
- if (!backupDocuments.value.length) return 0;
- return backupDocuments.value.length - toCreate.value.length - toUpdate.value.length;
-});
-
-// Methods
-const handleFileSelect = (file?: File) => {
- selectedFile.value = file;
- analyzeError.value = '';
-};
-
-async function analyzeFile() {
- if (!selectedFile.value) return;
-
- isAnalyzing.value = true;
- analyzeError.value = '';
-
- try {
- const result = await handleBackupFile(selectedFile.value);
- manifest.value = result.manifest;
- localData.value = result.localData;
-
- if (result.documents?.length) {
- backupDocuments.value = result.documents;
- const { toCreate: create, toUpdate: update } = nodesStore.prepareImport(result.documents);
- toCreate.value = create;
- toUpdate.value = update;
- } else {
- backupDocuments.value = [];
- toCreate.value = [];
- toUpdate.value = [];
- }
+</script>
- step.value = 'preview';
- } catch (e) {
- analyzeError.value = e instanceof Error ? e.message : 'Failed to analyze backup file';
- } finally {
- isAnalyzing.value = false;
- }
+<style scoped lang="scss">
+.import-page {
+ display: flex;
+ flex-direction: column;
+ gap: 1rem;
}
-function resetImport() {
- step.value = 'select';
- selectedFile.value = undefined;
- manifest.value = null;
- backupDocuments.value = [];
- toCreate.value = [];
- toUpdate.value = [];
-
- importJob.value = {
- status: 'pending',
- toCreate: 0,
- toUpdate: 0,
- created: [],
- updated: [],
- failures: 0,
- };
+.cards-grid {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 0.9rem;
}
-async function importNodes(type: 'create' | 'update', ids: string[]) {
- const nodes: DB_Node[] = type === 'create' ? toCreate.value.filter(d => ids.includes(d.id)) : toUpdate.value.filter(d => ids.includes(d.id));
-
- if (type === 'create') {
- importJob.value.toCreate = nodes.length;
- await nodesStore.importMultipleNodes({ toCreate: nodes, toUpdate: [] }, importJob);
- toCreate.value = toCreate.value.filter(d => !importJob.value.created.includes(d.id));
- } else if (type == 'update') {
- importJob.value.toUpdate = nodes.length;
- await nodesStore.importMultipleNodes({ toCreate: [], toUpdate: nodes }, importJob);
- toUpdate.value = toUpdate.value.filter(d => !importJob.value.updated.includes(d.id));
+.import-card {
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ background: var(--surface-raised);
+ padding: 0.9rem;
+ display: flex;
+ flex-direction: column;
+ gap: 0.65rem;
+ min-height: 185px;
+ transition:
+ transform 0.18s ease,
+ box-shadow 0.18s ease,
+ border-color 0.18s ease;
+
+ .top {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 0.6rem;
}
- notifications.add({
- type: 'success',
- title: 'Import complete',
- message: `${importJob.value.created.length + importJob.value.updated.length} documents ${type === 'create' ? 'imported' : 'updated'}`,
- });
-}
-
-function importLocalSettings() {
- if (!manifest.value) return;
-
- const preferences = usePreferencesStore();
- if (localData.value) {
- preferences.importPreferences(localData.value);
- notifications.add({
- type: 'success',
- title: t('import.notifications.localImportedTitle'),
- message: t('import.notifications.localImportedMessage'),
- });
- } else {
- notifications.add({
- type: 'error',
- title: t('import.notifications.importFailedTitle'),
- message: t('import.notifications.importFailedMessage'),
- });
+ h3 {
+ margin: 0;
+ font-size: 0.98rem;
}
-}
-
-async function importAll() {
- const createDocs = toCreate.value;
- const updateDocs = importOptions.skipExisting ? [] : toUpdate.value;
-
- importJob.value.toCreate = createDocs.length;
- importJob.value.toUpdate = updateDocs.length;
- await nodesStore.importMultipleNodes({ toCreate: createDocs, toUpdate: updateDocs }, importJob);
- toCreate.value = toCreate.value.filter(d => !importJob.value.created.includes(d.id));
- toUpdate.value = toUpdate.value.filter(d => !importJob.value.updated.includes(d.id));
+ p {
+ margin: 0;
+ color: var(--text-secondary);
+ font-size: 0.9rem;
+ line-height: 1.45;
+ }
- notifications.add({
- type: 'success',
- title: t('import.notifications.importCompleteTitle'),
- message: t('import.notifications.importCompleteMessage'),
- });
-}
-</script>
+ .cta {
+ margin-top: auto;
+ font-size: 0.84rem;
+ color: var(--primary);
+ font-weight: 600;
+ }
-<style scoped lang="scss">
-.import-page {
- display: flex;
- flex-direction: column;
- gap: 1.5rem;
-}
+ &:hover {
+ border-color: var(--primary);
+ transform: translateY(-2px);
+ box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
+ }
-.submit {
- display: flex;
- justify-content: center;
- margin-top: 1rem;
+ .icon-app {
+ width: 46px;
+ }
}
-.error-text {
- font-size: 0.9rem;
- color: var(--red);
- text-align: center;
- margin-top: 0.5rem;
+@media (max-width: 850px) {
+ .cards-grid {
+ grid-template-columns: 1fr;
+ }
}
</style>
diff --git a/frontend/app/stores/nodes.store.ts b/frontend/app/stores/nodes.store.ts
index 6643bf6b..58bf211b 100644
--- a/frontend/app/stores/nodes.store.ts
+++ b/frontend/app/stores/nodes.store.ts
@@ -342,7 +342,7 @@ export const useNodesStore = defineStore('nodes', {
} else throw request.message;
},
async post(node: Partial<Node>): Promise<DB_Node> {
- const request = await makeRequest('nodes', 'POST', node);
+ const request = await makeRequest('nodes', 'POST', { ...node, id: undefined });
if (request.status == 'success') {
this.nodes.set((request.result as DB_Node).id, { ...(request.result as DB_Node), partial: false, shared: false, permissions: [] });
return request.result as DB_Node;
diff --git a/frontend/i18n/locales/en/common.ts b/frontend/i18n/locales/en/common.ts
index 9bf42a79..d5bd41af 100644
--- a/frontend/i18n/locales/en/common.ts
+++ b/frontend/i18n/locales/en/common.ts
@@ -39,7 +39,9 @@ export default {
labels: {
action: 'Action',
+ advanced: 'Advanced',
all: 'All',
+ basic: 'Basic',
color: 'Color',
content: 'Content',
date: 'Date',
diff --git a/frontend/i18n/locales/en/import.ts b/frontend/i18n/locales/en/import.ts
index c26cce85..d1a2fec6 100644
--- a/frontend/i18n/locales/en/import.ts
+++ b/frontend/i18n/locales/en/import.ts
@@ -4,10 +4,47 @@ export default {
importAll: 'Import all',
importing: 'Importing...',
optionsTitle: 'Import options',
+ extractFrontMatter: 'Extract front matter as metadata',
+ normalizeLineEndings: 'Normalize line endings',
preserveTimestamps: 'Preserve original timestamps',
skipExisting: 'Skip existing documents (import only new ones)',
},
+ advanced: {
+ options: 'Advanced import options',
+ defaultDescription: 'Default description for imported documents',
+ defaultTags: 'Default tags for imported documents (comma-separated)',
+ defaultColor: 'Default color for imported documents',
+ defaultThumbnail: 'Default thumbnail for imported documents (svg or unicode emoji)',
+ defaultIcon: 'Default icon for imported documents (svg or unicode emoji)',
+ defaultTheme: 'Default theme for imported documents',
+ },
+
+ files: {
+ meta: {
+ title: 'Import from markdown files',
+ description: 'Quickly import markdown files with options for destination and processing.',
+ },
+ importable:
+ 'You can import markdown files or a folder containing markdown files. Folders will be imported recursively, preserving their structure if you choose import all option.',
+ toImport: 'Items to import',
+ },
+
+ categories: {
+ backup: {
+ title: 'Import from backup',
+ description: 'Restore a complete Alexandrie backup with documents and settings.',
+ },
+ files: {
+ title: 'Import from files',
+ description: 'Import documents from markdown files with flexible options.',
+ },
+ advanced: {
+ title: 'Advanced import',
+ description: 'Import documents using custom options for maximum control.',
+ },
+ },
+
header: {
changeFile: 'Change file',
created: 'Created',
@@ -23,8 +60,7 @@ export default {
meta: {
breadcrumb: 'Imports',
- description:
- "You can import documents from a previous export. If you don't have one, create it from the",
+ description: "You can import documents from a previous export. If you don't have one, create it from the",
settingsLink: 'settings',
title: 'Import documents',
},
diff --git a/frontend/i18n/locales/fr/common.ts b/frontend/i18n/locales/fr/common.ts
index 13b28600..dba263e7 100644
--- a/frontend/i18n/locales/fr/common.ts
+++ b/frontend/i18n/locales/fr/common.ts
@@ -39,7 +39,9 @@ export default {
labels: {
action: 'Action',
+ advanced: 'Avancé',
all: 'Tous',
+ basic: 'Basique',
color: 'Couleur',
content: 'Contenu',
date: 'Date',
diff --git a/frontend/i18n/locales/fr/import.ts b/frontend/i18n/locales/fr/import.ts
index 05d849b7..16824b66 100644
--- a/frontend/i18n/locales/fr/import.ts
+++ b/frontend/i18n/locales/fr/import.ts
@@ -1,13 +1,50 @@
export default {
actions: {
cancel: 'Annuler',
- importAll: 'Tout importer',
- importing: 'Importation...',
+ importAll: 'Importer tout',
+ importing: 'Importation en cours...',
optionsTitle: "Options d'importation",
+ extractFrontMatter: 'Extraire les métadonnées du front matter',
+ normalizeLineEndings: 'Normaliser les fins de ligne',
preserveTimestamps: 'Conserver les horodatages originaux',
skipExisting: 'Ignorer les documents existants (importer uniquement les nouveaux)',
},
+ advanced: {
+ options: "Options d'importation avancées",
+ defaultDescription: 'DDescription par défaut pour les documents importés',
+ defaultTags: 'Balises par défaut pour les documents importés (séparées par des virgules)',
+ defaultColor: 'Couleur par défaut pour les documents importés',
+ defaultThumbnail: 'Vignette par défaut pour les documents importés (svg ou emoji unicode)',
+ defaultIcon: 'Icône par défaut pour les documents importés (svg ou emoji unicode)',
+ defaultTheme: 'Default theme for imported documents',
+ },
+
+ files: {
+ meta: {
+ title: 'Importer à partir de fichiers markdown',
+ description: 'Importez rapidement des fichiers markdown avec des options pour la destination et le traitement.',
+ },
+ importable:
+ "Vous pouvez importer des fichiers markdown ou un dossier contenant des fichiers markdown. Les dossiers seront importés de manière récursive, en préservant leur structure si vous choisissez l'option importer tout.",
+ toImport: 'Éléments à importer',
+ },
+
+ categories: {
+ backup: {
+ title: 'Importer depuis une sauvegarde',
+ description: "Restaurez une sauvegarde complète d'Alexandrie avec les documents et les paramètres.",
+ },
+ files: {
+ title: 'Importer à partir de fichiers',
+ description: 'Importez des documents à partir de fichiers markdown avec des options flexibles.',
+ },
+ advanced: {
+ title: 'Importation avancée',
+ description: 'Importez des documents en utilisant des options personnalisées pour un contrôle maximum.',
+ },
+ },
+
header: {
changeFile: 'Changer de fichier',
created: 'Créé',
@@ -15,17 +52,16 @@ export default {
files: 'Fichiers',
metadata: 'Métadonnées',
settings: 'Paramètres',
- title: 'Informations de sauvegarde',
- totalDocuments: 'Total des documents',
+ title: 'Informations de la sauvegarde',
+ totalDocuments: 'Documents totaux',
totalSize: 'Taille totale',
version: 'Version',
},
meta: {
breadcrumb: 'Importations',
- description:
- "Vous pouvez importer des documents depuis une exportation précédente. Si vous n'avez pas d'exportation, vous pouvez en créer une depuis la page",
- settingsLink: 'paramètres',
+ description: "Vous pouvez importer des documents à partir d'une sauvegarde précédente. Si vous n'en avez pas vous pouvez en créer une depuis",
+ settingsLink: 'les paramètres',
title: 'Importer des documents',
},
diff --git a/frontend/i18n/locales/uk/cdn.ts b/frontend/i18n/locales/uk/cdn.ts
index 446653ab..e7ebaaa1 100644
--- a/frontend/i18n/locales/uk/cdn.ts
+++ b/frontend/i18n/locales/uk/cdn.ts
@@ -42,10 +42,10 @@ export default {
empty: 'Поки що файли не завантажено.',
},
- preview: {
+ preview: {
title: 'Попередній перегляд',
unavailable: 'Попередній перегляд недоступний для цього типу файлу',
},
- storageUsed: 'Використаний обсяг пам\'яті',
+ storageUsed: "Використаний обсяг пам'яті",
};
diff --git a/frontend/i18n/locales/uk/common.ts b/frontend/i18n/locales/uk/common.ts
index 811be00f..b08be8e1 100644
--- a/frontend/i18n/locales/uk/common.ts
+++ b/frontend/i18n/locales/uk/common.ts
@@ -39,7 +39,9 @@ export default {
labels: {
action: 'Дія',
+ advanced: 'Розширений',
all: 'Усе',
+ basic: 'Основний',
color: 'Колір',
content: 'Зміст',
date: 'Дата',
diff --git a/frontend/i18n/locales/uk/import.ts b/frontend/i18n/locales/uk/import.ts
index 9a85c020..c4bf54ff 100644
--- a/frontend/i18n/locales/uk/import.ts
+++ b/frontend/i18n/locales/uk/import.ts
@@ -4,10 +4,47 @@ export default {
importAll: 'Імпортувати все',
importing: 'Імпорт...',
optionsTitle: 'Параметри імпорту',
+ extractFrontMatter: 'Витягувати front matter як метадані',
+ normalizeLineEndings: 'Нормалізувати закінчення рядків',
preserveTimestamps: 'Зберегти оригінальні часові мітки',
skipExisting: 'Пропустити наявні документи (імпортувати лише нові)',
},
+ advanced: {
+ options: 'Розширені параметри імпорту',
+ defaultDescription: 'Типовий опис для імпортованих документів',
+ defaultTags: 'Типові теги для імпортованих документів (через кому)',
+ defaultColor: 'Типовий колір для імпортованих документів',
+ defaultThumbnail: 'Типова мініатюра для імпортованих документів (svg або emoji Unicode)',
+ defaultIcon: 'Типова іконка для імпортованих документів (svg або emoji Unicode)',
+ defaultTheme: 'Типова тема для імпортованих документів',
+ },
+
+ files: {
+ meta: {
+ title: 'Імпорт із markdown-файлів',
+ description: 'Швидко імпортуйте markdown-файли з параметрами призначення та обробки.',
+ },
+ importable:
+ 'Ви можете імпортувати markdown-файли або папку, що містить markdown-файли. Папки будуть імпортовані рекурсивно зі збереженням структури, якщо ви виберете параметр імпорту всього.',
+ toImport: 'Елементи для імпорту',
+ },
+
+ categories: {
+ backup: {
+ title: 'Імпорт із резервної копії',
+ description: 'Відновіть повну резервну копію Alexandrie з документами та налаштуваннями.',
+ },
+ files: {
+ title: 'Імпорт із файлів',
+ description: 'Імпортуйте документи з markdown-файлів із гнучкими параметрами.',
+ },
+ advanced: {
+ title: 'Розширений імпорт',
+ description: 'Імпортуйте документи з використанням власних параметрів для максимального контролю.',
+ },
+ },
+
header: {
changeFile: 'Змінити файл',
created: 'Створено',
@@ -22,10 +59,9 @@ export default {
},
meta: {
- breadcrumb: 'Імпортування',
- description:
- "Ви можете імпортувати документи з попереднього експорту. Якщо такого немає, створіть його з",
- settingsLink: 'налаштування',
+ breadcrumb: 'Імпорт',
+ description: 'Ви можете імпортувати документи з попереднього експорту. Якщо такого немає, створіть його в',
+ settingsLink: 'налаштуваннях',
title: 'Імпортувати документи',
},
@@ -53,12 +89,12 @@ export default {
},
tabs: {
- backup: 'Резервне копіювання',
+ backup: 'Резервна копія',
current: 'Поточний',
import: 'Імпорт',
importFromBackup: 'Імпортувати з резервної копії',
importLocalSettings: 'Імпортувати локальні налаштування',
- importSelected: 'Вибір для імпорту ({count})',
+ importSelected: 'Імпортувати вибране ({count})',
localSettings: 'Локальні налаштування та параметри',
localSettingsAvailable: 'Локальні налаштування та параметри можна імпортувати',
localSettingsWarning: 'Це замінить ваші поточні локальні налаштування, включаючи фрагменти коду',
@@ -66,9 +102,9 @@ export default {
noLocalSettings: 'У резервній копії не знайдено локальних налаштувань',
noNewDocuments: 'Нових документів для імпорту немає',
noUpdates: 'Документів для оновлення немає',
- replaceLocalSettings: 'Замінити локальні налаштування резервною копією?',
+ replaceLocalSettings: 'Замінити ваші локальні налаштування резервною копією?',
selectAll: 'Вибрати все',
updates: 'Оновлення',
- updateSelected: 'Оновити вибір ({count})',
+ updateSelected: 'Оновити вибране ({count})',
},
};