Improve file viewer dialog
This commit is contained in:
parent
91461d200f
commit
297b873393
@ -1,16 +1,20 @@
|
|||||||
import CloudDownloadIcon from "@mui/icons-material/CloudDownload";
|
import CloudDownloadIcon from "@mui/icons-material/CloudDownload";
|
||||||
import {
|
import {
|
||||||
|
AppBar,
|
||||||
Button,
|
Button,
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogActions,
|
DialogActions,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
|
IconButton,
|
||||||
Paper,
|
Paper,
|
||||||
|
Toolbar,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
import DownloadIcon from "@mui/icons-material/Download";
|
||||||
|
import CloseIcon from "@mui/icons-material/Close";
|
||||||
import { filesize } from "filesize";
|
import { filesize } from "filesize";
|
||||||
import { FileApi, UploadedFile } from "../api/FileApi";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { AsyncWidget } from "../widgets/AsyncWidget";
|
import { FileApi, UploadedFile } from "../api/FileApi";
|
||||||
|
|
||||||
export function FileViewerDialog(p: {
|
export function FileViewerDialog(p: {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -20,17 +24,40 @@ export function FileViewerDialog(p: {
|
|||||||
if (!p.open) return <></>;
|
if (!p.open) return <></>;
|
||||||
return (
|
return (
|
||||||
<Dialog open={p.open} onClose={p.onClose} fullScreen>
|
<Dialog open={p.open} onClose={p.onClose} fullScreen>
|
||||||
<DialogTitle>
|
<AppBar sx={{ position: "relative" }}>
|
||||||
{p.file.file_name} ({filesize(p.file.file_size)})
|
<Toolbar>
|
||||||
</DialogTitle>
|
<IconButton
|
||||||
|
edge="start"
|
||||||
|
color="inherit"
|
||||||
|
onClick={p.onClose}
|
||||||
|
aria-label="close"
|
||||||
|
autoFocus
|
||||||
|
>
|
||||||
|
<CloseIcon />
|
||||||
|
</IconButton>
|
||||||
|
<Typography sx={{ ml: 2, flex: 1 }} variant="h6" component="div">
|
||||||
|
{p.file.file_name} ({filesize(p.file.file_size)})
|
||||||
|
</Typography>
|
||||||
|
<a
|
||||||
|
href={FileApi.DownloadURL(p.file, true)}
|
||||||
|
target="_blank"
|
||||||
|
referrerPolicy="no-referrer"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
color="info"
|
||||||
|
onClick={p.onClose}
|
||||||
|
startIcon={<DownloadIcon />}
|
||||||
|
>
|
||||||
|
Download
|
||||||
|
</Button>
|
||||||
|
</a>
|
||||||
|
</Toolbar>
|
||||||
|
</AppBar>
|
||||||
<FileViewer
|
<FileViewer
|
||||||
url={FileApi.DownloadURL(p.file)}
|
url={FileApi.DownloadURL(p.file)}
|
||||||
downloadUrl={FileApi.DownloadURL(p.file, true)}
|
downloadUrl={FileApi.DownloadURL(p.file, true)}
|
||||||
{...p.file}
|
{...p.file}
|
||||||
/>
|
/>
|
||||||
<DialogActions>
|
|
||||||
<Button onClick={p.onClose}>Close</Button>
|
|
||||||
</DialogActions>
|
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user