Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-CloudComputing
/
C_Team_KhuDrive
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
김재형
2020-06-14 21:49:41 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3dd36f56972529df04a534e3b924faf99a39db5a
3dd36f56
1 parent
e1ad1437
Implement FileList component
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
76 additions
and
26 deletions
frontend/package-lock.json
frontend/package.json
frontend/src/file/FileList.module.scss
frontend/src/file/FileList.tsx
frontend/src/file/FileListItem.tsx
frontend/src/file/useFileList.ts
frontend/package-lock.json
View file @
3dd36f5
...
...
@@ -7965,10 +7965,9 @@
"optional"
:
true
},
"filesize"
:
{
"version"
:
"6.0.1"
,
"resolved"
:
"https://registry.npmjs.org/filesize/-/filesize-6.0.1.tgz"
,
"integrity"
:
"sha512-u4AYWPgbI5GBhs6id1KdImZWn5yfyFrrQ8OWZdN7ZMfA8Bf4HcO0BGo9bmUIEV8yrp8I1xVfJ/dn90GtFNNJcg=="
,
"dev"
:
true
"version"
:
"6.1.0"
,
"resolved"
:
"https://registry.npmjs.org/filesize/-/filesize-6.1.0.tgz"
,
"integrity"
:
"sha512-LpCHtPQ3sFx67z+uh2HnSyWSLLu5Jxo21795uRDuar/EOuYWXib5EmPaGIBuSnRqH2IODiKA2k5re/K9OnN/Yg=="
},
"fill-range"
:
{
"version"
:
"7.0.1"
,
...
...
@@ -17053,6 +17052,12 @@
"integrity"
:
"sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w=="
,
"dev"
:
true
},
"filesize"
:
{
"version"
:
"6.0.1"
,
"resolved"
:
"https://registry.npmjs.org/filesize/-/filesize-6.0.1.tgz"
,
"integrity"
:
"sha512-u4AYWPgbI5GBhs6id1KdImZWn5yfyFrrQ8OWZdN7ZMfA8Bf4HcO0BGo9bmUIEV8yrp8I1xVfJ/dn90GtFNNJcg=="
,
"dev"
:
true
},
"has-flag"
:
{
"version"
:
"3.0.0"
,
"resolved"
:
"https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz"
,
...
...
frontend/package.json
View file @
3dd36f5
...
...
@@ -7,6 +7,7 @@
"@ant-design/icons"
:
"^4.2.1"
,
"antd"
:
"^4.3.3"
,
"classnames"
:
"^2.2.6"
,
"filesize"
:
"^6.1.0"
,
"ky"
:
"^0.20.0"
,
"miragejs"
:
"^0.1.40"
,
"react"
:
"^16.13.1"
,
...
...
frontend/src/file/FileList.module.scss
0 → 100644
View file @
3dd36f5
.actions
{
a
{
margin
:
0
4px
;
}
}
frontend/src/file/FileList.tsx
View file @
3dd36f5
import React from "react";
import { Table } from "antd";
import { ColumnsType } from "antd/lib/table";
import filesize from "filesize";
import { useParams } from "react-router-dom";
import { useFileList } from "./useFileList";
import { useFileList, FileItem } from "./useFileList";
import { FileListItem } from "./FileListItem";
import styles from "./FileList.module.scss";
const columns: ColumnsType<FileItem> = [
{
title: "파일명",
dataIndex: "name",
render: (_name: string, item) => <FileListItem item={item} />,
},
{
title: "크기",
dataIndex: "size",
width: 120,
render: (bytes: number, item) =>
item.is_folder ? "" : filesize(bytes, { round: 0 }),
},
{
title: "",
dataIndex: "",
width: 200,
render: (__: any, item) =>
item.is_folder ? null : (
<div className={styles.actions}>
<a>공유</a>
<a>이동</a>
<a>복사</a>
<a>삭제</a>
</div>
),
},
];
export function FileList() {
const id = useParams<{ id: string }>().id;
const { data } = useFileList(id);
return <div>{JSON.stringify(data, null, 2)}</div>;
if (data && data.parent !== null) {
data.list.unshift(({
id: data.parent,
is_folder: true,
name: "..",
file_type: "folder",
} as unknown) as FileItem);
}
return data && <Table columns={columns} dataSource={data.list} />;
}
...
...
frontend/src/file/FileListItem.tsx
0 → 100644
View file @
3dd36f5
import React, { Fragment } from "react";
import { FileItem } from "./useFileList";
export function FileListItem({ item }: { item: FileItem }) {
return <Fragment>{item.name}</Fragment>;
}
frontend/src/file/useFileList.ts
View file @
3dd36f5
import
{
useState
,
useCallback
,
useEffect
}
from
"react"
;
import
ky
from
"ky"
;
interface
FileListResponse
{
data
:
FileItem
&
{
interface
FileListData
extends
FileItem
{
list
:
FileItem
[];
};
}
interface
FileItem
{
interface
FileListResponse
{
data
:
FileListData
;
}
export
interface
FileItem
{
is_folder
:
boolean
;
name
:
string
;
file_type
:
"folder"
|
"file"
;
...
...
@@ -22,29 +24,15 @@ interface FileItem {
id
:
number
;
}
interface
Token
{
accessToken
:
string
;
refreshToken
:
string
;
expiration
:
Date
;
user
:
{
id
:
number
;
username
:
string
;
name
:
string
;
totalSize
:
number
;
currentSize
:
number
;
rootFolder
:
number
;
};
}
export
function
useFileList
(
id
:
string
)
{
const
[
data
,
setData
]
=
useState
<
FileList
Response
|
null
>
(
null
);
const
[
data
,
setData
]
=
useState
<
FileList
Data
|
null
>
(
null
);
const
reload
=
useCallback
(
async
()
=>
{
const
response
=
await
ky
.
get
(
`/items/
${
id
}
/children/`
)
.
json
<
FileListResponse
>
();
setData
(
response
);
setData
(
response
.
data
);
},
[
id
]);
useEffect
(()
=>
{
...
...
Please
register
or
login
to post a comment