Showing
11 changed files
with
458 additions
and
2 deletions
| ... | @@ -9,7 +9,7 @@ import { | ... | @@ -9,7 +9,7 @@ import { |
| 9 | RecentFileList as RecentFileListView, | 9 | RecentFileList as RecentFileListView, |
| 10 | MyDrive as MyDriveView, | 10 | MyDrive as MyDriveView, |
| 11 | SharedFileList as SharedFileView, | 11 | SharedFileList as SharedFileView, |
| 12 | - Typography as TypographyView, | 12 | + Trash as TrashView, |
| 13 | Icons as IconsView, | 13 | Icons as IconsView, |
| 14 | Account as AccountView, | 14 | Account as AccountView, |
| 15 | Settings as SettingsView, | 15 | Settings as SettingsView, |
| ... | @@ -45,7 +45,7 @@ const Routes = () => { | ... | @@ -45,7 +45,7 @@ const Routes = () => { |
| 45 | path="/recent" | 45 | path="/recent" |
| 46 | /> | 46 | /> |
| 47 | <RouteWithLayout | 47 | <RouteWithLayout |
| 48 | - component={TypographyView} | 48 | + component={TrashView} |
| 49 | exact | 49 | exact |
| 50 | layout={MainLayout} | 50 | layout={MainLayout} |
| 51 | path="/trash" | 51 | path="/trash" | ... | ... |
| 1 | +import React, { useState } from 'react'; | ||
| 2 | +import clsx from 'clsx'; | ||
| 3 | +import PropTypes from 'prop-types'; | ||
| 4 | +import moment from 'moment'; | ||
| 5 | +import PerfectScrollbar from 'react-perfect-scrollbar'; | ||
| 6 | +import { makeStyles } from '@material-ui/styles'; | ||
| 7 | +import { | ||
| 8 | + Card, | ||
| 9 | + CardActions, | ||
| 10 | + CardContent, | ||
| 11 | + Avatar, | ||
| 12 | + Checkbox, | ||
| 13 | + Table, | ||
| 14 | + TableBody, | ||
| 15 | + TableCell, | ||
| 16 | + TableHead, | ||
| 17 | + TableRow, | ||
| 18 | + Typography, | ||
| 19 | + TablePagination | ||
| 20 | +} from '@material-ui/core'; | ||
| 21 | + | ||
| 22 | +import { getInitials } from '../../../Trash/components/RemovedFileTable/node_modules/helpers'; | ||
| 23 | + | ||
| 24 | +const useStyles = makeStyles(theme => ({ | ||
| 25 | + root: {}, | ||
| 26 | + content: { | ||
| 27 | + padding: 0 | ||
| 28 | + }, | ||
| 29 | + inner: { | ||
| 30 | + minWidth: 1050 | ||
| 31 | + }, | ||
| 32 | + nameContainer: { | ||
| 33 | + display: 'flex', | ||
| 34 | + alignItems: 'center' | ||
| 35 | + }, | ||
| 36 | + avatar: { | ||
| 37 | + marginRight: theme.spacing(2) | ||
| 38 | + }, | ||
| 39 | + actions: { | ||
| 40 | + justifyContent: 'flex-end' | ||
| 41 | + } | ||
| 42 | +})); | ||
| 43 | + | ||
| 44 | +const FileTable = props => { | ||
| 45 | + const { className, files: files, ...rest } = props; | ||
| 46 | + | ||
| 47 | + const classes = useStyles(); | ||
| 48 | + | ||
| 49 | + const [selectedUsers, setSelectedUsers] = useState([]); | ||
| 50 | + const [rowsPerPage, setRowsPerPage] = useState(10); | ||
| 51 | + const [page, setPage] = useState(0); | ||
| 52 | + | ||
| 53 | + const handleSelectAll = event => { | ||
| 54 | + const { files } = props; | ||
| 55 | + | ||
| 56 | + let selectedUsers; | ||
| 57 | + | ||
| 58 | + if (event.target.checked) { | ||
| 59 | + selectedUsers = files.map(user => user.id); | ||
| 60 | + } else { | ||
| 61 | + selectedUsers = []; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + setSelectedUsers(selectedUsers); | ||
| 65 | + }; | ||
| 66 | + | ||
| 67 | + const handleSelectOne = (event, id) => { | ||
| 68 | + const selectedIndex = selectedUsers.indexOf(id); | ||
| 69 | + let newSelectedUsers = []; | ||
| 70 | + | ||
| 71 | + if (selectedIndex === -1) { | ||
| 72 | + newSelectedUsers = newSelectedUsers.concat(selectedUsers, id); | ||
| 73 | + } else if (selectedIndex === 0) { | ||
| 74 | + newSelectedUsers = newSelectedUsers.concat(selectedUsers.slice(1)); | ||
| 75 | + } else if (selectedIndex === selectedUsers.length - 1) { | ||
| 76 | + newSelectedUsers = newSelectedUsers.concat(selectedUsers.slice(0, -1)); | ||
| 77 | + } else if (selectedIndex > 0) { | ||
| 78 | + newSelectedUsers = newSelectedUsers.concat( | ||
| 79 | + selectedUsers.slice(0, selectedIndex), | ||
| 80 | + selectedUsers.slice(selectedIndex + 1) | ||
| 81 | + ); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + setSelectedUsers(newSelectedUsers); | ||
| 85 | + }; | ||
| 86 | + | ||
| 87 | + const handlePageChange = (event, page) => { | ||
| 88 | + setPage(page); | ||
| 89 | + }; | ||
| 90 | + | ||
| 91 | + const handleRowsPerPageChange = event => { | ||
| 92 | + setRowsPerPage(event.target.value); | ||
| 93 | + }; | ||
| 94 | + | ||
| 95 | + return ( | ||
| 96 | + <Card | ||
| 97 | + {...rest} | ||
| 98 | + className={clsx(classes.root, className)} | ||
| 99 | + > | ||
| 100 | + <CardContent className={classes.content}> | ||
| 101 | + <PerfectScrollbar> | ||
| 102 | + <div className={classes.inner}> | ||
| 103 | + <Table> | ||
| 104 | + <TableHead> | ||
| 105 | + <TableRow> | ||
| 106 | + <TableCell padding="checkbox"> | ||
| 107 | + <Checkbox | ||
| 108 | + checked={selectedUsers.length === files.length} | ||
| 109 | + color="primary" | ||
| 110 | + indeterminate={ | ||
| 111 | + selectedUsers.length > 0 && | ||
| 112 | + selectedUsers.length < files.length | ||
| 113 | + } | ||
| 114 | + onChange={handleSelectAll} | ||
| 115 | + /> | ||
| 116 | + </TableCell> | ||
| 117 | + <TableCell>이름</TableCell> | ||
| 118 | + <TableCell>마지막으로 수정한 날짜</TableCell> | ||
| 119 | + <TableCell>크기</TableCell> | ||
| 120 | + <TableCell>공유</TableCell> | ||
| 121 | + </TableRow> | ||
| 122 | + </TableHead> | ||
| 123 | + <TableBody> | ||
| 124 | + {files.slice(0, rowsPerPage).map(file => ( | ||
| 125 | + <TableRow | ||
| 126 | + className={classes.tableRow} | ||
| 127 | + hover | ||
| 128 | + key={file.id} | ||
| 129 | + selected={selectedUsers.indexOf(file.id) !== -1} | ||
| 130 | + > | ||
| 131 | + <TableCell padding="checkbox"> | ||
| 132 | + <Checkbox | ||
| 133 | + checked={selectedUsers.indexOf(file.id) !== -1} | ||
| 134 | + color="primary" | ||
| 135 | + onChange={event => handleSelectOne(event, file.id)} | ||
| 136 | + value="true" | ||
| 137 | + /> | ||
| 138 | + </TableCell> | ||
| 139 | + <TableCell> | ||
| 140 | + <div className={classes.nameContainer}> | ||
| 141 | + {/* 파일 아이콘 */} | ||
| 142 | + <Typography variant="body1">{file.name}</Typography> | ||
| 143 | + </div> | ||
| 144 | + </TableCell> | ||
| 145 | + <TableCell> | ||
| 146 | + {moment(file.modifiedAt).format('DD/MM/YYYY')} | ||
| 147 | + </TableCell> | ||
| 148 | + <TableCell>{file.size}</TableCell> | ||
| 149 | + <TableCell> | ||
| 150 | + {file.share} | ||
| 151 | + </TableCell> | ||
| 152 | + | ||
| 153 | + </TableRow> | ||
| 154 | + ))} | ||
| 155 | + </TableBody> | ||
| 156 | + </Table> | ||
| 157 | + </div> | ||
| 158 | + </PerfectScrollbar> | ||
| 159 | + </CardContent> | ||
| 160 | + <CardActions className={classes.actions}> | ||
| 161 | + <TablePagination | ||
| 162 | + component="div" | ||
| 163 | + count={files.length} | ||
| 164 | + onChangePage={handlePageChange} | ||
| 165 | + onChangeRowsPerPage={handleRowsPerPageChange} | ||
| 166 | + page={page} | ||
| 167 | + rowsPerPage={rowsPerPage} | ||
| 168 | + rowsPerPageOptions={[5, 10, 25]} | ||
| 169 | + /> | ||
| 170 | + </CardActions> | ||
| 171 | + </Card> | ||
| 172 | + ); | ||
| 173 | +}; | ||
| 174 | + | ||
| 175 | +FileTable.propTypes = { | ||
| 176 | + className: PropTypes.string, | ||
| 177 | + files: PropTypes.array.isRequired | ||
| 178 | +}; | ||
| 179 | + | ||
| 180 | +export default FileTable; |
khubox-front/src/views/Trash/Trash.js
0 → 100644
| 1 | +import React, { useState } from 'react'; | ||
| 2 | +import { makeStyles } from '@material-ui/styles'; | ||
| 3 | + | ||
| 4 | +import { TrashToolbar, RemovedFileTable } from './components'; | ||
| 5 | +import mockData from './data'; | ||
| 6 | + | ||
| 7 | +const useStyles = makeStyles(theme => ({ | ||
| 8 | + root: { | ||
| 9 | + padding: theme.spacing(3) | ||
| 10 | + }, | ||
| 11 | + content: { | ||
| 12 | + marginTop: theme.spacing(2) | ||
| 13 | + } | ||
| 14 | +})); | ||
| 15 | + | ||
| 16 | +const Trash = () => { | ||
| 17 | + const classes = useStyles(); | ||
| 18 | + | ||
| 19 | + const [files] = useState(mockData); | ||
| 20 | + | ||
| 21 | + return ( | ||
| 22 | + <div className={classes.root}> | ||
| 23 | + <TrashToolbar /> | ||
| 24 | + <div className={classes.content}> | ||
| 25 | + <RemovedFileTable files={files} /> | ||
| 26 | + </div> | ||
| 27 | + </div> | ||
| 28 | + ); | ||
| 29 | +}; | ||
| 30 | + | ||
| 31 | +export default Trash; |
| 1 | +import React, { useState } from 'react'; | ||
| 2 | +import clsx from 'clsx'; | ||
| 3 | +import PropTypes from 'prop-types'; | ||
| 4 | +import moment from 'moment'; | ||
| 5 | +import PerfectScrollbar from 'react-perfect-scrollbar'; | ||
| 6 | +import { makeStyles } from '@material-ui/styles'; | ||
| 7 | +import { | ||
| 8 | + Card, | ||
| 9 | + CardActions, | ||
| 10 | + CardContent, | ||
| 11 | + Avatar, | ||
| 12 | + Checkbox, | ||
| 13 | + Table, | ||
| 14 | + TableBody, | ||
| 15 | + TableCell, | ||
| 16 | + TableHead, | ||
| 17 | + TableRow, | ||
| 18 | + Typography, | ||
| 19 | + TablePagination | ||
| 20 | +} from '@material-ui/core'; | ||
| 21 | + | ||
| 22 | +import { getInitials } from 'helpers'; | ||
| 23 | + | ||
| 24 | +const useStyles = makeStyles(theme => ({ | ||
| 25 | + root: {}, | ||
| 26 | + content: { | ||
| 27 | + padding: 0 | ||
| 28 | + }, | ||
| 29 | + inner: { | ||
| 30 | + minWidth: 1050 | ||
| 31 | + }, | ||
| 32 | + nameContainer: { | ||
| 33 | + display: 'flex', | ||
| 34 | + alignItems: 'center' | ||
| 35 | + }, | ||
| 36 | + avatar: { | ||
| 37 | + marginRight: theme.spacing(2) | ||
| 38 | + }, | ||
| 39 | + actions: { | ||
| 40 | + justifyContent: 'flex-end' | ||
| 41 | + } | ||
| 42 | +})); | ||
| 43 | + | ||
| 44 | +const RemovedFileTable = props => { | ||
| 45 | + const { className, files: files, ...rest } = props; | ||
| 46 | + | ||
| 47 | + const classes = useStyles(); | ||
| 48 | + | ||
| 49 | + const [selectedUsers, setSelectedUsers] = useState([]); | ||
| 50 | + const [rowsPerPage, setRowsPerPage] = useState(10); | ||
| 51 | + const [page, setPage] = useState(0); | ||
| 52 | + | ||
| 53 | + const handleSelectAll = event => { | ||
| 54 | + const { files } = props; | ||
| 55 | + | ||
| 56 | + let selectedUsers; | ||
| 57 | + | ||
| 58 | + if (event.target.checked) { | ||
| 59 | + selectedUsers = files.map(user => user.id); | ||
| 60 | + } else { | ||
| 61 | + selectedUsers = []; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + setSelectedUsers(selectedUsers); | ||
| 65 | + }; | ||
| 66 | + | ||
| 67 | + const handleSelectOne = (event, id) => { | ||
| 68 | + const selectedIndex = selectedUsers.indexOf(id); | ||
| 69 | + let newSelectedUsers = []; | ||
| 70 | + | ||
| 71 | + if (selectedIndex === -1) { | ||
| 72 | + newSelectedUsers = newSelectedUsers.concat(selectedUsers, id); | ||
| 73 | + } else if (selectedIndex === 0) { | ||
| 74 | + newSelectedUsers = newSelectedUsers.concat(selectedUsers.slice(1)); | ||
| 75 | + } else if (selectedIndex === selectedUsers.length - 1) { | ||
| 76 | + newSelectedUsers = newSelectedUsers.concat(selectedUsers.slice(0, -1)); | ||
| 77 | + } else if (selectedIndex > 0) { | ||
| 78 | + newSelectedUsers = newSelectedUsers.concat( | ||
| 79 | + selectedUsers.slice(0, selectedIndex), | ||
| 80 | + selectedUsers.slice(selectedIndex + 1) | ||
| 81 | + ); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + setSelectedUsers(newSelectedUsers); | ||
| 85 | + }; | ||
| 86 | + | ||
| 87 | + const handlePageChange = (event, page) => { | ||
| 88 | + setPage(page); | ||
| 89 | + }; | ||
| 90 | + | ||
| 91 | + const handleRowsPerPageChange = event => { | ||
| 92 | + setRowsPerPage(event.target.value); | ||
| 93 | + }; | ||
| 94 | + | ||
| 95 | + return ( | ||
| 96 | + <Card | ||
| 97 | + {...rest} | ||
| 98 | + className={clsx(classes.root, className)} | ||
| 99 | + > | ||
| 100 | + <CardContent className={classes.content}> | ||
| 101 | + <PerfectScrollbar> | ||
| 102 | + <div className={classes.inner}> | ||
| 103 | + <Table> | ||
| 104 | + <TableHead> | ||
| 105 | + <TableRow> | ||
| 106 | + <TableCell padding="checkbox"> | ||
| 107 | + <Checkbox | ||
| 108 | + checked={selectedUsers.length === files.length} | ||
| 109 | + color="primary" | ||
| 110 | + indeterminate={ | ||
| 111 | + selectedUsers.length > 0 && | ||
| 112 | + selectedUsers.length < files.length | ||
| 113 | + } | ||
| 114 | + onChange={handleSelectAll} | ||
| 115 | + /> | ||
| 116 | + </TableCell> | ||
| 117 | + <TableCell>이름</TableCell> | ||
| 118 | + <TableCell>마지막으로 수정한 날짜</TableCell> | ||
| 119 | + <TableCell>크기</TableCell> | ||
| 120 | + <TableCell>공유</TableCell> | ||
| 121 | + </TableRow> | ||
| 122 | + </TableHead> | ||
| 123 | + <TableBody> | ||
| 124 | + {files.slice(0, rowsPerPage).map(file => ( | ||
| 125 | + <TableRow | ||
| 126 | + className={classes.tableRow} | ||
| 127 | + hover | ||
| 128 | + key={file.id} | ||
| 129 | + selected={selectedUsers.indexOf(file.id) !== -1} | ||
| 130 | + > | ||
| 131 | + <TableCell padding="checkbox"> | ||
| 132 | + <Checkbox | ||
| 133 | + checked={selectedUsers.indexOf(file.id) !== -1} | ||
| 134 | + color="primary" | ||
| 135 | + onChange={event => handleSelectOne(event, file.id)} | ||
| 136 | + value="true" | ||
| 137 | + /> | ||
| 138 | + </TableCell> | ||
| 139 | + <TableCell> | ||
| 140 | + <div className={classes.nameContainer}> | ||
| 141 | + {/* 파일 아이콘 */} | ||
| 142 | + <Typography variant="body1">{file.name}</Typography> | ||
| 143 | + </div> | ||
| 144 | + </TableCell> | ||
| 145 | + <TableCell> | ||
| 146 | + {moment(file.modifiedAt).format('DD/MM/YYYY')} | ||
| 147 | + </TableCell> | ||
| 148 | + <TableCell>{file.size}</TableCell> | ||
| 149 | + <TableCell> | ||
| 150 | + {file.share} | ||
| 151 | + </TableCell> | ||
| 152 | + | ||
| 153 | + </TableRow> | ||
| 154 | + ))} | ||
| 155 | + </TableBody> | ||
| 156 | + </Table> | ||
| 157 | + </div> | ||
| 158 | + </PerfectScrollbar> | ||
| 159 | + </CardContent> | ||
| 160 | + <CardActions className={classes.actions}> | ||
| 161 | + <TablePagination | ||
| 162 | + component="div" | ||
| 163 | + count={files.length} | ||
| 164 | + onChangePage={handlePageChange} | ||
| 165 | + onChangeRowsPerPage={handleRowsPerPageChange} | ||
| 166 | + page={page} | ||
| 167 | + rowsPerPage={rowsPerPage} | ||
| 168 | + rowsPerPageOptions={[5, 10, 25]} | ||
| 169 | + /> | ||
| 170 | + </CardActions> | ||
| 171 | + </Card> | ||
| 172 | + ); | ||
| 173 | +}; | ||
| 174 | + | ||
| 175 | +RemovedFileTable.propTypes = { | ||
| 176 | + className: PropTypes.string, | ||
| 177 | + files: PropTypes.array.isRequired | ||
| 178 | +}; | ||
| 179 | + | ||
| 180 | +export default RemovedFileTable; |
| 1 | +export { default } from './RemovedFileTable'; |
| 1 | +import React from 'react'; | ||
| 2 | +import PropTypes from 'prop-types'; | ||
| 3 | +import clsx from 'clsx'; | ||
| 4 | +import { makeStyles } from '@material-ui/styles'; | ||
| 5 | +import { Button } from '@material-ui/core'; | ||
| 6 | + | ||
| 7 | +import { SearchInput } from 'components'; | ||
| 8 | + | ||
| 9 | +const useStyles = makeStyles(theme => ({ | ||
| 10 | + root: {}, | ||
| 11 | + row: { | ||
| 12 | + height: '42px', | ||
| 13 | + display: 'flex', | ||
| 14 | + alignItems: 'center', | ||
| 15 | + marginTop: theme.spacing(1) | ||
| 16 | + }, | ||
| 17 | + spacer: { | ||
| 18 | + flexGrow: 1 | ||
| 19 | + }, | ||
| 20 | + importButton: { | ||
| 21 | + marginRight: theme.spacing(1) | ||
| 22 | + }, | ||
| 23 | + exportButton: { | ||
| 24 | + marginRight: theme.spacing(1) | ||
| 25 | + }, | ||
| 26 | + searchInput: { | ||
| 27 | + marginRight: theme.spacing(1) | ||
| 28 | + } | ||
| 29 | +})); | ||
| 30 | + | ||
| 31 | +const DriveToolbar = props => { | ||
| 32 | + const { className, ...rest } = props; | ||
| 33 | + | ||
| 34 | + const classes = useStyles(); | ||
| 35 | + | ||
| 36 | + return ( | ||
| 37 | + <div | ||
| 38 | + {...rest} | ||
| 39 | + className={clsx(classes.root, className)} | ||
| 40 | + > | ||
| 41 | + <div className={classes.row}> | ||
| 42 | + <SearchInput | ||
| 43 | + className={classes.searchInput} | ||
| 44 | + placeholder="파일, 폴더 검색" | ||
| 45 | + /> | ||
| 46 | + </div> | ||
| 47 | + </div> | ||
| 48 | + ); | ||
| 49 | +}; | ||
| 50 | + | ||
| 51 | +DriveToolbar.propTypes = { | ||
| 52 | + className: PropTypes.string | ||
| 53 | +}; | ||
| 54 | + | ||
| 55 | +export default DriveToolbar; |
| 1 | +export { default } from './TrashToolbar'; |
khubox-front/src/views/Trash/data.js
0 → 100644
khubox-front/src/views/Trash/index.js
0 → 100644
| 1 | +export { default } from './Trash'; |
| ... | @@ -9,3 +9,4 @@ export { default as SignUp } from './SignUp'; | ... | @@ -9,3 +9,4 @@ export { default as SignUp } from './SignUp'; |
| 9 | export { default as Typography } from './Typography'; | 9 | export { default as Typography } from './Typography'; |
| 10 | export { default as MyDrive } from './MyDrive'; | 10 | export { default as MyDrive } from './MyDrive'; |
| 11 | export { default as SharedFileList } from './SharedFileList'; | 11 | export { default as SharedFileList } from './SharedFileList'; |
| 12 | +export { default as Trash } from './Trash'; | ... | ... |
-
Please register or login to post a comment