Skip to content

Commit

Permalink
#1619: Fix - Preview remote document in iframe (#1620) (#1623)
Browse files Browse the repository at this point in the history
Co-authored-by: Suren <[email protected]>
  • Loading branch information
giohappy and dsuren1 authored Nov 20, 2023
1 parent 828c5a8 commit 655cbe0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const Media = ({ resource, ...props }) => {
thumbnail={() => getResourceImageSource(resource?.thumbnail_url)}
src={resource.href}
url={resource ? metadataPreviewUrl(resource) : ''}
embedUrl={resource?.embed_url}
/>
</Suspense>);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ import Loader from '@mapstore/framework/components/misc/Loader';

import { getFileFromDownload } from '@js/utils/FileUtils';

const PdfViewer = ({src}) => {
const PdfViewer = ({src, embedUrl}) => {
const [filePath, setFilePath] = useState(null);
const [loading, setLoading] = useState(false);

useEffect(() => {
setLoading(true);
getFileFromDownload(src)
.then((fileURL) => {
setLoading(false);
setFilePath(fileURL);
}).finally(() => {
setLoading(false);
});
if (embedUrl) {
setFilePath(embedUrl);
} else {
setLoading(true);
getFileFromDownload(src)
.then((fileURL) => {
setFilePath(fileURL);
}).finally(() => {
setLoading(false);
});
}
}, []);

if (loading) {
Expand Down

0 comments on commit 655cbe0

Please sign in to comment.