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.

New cards, badges works !, some fixes

Smaug67397fd295a05325
diff --git a/TODO.md b/TODO.md
index 28b5a4da..68ed73b0 100644
--- a/TODO.md
+++ b/TODO.md
@@ -5,3 +5,6 @@
- Unification of classes / params
- Badges frontend (interfaces and markdown)
+- Login page
+- Documents cards
+- User account (+security) page
diff --git a/frontend/components/DocumentCardHeader.vue b/frontend/components/DocumentCardHeader.vue
index e283a342..25980bd0 100644
--- a/frontend/components/DocumentCardHeader.vue
+++ b/frontend/components/DocumentCardHeader.vue
@@ -6,6 +6,9 @@
</p>
<h1 class="title">{{ doc?.name }}</h1>
<p class="description">{{ doc?.description }}</p>
+ <div class="document-tags" v-if="doc.tags">
+ <span v-for="tag in doc.tags.split(',')" :key="tag" class="tag">{{ tag.trim() }}</span>
+ </div>
</div>
<div class="icon">
<svg height="150" viewBox="0 0 297 205" fill="none" xmlns="http://www.w3.org/2000/svg"
@@ -126,12 +129,16 @@ p {
.text {
flex: 2;
padding-right: 10px;
- .category, .title {
- font-family: Inter;
- }
- .title {
- font-weight: 700;
- }
+
+ .category,
+ .title {
+ font-family: Inter;
+ }
+
+ .title {
+ font-weight: 700;
+ }
+
.category {
display: flex;
align-items: baseline;
@@ -142,6 +149,24 @@ p {
}
}
+.document-tags {
+ padding-top: 5px;
+ margin-bottom: 10px;
+ display: flex;
+ flex-wrap: wrap;
+}
+
+.tag {
+ border-color: var(--blue-border);
+ color: var(--blue);
+ background-color: var(--blue-bg);
+ padding: 2px 5px;
+ border-radius: 8px;
+ margin-right: 5px;
+ margin-bottom: 5px;
+ font-size: 12px;
+}
+
@media print,
screen and (min-width: 1024px) {
.icon {
diff --git a/frontend/components/MarkdownEditor/Editor.ts b/frontend/components/MarkdownEditor/Editor.ts
index d1bf78a0..4d44edef 100644
--- a/frontend/components/MarkdownEditor/Editor.ts
+++ b/frontend/components/MarkdownEditor/Editor.ts
@@ -127,22 +127,22 @@ export class Editor extends EventTarget {
}
public updateContextMenu() {
- console.log('selectionchange');
-
- if (!this.inlineToolbar?.value?.element) return;
- const toolbarElement = this.inlineToolbar.value.element;
- toolbarElement.style.display = 'none';
- if (!this.area?.value) return;
- const selection = window.getSelection();
- if (!selection || selection.rangeCount === 0 || selection.toString().length == 0) return;
- const range = selection.getRangeAt(0);
- if (!this.area.value.contains(range.startContainer) || !this.area.value.contains(range.endContainer)) return;
- const containerRect = this.area.value?.getBoundingClientRect(); //const selectionRect = range.getBoundingClientRect();
- const rects = range.getClientRects();
- if (!containerRect) return;
- const last_rect = rects[rects.length - 1];
- toolbarElement.style.top = `${last_rect.top - containerRect.top + 25}px`;
- toolbarElement.style.left = `${last_rect.left - containerRect.left}px`;
- toolbarElement.style.display = 'flex';
+ setTimeout(() => {
+ if (!this.inlineToolbar?.value?.element) return;
+ const toolbarElement = this.inlineToolbar.value.element;
+ toolbarElement.style.display = 'none';
+ if (!this.area?.value) return;
+ const selection = window.getSelection();
+ if (!selection || selection.rangeCount === 0 || selection.toString().length == 0) return;
+ const range = selection.getRangeAt(0);
+ if (!this.area.value.contains(range.startContainer) || !this.area.value.contains(range.endContainer)) return;
+ const containerRect = this.area.value?.getBoundingClientRect(); //const selectionRect = range.getBoundingClientRect();
+ const rects = range.getClientRects();
+ if (!containerRect) return;
+ const last_rect = rects[rects.length - 1];
+ toolbarElement.style.top = `${last_rect.top - containerRect.top + 25}px`;
+ toolbarElement.style.left = `${last_rect.left - containerRect.left}px`;
+ toolbarElement.style.display = 'flex';
+ }, 10);
}
}
diff --git a/frontend/components/MarkdownEditor/LazyToolbar.vue b/frontend/components/MarkdownEditor/LazyToolbar.vue
index 254567a2..c17dacd0 100644
--- a/frontend/components/MarkdownEditor/LazyToolbar.vue
+++ b/frontend/components/MarkdownEditor/LazyToolbar.vue
@@ -14,7 +14,7 @@
</option>
</optgroup>
</select>
-
+ <input type="text" v-model="copy.tags" placeholder="Tags" style="margin-right:5px;" />
</div>
</template>
@@ -98,7 +98,7 @@ const toolbar = [
<style scoped lang="scss">
button {
- padding: 3px 5px 3px 0;
+ padding: 0 3px;
margin: 0;
transform: none;
}
@@ -106,7 +106,7 @@ button {
.toolbar {
user-select: none;
display: flex;
- align-items: center;
+ align-items: stretch;
}
svg,
diff --git a/frontend/components/sidebar/Search.vue b/frontend/components/sidebar/Search.vue
index ca361455..216f5f4e 100644
--- a/frontend/components/sidebar/Search.vue
+++ b/frontend/components/sidebar/Search.vue
@@ -138,7 +138,6 @@ const handleSearchShortCut = (e: KeyboardEvent) => {
color: var(--font-color);
cursor: pointer;
- &:hover,
&.router-link-active {
background: var(--bg-contrast-2);
}
diff --git a/frontend/components/sidebar/SidebarItem.vue b/frontend/components/sidebar/SidebarItem.vue
index 3df441e4..3f9ede64 100644
--- a/frontend/components/sidebar/SidebarItem.vue
+++ b/frontend/components/sidebar/SidebarItem.vue
@@ -110,6 +110,7 @@ const drop = async (event: DragEvent) => {
color: var(--font-color);
cursor: pointer;
width: 98%;
+
&:hover,
&.router-link-active {
background: var(--bg-contrast-2);
@@ -120,9 +121,14 @@ const drop = async (event: DragEvent) => {
align-items: center;
&:deep(svg) {
+ fill: var(--blue);
width: 20px;
max-height: 25px;
margin-right: 5px;
+
+ path {
+ fill: var(--blue);
+ }
}
}
}
diff --git a/frontend/composables/utils.ts b/frontend/composables/utils.ts
index 1ef4656f..89f1286e 100644
--- a/frontend/composables/utils.ts
+++ b/frontend/composables/utils.ts
@@ -1,4 +1,4 @@
-const colors = ['var(--yellow)', 'var(--green)', 'var(--blue)', 'var(--turquoise)', 'var(--pink)', 'var(--red)', 'var(--font-color)'];
+const colors = ['var(--blue)', 'var(--turquoise)', 'var(--yellow)', 'var(--pink)', 'var(--red)'];
export function useColorHash(str: string): string {
// Calculer un hash unique pour la chaîne
diff --git a/frontend/pages/dashboard/category/[id].vue b/frontend/pages/dashboard/category/[id].vue
index 928ac858..38747d26 100644
--- a/frontend/pages/dashboard/category/[id].vue
+++ b/frontend/pages/dashboard/category/[id].vue
@@ -1,14 +1,32 @@
<template>
- <div class="view-medium">
+ <div>
<h1>Documents de la catégorie {{ category?.name }}</h1>
- <div class="article-list">
- <div v-for="document in allDocuments" :key="document.id" class="article"
- :style="`border-bottom: 4px solid ${useColorHash(document.id)};`">
+ <div class="document-list">
+ <div v-for="document in documents" :key="document.id" class="document-card">
<div>
- <NuxtLink :to="`/dashboard/doc/${document.id}`">{{ document.name }}</NuxtLink>
- <p class="description">{{ document.description }}</p>
+ <header class="document-header">
+ <i v-html="category?.icon" class="category-icon"></i>
+ <NuxtLink :to="`/dashboard/doc/${document.id}`" class="document-title"
+ :style="`border-bottom: 2px solid ${useColorHash(document.id)};`">{{ document.name }}</NuxtLink>
+ </header>
+ <p class="document-description">{{ document.description }}</p>
</div>
- <p>{{ formatDate(parseInt(document.created_timestamp)) }}</p>
+ <div class="document-tags" v-if="document.tags">
+ <span v-for="tag in document.tags.split(',')" :key="tag" class="tag">{{ tag.trim() }}</span>
+ </div>
+ <footer class="document-footer">
+ <div class="footer-item">
+ <svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px"
+ fill="var(--font-color)">
+ <path
+ d="m612-292 56-56-148-148v-184h-80v216l172 172ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 320q133 0 226.5-93.5T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160Z" />
+ </svg>
+ <span>{{ formatDate(parseInt(document.created_timestamp)) }}</span>
+ </div>
+ <div class="footer-item">
+ <span>Mis à jour: {{ formatDate(parseInt(document.updated_timestamp)) }}</span>
+ </div>
+ </footer>
</div>
</div>
</div>
@@ -21,7 +39,7 @@ const categoriesStore = useCategoriesStore();
const documentsStore = useDocumentsStore();
const category = computed(() => categoriesStore.getById(route.params.id as string));
-const allDocuments = computed(() => {
+const documents = computed(() => {
const documents = documentsStore.getByCategories(category.value?.id || '');
const childCategories = categoriesStore.getChilds(category.value?.id || '');
for (const childCategory of childCategories) {
@@ -36,42 +54,111 @@ function formatDate(timestamp: number): string {
const date = new Date(timestamp);
return `${date.getDate()} ${date.toLocaleString('default', { month: 'short' })} ${date.getFullYear()}`;
}
-
</script>
-
<style scoped lang="scss">
-.article-list {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
+h1 {
+ font-size: 32px;
+ margin-bottom: 20px;
+}
+
+.document-list {
+ display: flex;
+ flex-wrap: wrap;
gap: 20px;
+ max-width: 420px * 3 + 100px;
+ margin: 0 auto;
}
-.article {
- background-color: var(--bg-contrast);
- padding: 15px;
- border-radius: 8px;
- position: relative;
- transition: box-shadow $transition-duration;
- margin-bottom: 10px;
+.document-card {
+ border-radius: 10px;
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
+ overflow: hidden;
+ width: 420px;
display: flex;
flex-direction: column;
justify-content: space-between;
+ transition: transform 0.2s;
+ flex: 0 1 auto;
}
-h1 {
- font-size: 28px;
- margin-bottom: 20px;
+.document-card:hover {
+ transform: scale(1.02);
}
-a {
- font-size: 24px;
- font-weight: 600;
- margin: 0;
+.document-header {
+ background-color: var(--bg-contrast-2);
+ padding: 15px;
+ display: flex;
+ align-items: center;
}
-.description {
+.category-icon {
+ font-size: 30px;
+ margin-right: 10px;
+}
+
+.document-title {
+ font-size: 18px;
+ font-weight: bold;
+ text-decoration: none;
+}
+
+.document-description {
+ padding: 5px;
font-size: 16px;
- margin: 10px 0;
+}
+
+.document-tags {
+ padding: 0 5px;
+ margin-bottom: 10px;
+ display: flex;
+ flex-wrap: wrap;
+}
+
+.tag {
+ border-color: var(--blue-border);
+ color: var(--blue);
+ background-color: var(--blue-bg);
+ padding: 2px 5px;
+ border-radius: 8px;
+ margin-right: 5px;
+ margin-bottom: 5px;
+ font-size: 12px;
+}
+
+.document-footer {
+ padding: 15px;
+ background-color: var(--bg-contrast);
+ display: flex;
+ flex-direction: column;
+ font-size: 14px;
+ color: #777;
+ border-top: 1px solid #eaeaea;
+}
+
+.footer-item {
+ display: flex;
+ align-items: center;
+ margin-bottom: 5px;
+}
+
+.footer-item svg {
+ margin-right: 5px;
+}
+
+.category-icon {
+ display: flex;
+ align-items: center;
+
+ &:deep(svg) {
+ fill: var(--font-color);
+ width: 35px;
+ height: 35px;
+
+ path {
+ fill: var(--font-color);
+ }
+ }
}
</style>
diff --git a/frontend/pages/login.vue b/frontend/pages/login.vue
index c23b7dce..c7cf757b 100644
--- a/frontend/pages/login.vue
+++ b/frontend/pages/login.vue
@@ -1,11 +1,9 @@
<template>
<div class="container">
- <h3 class="header">Log in</h3>
- <form @submit.prevent="login" class="body">
- <p class="signup-link">Need an account? <a href="mailto:[email protected]">Sign up</a></p>
+ <form @submit.prevent="login" class="form-body">
<div class="form-group">
<label for="username">Username</label>
- <input type="username" id="username" v-model="username" :class="{ 'is-invalid': errors.username }">
+ <input type="text" id="username" v-model="username" :class="{ 'is-invalid': errors.username }">
<p v-if="errors.username" class="invalid-feedback">{{ errors.username }}</p>
</div>
<div class="form-group">
@@ -18,70 +16,75 @@
</div>
<p v-if="errors.password" class="invalid-feedback">{{ errors.password }}</p>
</div>
+ <p class="signup-link">Need an account? <a>Sign up</a></p>
<button type="submit" class="btn">Login</button>
<p v-if="errors.general" class="invalid-feedback">{{ errors.general }}</p>
- <p class="forgot-password-link">Forgot your password? <a href="mailto:[email protected]">Click here</a></p>
</form>
</div>
</template>
+
<script setup lang="ts">
-const router = useRouter()
-const username = ref('')
+import { ref } from 'vue';
+import { useRouter } from 'vue-router';
+
+const username = ref('');
+const password = ref('');
const errors = ref({
username: '',
password: '',
general: ''
-})
-const showPassword = ref(false)
-const password = ref('')
+});
+const showPassword = ref(false);
-definePageMeta({
- viewTransition: false
-})
+const router = useRouter();
function login() {
- if (!username.value) errors.value.username = 'Username is required'
- else errors.value.username = '';
-
- if (!password.value) errors.value.password = 'Password is required'
- else errors.value.password = '';
+ errors.value.username = !username.value.trim() ? 'Username is required' : '';
+ errors.value.password = !password.value.trim() ? 'Password is required' : '';
if (username.value && password.value) {
connect(username.value, password.value);
}
}
-
-
async function connect(username: string, password: string) {
- const content = JSON.stringify({
- username: username,
- password: password
- });
- const responce = await fetch(`${import.meta.env.VITE_BASE_API}/api/v1/auth`, {
- method: "POST",
- headers: {
- Accept: "application/json",
- "Content-Type": "application/json",
- },
- body: content,
- credentials: "include",
- });
-
- const result = await responce.json();
- if (result.status == "success" && result.result.auth) {
- logIn();
- router.push("/dashboard");
+ try {
+ const response = await fetch(`${import.meta.env.VITE_BASE_API}/api/v1/auth`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Accept': 'application/json'
+ },
+ body: JSON.stringify({ username, password }),
+ credentials: 'include'
+ });
+
+ const result = await response.json();
+
+ if (result.status === 'success' && result.result.auth) {
+ logIn();
+ router.push('/dashboard');
+ } else {
+ errors.value.general = result.message || 'Login failed';
+ }
+ } catch (error) {
+ errors.value.general = 'Failed to connect';
}
- else errors.value.general = result.message;
+}
+function logIn() {
+ // Handle successful login action if needed
}
</script>
-<style scoped lang="scss">
+
+<style scoped>
.container {
display: flex;
flex-direction: column;
+ justify-content: center;
align-items: center;
+ min-height: 100vh;
+ background-color: #f0f0f0;
}
.header {
@@ -89,40 +92,39 @@ async function connect(username: string, password: string) {
margin-bottom: 1rem;
text-align: center;
text-transform: uppercase;
- letter-spacing: 0.1em;
font-weight: bold;
+ letter-spacing: 0.1em;
}
-.body {
- display: flex;
- flex-direction: column;
- align-items: center;
+.form-body {
width: 100%;
- max-width: 550px;
+ max-width: 400px;
padding: 2rem;
- background-color: var(--bg-contrast);
- border-radius: 5px;
+ background-color: #ffffff;
+ border-radius: 8px;
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.form-group {
- display: flex;
- flex-direction: column;
- width: 100%;
margin-bottom: 1rem;
}
.signup-link {
font-size: 0.8rem;
- margin-top: -0.5rem;
- margin-bottom: 1rem;
text-align: right;
- text-decoration: none;
+ margin-bottom: 1rem;
+ color: #666666;
+ text-align: center;
+}
- &:hover {
- text-decoration: underline;
- }
+.signup-link a {
+ color: #007bff;
+ text-decoration: none;
}
+.signup-link a:hover {
+ text-decoration: underline;
+}
.password-input {
position: relative;
@@ -138,41 +140,31 @@ async function connect(username: string, password: string) {
background-color: transparent;
border: none;
cursor: pointer;
- outline: none;
-
- &:hover {
- text-decoration: underline;
- }
-
}
.btn {
- font-size: 1.2rem;
- border-radius: 50px;
+ font-size: 1rem;
width: 100%;
+ padding: 0.75rem 0;
+ color: #ffffff;
+ background-color: #007bff;
+ border: none;
+ border-radius: 5px;
+ cursor: pointer;
+ transition: background-color 0.3s ease;
+}
+.btn:hover {
+ background-color: #0056b3;
}
.is-invalid {
- border-color: $red !important;
+ border-color: #dc3545 !important;
}
.invalid-feedback {
font-size: 0.8rem;
- color: $red;
-}
-
-.forgot-password-link {
- margin-top: 20px;
- text-align: center;
- font-size: 14px;
-
- a {
- text-decoration: underline;
- }
-
- a:hover {
- text-decoration: none;
- }
+ color: #dc3545;
+ margin-top: 0.25rem;
}
</style>
diff --git a/frontend/styles/_variables.scss b/frontend/styles/_variables.scss
index 6f7ba418..f4eed831 100644
--- a/frontend/styles/_variables.scss
+++ b/frontend/styles/_variables.scss
@@ -89,7 +89,6 @@ $transition-duration: 0.3s;
--bg-contrast: #F5F5F5;
--bg-contrast-2: #ECECEC;
--font-color: #333333;
- --border-color: rgba(0, 0, 0, 0.1);
// COLORS \\
--blue: #007bff;
--blue-bg: rgba(0, 123, 255, 0.2);