π 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
Merge branch 'main' into fix/typo-and-vnames
Smaug6739df344d25312a
diff --cc frontend/app/helpers/resources.tsindex 2f3ff804,b898ef7f..b2855578--- a/frontend/app/helpers/resources.ts+++ b/frontend/app/helpers/resources.ts@@@ -25,23 -28,4 +28,23 @@@ const resolvePreviewUrl = (node: Node)return '/file_placeholder.png';};-export { readableFileSize, resolvePreviewUrl, isImageFile, isPdfFile };+/** Resolve the appropriate icon for a file based on its role and properties */+const resolveFileIcon = (mimeType: string) => {+ if (mimeType.startsWith('image/')) return 'image';+ if (mimeType.startsWith('video/')) return 'video';+ if (mimeType.startsWith('audio/')) return 'music';+ if (mimeType.includes('pdf')) return 'pdf';+ return 'file';+};++/** Get human-readable type name for a file based on its MIME type */+const resolveFileType = (mimeType: string) => {+ if (mimeType.startsWith('image/')) return 'Image';+ if (mimeType.startsWith('video/')) return 'Video';+ if (mimeType.startsWith('audio/')) return 'Audio';+ if (mimeType.includes('pdf')) return 'PDF';+ if (mimeType.includes('zip') || mimeType.includes('archive')) return 'Archive';+ return 'File';+};+- export { readableFileSize, resolvePreviewUrl, isImageFile, resolveFileIcon, resolveFileType };++export { readableFileSize, resolvePreviewUrl, isImageFile, resolveFileIcon, resolveFileType, isPdfFile };diff --cc frontend/app/pages/dashboard/cdn/[id]/preview.vueindex 0e1a72c8,7b3219f6..5214f51e--- a/frontend/app/pages/dashboard/cdn/[id]/preview.vue+++ b/frontend/app/pages/dashboard/cdn/[id]/preview.vue@@@ -1,33 -1,20 +1,20 @@@<template>- <div class="card-component">- <div v-if="resource">- <header style="display: flex; align-items: center; justify-content: space-between">- <h1>Preview <tag blue>New</tag></h1>- <div style="display: flex">+ <div class="card">- <template v-if="ressource">++ <template v-if="resource">+ <header>- <h1>Preview <tag yellow>Beta</tag> β’ {{ ressource.name }}</h1>++ <h1>Preview <tag yellow>Beta</tag> β’ {{ resource.name }}</h1>+ <div class="actions">+ <AppSelect v-if="isPdfFile(mimeType)" v-model="scale" :items="PDF_SCALES" :searchable="false" label="Scale" style="margin-right: 12px" />- <NuxtLink :to="`/dashboard/cdn/${ressource.id}`"><AppButton type="primary">Edit</AppButton></NuxtLink>+ <NuxtLink :to="`/dashboard/cdn/${resource.id}`"><AppButton type="primary">Edit</AppButton></NuxtLink><AppButton type="secondary" @click="copyLink">Copy link</AppButton></div></header>- Name: <strong>{{ resource.name }}</strong>- <p>- Type: <strong>{{ resource.metadata?.filetype }}</strong>- </p>- <p>- Size: <strong>{{ readableFileSize(resource.size ?? 0) }}</strong>- </p><div class="preview">- <img- v-if="(resource?.metadata?.filetype as string)?.startsWith('image/')"- <img v-if="isImageFile(mimeType)" :src="`${CDN}/${ressource!.user_id}/${ressource!.metadata?.transformed_path || ressource!.content}`" alt="Preview" />++ <img v-if="isImageFile(mimeType)" :src="`${CDN}/${resource!.user_id}/${resource!.metadata?.transformed_path || resource!.content}`" alt="Preview" />+ <LazyPDFViewer+ v-else-if="isPdfFile(mimeType)"- :src="`${CDN}/${ressource!.user_id}/${ressource!.metadata?.transformed_path || ressource!.content}`"+ :src="`${CDN}/${resource!.user_id}/${resource!.metadata?.transformed_path || resource!.content}`"- alt="Preview"- />- <iframe- v-else-if="(resource?.metadata?.filetype as string)?.startsWith('application/pdf')"- :src="`${CDN}/${resource!.user_id}/${resource!.metadata?.transformed_path || resource!.content}`"- width="100%"- height="500px"- frameborder="0"- allowfullscreen+ :scale="scale"/><p v-else>Preview not available for this file type.</p></div>@@@ -36,13 -23,21 +23,21 @@@</template><script setup lang="ts">- import { readableFileSize } from '~/helpers/resources';+ import { PDF_SCALES, DEFAULT_PDF_SCALE } from '~/helpers/constants';-import { isImageFile, isPdfFile } from '~/helpers/ressources';++import { isImageFile, isPdfFile } from '~/helpers/resources';+definePageMeta({ breadcrumb: 'Preview' });- const resource = computed(() => useNodesStore().getById(useRoute().params.id as string));+const { CDN } = useApi();+ const { isMobile } = useDevice();++ const scale = ref(isMobile.value ? DEFAULT_PDF_SCALE.mobile : DEFAULT_PDF_SCALE.desktop);+-const ressource = computed(() => useNodesStore().getById(useRoute().params.id as string));-const mimeType = computed(() => ressource.value?.metadata?.filetype || '');++const resource = computed(() => useNodesStore().getById(useRoute().params.id as string));++const mimeType = computed(() => resource.value?.metadata?.filetype || '');const copyLink = () => {- const link = `${CDN}/${ressource.value?.user_id}/${ressource.value?.metadata?.transformed_path || ressource.value?.content}`;+ const link = `${CDN}/${resource.value?.user_id}/${resource.value?.metadata?.transformed_path || resource.value?.content}`;navigator.clipboard.writeText(link);};</script>