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

Smaug6739b9da8a47482f
diff --git a/frontend/components/DataTable.vue b/frontend/components/DataTable.vue
new file mode 100644
index 00000000..433f314d
--- /dev/null
+++ b/frontend/components/DataTable.vue
@@ -0,0 +1,160 @@
+<template>
+ <div class="container">
+ <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
+ <path
+ d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z" />
+ </svg>
+ <input type="text" placeholder="Search" v-model="searchInput" />
+ <table>
+ <thead>
+ <tr>
+ <th v-for="(header, index) in headers" :key="index" :class="{ noMobile: index > 1 }">
+ {{ header.title }}
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr v-for="(row, index) in data" :key="index">
+ <td v-for=" (field, index) in row.fields" :key="index" :class="{ noMobile: index > 1 }">
+ <span v-if="!field.action" v-text="field.content"></span>
+ <span v-else>
+ <NuxtLink :to="field.action" class="small-btn" type="button" v-text="field.content">
+ </NuxtLink>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="100%">
+ <div class="actions-bar">
+ <div class="left">
+ <button type="button" class="small-btn" @click="page--">&lt;Previous</button>
+ <button type="button" class="small-btn" @click="page++">Next&gt;</button>
+ </div>
+ <div class="right">
+ <span>Items per page</span>
+ <select v-model="itemsPerPage">
+ <option value="15">15</option>
+ <option value="30">30</option>
+ <option value="50">50</option>
+ <option value="100">100</option>
+ <option value="250">250</option>
+ </select>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+</template>
+
+<script lang="ts" setup>
+
+const props = defineProps<{ headers: Header[], rows: Row[] }>()
+const itemsPerPage = ref(15)
+const page = ref(1)
+const searchInput = ref('')
+
+const data = computed(() => {
+ return props.rows.filter((row) => {
+ return row.fields.some((field) => {
+ return field.content.toLowerCase().includes(searchInput.value.toLowerCase())
+ })
+ }).slice((page.value - 1) * itemsPerPage.value, page.value * itemsPerPage.value)
+})
+
+interface Header {
+ title: string;
+}
+interface Row {
+ fields: Field[];
+}
+interface Field {
+ content: string;
+ action?: string;
+}
+</script>
+<style lang="scss" scoped>
+.container {
+ position: relative;
+ zoom: 0.7;
+}
+
+table {
+ width: 100%;
+}
+
+button {
+ margin-right: 20px;
+}
+
+.small-btn {
+ padding: 0.1rem 0.25rem;
+ font-size: 1rem;
+}
+
+.noMobile {
+ display: none;
+}
+
+button {
+ background-color: $primary-400;
+ color: #fff;
+}
+
+.actions-bar {
+ display: flex;
+ width: 100%;
+ justify-content: space-between;
+
+ select {
+ max-width: 100px;
+ margin: 0;
+ margin-left: 10px;
+ }
+
+ .left,
+ .right {
+ display: flex;
+ align-items: center;
+ width: 100%;
+ }
+
+ .left {
+ justify-content: flex-start;
+ }
+
+ .right {
+ justify-content: flex-end;
+ }
+}
+
+
+svg {
+ position: absolute;
+ top: 13px;
+ left: 13px;
+ fill: var(--grey);
+}
+
+input {
+ height: 50px;
+ padding: 0 0 0 45px;
+ outline: none;
+ border-radius: 10px;
+}
+
+@media screen and (min-width: 1000px) {
+ .container {
+ zoom: 1;
+ }
+
+ .noMobile {
+ display: table-cell;
+ }
+
+ table {
+ zoom: 1;
+ }
+}
+</style>
\ No newline at end of file
diff --git a/frontend/components/DocumentCardHeader.vue b/frontend/components/DocumentCardHeader.vue
index 0faae4eb..afc5d811 100644
--- a/frontend/components/DocumentCardHeader.vue
+++ b/frontend/components/DocumentCardHeader.vue
@@ -1,5 +1,3 @@
-<!-- Beautiful header with title, description and image -->
-
<template>
<div class="header">
<div class="text">
@@ -99,8 +97,6 @@
stroke-miterlimit="10"></path>
</svg>
</div>
-
-
</div>
</template>
diff --git a/frontend/components/DocumentCardHeaderActionRow.vue b/frontend/components/DocumentCardHeaderActionRow.vue
index aecb02fe..4010e013 100644
--- a/frontend/components/DocumentCardHeaderActionRow.vue
+++ b/frontend/components/DocumentCardHeaderActionRow.vue
@@ -36,17 +36,16 @@
<script setup lang="ts">
import { useDocumentsStore } from '~/store';
-
+const router = useRouter();
const documentsStore = useDocumentsStore();
const showDeleteModal = ref(false);
-
const props = defineProps<{ doc_id: string }>();
const print = () => window.print();
const deleteDoc = () => {
showDeleteModal.value = false;
- documentsStore.delete(props.doc_id)
+ documentsStore.delete(props.doc_id).then(() => router.push('/dashboard'));
};
</script>
diff --git a/frontend/components/Modal.vue b/frontend/components/Modal.vue
index 555ac330..7322414a 100644
--- a/frontend/components/Modal.vue
+++ b/frontend/components/Modal.vue
@@ -31,7 +31,7 @@ const emit = defineEmits(['close', 'confirm'])
<style lang="scss" scoped>
.modal-mask {
position: fixed;
- z-index: 9998;
+ z-index: 100;
top: 0;
left: 0;
width: 100%;
@@ -39,6 +39,7 @@ const emit = defineEmits(['close', 'confirm'])
background-color: rgba(0, 0, 0, 0.5);
display: flex;
transition: opacity 0.3s ease;
+ font-size: normal;
}
.modal-container {
diff --git a/frontend/components/sidebar/SidebarItem.vue b/frontend/components/sidebar/SidebarItem.vue
index d21e0ac5..d517f542 100644
--- a/frontend/components/sidebar/SidebarItem.vue
+++ b/frontend/components/sidebar/SidebarItem.vue
@@ -54,6 +54,8 @@ const drop = async (event: DragEvent) => {
const draggedItemId = event.dataTransfer!.getData('text/plain');
let draggedItem = documentStore.getById(draggedItemId) || categoriesStore.getById(draggedItemId) || navigationItems.find((item) => item.id === draggedItemId);
+ console.log(draggedItem);
+
if (!draggedItem) return;
if (draggedItem.type === "document" && draggedItem.partial) {
diff --git a/frontend/components/sidebar/helpers.ts b/frontend/components/sidebar/helpers.ts
index ac616308..f5703d05 100644
--- a/frontend/components/sidebar/helpers.ts
+++ b/frontend/components/sidebar/helpers.ts
@@ -8,6 +8,14 @@ export interface DefaultItem {
}
export const navigationItems: DefaultItem[] = [
+ {
+ id: 'search',
+ type: 'default',
+ title: 'Search',
+ icon: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/></svg>',
+ route: '/dashboard/search',
+ childrens: [],
+ },
{
id: 'manage-categories',
type: 'default',
@@ -28,7 +36,7 @@ export const navigationItems: DefaultItem[] = [
id: 'backup',
type: 'default',
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>',
+ icon: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M320-320h200v-200H320v200Zm0-280h480v-200H320v200Zm280 280h200v-200H600v200Zm-280 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-560h80v560h560v80H160Z"/></svg>',
route: '/dashboard/backup',
childrens: [],
},
diff --git a/frontend/pages/dashboard/search.vue b/frontend/pages/dashboard/search.vue
new file mode 100644
index 00000000..d1db560e
--- /dev/null
+++ b/frontend/pages/dashboard/search.vue
@@ -0,0 +1,32 @@
+<template>
+ <h2 style="text-align: center;">Rechercher un document</h2>
+ <DataTable :headers="headers" :rows="rows" />
+</template>
+
+<script setup lang="ts">
+
+import { useDocumentsStore, useCategoriesStore } from '~/store';
+
+const documents = computed(() => useDocumentsStore().getAll)
+const categoriesStore = useCategoriesStore();
+const headers = [
+ { title: 'Name' },
+ { title: 'Category' },
+ { title: 'Created At' },
+ { title: 'Updated At' },
+ { title: 'Actions' },
+];
+const rows = computed(() => documents.value.map((doc) => {
+ const val = {
+ fields: [
+ { content: doc.name, action: `/dashboard/doc/${doc.id}` },
+ { content: categoriesStore.getById(doc.category || '')?.name || '', action: `/dashboard/category/${doc.category}` },
+ { content: new Date(parseInt(doc.created_timestamp)).toDateString() },
+ { content: new Date(parseInt(doc.updated_timestamp)).toDateString() },
+ { content: 'View document', action: `/dashboard/doc/${doc.id}` },
+ ],
+ };
+ return val
+}));
+
+</script>
\ No newline at end of file
diff --git a/frontend/store/categories.store.ts b/frontend/store/categories.store.ts
index f5e641e9..9bb9fb50 100644
--- a/frontend/store/categories.store.ts
+++ b/frontend/store/categories.store.ts
@@ -1,7 +1,7 @@
import { defineStore } from 'pinia';
import { makeRequest, type FetchOptions } from './utils';
-import type { Category } from './db_strustures';
+import type { Category, DB_Category } from './db_strustures';
export const useCategoriesStore = defineStore('categories', {
state: () => ({
@@ -14,16 +14,16 @@ export const useCategoriesStore = defineStore('categories', {
getChilds: state => (id: string) => state.categories.filter(c => c.parent_id == id),
},
actions: {
- fetch: async function (opts?: FetchOptions<Array<keyof Category>>) {
+ fetch: async function (opts?: FetchOptions) {
return new Promise(async (resolve, reject) => {
const request = await makeRequest(`categories/${opts?.id || ''}`, 'GET', {});
if (request.status == 'success') {
if (opts?.id) {
// replace the document with the new one
const index = this.categories.findIndex(d => d.id == opts?.id);
- if (index == -1) this.categories.push(request.result as Category);
- else this.categories[index] = { ...(request.result as Category), type: 'category' };
- } else this.categories = (request.result as Category[]).map((d: Category) => ({ ...d, type: 'category' }));
+ if (index == -1) this.categories.push({ ...(request.result as DB_Category), type: 'category' });
+ else this.categories[index] = { ...(request.result as DB_Category), type: 'category' };
+ } else this.categories = (request.result as DB_Category[]).map((d: DB_Category) => ({ ...d, type: 'category' }));
resolve(this.categories);
} else reject(request.message);
});
@@ -31,7 +31,7 @@ export const useCategoriesStore = defineStore('categories', {
post(category: Category) {
return new Promise(async (resolve, reject) => {
const request = await makeRequest(`categories`, 'POST', category);
- if (request.status == 'success') resolve(this.categories.push(request.result as Category));
+ if (request.status == 'success') resolve(this.categories.push({ ...(request.result as DB_Category), type: 'category' }));
else reject(request.message);
});
},
diff --git a/frontend/store/db_strustures.d.ts b/frontend/store/db_strustures.d.ts
index c189e1b1..56e74cec 100644
--- a/frontend/store/db_strustures.d.ts
+++ b/frontend/store/db_strustures.d.ts
@@ -1,4 +1,4 @@
-export interface Document {
+export interface DB_Document {
id: string;
name: string;
description?: string;
@@ -11,20 +11,19 @@ export interface Document {
author_id: string;
created_timestamp: string;
updated_timestamp: string;
-
- // not in the database
+}
+export interface Document extends DB_Document {
partial?: boolean;
type: 'document';
}
-
-export interface Category {
+export interface DB_Category {
id: string;
name: string;
icon?: string;
order?: number;
parent_id?: string;
-
- // not in the database
+}
+export interface Category extends DB_Category {
type: 'category';
}
diff --git a/frontend/store/documents.store.ts b/frontend/store/documents.store.ts
index 7321f7f6..00f8641b 100644
--- a/frontend/store/documents.store.ts
+++ b/frontend/store/documents.store.ts
@@ -1,7 +1,7 @@
import { defineStore } from 'pinia';
import { ref } from 'vue';
import { makeRequest, type FetchOptions } from './utils';
-import type { Document } from './db_strustures';
+import type { DB_Document, Document } from './db_strustures';
export const useDocumentsStore = defineStore('documents', {
state: () => ({
@@ -41,19 +41,19 @@ export const useDocumentsStore = defineStore('documents', {
},
},
actions: {
- fetch: async function <T extends FetchOptions<Array<keyof Document>>>(opts?: T): Promise<'id' extends keyof T ? Document : Document[]> {
+ fetch: async function <T extends FetchOptions>(opts?: T): Promise<'id' extends keyof T ? Document : Document[]> {
console.log(`[store/documents] Fetching documents with options: ${JSON.stringify(opts)}`);
return new Promise(async (resolve, reject) => {
const request = await makeRequest(`documents/${opts?.id || ''}?all=true`, 'GET', {});
if (request.status == 'success') {
if (opts?.id) {
const index = this.documents.findIndex(d => d.id == opts?.id);
- const updatedDocument: Document = { ...(request.result as Document), partial: false, type: 'document' };
+ const updatedDocument: Document = { ...(request.result as DB_Document), partial: false, type: 'document' };
if (index == -1) this.documents.push(updatedDocument);
else this.documents[index] = updatedDocument;
resolve(updatedDocument as 'id' extends keyof T ? Document : Document[]);
} else {
- this.documents = (request.result as Document[]).map((d: Document) => ({ ...d, partial: true, type: 'document' }));
+ this.documents = (request.result as DB_Document[]).map((d: DB_Document) => ({ ...d, partial: true, type: 'document' }));
resolve(this.documents as 'id' extends keyof T ? Document : Document[]);
}
} else reject(request.message);
@@ -62,7 +62,7 @@ export const useDocumentsStore = defineStore('documents', {
post(doc: Document) {
return new Promise(async (resolve, reject) => {
const request = await makeRequest('documents', 'POST', doc);
- if (request.status == 'success') resolve(this.documents.push(request.result as Document));
+ if (request.status == 'success') resolve(this.documents.push({ ...(request.result as DB_Document), type: 'document' }));
else reject(request.message);
});
},
diff --git a/frontend/store/utils.ts b/frontend/store/utils.ts
index 6538a102..4c3f3e21 100644
--- a/frontend/store/utils.ts
+++ b/frontend/store/utils.ts
@@ -1,4 +1,4 @@
-import type { Document, Category } from './db_strustures';
+import type { DB_Category, DB_Document } from './db_strustures';
export interface APIResult<Data> {
status: 'success' | 'error';
@@ -6,12 +6,16 @@ export interface APIResult<Data> {
result?: Data;
}
-export interface FetchOptions<K> {
+export interface FetchOptions {
id: string; // id of the ressource
}
export const baseUrl = import.meta.env.VITE_BASE_API?.toString() || '';
-export async function makeRequest(route: string, method: string, body: Object): Promise<APIResult<Document | Category | Document[] | Category[]>> {
+export async function makeRequest(
+ route: string,
+ method: string,
+ body: Object,
+): Promise<APIResult<DB_Document | DB_Category | DB_Document[] | DB_Category[]>> {
try {
const responce = await fetch(`${baseUrl}/api/v1/${route}`, {
method: method,
diff --git a/frontend/styles/theme.scss b/frontend/styles/theme.scss
index 1363ecfc..cb1d9299 100644
--- a/frontend/styles/theme.scss
+++ b/frontend/styles/theme.scss
@@ -115,7 +115,6 @@ input,
select,
textarea {
width: 100%;
- padding: 12px 14px;
margin: 0;
border: 1px solid var(--border-color);
color: var(--font-color);