X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6fbcbe191d8356ad2029e79ad961c983b2284afd..a2bf1ed3a15cf55e426c51ad8e6febd7ff2e3020:/src/components/file-upload/file-upload.tsx

diff --git a/src/components/file-upload/file-upload.tsx b/src/components/file-upload/file-upload.tsx
index 3a98e27af2..e7f402cdb2 100644
--- a/src/components/file-upload/file-upload.tsx
+++ b/src/components/file-upload/file-upload.tsx
@@ -3,10 +3,18 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { Grid, StyleRulesCallback, Typography, WithStyles } from '@material-ui/core';
+import {
+    Grid,
+    StyleRulesCallback,
+    Table, TableBody, TableCell, TableHead, TableRow,
+    Typography,
+    WithStyles
+} from '@material-ui/core';
 import { withStyles } from '@material-ui/core';
 import Dropzone from 'react-dropzone';
 import { CloudUploadIcon } from "../icon/icon";
+import { formatFileSize, formatProgress, formatUploadSpeed } from "~/common/formatters";
+import { UploadFile } from '~/store/file-uploader/file-uploader-actions';
 
 type CssRules = "root" | "dropzone" | "container" | "uploadIcon";
 
@@ -15,7 +23,8 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
     },
     dropzone: {
         width: "100%",
-        height: "100px",
+        height: "200px",
+        overflow: "auto",
         border: "1px dashed black",
         borderRadius: "5px"
     },
@@ -27,23 +36,44 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
     }
 });
 
-interface FileUploadProps {
+export interface FileUploadProps {
+    files: UploadFile[];
+    disabled: boolean;
+    onDrop: (files: File[]) => void;
 }
 
 export const FileUpload = withStyles(styles)(
-    ({ classes }: FileUploadProps & WithStyles<CssRules>) =>
-    <Grid container direction={"column"}>
-        <Typography variant={"subheading"}>
-            Upload data
-        </Typography>
-        <Dropzone className={classes.dropzone}>
-            <Grid container justify="center" alignItems="center" className={classes.container}>
-                <Grid item component={"span"}>
-                    <Typography variant={"subheading"}>
-                        <CloudUploadIcon className={classes.uploadIcon}/> Drag and drop data or <a>browse</a>
+    ({ classes, files, disabled, onDrop }: FileUploadProps & WithStyles<CssRules>) =>
+        <Dropzone className={classes.dropzone} onDrop={files => onDrop(files)} disabled={disabled}>
+            {files.length === 0 &&
+                <Grid container justify="center" alignItems="center" className={classes.container}>
+                    <Grid item component={"span"}>
+                        <Typography variant={"subheading"}>
+                            <CloudUploadIcon className={classes.uploadIcon} /> Drag and drop data or click to browse
                     </Typography>
-                </Grid>
-            </Grid>
+                    </Grid>
+                </Grid>}
+            {files.length > 0 &&
+                <Table style={{ width: "100%" }}>
+                    <TableHead>
+                        <TableRow>
+                            <TableCell>File name</TableCell>
+                            <TableCell>File size</TableCell>
+                            <TableCell>Upload speed</TableCell>
+                            <TableCell>Upload progress</TableCell>
+                        </TableRow>
+                    </TableHead>
+                    <TableBody>
+                        {files.map(f =>
+                            <TableRow key={f.id}>
+                                <TableCell>{f.file.name}</TableCell>
+                                <TableCell>{formatFileSize(f.file.size)}</TableCell>
+                                <TableCell>{formatUploadSpeed(f.prevLoaded, f.loaded, f.prevTime, f.currentTime)}</TableCell>
+                                <TableCell>{formatProgress(f.loaded, f.total)}</TableCell>
+                            </TableRow>
+                        )}
+                    </TableBody>
+                </Table>
+            }
         </Dropzone>
-    </Grid>
 );
