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.
This commit is contained in:
parent
869a5309fb
commit
db23e685ff
@ -158,7 +158,9 @@ const EmailMessageInfo = () => {
|
||||
spinning={objectFormState.loading}
|
||||
indicator={<LoadingOutlined />}
|
||||
>
|
||||
<Card>
|
||||
<Card
|
||||
styles={{ body: { height: 'calc(100vh - 218px)' } }}
|
||||
>
|
||||
<TemplatePreview
|
||||
template={objectData?.template}
|
||||
content={objectData?.content}
|
||||
|
||||
@ -30,7 +30,10 @@ import { ApiServerContext } from '../../context/ApiServerContext.jsx'
|
||||
import ScrollBox from '../../common/ScrollBox.jsx'
|
||||
import JsonObjectIcon from '../../../Icons/JsonObjectIcon.jsx'
|
||||
import ObjectProperty from '../../common/ObjectProperty.jsx'
|
||||
import { getModelProperty, getModelByName } from '../../../../database/ObjectModels.js'
|
||||
import {
|
||||
getModelProperty,
|
||||
getModelByName
|
||||
} from '../../../../database/ObjectModels.js'
|
||||
|
||||
const log = loglevel.getLogger('FileInfo')
|
||||
log.setLevel(config.logLevel)
|
||||
@ -87,7 +90,7 @@ const FileInfo = () => {
|
||||
download: () => {
|
||||
fetchFileContent(objectFormState?.objectData, true)
|
||||
return true
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
@ -203,7 +206,7 @@ const FileInfo = () => {
|
||||
collapseKey='preview'
|
||||
>
|
||||
{objectFormState?.objectData?._id ? (
|
||||
<Card>
|
||||
<Card styles={{ body: { minHeight: 'calc(100vh - 218px)' } }}>
|
||||
<FilePreview
|
||||
file={objectFormState?.objectData}
|
||||
style={{ width: '100%', height: '100%' }}
|
||||
@ -262,10 +265,7 @@ const FileInfo = () => {
|
||||
<ObjectTable
|
||||
type='auditLog'
|
||||
masterFilter={{
|
||||
parent:
|
||||
getModelByName('file').prefix +
|
||||
':' +
|
||||
fileId
|
||||
parent: getModelByName('file').prefix + ':' + fileId
|
||||
}}
|
||||
visibleColumns={{ _id: false, parent: false }}
|
||||
/>
|
||||
|
||||
@ -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 <div style={{ color: 'red' }}>{error}</div>
|
||||
}
|
||||
|
||||
return (
|
||||
<PDFPreview
|
||||
file={fileObjectUrl}
|
||||
loading={loading}
|
||||
style={{
|
||||
...style,
|
||||
height: hasExplicitPreviewHeight(style.height)
|
||||
? style.height
|
||||
: '72vh'
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
if (loading == true || !file?.type) {
|
||||
return <LoadingPlaceholder message={'Loading file preview...'} />
|
||||
}
|
||||
@ -57,14 +85,6 @@ const FilePreview = ({ file, style = {} }) => {
|
||||
return <div style={{ color: 'red' }}>{error}</div>
|
||||
}
|
||||
|
||||
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 (
|
||||
<GCodePreview
|
||||
|
||||
@ -35,16 +35,9 @@ const PDFPreview = ({ file, loading = false, style }) => {
|
||||
}}
|
||||
disabled={loading}
|
||||
/>
|
||||
<Button
|
||||
icon={<MinusIcon />}
|
||||
onClick={() => {
|
||||
setPreviewScale((prev) => clampPreviewScale(prev - 0.05))
|
||||
}}
|
||||
disabled={loading}
|
||||
/>
|
||||
<Button
|
||||
readOnly={true}
|
||||
style={{ width: '65px' }}
|
||||
style={{ minWidth: '70px' }}
|
||||
disabled={loading}
|
||||
onClick={() => {
|
||||
setPreviewScale(1)
|
||||
@ -52,6 +45,13 @@ const PDFPreview = ({ file, loading = false, style }) => {
|
||||
>
|
||||
{previewScale.toFixed(2)}x
|
||||
</Button>
|
||||
<Button
|
||||
icon={<MinusIcon />}
|
||||
onClick={() => {
|
||||
setPreviewScale((prev) => clampPreviewScale(prev - 0.05))
|
||||
}}
|
||||
disabled={loading}
|
||||
/>
|
||||
</Flex>
|
||||
|
||||
<div
|
||||
|
||||
@ -242,7 +242,7 @@ export const EmailMessage = {
|
||||
},
|
||||
{
|
||||
name: 'recipientEmail',
|
||||
label: 'Recipient',
|
||||
label: 'Recipient Email',
|
||||
type: 'email',
|
||||
required: true,
|
||||
readOnly: readOnlyAfterCreate,
|
||||
@ -278,7 +278,7 @@ export const EmailMessage = {
|
||||
},
|
||||
{
|
||||
name: 'recipient',
|
||||
label: 'Recipient Object',
|
||||
label: 'Recipient',
|
||||
type: 'object',
|
||||
objectType: (data) => data?.recipientType,
|
||||
readOnly: readOnlyAfterCreate,
|
||||
|
||||
@ -156,6 +156,13 @@ export const File = {
|
||||
readOnly: true,
|
||||
columnWidth: 180
|
||||
},
|
||||
{
|
||||
name: 'updatedAt',
|
||||
label: 'Updated At',
|
||||
type: 'dateTime',
|
||||
readOnly: true,
|
||||
columnWidth: 200
|
||||
},
|
||||
{
|
||||
name: 'name',
|
||||
label: 'Name',
|
||||
@ -164,13 +171,7 @@ export const File = {
|
||||
type: 'text',
|
||||
columnWidth: 200
|
||||
},
|
||||
{
|
||||
name: 'updatedAt',
|
||||
label: 'Updated At',
|
||||
type: 'dateTime',
|
||||
readOnly: true,
|
||||
columnWidth: 200
|
||||
},
|
||||
|
||||
{
|
||||
name: 'type',
|
||||
label: 'Type',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user