diff --git a/src/api/model.ts b/src/api/model.ts index 6824a2b5f..7d7ecfbf4 100644 --- a/src/api/model.ts +++ b/src/api/model.ts @@ -165,6 +165,7 @@ export class TreeModel { export interface IFileBlob { blob?: Blob; file?: FeedFile; + url?: string; fileType: string; } @@ -192,6 +193,11 @@ export const fileViewerMap: any = { smoothwm: "XtkDisplay", pial: "XtkDisplay", "nii.gz": "NiiVueDisplay", + mp4: "VideoDisplay", // Add mp4 format + avi: "VideoDisplay", // Add avi format + mov: "VideoDisplay", // Add mov format + wmv: "VideoDisplay", // Add wmv format + mkv: "VideoDisplay", // Add mkv format }; // Description: get file type by file extension diff --git a/src/components/FeedOutputBrowser/FileBrowser.tsx b/src/components/FeedOutputBrowser/FileBrowser.tsx index 1005bdcb4..832068632 100644 --- a/src/components/FeedOutputBrowser/FileBrowser.tsx +++ b/src/components/FeedOutputBrowser/FileBrowser.tsx @@ -275,6 +275,7 @@ const FileBrowser = (props: FileBrowserProps) => { handlePrevious={handlePrevious} selectedFile={selectedFile} preview="large" + isPublic={feed?.data.public} /> )} {drawerState.preview.currentlyActive === "xtk" && } diff --git a/src/components/Preview/FileDetailView.tsx b/src/components/Preview/FileDetailView.tsx index be3907efa..d7b0f46fb 100644 --- a/src/components/Preview/FileDetailView.tsx +++ b/src/components/Preview/FileDetailView.tsx @@ -37,12 +37,15 @@ interface AllProps { handleNext?: () => void; handlePrevious?: () => void; gallery?: boolean; + isPublic?: boolean; } export interface ActionState { [key: string]: boolean | string; } +const fileTypes = ["nii", "dcm", "fsm", "crv", "smoothwm", "pial", "nii.gz"]; + const FileDetailView = (props: AllProps) => { const [tagInfo, setTagInfo] = React.useState(); const [actionState, setActionState] = React.useState({ @@ -117,6 +120,15 @@ const FileDetailView = (props: AllProps) => { const fileName = selectedFile.data.fname; const fileType = getFileExtension(fileName); + if (props.isPublic && !fileTypes.includes(fileType)) { + return { + blob: undefined, + file: selectedFile, + fileType, + url: selectedFile?.collection.items[0].links[0].href, // Corrected semicolon to comma + }; + } + try { const blob = await selectedFile.getFileBlob(); return { diff --git a/src/components/Preview/displays/ImageDisplay.tsx b/src/components/Preview/displays/ImageDisplay.tsx index f1c3d3821..ea97f3de4 100644 --- a/src/components/Preview/displays/ImageDisplay.tsx +++ b/src/components/Preview/displays/ImageDisplay.tsx @@ -7,9 +7,11 @@ type AllProps = { const ImageDisplay: React.FunctionComponent = (props: AllProps) => { const { fileItem } = props; - const url = fileItem.blob - ? window.URL.createObjectURL(new Blob([fileItem.blob])) - : ""; + const url = fileItem.url + ? fileItem.url + : fileItem.blob + ? window.URL.createObjectURL(new Blob([fileItem.blob])) + : ""; return ( = ({ fileItem }: AllProps) => { - const url = fileItem.blob - ? window.URL.createObjectURL( - new Blob([fileItem.blob], { type: "application/pdf" }), - ) - : ""; + const url = fileItem.url + ? fileItem.url + : fileItem.blob + ? window.URL.createObjectURL( + new Blob([fileItem.blob], { type: "application/pdf" }), + ) + : ""; return (