π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
New file system improvments
Veauville Raphaelde5b9ddee6a9
diff --git a/@alexandrie/styles/src/_variables.scss b/@alexandrie/styles/src/_variables.scssindex 10b60c2b..477244a7 100644--- a/@alexandrie/styles/src/_variables.scss+++ b/@alexandrie/styles/src/_variables.scss@@ -46,7 +46,7 @@ $transition-duration: 0.3s;--red: #DC3545;--red-bg: rgba(220, 53, 69, 0.15);--red-border: rgba(220, 53, 69, 0.3);- --yellow: #fdbf4c;+ --yellow: #f7b32d;--yellow-bg: rgba(255, 193, 7, 0.15);--yellow-border: rgba(255, 193, 7, 0.3);--turquoise: #17A2B8;diff --git a/backend/classes/DocumentsManager.ts b/backend/classes/DocumentsManager.tsindex f8fe0472..f27b3f38 100644--- a/backend/classes/DocumentsManager.ts+++ b/backend/classes/DocumentsManager.ts@@ -56,13 +56,14 @@ export default class DocumentsManager extends Base {if (!data.author_id) return reject(new Error('[MISSING_KEY] : author_id must be provided'));this.app.db.query<DocumentDB[]>(- 'INSERT INTO documents (`id`, `name`, `description`, `tags`, `category`, `accessibility`, `content_markdown`, `content_html`, `author_id`, `created_timestamp`, `updated_timestamp`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',+ 'INSERT INTO documents (`id`, `name`, `description`, `tags`, `category`, `parent_id`, `accessibility`, `content_markdown`, `content_html`, `author_id`, `created_timestamp`, `updated_timestamp`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',[id,data.name,data.description,data.tags,data.category,+ data.parent_id,data.accessibility,data.content_markdown,data.content_html,@@ -86,12 +87,13 @@ export default class DocumentsManager extends Base {if (!data.author_id) return reject(new Error('[MISSING_KEY] : author_id must be provided'));const time = Date.now().toString();this.app.db.query<DocumentDB[]>(- 'UPDATE documents SET name = ?, description = ?, tags = ?, category = ?, accessibility = ?, content_markdown = ?, content_html = ?, updated_timestamp = ? WHERE id = ?',+ 'UPDATE documents SET name = ?, description = ?, tags = ?, category = ?, parent_id = ?, accessibility = ?, content_markdown = ?, content_html = ?, updated_timestamp = ? WHERE id = ?',[data.name,data.description,data.tags,data.category,+ data.parent_id,data.accessibility,data.content_markdown,data.content_html,diff --git a/backend/controllers/documents.controller.ts b/backend/controllers/documents.controller.tsindex bc563130..031e5da2 100644--- a/backend/controllers/documents.controller.ts+++ b/backend/controllers/documents.controller.ts@@ -54,6 +54,7 @@ export default class DocumentsController {description: req.body.description,tags: req.body.tags,category: req.body.category,+ parent_id: req.body.parent_id,accessibility: req.body.accessibility,content_markdown: req.body.content_markdown,content_html: req.body.content_html,@@ -69,6 +70,7 @@ export default class DocumentsController {description: req.body.description,tags: req.body.tags,category: req.body.category,+ parent_id: req.body.parent_id,accessibility: req.body.accessibility,content_markdown: req.body.content_markdown,content_html: req.body.content_html,diff --git a/backend/types/Structures.d.ts b/backend/types/Structures.d.tsindex 9151a42a..6bf4aa66 100644--- a/backend/types/Structures.d.ts+++ b/backend/types/Structures.d.ts@@ -6,6 +6,7 @@ export interface Document {description?: string;tags?: string;category?: string;+ parent_id?: string;accessibility: number; // 0: No; 1: Yes;content_markdown?: string;content_html?: string;diff --git a/dashboard/App.vue b/dashboard/App.vueindex a16c8565..5da4e3da 100644--- a/dashboard/App.vue+++ b/dashboard/App.vue@@ -11,7 +11,7 @@import { useDocumentsStore, useCategoriesStore } from './store';// @ts-ignore-useDocumentsStore().fetch({ fields: ['id', 'name', 'description', 'accessibility', 'category', 'created_timestamp'] });+useDocumentsStore().fetch({ fields: ['id', 'name', 'description', 'accessibility', 'category', 'parent_id', 'created_timestamp'] });useCategoriesStore().fetch();</script>diff --git a/dashboard/components/MarkdownEditor/Toolbar.vue b/dashboard/components/MarkdownEditor/Toolbar.vueindex 53b734cf..8c131bf1 100644--- a/dashboard/components/MarkdownEditor/Toolbar.vue+++ b/dashboard/components/MarkdownEditor/Toolbar.vue@@ -10,7 +10,6 @@<option value="1">Visible</option><option value="2">Draf</option><option value="3">Archive</option>- <option value="4">Trash</option></select><select v-model="copy.category"><optgroup v-for="cat in categoriesStore.getParents" :label="cat.name" :key="cat.id">@@ -19,14 +18,21 @@</option></optgroup></select>+ <select v-model="copy.parent_id">+ <option selected :value="null"> No parent </option>+ <option v-for="doc in documentsStore.getByCategories(copy.category || '')" :value="doc.id" :key="doc.id"+ v-text="doc.name">+ </option>+ </select></div></div></template><script setup lang="ts">-import { useCategoriesStore, type Document, type Category } from "~/store";+import { useCategoriesStore, useDocumentsStore, type Document, type Category } from "~/store";const categoriesStore = useCategoriesStore();+const documentsStore = useDocumentsStore();const props = defineProps<{ document: Partial<Document> }>();const copy = ref(props.document);diff --git a/dashboard/components/sidebar/Collapse.vue b/dashboard/components/sidebar/Collapse.vueindex be73daed..7cb8c18a 100644--- a/dashboard/components/sidebar/Collapse.vue+++ b/dashboard/components/sidebar/Collapse.vue@@ -1,6 +1,7 @@<template>- <div class="collapse-header item" @click="toggleShow">- <svg :class="{ 'rotated': !show }" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">+ <div class="collapse-header item">+ <svg @click="toggleShow" :class="{ 'rotated': !show }" xmlns="http://www.w3.org/2000/svg" height="24"+ viewBox="0 -960 960 960" width="24"><path d="M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z" /></svg><slot name="header"></slot>diff --git a/dashboard/components/sidebar/CollapseItem.vue b/dashboard/components/sidebar/CollapseItem.vueindex 770f6955..672b3474 100644--- a/dashboard/components/sidebar/CollapseItem.vue+++ b/dashboard/components/sidebar/CollapseItem.vue@@ -1,66 +1,23 @@<template>- <Collapse>+ <Collapse v-if="item.childrens.length"><template v-slot:header>- <NuxtLink class="item">- <i v-if="item.icon" v-html="item.icon" class="icon"></i>- <span>{{ item.title }}</span>- </NuxtLink>+ <SidebarItem :item="item" /></template><template v-slot:body><template v-for="(child, index) in item.childrens">- <div style="margin-left:15px;">+ <div style="margin-left:25px;"><CollapseItem v-if="child.childrens?.length" :item="child" :key="index" />- <NuxtLink v-else class="item" :to="child.route" :class="{ active: isActive(child.id) }">- <i v-html="child.icon" class="icon"></i>- <span>{{ child.title }}</span>- </NuxtLink>+ <SidebarItem v-else :item="child" /></div></template></template></Collapse>+ <SidebarItem v-else :item="item" /></template><script setup lang="ts">import { type Item } from './helpers';import Collapse from './Collapse.vue';+import SidebarItem from './SidebarItem.vue';defineProps<{ item: Item }>();-const route = useRoute();-const doc_id = computed(() => route.query.doc as string);-const isActive = (id: string) => doc_id.value === id;</script>--<style lang="scss" scoped>-.item {- display: flex;- justify-content: flex-start;- align-items: center;- height: 30px;- padding: 0 2.5px;- margin: 2.5px 0;- border-radius: 5px;- color: var(--font-color);- cursor: pointer;- width: 90%;-- &:hover,- &.active {- background: var(--bg-contrast-2);- }-- .icon {- display: flex;- align-items: center;-- &:deep(svg) {- fill: var(--blue);- width: 22px;- height: 20px;- margin-right: 7px;-- path {- fill: var(--blue);- }- }- }-}-</style>\ No newline at end of filediff --git a/dashboard/components/sidebar/Sidebar.vue b/dashboard/components/sidebar/Sidebar.vueindex cd37e772..e9e3f63c 100644--- a/dashboard/components/sidebar/Sidebar.vue+++ b/dashboard/components/sidebar/Sidebar.vue@@ -32,7 +32,10 @@ const items = computed((): Item[] => [...formatTree()]);+type DocumentTree = Document & { childrens: DocumentTree[] };+function formatTree(): Item[] {+ console.log('formatTree');const parents = categoriesStore.getParents;const items: Item[] = [];parents.forEach((parent) => {@@ -42,8 +45,8 @@ function formatTree(): Item[] {id: child.id,title: child.name,icon: child.icon,- route: `/dashboard/?category=${child.id}`,- childrens: documentsToItems(documentsStore.getByCategories(child.id))+ route: '',+ childrens: documentsTreeToItems(convertDocumentsToTree(documentsStore.getByCategories(child.id)))});});items.push({@@ -57,20 +60,48 @@ function formatTree(): Item[] {return items;}-function documentsToItems(documents: Document[]): Item[] {+function convertDocumentsToTree(documents: Document[]): DocumentTree[] {+ const documentMap: { [id: string]: DocumentTree } = {};++ // Create a map of documents indexed by their id+ documents.forEach(doc => {+ documentMap[doc.id] = { ...doc, childrens: [] };+ });++ // Build the tree structure+ const documentTree: DocumentTree[] = [];+ documents.forEach(doc => {+ if (doc.parent_id && documentMap[doc.parent_id]) {+ documentMap[doc.parent_id].childrens.push(documentMap[doc.id]);+ } else {+ documentTree.push(documentMap[doc.id]);+ }+ });++ return documentTree;+}++function documentsTreeToItems(documentsTree: DocumentTree[]): Item[] {const items: Item[] = [];- documents.forEach((document) => {+ documentsTree.forEach((doc) => {+ const childrens: Item[] = documentsTreeToItems(doc.childrens);items.push({- id: document.id,- title: document.name,- icon: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path style="fill:var(--yellow);" d="M320-240h320v-80H320v80Zm0-160h320v-80H320v80ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z"/></svg>',- route: `/dashboard?doc=${document.id}`,- childrens: []+ id: doc.id,+ title: doc.name,+ icon: defaultIcon(childrens.length > 0),+ route: `/dashboard?doc=${doc.id}`,+ childrens: childrens,});});return items;}+function defaultIcon(hasChild: boolean): string {+ if (hasChild) return '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path style="fill:var(--green);" d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h240v-560H200v560Zm320 0h240v-280H520v280Zm0-360h240v-200H520v200Z"/></svg>';+ return '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path style="fill:var(--yellow);" d="M320-240h320v-80H320v80Zm0-160h320v-80H320v80ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z"/></svg>';+}++onMounted(() => {hasSidebar.value = true;if (!process.client) return;diff --git a/dashboard/components/sidebar/SidebarItem.vue b/dashboard/components/sidebar/SidebarItem.vuenew file mode 100644index 00000000..4551fc6d--- /dev/null+++ b/dashboard/components/sidebar/SidebarItem.vue@@ -0,0 +1,51 @@+<template>+ <NuxtLink class="item" :to="item.route" :class="{ active: isActive(item.id) }">+ <i v-html="item.icon" class="icon"></i>+ <span>{{ item.title }}</span>+ </NuxtLink>+</template>++<script setup lang="ts">+import { type Item } from './helpers';+const route = useRoute();++defineProps<{ item: Item }>();+const doc_id = computed(() => route.query.doc as string);+const isActive = (id: string) => doc_id.value === id;+</script>++<style lang="scss" scoped>+.item {+ display: flex;+ justify-content: flex-start;+ align-items: center;+ min-height: 30px;+ padding: 0 2.5px;+ margin: 2.5px 0;+ border-radius: 5px;+ color: var(--font-color);+ cursor: pointer;+ width: 90%;++ &:hover,+ &.active {+ background: var(--bg-contrast-2);+ }++ .icon {+ display: flex;+ align-items: center;++ &:deep(svg) {+ fill: var(--blue);+ width: 22px;+ height: 20px;+ margin-right: 7px;++ path {+ fill: var(--blue);+ }+ }+ }+}+</style>\ No newline at end of filediff --git a/dashboard/components/sidebar/helpers.ts b/dashboard/components/sidebar/helpers.tsindex 75091dc4..8d4acc6e 100644--- a/dashboard/components/sidebar/helpers.ts+++ b/dashboard/components/sidebar/helpers.ts@@ -13,39 +13,31 @@ export interface Item {export const defaultItems: Item[] = [{- id: '#1',- title: 'Navigattion',- icon: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M320-160q-117 0-198.5-81.5T40-440q0-107 70.5-186.5T287-718l-63-66 56-56 160 160-160 160-56-57 59-59q-71 14-117 69t-46 127q0 83 58.5 141.5T320-240h120v80H320Zm200-360v-280h360v280H520Zm0 360v-280h360v280H520Zm80-80h200v-120H600v120Z"/></svg>',- route: '/dashboard/scategory&ettings',- childrens: [- {- id: 'manage-categories',- title: 'Manage categories',- icon: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M320-320h480v-480h-80v280l-100-60-100 60v-280H320v480Zm0 80q-33 0-56.5-23.5T240-320v-480q0-33 23.5-56.5T320-880h480q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H320ZM160-80q-33 0-56.5-23.5T80-160v-560h80v560h560v80H160Zm360-720h200-200Zm-200 0h480-480Z"/></svg>',- route: '/dashboard/categories',- childrens: [],- },- {- id: 'cdn',- title: 'CDN',- icon: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M485-440h163q26 0 44-18t18-44q0-26-18-44.5T648-565h-2q-5-32-29-53.5T560-640q-26 0-47 13.5T481-590q-30 2-50.5 23.5T410-515q0 30 21.5 52.5T485-440ZM120-120q-33 0-56.5-23.5T40-200v-520h80v520h680v80H120Zm160-160q-33 0-56.5-23.5T200-360v-440q0-33 23.5-56.5T280-880h200l80 80h280q33 0 56.5 23.5T920-720v360q0 33-23.5 56.5T840-280H280Zm0-80h560v-360H527l-80-80H280v440Zm0 0v-440 440Z"/></svg>',- route: '/dashboard/cdn',- childrens: [],- },- {- id: 'backup',- title: 'Backup',- icon: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M260-160q-91 0-155.5-63T40-377q0-78 47-139t123-78q17-72 85-137t145-65q33 0 56.5 23.5T520-716v242l64-62 56 56-160 160-160-160 56-56 64 62v-242q-76 14-118 73.5T280-520h-20q-58 0-99 41t-41 99q0 58 41 99t99 41h480q42 0 71-29t29-71q0-42-29-71t-71-29h-60v-80q0-48-22-89.5T600-680v-93q74 35 117 103.5T760-520q69 8 114.5 59.5T920-340q0 75-52.5 127.5T740-160H260Zm220-358Z"/></svg>',- route: '/dashboard/backup',- childrens: [],- },- {- id: 'new-page',- title: 'New page',- icon: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M440-280h80v-160h160v-80H520v-160h-80v160H280v80h160v160ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"/></svg>',- route: '/dashboard/new',- childrens: [],- },- ],+ id: 'manage-categories',+ title: 'Manage categories',+ icon: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M320-320h480v-480h-80v280l-100-60-100 60v-280H320v480Zm0 80q-33 0-56.5-23.5T240-320v-480q0-33 23.5-56.5T320-880h480q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H320ZM160-80q-33 0-56.5-23.5T80-160v-560h80v560h560v80H160Zm360-720h200-200Zm-200 0h480-480Z"/></svg>',+ route: '/dashboard/categories',+ childrens: [],+ },+ {+ id: 'cdn',+ title: 'CDN',+ icon: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M485-440h163q26 0 44-18t18-44q0-26-18-44.5T648-565h-2q-5-32-29-53.5T560-640q-26 0-47 13.5T481-590q-30 2-50.5 23.5T410-515q0 30 21.5 52.5T485-440ZM120-120q-33 0-56.5-23.5T40-200v-520h80v520h680v80H120Zm160-160q-33 0-56.5-23.5T200-360v-440q0-33 23.5-56.5T280-880h200l80 80h280q33 0 56.5 23.5T920-720v360q0 33-23.5 56.5T840-280H280Zm0-80h560v-360H527l-80-80H280v440Zm0 0v-440 440Z"/></svg>',+ route: '/dashboard/cdn',+ childrens: [],+ },+ {+ id: 'backup',+ title: 'Backup',+ icon: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M260-160q-91 0-155.5-63T40-377q0-78 47-139t123-78q17-72 85-137t145-65q33 0 56.5 23.5T520-716v242l64-62 56 56-160 160-160-160 56-56 64 62v-242q-76 14-118 73.5T280-520h-20q-58 0-99 41t-41 99q0 58 41 99t99 41h480q42 0 71-29t29-71q0-42-29-71t-71-29h-60v-80q0-48-22-89.5T600-680v-93q74 35 117 103.5T760-520q69 8 114.5 59.5T920-340q0 75-52.5 127.5T740-160H260Zm220-358Z"/></svg>',+ route: '/dashboard/backup',+ childrens: [],+ },+ {+ id: 'new-page',+ title: 'New page',+ icon: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M440-280h80v-160h160v-80H520v-160h-80v160H280v80h160v160ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"/></svg>',+ route: '/dashboard/new',+ childrens: [],},];diff --git a/dashboard/pages/dashboard/index.vue b/dashboard/pages/dashboard/index.vueindex 3ac0904f..5eb6aefb 100644--- a/dashboard/pages/dashboard/index.vue+++ b/dashboard/pages/dashboard/index.vue@@ -70,7 +70,10 @@ watchEffect(async () => {});const print = () => window.print();-const deleteDoc = () => doc.value?.id ? documentsStore.delete(doc.value.id) : null;+const deleteDoc = () => {+ showDeleteModal.value = false;+ doc.value?.id ? documentsStore.delete(doc.value.id) : null+};</script><style lang="scss" scoped>diff --git a/dashboard/store/db_strustures.d.ts b/dashboard/store/db_strustures.d.tsindex 3cff3244..7bf68bf8 100644--- a/dashboard/store/db_strustures.d.ts+++ b/dashboard/store/db_strustures.d.ts@@ -4,6 +4,7 @@ export interface Document {description?: string;tags?: string;category?: string;+ parent_id?: string | null;accessibility: number; // 0: No; 1: Yes;content_markdown?: string;content_html?: string;diff --git a/dashboard/store/documents.store.ts b/dashboard/store/documents.store.tsindex dadf8143..9bfca772 100644--- a/dashboard/store/documents.store.ts+++ b/dashboard/store/documents.store.ts@@ -38,6 +38,8 @@ export const useDocumentsStore = defineStore('documents', {);if (request.status == 'success') {if (opts?.id) {+ console.log(request.result);+const index = this.documents.findIndex(d => d.id == opts?.id);const updatedDocument: Document = { ...request.result, partial: false };if (index == -1) this.documents.push(updatedDocument);