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.

Notifications improvments & fixes

Smaug6739c05c6ee3964b
diff --git a/backend/controllers/categories.controller.go b/backend/controllers/categories.controller.go
index 40b71526..44533151 100644
--- a/backend/controllers/categories.controller.go
+++ b/backend/controllers/categories.controller.go
@@ -4,7 +4,6 @@ import (
"alexandrie/app"
"alexandrie/models"
"alexandrie/utils"
- "errors"
"net/http"
"github.com/gin-gonic/gin"
@@ -55,7 +54,7 @@ func (ctr *Controller) GetCategories(c *gin.Context) (int, any) {
func (ctr *Controller) CreateCategory(c *gin.Context) (int, any) {
var category models.Category
if err := c.ShouldBind(&category); err != nil {
- return http.StatusBadRequest, errors.New("invalid request payload")
+ return http.StatusBadRequest, err
}
userId, err := utils.GetUserIdCtx(c)
diff --git a/frontend/components/AppSelect.vue b/frontend/components/AppSelect.vue
index 3adb1824..0e449fb8 100644
--- a/frontend/components/AppSelect.vue
+++ b/frontend/components/AppSelect.vue
@@ -1,5 +1,5 @@
<template>
- <div class="category-select" :style="{ width: size ? size + 'px' : '100%' }">
+ <div class="category-select" :style="{ width: size || '100%' }">
<button @click="toggleDropdown">{{ selected?.title || placeholder }}</button>
<div v-if="open" class="dropdown">
<ul>
diff --git a/frontend/components/MarkdownEditor/Toolbar.vue b/frontend/components/MarkdownEditor/Toolbar.vue
index a0bbd6b1..bc98b051 100644
--- a/frontend/components/MarkdownEditor/Toolbar.vue
+++ b/frontend/components/MarkdownEditor/Toolbar.vue
@@ -1,8 +1,8 @@
<template>
<div class="toolbar">
<button v-for="item in toolbar" :key="item.name" v-html="item.icon" @click="emitAction(item.action)" :title="item.name"></button>
- <AppSelect v-model="document.accessibility" :items="accessibilities" placeholder="Select accessibility" size="100" />
- <AppSelect v-model="document.category" :items="categories" placeholder="Select category" size="220" />
+ <AppSelect v-model="document.accessibility" :items="accessibilities" placeholder="Select accessibility" size="100px" />
+ <AppSelect v-model="document.category" :items="categories" placeholder="Select category" size="220px" />
<input type="text" v-model="document.tags" placeholder="Tags" style="margin-right: 5px" />
<AppHint text="Markdown supported" />
</div>
diff --git a/frontend/components/Notification.vue b/frontend/components/Notification.vue
index f7fd00be..aee6f66b 100644
--- a/frontend/components/Notification.vue
+++ b/frontend/components/Notification.vue
@@ -2,9 +2,11 @@
<TransitionGroup name="notification-slide" tag="div" class="notification-container">
<div v-for="notification in notifications" :key="notification.id" class="notification" :class="notification.type">
<div class="content">
- <p class="title">{{ notification.title }}</p>
+ <div class="header">
+ <p class="title">{{ notification.title }}</p>
+ <span class="btn" @click="close(notification.id)" aria-label="Close">&times;</span>
+ </div>
<p v-if="notification.message" class="message">{{ notification.message }}</p>
- <button @click="close(notification.id)" aria-label="Close">&times;</button>
</div>
</div>
</TransitionGroup>
@@ -41,7 +43,12 @@ const close = (id: number) => useNotifications().remove(id);
animation: fadeIn 0.3s ease;
position: relative;
}
-
+.header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ width: 100%;
+}
p {
font-size: 14px;
margin: 0;
@@ -54,14 +61,14 @@ p {
opacity: 0.8;
margin-top: 4px;
}
-button {
- font-size: 30px;
+.btn {
+ font-size: 25px;
color: white;
border: none;
cursor: pointer;
opacity: 0.6;
position: absolute;
- top: 10px;
+ top: 5px;
right: 15px;
}
/* Notification types */
diff --git a/frontend/components/Sidebar/Sidebar.vue b/frontend/components/Sidebar/Sidebar.vue
index 11cb519a..c183e18f 100644
--- a/frontend/components/Sidebar/Sidebar.vue
+++ b/frontend/components/Sidebar/Sidebar.vue
@@ -20,7 +20,7 @@
</div>
<div class="icons">
<NuxtLink @click="onClick" to="/dashboard/docs/new"><Icon name="add_file" :mid="true" fill="var(--font-color-dark)" /></NuxtLink>
- <NuxtLink @click="onClick" to="/dashboard/categories/new"><Icon name="add_folder" :mid="true" fill="var(--font-color-dark)" /></NuxtLink>
+ <NuxtLink @click="newCategory"><Icon name="add_folder" :mid="true" fill="var(--font-color-dark)" /></NuxtLink>
<NuxtLink @click="sidebarTree.collapseAll"><Icon name="collapse" :mid="true" fill="var(--font-color-dark)" /></NuxtLink>
</div>
</div>
@@ -39,8 +39,9 @@ import Resizable from './Resizable.vue';
import IconClose from './IconClose.vue';
import Search from './Search.vue';
import { navigationItems } from './helpers';
+import NewCategoryModal from '../../pages/dashboard/categories/_modals/CreateCategoryModal.vue';
-const { isOpened, hasSidebar, workspaceId } = useSidebar();
+const { isOpened, hasSidebar } = useSidebar();
const categoriesStore = useCategoriesStore();
const preferences = usePreferencesStore();
const userStore = useUserStore();
@@ -70,8 +71,11 @@ const tree = computed(() => [...navigationItemsComputed.value, ...sidebarTree.fi
const handleClickOutside = (e: MouseEvent) => {
if (isOpened.value && e.target && !(e.target as Element).closest('.sidebar') && !(e.target as Element).closest('.open-sidebar')) isOpened.value = false;
};
-
-const onClick = (_: MouseEvent) => {
+const newCategory = (m: MouseEvent) => {
+ onClick();
+ useModal().add(new Modal(shallowRef(NewCategoryModal), { role: 1 }));
+};
+const onClick = () => {
if (isMobile()) isOpened.value = false;
};
diff --git a/frontend/composables/modal_bus.ts b/frontend/composables/modal_bus.ts
index 068ec710..b365821f 100644
--- a/frontend/composables/modal_bus.ts
+++ b/frontend/composables/modal_bus.ts
@@ -22,5 +22,5 @@ export function useModal() {
}
export class Modal {
- constructor(public component: any, public name: string, public props: any, public onClose: () => void = () => {}) {}
+ constructor(public component: any, public props: any, public onClose: () => void = () => {}) {}
}
diff --git a/frontend/pages/dashboard/categories/[id]/edit.vue b/frontend/pages/dashboard/categories/[id]/edit.vue
index b496d13f..abcec49e 100644
--- a/frontend/pages/dashboard/categories/[id]/edit.vue
+++ b/frontend/pages/dashboard/categories/[id]/edit.vue
@@ -46,6 +46,8 @@
</template>
<script lang="ts" setup>
+import DeleteModal from '../_modals/DeleteCategoryModal.vue';
+
const categoriesStore = useCategoriesStore();
const route = useRoute();
const category = computed(() => categoriesStore.getById(route.params.id as string));
@@ -63,14 +65,7 @@ const updateCategory = async () => {
.catch(e => useNotifications().add({ title: 'Error:', message: e, type: 'error', timeout: 3000 }));
};
const deleteCategory = async () => {
- if (category.value)
- categoriesStore
- .delete(category.value.id)
- .then(() => {
- useNotifications().add({ title: 'Success:', message: 'Category deleted', type: 'success', timeout: 3000 });
- useRouter().push('/dashboard/categories');
- })
- .catch(e => useNotifications().add({ title: 'Error:', message: e, type: 'error', timeout: 3000 }));
+ useModal().add(new Modal(shallowRef(DeleteModal), { categoryId: category.value?.id || '' }));
};
</script>
diff --git a/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue b/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue
index 3cf86613..eeb94e1e 100644
--- a/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue
+++ b/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue
@@ -39,11 +39,11 @@ const createCategory = () => {
categoriesStore
.post(category.value)
.then(() => {
- useNotifications().add({ title: 'Success:', message: 'Category created', type: 'success', timeout: 3000 });
+ useNotifications().add({ title: 'Category successfully created', message: '', type: 'success', timeout: 3000 });
emit('close');
})
.catch(e => {
- useNotifications().add({ title: 'Error:', message: e, type: 'error', timeout: 3000 });
+ useNotifications().add({ title: 'Error: ' + e, message: '', type: 'error', timeout: 3000 });
});
};
</script>
diff --git a/frontend/pages/dashboard/categories/_modals/DeleteCategoryModal.vue b/frontend/pages/dashboard/categories/_modals/DeleteCategoryModal.vue
new file mode 100644
index 00000000..6d720113
--- /dev/null
+++ b/frontend/pages/dashboard/categories/_modals/DeleteCategoryModal.vue
@@ -0,0 +1,40 @@
+<template>
+ <div class="modal">
+ <h3>Delete category</h3>
+ <p>Are you sure you want to delete this category ?</p>
+ <p style="opacity: 0.7">This action is irreversible</p>
+ <p v-if="allChildren.length > 0" class="warn">This category has {{ allChildren.length }} child documents/categories. They will be deleted too.</p>
+ <div class="footer">
+ <AppButton @click="emit('close')" type="secondary">Cancel</AppButton>
+ <AppButton @click="deleteDoc" type="danger">Confirm</AppButton>
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+const props = defineProps<{ categoryId: string }>();
+const deleteDoc = () => {
+ useCategoriesStore()
+ .delete(props.categoryId)
+ .then(() => {
+ useNotifications().add({ title: 'Success:', message: 'Category deleted', type: 'success', timeout: 3000 });
+ emit('close');
+ useRouter().push('/dashboard');
+ })
+ .catch(e => {
+ useNotifications().add({ title: 'Error:', message: e, type: 'error', timeout: 3000 });
+ });
+};
+const emit = defineEmits(['close']);
+const allChildren = useSidebarTree().getSubTreeById(props.categoryId);
+</script>
+
+<style scoped lang="scss">
+.modal {
+ min-width: 500px;
+}
+.warn {
+ color: $red-dark;
+ opacity: 0.7;
+}
+</style>
diff --git a/frontend/pages/dashboard/categories/index.vue b/frontend/pages/dashboard/categories/index.vue
index ae617e25..8792c8ac 100644
--- a/frontend/pages/dashboard/categories/index.vue
+++ b/frontend/pages/dashboard/categories/index.vue
@@ -27,8 +27,8 @@ import type { Category } from '~/stores';
const tree = new TreeStructure(useSidebarTree().categories.value).generateTree().filter(i => i.data.type === 'category' && i.data.role == 2) as Item<Category>[];
-const createWorkspace = () => useModal().add(new Modal(shallowRef(CreateCategoryModal), '', { role: 2 }));
-const createCategory = () => useModal().add(new Modal(shallowRef(CreateCategoryModal), '', { role: 1 }));
+const createWorkspace = () => useModal().add(new Modal(shallowRef(CreateCategoryModal), { role: 2 }));
+const createCategory = () => useModal().add(new Modal(shallowRef(CreateCategoryModal), { role: 1 }));
function editNode(node: Item) {
// ouvrir modal ou formulaire d'édition
diff --git a/frontend/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue b/frontend/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
index e4410cc3..48568c59 100644
--- a/frontend/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
+++ b/frontend/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
@@ -25,7 +25,7 @@ import DeleteDocumentModal from '../_modals/DeleteDocumentModal.vue';
const props = defineProps<{ doc_id: string }>();
const print = () => window.print();
-const openDeleteModal = () => useModal().add(new Modal(shallowRef(DeleteDocumentModal), 'Delete modal', { documentId: props.doc_id }));
+const openDeleteModal = () => useModal().add(new Modal(shallowRef(DeleteDocumentModal), { documentId: props.doc_id }));
</script>
<style lang="scss" scoped>
diff --git a/frontend/pages/dashboard/docs/edit/[id].vue b/frontend/pages/dashboard/docs/edit/[id].vue
index 2f7d55e7..35bdd434 100644
--- a/frontend/pages/dashboard/docs/edit/[id].vue
+++ b/frontend/pages/dashboard/docs/edit/[id].vue
@@ -29,7 +29,7 @@ definePageMeta({ breadcrumb: 'Edit' });
function save(doc: Document) {
store
.update(doc)
- .then(() => notifications.add({ title: 'Document successfully updated:', message: '', type: 'success', timeout: 3000 }))
+ .then(() => notifications.add({ title: 'Document successfully updated', message: '', type: 'success', timeout: 3000 }))
.catch(e => notifications.add({ title: 'Error:', message: e, type: 'error', timeout: 3000 }));
}
function exit() {
diff --git a/frontend/pages/dashboard/docs/index.vue b/frontend/pages/dashboard/docs/index.vue
index acaf366a..d7ff1fc1 100644
--- a/frontend/pages/dashboard/docs/index.vue
+++ b/frontend/pages/dashboard/docs/index.vue
@@ -2,8 +2,8 @@
<h2 style="text-align: center">Search documents</h2>
<DataTable :headers="headers" :rows="rows">
<template #actions="{ cell }">
- <NuxtLink :to="`/dashboard/docs/${cell?.data.id}`" class="btn btn-primary"><Icon name="view" /></NuxtLink>
- <NuxtLink :to="`/dashboard/docs/edit/${cell?.data.id}`" class="btn btn-primary"><Icon name="edit" /></NuxtLink>
+ <NuxtLink :to="`/dashboard/docs/${cell?.data.id}`"><Icon name="view" /></NuxtLink>
+ <NuxtLink :to="`/dashboard/docs/edit/${cell?.data.id}`"><Icon name="edit" /></NuxtLink>
</template>
</DataTable>
</template>
diff --git a/frontend/pages/dashboard/docs/new.vue b/frontend/pages/dashboard/docs/new.vue
index 3aaa0c42..532bb2ce 100644
--- a/frontend/pages/dashboard/docs/new.vue
+++ b/frontend/pages/dashboard/docs/new.vue
@@ -18,10 +18,10 @@ function save(doc: Document) {
store
.post(doc)
.then(d => {
- notifications.add({ title: 'Success:', message: 'Document posted', type: 'success', timeout: 3000 });
+ notifications.add({ title: 'Document successfully posted', message: '', type: 'success', timeout: 3000 });
useRouter().push(`/dashboard/docs/edit/${d.id}`);
})
- .catch(e => notifications.add({ title: 'Error:', message: e, type: 'error', timeout: 3000 }));
+ .catch(e => notifications.add({ title: 'Error: ' + e, message: '', type: 'error', timeout: 3000 }));
}
function exit() {
useRouter().push('/dashboard');