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.

Fixes and improvments

Smaug6739e4fd6003fea3
diff --git a/frontend/components/Icon.vue b/frontend/components/Icon.vue
index e6d6b5c9..142e02a2 100644
--- a/frontend/components/Icon.vue
+++ b/frontend/components/Icon.vue
@@ -3,7 +3,7 @@
</template>
<script setup lang="ts">
-import type { IconName } from '~/composables/icons';
+import { useIcon, type IconName } from '~/helpers/icons';
const props = defineProps<{ name: IconName | string; fill?: string; big?: true; mid?: boolean }>();
const icon = useIcon(props.name as IconName) || props.name;
</script>
diff --git a/frontend/composables/modal_bus.ts b/frontend/composables/ModalBus.ts
similarity index 100%
rename from frontend/composables/modal_bus.ts
rename to frontend/composables/ModalBus.ts
diff --git a/frontend/composables/NotificationBus.ts b/frontend/composables/NotificationBus.ts
new file mode 100644
index 00000000..e69de29b
diff --git a/frontend/composables/utils.ts b/frontend/composables/utils.ts
index 1bf9f8ef..d322eac9 100644
--- a/frontend/composables/utils.ts
+++ b/frontend/composables/utils.ts
@@ -3,19 +3,6 @@ import type { User } from '../stores/db_strustures';
export const CDN = import.meta.env.VITE_BASE_CDN;
export const API = `${import.meta.env.VITE_BASE_API}/api`;
-const colors = ['var(--blue)', 'var(--turquoise)', 'var(--yellow)', 'var(--red)', 'var(--red)'];
-
-export function useColorHash(str: string): string {
- // Calculer un hash unique pour la chaîne
- let hash = 0;
- for (let i = 0; i < str.length; i++) {
- hash = str.charCodeAt(i) + ((hash << 5) - hash);
- }
-
- const index = Math.abs(hash % colors.length);
- return colors[index] as string;
-}
-
// Little screen size
export const isMobile = () => (import.meta.client ? window.innerWidth <= 768 : false);
// Intermediate screen size
@@ -24,46 +11,3 @@ export const isTablet = () => (import.meta.client ? window.innerWidth <= 1280 :
export function useAvatar(user: User): string {
return user.avatar ? CDN + user.id + '/avatar' : CDN + '/default_avatar.png';
}
-export function parseUserAgent(uaString?: string) {
- if (!uaString) return { os: 'Unknown OS', browser: 'Unknown Browser' };
- const osList = [
- { name: 'Windows 10', regex: /Windows NT 10.0/ },
- { name: 'Windows 8.1', regex: /Windows NT 6.3/ },
- { name: 'Windows 8', regex: /Windows NT 6.2/ },
- { name: 'Windows 7', regex: /Windows NT 6.1/ },
- { name: 'Windows Vista', regex: /Windows NT 6.0/ },
- { name: 'Windows XP', regex: /Windows NT 5.1/ },
- { name: 'Mac OS X', regex: /Mac OS X ([\d_]+)/ },
- { name: 'iOS', regex: /iPhone|iPad/ },
- { name: 'Android', regex: /Android/ },
- { name: 'Linux', regex: /Linux/ },
- ];
-
- const browserList = [
- { name: 'Chrome', regex: /Chrome\/([0-9.]+)/ },
- { name: 'Firefox', regex: /Firefox\/([0-9.]+)/ },
- { name: 'Safari', regex: /Safari\/([0-9.]+)/ },
- { name: 'Edge', regex: /Edg\/([0-9.]+)/ },
- { name: 'Opera', regex: /OPR\/([0-9.]+)/ },
- { name: 'Internet Explorer', regex: /MSIE ([0-9.]+);/ },
- ];
-
- let os = 'Unknown OS';
- for (let i = 0; i < osList.length; i++) {
- if (osList[i]!.regex.test(uaString)) {
- os = osList[i]!.name;
- break;
- }
- }
-
- let browser = 'Unknown Browser';
- for (let i = 0; i < browserList.length; i++) {
- let match = uaString.match(browserList[i]!.regex);
- if (match) {
- browser = browserList[i]!.name + ' ' + match[1];
- break;
- }
- }
-
- return { os, browser };
-}
diff --git a/frontend/composables/icons.ts b/frontend/helpers/icons.ts
similarity index 100%
rename from frontend/composables/icons.ts
rename to frontend/helpers/icons.ts
diff --git a/frontend/helpers/utils.ts b/frontend/helpers/utils.ts
new file mode 100644
index 00000000..79134b2b
--- /dev/null
+++ b/frontend/helpers/utils.ts
@@ -0,0 +1,56 @@
+const colors = ['var(--blue)', 'var(--turquoise)', 'var(--yellow)', 'var(--red)', 'var(--red)'];
+
+export function useColorHash(str: string): string {
+ // Calculer un hash unique pour la chaîne
+ let hash = 0;
+ for (let i = 0; i < str.length; i++) {
+ hash = str.charCodeAt(i) + ((hash << 5) - hash);
+ }
+
+ const index = Math.abs(hash % colors.length);
+ return colors[index] as string;
+}
+
+export function parseUserAgent(uaString?: string) {
+ if (!uaString) return { os: 'Unknown OS', browser: 'Unknown Browser' };
+ const osList = [
+ { name: 'Windows 10', regex: /Windows NT 10.0/ },
+ { name: 'Windows 8.1', regex: /Windows NT 6.3/ },
+ { name: 'Windows 8', regex: /Windows NT 6.2/ },
+ { name: 'Windows 7', regex: /Windows NT 6.1/ },
+ { name: 'Windows Vista', regex: /Windows NT 6.0/ },
+ { name: 'Windows XP', regex: /Windows NT 5.1/ },
+ { name: 'Mac OS X', regex: /Mac OS X ([\d_]+)/ },
+ { name: 'iOS', regex: /iPhone|iPad/ },
+ { name: 'Android', regex: /Android/ },
+ { name: 'Linux', regex: /Linux/ },
+ ];
+
+ const browserList = [
+ { name: 'Chrome', regex: /Chrome\/([0-9.]+)/ },
+ { name: 'Firefox', regex: /Firefox\/([0-9.]+)/ },
+ { name: 'Safari', regex: /Safari\/([0-9.]+)/ },
+ { name: 'Edge', regex: /Edg\/([0-9.]+)/ },
+ { name: 'Opera', regex: /OPR\/([0-9.]+)/ },
+ { name: 'Internet Explorer', regex: /MSIE ([0-9.]+);/ },
+ ];
+
+ let os = 'Unknown OS';
+ for (let i = 0; i < osList.length; i++) {
+ if (osList[i]!.regex.test(uaString)) {
+ os = osList[i]!.name;
+ break;
+ }
+ }
+
+ let browser = 'Unknown Browser';
+ for (let i = 0; i < browserList.length; i++) {
+ let match = uaString.match(browserList[i]!.regex);
+ if (match) {
+ browser = browserList[i]!.name + ' ' + match[1];
+ break;
+ }
+ }
+
+ return { os, browser };
+}
diff --git a/frontend/pages/dashboard/admin/index.vue b/frontend/pages/dashboard/admin/index.vue
deleted file mode 100644
index 8f62b8bf..00000000
--- a/frontend/pages/dashboard/admin/index.vue
+++ /dev/null
@@ -1,3 +0,0 @@
-<template>
- <NuxtPage />
-</template>
diff --git a/frontend/pages/dashboard/admin/users/[id].vue b/frontend/pages/dashboard/admin/users/[id].vue
deleted file mode 100644
index fbf12a66..00000000
--- a/frontend/pages/dashboard/admin/users/[id].vue
+++ /dev/null
@@ -1,96 +0,0 @@
-<template>
- <div class="card-component">
- <h2>User Details</h2>
- <div v-if="user" style="width: 100%">
- <div class="user-details">
- <div class="user-detail">
- <label for="username">Username</label>
- <input id="username" v-model="user.username" type="text" />
- </div>
- <div class="user-detail">
- <label for="firstname">Firstname</label>
- <input id="firstname" v-model="user.firstname" type="text" />
- </div>
- <div class="user-detail">
- <label for="lastname">Lastname</label>
- <input id="lastname" v-model="user.lastname" type="text" />
- </div>
- <div class="user-detail">
- <label for="email">Email</label>
- <input id="email" v-model="user.email" type="email" />
- </div>
- <div class="user-detail">
- <label for="role">Role</label>
- <select id="role" v-model="user.role">
- <option :value="1">User</option>
- <option :value="2">Admin</option>
- </select>
- </div>
- <div style="display: flex; width: 100%">
- <div class="user-detail">
- <label>Created At</label>
- <div class="value">{{ new Date(user.created_timestamp).toLocaleDateString() }}</div>
- </div>
- <div class="user-detail">
- <label>Updated At</label>
- <div class="value">{{ new Date(user.updated_timestamp || 0).toLocaleDateString() }}</div>
- </div>
- </div>
- </div>
-
- <AppButton @click="saveChanges" type="success">Save Changes</AppButton>
- </div>
- <div v-else>No user found.</div>
- </div>
-</template>
-
-<script setup lang="ts">
-import type { User } from '@/stores';
-import AppButton from '~/components/AppButton.vue';
-
-const route = useRoute();
-const user = ref<User | undefined>(undefined);
-
-watchEffect(async () => {
- user.value = await useUserStore().fetchById(route.params.id as string);
-});
-
-const saveChanges = async () => {
- if (!user.value) return;
- useUserStore()
- .update(user.value)
- .then(() => {
- useNotifications().add({ type: 'success', title: 'Success', message: 'User updated successfully', timeout: 3000 });
- })
- .catch(e => {
- useNotifications().add({ type: 'error', title: 'Error', message: e, timeout: 3000 });
- });
-};
-
-definePageMeta({ breadcrumb: 'User Details' });
-</script>
-
-<style scoped lang="scss">
-.user-details {
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- gap: 1rem;
- width: 100%;
-}
-
-.user-detail {
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- gap: 0.5rem;
- width: 100%;
-}
-
-label {
- font-weight: bold;
-}
-button {
- margin-top: 1rem;
-}
-</style>
diff --git a/frontend/pages/dashboard/admin/users/index.vue b/frontend/pages/dashboard/admin/users/index.vue
deleted file mode 100644
index 8b9be02b..00000000
--- a/frontend/pages/dashboard/admin/users/index.vue
+++ /dev/null
@@ -1,42 +0,0 @@
-<template>
- <div class="card-component">
- <h2 style="margin: 0">Users manager</h2>
- <DataTable v-if="userStore.users.length" :headers="headers" :rows="rows">
- <template #action="{ cell }">
- <NuxtLink :to="`/dashboard/admin/users/${cell?.data.id}`"><Icon name="view" /></NuxtLink>
- </template>
- </DataTable>
- <div v-else>No user found.</div>
- </div>
-</template>
-<script setup lang="ts">
-const userStore = useUserStore();
-userStore.fetchAll();
-definePageMeta({ breadcrumb: 'Users' });
-
-const headers = [
- { label: 'Name', key: 'username' },
- { label: 'Firstname', key: 'firstname' },
- { label: 'Lastname', key: 'lastname' },
- { label: 'Email', key: 'email' },
- { label: 'Role', key: 'role' },
- { label: 'Created at', key: 'created_at' },
- { label: 'Action', key: 'action' },
-];
-
-const rows = computed(() =>
- userStore.users.map(u => {
- return {
- username: { content: `<img style="border-radius:50%;width:25px;height:25px;" src="${useAvatar(u)}"/>&nbsp;&nbsp;&nbsp;${u.username}`, type: 'html' as const },
- firstname: { content: u.firstname, type: 'text' as const },
- lastname: { content: u.lastname, type: 'text' as const },
- email: { content: u.email, type: 'text' as const },
- role: { content: u.role == 2 ? `<span class="tag red">Admin</span>` : `<span class="tag blue">User</span>`, type: 'html' as const },
- created_at: { content: new Date(u.created_timestamp).toLocaleDateString(), type: 'text' as const },
- action: { type: 'slot' as const, data: { id: u.id } },
- };
- }),
-);
-</script>
-
-<style scoped lang="scss"></style>
diff --git a/frontend/pages/dashboard/categories/[id]/index.vue b/frontend/pages/dashboard/categories/[id]/index.vue
index e542dbaf..d7817606 100644
--- a/frontend/pages/dashboard/categories/[id]/index.vue
+++ b/frontend/pages/dashboard/categories/[id]/index.vue
@@ -37,6 +37,8 @@
</template>
<script setup lang="ts">
+import { useColorHash } from '~/helpers/utils';
+
const route = useRoute();
const categoriesStore = useCategoriesStore();
const documentsStore = useDocumentsStore();
diff --git a/frontend/pages/dashboard/docs/[id].vue b/frontend/pages/dashboard/docs/[id].vue
index 3a621c67..a67da2c2 100644
--- a/frontend/pages/dashboard/docs/[id].vue
+++ b/frontend/pages/dashboard/docs/[id].vue
@@ -13,7 +13,7 @@
</template>
<script setup lang="ts">
-import type { Document } from '@/stores';
+import type { Document } from '~/stores';
import TableOfContent from './_components/table-of-content/TableOfContents.vue';
import DocumentCardHeader from './_components/DocumentCardHeader.vue';
import DocumentCardFooter from './_components/DocumentCardFooter.vue';
diff --git a/frontend/pages/dashboard/docs/_components/DocumentCardFooter.vue b/frontend/pages/dashboard/docs/_components/DocumentCardFooter.vue
index 75d79318..207c6d39 100644
--- a/frontend/pages/dashboard/docs/_components/DocumentCardFooter.vue
+++ b/frontend/pages/dashboard/docs/_components/DocumentCardFooter.vue
@@ -25,7 +25,7 @@
</template>
<script lang="ts" setup>
-import type { Document } from '@/stores';
+import type { Document } from '~/stores';
defineProps<{ document: Document; next?: Document; previous?: Document }>();
</script>
diff --git a/frontend/pages/dashboard/docs/edit/[id].vue b/frontend/pages/dashboard/docs/edit/[id].vue
index 35bdd434..d879966d 100644
--- a/frontend/pages/dashboard/docs/edit/[id].vue
+++ b/frontend/pages/dashboard/docs/edit/[id].vue
@@ -2,7 +2,7 @@
<MarkdownEditor v-if="document" ref="editor" :doc="document" @save="data => save(data)" @exit="exit" />
</template>
<script lang="ts" setup>
-import type { Document } from '@/stores';
+import type { Document } from '~/stores';
import MarkdownEditor from '~/components/MarkdownEditor/MarkdownEditor.vue';
const store = useDocumentsStore();
diff --git a/frontend/pages/dashboard/docs/new.vue b/frontend/pages/dashboard/docs/new.vue
index 532bb2ce..7fc226eb 100644
--- a/frontend/pages/dashboard/docs/new.vue
+++ b/frontend/pages/dashboard/docs/new.vue
@@ -3,7 +3,7 @@
</template>
<script lang="ts" setup>
import MarkdownEditor from '~/components/MarkdownEditor/MarkdownEditor.vue';
-import type { Document } from '@/stores';
+import type { Document } from '~/stores';
const store = useDocumentsStore();
const document = ref<Partial<Document>>({
diff --git a/frontend/pages/dashboard/import.vue b/frontend/pages/dashboard/import.vue
index ab994c85..2a74ed74 100644
--- a/frontend/pages/dashboard/import.vue
+++ b/frontend/pages/dashboard/import.vue
@@ -36,7 +36,7 @@
</template>
<script setup lang="ts">
-import { analyseFile, validateFileStructure, compareDocumentsAndLocal, prepareNewDocuments, uploadDocument, uploadDocuments } from '@/helpers/importations';
+import { analyseFile, validateFileStructure, compareDocumentsAndLocal, prepareNewDocuments, uploadDocument, uploadDocuments } from '~/helpers/importations';
import type { DB_Document } from '~/stores';
definePageMeta({ breadcrumb: 'Importations' });
diff --git a/frontend/pages/dashboard/settings/_views/security.vue b/frontend/pages/dashboard/settings/_views/security.vue
index d7354f39..8b0e7e1e 100644
--- a/frontend/pages/dashboard/settings/_views/security.vue
+++ b/frontend/pages/dashboard/settings/_views/security.vue
@@ -27,7 +27,7 @@
<input id="password" type="password" required v-model="passwordValue" />
</div>
<div class="form-group">
- <span style="display: flex"><label for="password_confirm">Confirm password</label> <span v-if="errorMessages.passwordNotMatch" class="err"> Password do not match !</span></span>
+ <span style="display: flex"><label for="password_confirm">Confirm password</label> <span v-if="err_password_not_match" class="err"> Password do not match !</span></span>
<input id="password_confirm" type="password" required v-model="passwordConfirmValue" />
</div>
<AppButton type="danger">Change password</AppButton>
@@ -38,20 +38,19 @@
</template>
<script setup lang="ts">
+import { parseUserAgent } from '~/helpers/utils';
const route = useRoute();
const currentPage = ref(route.query.p || 'profile');
const store = useUserStore();
const passwordValue = ref('');
const passwordConfirmValue = ref('');
-const errorMessages = ref({
- passwordNotMatch: false,
-});
+const err_password_not_match = ref(false);
watchEffect(() => (currentPage.value = route.query.p || 'profile'));
const changePassword = async () => {
if (!store.user) return;
- if (passwordValue.value !== passwordConfirmValue.value) return (errorMessages.value.passwordNotMatch = true);
+ if (passwordValue.value !== passwordConfirmValue.value) return (err_password_not_match.value = true);
store.updatePassword(passwordValue.value);
};