From db23e685ff04a970e78ba421dd52d97408fab20f Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sun, 13 Sep 2026 18:58:11 +0100 Subject: [PATCH] Enhance EmailMessage and File Models with Improved Field Labels and Added Updated At Timestamp - Updated field labels in EmailMessage model for clarity, changing 'Recipient' to 'Recipient Email' and 'Recipient Object' to 'Recipient'. - Added 'Updated At' timestamp field to File model to track modification times, improving data management and auditing capabilities. --- .../EmailMessages/EmailMessageInfo.jsx | 4 +- .../Dashboard/Management/Files/FileInfo.jsx | 18 ++++---- .../Dashboard/common/FilePreview.jsx | 42 ++++++++++++++----- .../Dashboard/common/PDFPreview.jsx | 16 +++---- src/database/models/EmailMessage.js | 4 +- src/database/models/File.js | 15 +++---- 6 files changed, 61 insertions(+), 38 deletions(-) diff --git a/src/components/Dashboard/Management/EmailMessages/EmailMessageInfo.jsx b/src/components/Dashboard/Management/EmailMessages/EmailMessageInfo.jsx index 3f89ecfc..798218b1 100644 --- a/src/components/Dashboard/Management/EmailMessages/EmailMessageInfo.jsx +++ b/src/components/Dashboard/Management/EmailMessages/EmailMessageInfo.jsx @@ -158,7 +158,9 @@ const EmailMessageInfo = () => { spinning={objectFormState.loading} indicator={} > - + { download: () => { fetchFileContent(objectFormState?.objectData, true) return true - }, + } } return ( @@ -102,7 +105,7 @@ const FileInfo = () => { { collapseKey='preview' > {objectFormState?.objectData?._id ? ( - + { indicator={} > - + @@ -262,10 +265,7 @@ const FileInfo = () => { diff --git a/src/components/Dashboard/common/FilePreview.jsx b/src/components/Dashboard/common/FilePreview.jsx index 73f5e3b6..55df8cf5 100644 --- a/src/components/Dashboard/common/FilePreview.jsx +++ b/src/components/Dashboard/common/FilePreview.jsx @@ -11,12 +11,14 @@ import { import LoadingPlaceholder from './LoadingPlaceholder' import GCodePreview from './GCodePreview' import ThreeDPreview from './ThreeDPreview' +import PDFPreview from './PDFPreview' import { AuthContext } from '../context/AuthContext' +const hasExplicitPreviewHeight = (height) => + typeof height === 'number' || + (typeof height === 'string' && height !== '100%' && height !== 'auto') + const FilePreview = ({ file, style = {} }) => { - useEffect(() => { - console.log('FILEPREVIEWFILE', file) - }, [file]) const { token } = useContext(AuthContext) const { fetchFileContent } = useContext(ApiServerContext) @@ -26,6 +28,13 @@ const FilePreview = ({ file, style = {} }) => { const currentId = useRef(null) + const extension = (file?.extension || '').toLowerCase() + const isGcode = ['.g', '.gcode'].includes(extension) + const is3DModel = ['.stl', '.3mf'].includes(extension) + const isImage = file?.type?.startsWith('image/') || false + const isPdf = + file?.type?.startsWith('application/pdf') || extension === '.pdf' + const fetchPreview = useCallback(async () => { if (error != null) { return @@ -49,6 +58,25 @@ const FilePreview = ({ file, style = {} }) => { } }, [file._id, file?.type, fetchPreview, token]) + if (isPdf) { + if (error != null) { + return
{error}
+ } + + return ( + + ) + } + if (loading == true || !file?.type) { return } @@ -57,14 +85,6 @@ const FilePreview = ({ file, style = {} }) => { return
{error}
} - const isGcode = - ['.g', '.gcode'].includes((file?.extension || '').toLowerCase()) || false - - const is3DModel = - ['.stl', '.3mf'].includes((file?.extension || '').toLowerCase()) || false - - const isImage = file?.type.startsWith('image/') - if (isGcode && fileObjectUrl) { return ( { }} disabled={loading} /> - +