diff --git a/moneymgr_web/src/api/FileApi.ts b/moneymgr_web/src/api/FileApi.ts index 4f1565c..e9524e0 100644 --- a/moneymgr_web/src/api/FileApi.ts +++ b/moneymgr_web/src/api/FileApi.ts @@ -37,4 +37,11 @@ export class FileApi { }) ).data; } + + /** + * Get a file download URL + */ + static DownloadURL(file: UploadedFile): string { + return APIClient.backendURL() + `/file/${file.id}/download`; + } } diff --git a/moneymgr_web/src/dialogs/FileViewerDialog.tsx b/moneymgr_web/src/dialogs/FileViewerDialog.tsx index dc431e4..331b9d8 100644 --- a/moneymgr_web/src/dialogs/FileViewerDialog.tsx +++ b/moneymgr_web/src/dialogs/FileViewerDialog.tsx @@ -1,21 +1,73 @@ -import { Button, Dialog, DialogActions, DialogTitle } from "@mui/material"; -import { UploadedFile } from "../api/FileApi"; +import { + Button, + Dialog, + DialogActions, + DialogTitle, + Paper, + Typography, +} from "@mui/material"; +import { FileApi, UploadedFile } from "../api/FileApi"; import { filesize } from "filesize"; +import CloudDownloadIcon from "@mui/icons-material/CloudDownload"; export function FileViewerDialog(p: { open: boolean; onClose: () => void; file: UploadedFile; }): React.ReactElement { + if (!p.open) return <>; return ( {p.file.file_name} ({filesize(p.file.file_size)}) - TODO + ); } + +interface ViewerProps { + fileName: string; + fileSize: number; + url: string; + mimetype: string; +} + +function FileViewer(p: ViewerProps): React.ReactElement { + // Default viewer + return ; +} + +function DefaultViewer(p: ViewerProps): React.ReactElement { + return ( + + + + + + {filesize(p.fileSize)} + + + + + + ); +}