From 3361f1e28d562cc079c4aea34c1eb2fd5cec6ba0 Mon Sep 17 00:00:00 2001 From: Matthias Hochmeister Date: Fri, 13 Mar 2026 13:51:08 +0100 Subject: [PATCH] update --- .../components/chat/FileMessageContent.tsx | 135 ++++++++++++++---- 1 file changed, 109 insertions(+), 26 deletions(-) diff --git a/frontend/src/components/chat/FileMessageContent.tsx b/frontend/src/components/chat/FileMessageContent.tsx index 83f42fa..c03a0ea 100644 --- a/frontend/src/components/chat/FileMessageContent.tsx +++ b/frontend/src/components/chat/FileMessageContent.tsx @@ -1,10 +1,13 @@ -import React from 'react'; +import React, { useState } from 'react'; import Box from '@mui/material/Box'; import Typography from '@mui/material/Typography'; import IconButton from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; +import Dialog from '@mui/material/Dialog'; +import DialogContent from '@mui/material/DialogContent'; import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile'; import DownloadIcon from '@mui/icons-material/Download'; +import CloseIcon from '@mui/icons-material/Close'; interface FileParam { name: string; @@ -40,7 +43,67 @@ function extractFileParams(messageParameters: Record): FileParam[] return files; } +interface ImageLightboxProps { + open: boolean; + onClose: () => void; + previewUrl: string; + downloadUrl: string; + name: string; +} + +const ImageLightbox: React.FC = ({ open, onClose, previewUrl, downloadUrl, name }) => ( + + + + {/* Close button */} + + + + + + {/* Download button */} + + + + + + {/* Filename */} + + {name} + + + +); + const FileMessageContent: React.FC = ({ messageParameters, isOwnMessage }) => { + const [lightboxFile, setLightboxFile] = useState(null); const files = extractFileParams(messageParameters); if (files.length === 0) return null; @@ -48,30 +111,45 @@ const FileMessageContent: React.FC = ({ messageParamete <> {files.map((file, idx) => { const downloadUrl = `/api/nextcloud/talk/files/${file.id}/download${file.path ? `?path=${encodeURIComponent(file.path)}` : ''}`; - const previewUrl = `/api/nextcloud/talk/files/${file.id}/preview?w=400&h=400`; + const thumbUrl = `/api/nextcloud/talk/files/${file.id}/preview?w=400&h=400`; + const fullUrl = `/api/nextcloud/talk/files/${file.id}/preview?w=1200&h=1200`; const isImage = file.mimetype?.startsWith('image/') && file.previewAvailable === 'yes'; if (isImage) { return ( - - - - - {file.name} - + setLightboxFile(file)} + sx={{ + maxWidth: '100%', + maxHeight: 200, + borderRadius: 1, + display: 'block', + cursor: 'zoom-in', + '&:hover': { opacity: 0.9 }, + }} + /> + + + {file.name} + + + + + + + ); } @@ -93,12 +171,7 @@ const FileMessageContent: React.FC = ({ messageParamete > - + {file.name} {file.size && ( @@ -123,6 +196,16 @@ const FileMessageContent: React.FC = ({ messageParamete ); })} + + {lightboxFile && ( + setLightboxFile(null)} + previewUrl={`/api/nextcloud/talk/files/${lightboxFile.id}/preview?w=1200&h=1200`} + downloadUrl={`/api/nextcloud/talk/files/${lightboxFile.id}/download${lightboxFile.path ? `?path=${encodeURIComponent(lightboxFile.path)}` : ''}`} + name={lightboxFile.name} + /> + )} ); };