📚 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
feat: support default category for uploads and separe advanced options from other options in settings
Smaug673996f22d9fbbf5
diff --git a/backend/controllers/resources.controller.go b/backend/controllers/resources.controller.goindex 347f3f96..882a5c26 100644--- a/backend/controllers/resources.controller.go+++ b/backend/controllers/resources.controller.go@@ -3,6 +3,7 @@ package controllersimport ("alexandrie/app""alexandrie/permissions"+ "alexandrie/types""alexandrie/utils""errors""io"@@ -36,8 +37,11 @@ func (ctr *Controller) UploadFile(c *gin.Context) (int, any) {int64(ctr.app.Config.Cdn.MaxSize),)file, header, err := c.Request.FormFile("file")- if err != nil {- return http.StatusBadRequest, errors.New("file too large or failed to get file")+ parentIdStr := c.Request.FormValue("parent_id")++ var parentId *types.Snowflake = nil+ if parentIdStr != "" {+ parentId, err = types.SnowflakeFromString(parentIdStr)}defer file.Close()@@ -58,6 +62,7 @@ func (ctr *Controller) UploadFile(c *gin.Context) (int, any) {fileContent,mimeType,userId,+ parentId,ctr.app.Config.Cdn.MaxUploadsSize,ctr.app.Config.Cdn.SupportedTypes,ctr.app.MinioClient,diff --git a/backend/services/resource.service.go b/backend/services/resource.service.goindex 388495dd..9c044138 100644--- a/backend/services/resource.service.go+++ b/backend/services/resource.service.go@@ -19,7 +19,7 @@ import ()type ResourceService interface {- UploadFile(filename string, fileSize int64, fileContent []byte, mimeType string, userId types.Snowflake, maxUploadsSize float64, supportedTypes []string, minioClient *minio.Client) (*models.Node, error)+ UploadFile(filename string, fileSize int64, fileContent []byte, mimeType string, userId types.Snowflake, parentId *types.Snowflake, maxUploadsSize float64, supportedTypes []string, minioClient *minio.Client) (*models.Node, error)UploadAvatar(filename string, fileSize int64, fileContent []byte, mimeType string, userId types.Snowflake, supportedTypes []string, minioClient *minio.Client) error}@@ -35,7 +35,7 @@ func NewResourceService(nodeRepo repositories.NodeRepository, snowflake *snowfla}}-func (s *resourceService) UploadFile(filename string, fileSize int64, fileContent []byte, mimeType string, userId types.Snowflake, maxUploadsSize float64, supportedTypes []string, minioClient *minio.Client) (*models.Node, error) {+func (s *resourceService) UploadFile(filename string, fileSize int64, fileContent []byte, mimeType string, userId types.Snowflake, parentId *types.Snowflake, maxUploadsSize float64, supportedTypes []string, minioClient *minio.Client) (*models.Node, error) {if minioClient == nil {return nil, errors.New("minio client not initialized")}@@ -70,7 +70,7 @@ func (s *resourceService) UploadFile(filename string, fileSize int64, fileContennode := &models.Node{Id: id,UserId: userId,- ParentId: nil,+ ParentId: parentId,Name: name,Role: 4,Accessibility: accessibility,diff --git a/backend/types/Snowflake.go b/backend/types/Snowflake.goindex c2eca814..ec92f57a 100644--- a/backend/types/Snowflake.go+++ b/backend/types/Snowflake.go@@ -8,6 +8,16 @@ import (type Snowflake uint64+// Convert string to Snowflake+func SnowflakeFromString(s string) (*Snowflake, error) {+ val, err := strconv.ParseUint(s, 10, 64)+ if err != nil {+ return nil, err+ }+ sf := Snowflake(val)+ return &sf, nil+}+func (s Snowflake) MarshalJSON() ([]byte, error) {// Renvoie l'ID entre guillemets, pour JSONreturn json.Marshal(strconv.FormatUint(uint64(s), 10))diff --git a/frontend/app/composables/usePreferences.ts b/frontend/app/composables/usePreferences.tsindex 0bb2c47f..f6a3213d 100644--- a/frontend/app/composables/usePreferences.ts+++ b/frontend/app/composables/usePreferences.ts@@ -53,6 +53,7 @@ export const DEFAULT_PREFERENCES = {stylesInjectionEnabled: false as boolean,stylesInjection: '' as string,stylesDocumentsInjection: '' as string,+ defaultUploadFolder: null as string | null,};// Crée un type mapping automatique : chaque clé => type exactdiff --git a/frontend/app/pages/dashboard/settings/_views/advanced.vue b/frontend/app/pages/dashboard/settings/_views/advanced.vueindex 451b24ea..7b828649 100644--- a/frontend/app/pages/dashboard/settings/_views/advanced.vue+++ b/frontend/app/pages/dashboard/settings/_views/advanced.vue@@ -3,8 +3,6 @@<h2 class="page-title">Advanced</h2><p class="page-subtitle">Manage advanced settings for the application.</p>- <AppPreferenceInputSection :options="options" />- <hr /><div><h3>Reset all preferences</h3><p>This will reset all your preferences to their default values. This action cannot be undone.</p>@@ -25,40 +23,6 @@ const deleteLocalStorage = () => {localStorage.clear();location.reload();};-type InterfaceOption = Option & {- tag?: string;-};--const options: Array<{ label: string; options: InterfaceOption[] }> = [- {- label: 'Datatable',- options: [- {- label: 'Default datatable items count',- type: 'select',- key: 'datatableItemsCount',- choices: [- { label: '10', id: 10 },- { label: '30', id: 30 },- { label: '50', id: 50 },- { label: '100', id: 100 },- { label: '250', id: 250 },- ],- },- ],- },- {- label: 'Other',- options: [- {- label: 'Developer Mode',- description: 'Enable additional debugging features and options like "Copy ID" in context menus.',- type: 'toggle',- key: 'developerMode',- },- ],- },-];</script><style scoped lang="scss">diff --git a/frontend/app/pages/dashboard/settings/_views/other.vue b/frontend/app/pages/dashboard/settings/_views/other.vuenew file mode 100644index 00000000..75e3e4cf--- /dev/null+++ b/frontend/app/pages/dashboard/settings/_views/other.vue@@ -0,0 +1,60 @@+<template>+ <div>+ <h2 class="page-title">Other</h2>+ <p class="page-subtitle">Manage other general settings for the application.</p>++ <AppPreferenceInputSection :options="options" />+ </div>+</template>++<script setup lang="ts">+type InterfaceOption = Option & {+ tag?: string;+};++const nodesTree = useNodesTree();+const categories = nodesTree.categoriesTree.value;++const options: Array<{ label: string; options: InterfaceOption[] }> = [+ {+ label: 'Datatable',+ options: [+ {+ label: 'Default datatable items count',+ type: 'select',+ key: 'datatableItemsCount',+ choices: [+ { label: '10', id: 10 },+ { label: '30', id: 30 },+ { label: '50', id: 50 },+ { label: '100', id: 100 },+ { label: '250', id: 250 },+ ],+ },+ ],+ },+ {+ label: 'Uploads',+ options: [+ {+ label: 'Default upload folder',+ description: 'Choose the default folder where your uploads will be stored. You can change this for each upload.',+ type: 'select',+ key: 'defaultUploadFolder',+ choices: categories,+ },+ ],+ },+ {+ label: 'Other',+ options: [+ {+ label: 'Developer Mode',+ description: 'Enable additional debugging features and options like "Copy ID" in context menus.',+ type: 'toggle',+ key: 'developerMode',+ },+ ],+ },+];+</script>diff --git a/frontend/app/pages/dashboard/settings/index.vue b/frontend/app/pages/dashboard/settings/index.vueindex 72e118b2..316d5b89 100644--- a/frontend/app/pages/dashboard/settings/index.vue+++ b/frontend/app/pages/dashboard/settings/index.vue@@ -40,6 +40,7 @@ import SnippetsView from './_views/snippets.vue';import MarkdownView from './_views/markdown.vue';import AboutView from './_views/about.vue';import AdvancedView from './_views/advanced.vue';+import OtherView from './_views/other.vue';import StylesView from './_views/styles.vue';type PageKey = keyof typeof pages;@@ -70,6 +71,7 @@ const pages = {markdown: MarkdownView,about: AboutView,advanced: AdvancedView,+ other: OtherView,styles: StylesView,} as const;@@ -106,7 +108,7 @@ const navSections: NavSection[] = [{ key: 'documents', label: 'Documents settings', icon: 'bookmark-stack' },{ key: 'editor', label: 'Editor settings', icon: 'editor' },{ key: 'styles', label: 'Styles injection', icon: 'styles' },- { key: 'advanced', label: 'Advanced', icon: 'advanced' },+ { key: 'other', label: 'Other', icon: 'advanced' },],},{@@ -114,6 +116,7 @@ const navSections: NavSection[] = [items: [{ key: 'snippets', label: 'Snippets', icon: 'snippets' },{ key: 'backup', label: 'Backup', icon: 'backup' },+ { key: 'advanced', label: 'Advanced', icon: 'build' },],},{diff --git a/frontend/app/stores/resources.store.ts b/frontend/app/stores/resources.store.tsindex 544a7251..0ebc9f8f 100644--- a/frontend/app/stores/resources.store.ts+++ b/frontend/app/stores/resources.store.ts@@ -4,9 +4,14 @@ export const useResourcesStore = defineStore('resources', {state: () => ({}),actions: {async post(resource: FormData): Promise<Node> {+ const defaultUploadFolder = usePreferences().get('defaultUploadFolder').value;+ const nodesStore = useNodesStore();+ if (defaultUploadFolder && nodesStore.nodes.has(defaultUploadFolder)) {+ resource.append('parent_id', defaultUploadFolder);+ }const request = await makeRequest(`resources`, 'POST', resource);if (request.status == 'success') {- useNodesStore().nodes.set((request.result as Node).id, request.result as Node);+ nodesStore.nodes.set((request.result as Node).id, request.result as Node);return request.result as Node;} else throw request.message;},diff --git a/frontend/public/app-icons/build.svg b/frontend/public/app-icons/build.svgnew file mode 100644index 00000000..fa397ca7--- /dev/null+++ b/frontend/public/app-icons/build.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M686-132 444-376q-20 8-40.5 12t-43.5 4q-100 0-170-70t-70-170q0-36 10-68.5t28-61.5l146 146 72-72-146-146q29-18 61.5-28t68.5-10q100 0 170 70t70 170q0 23-4 43.5T584-516l244 242q12 12 12 29t-12 29l-84 84q-12 12-29 12t-29-12Zm29-85 27-27-256-256q18-20 26-46.5t8-53.5q0-60-38.5-104.5T386-758l74 74q12 12 12 28t-12 28L332-500q-12 12-28 12t-28-12l-74-74q9 57 53.5 95.5T360-440q26 0 52-8t47-25l256 256ZM472-488Z"/></svg>\ No newline at end of file