-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dcellar-web-ui): using table to manage pending and uploading lists
- Loading branch information
Showing
15 changed files
with
330 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
apps/dcellar-web-ui/src/modules/upload/ObjectUploadStatus.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { UploadObject } from '@/store/slices/global'; | ||
import { Flex, Text } from '@node-real/uikit'; | ||
import { Loading } from '@/components/common/Loading'; | ||
import { UploadProgress } from './UploadProgress'; | ||
import { IconFont } from '@/components/IconFont'; | ||
|
||
export const ObjectUploadStatus = ({ task }: { task: UploadObject }) => { | ||
switch (task.status) { | ||
case 'WAIT': | ||
return ( | ||
<> | ||
<Loading iconSize={12} justifyContent={'flex-end'} /> | ||
<Text marginLeft={'4px'} fontWeight={400}> | ||
Waiting | ||
</Text> | ||
</> | ||
); | ||
case 'HASH': | ||
return ( | ||
<> | ||
<Loading iconSize={12} justifyContent={'flex-end'} /> | ||
<Text marginLeft={'4px'} fontWeight={400}> | ||
Hashing | ||
</Text> | ||
</> | ||
); | ||
case 'HASHED': | ||
return <UploadProgress value={0} />; | ||
case 'SIGN': | ||
return <UploadProgress value={0} />; | ||
case 'SIGNED': | ||
return <UploadProgress value={0} />; | ||
case 'UPLOAD': | ||
return <UploadProgress value={task.progress || 0} />; | ||
case 'SEAL': | ||
case 'SEALING': | ||
return ( | ||
<> | ||
<Loading iconSize={12} justifyContent={'flex-end'} /> | ||
<Text marginLeft={'4px'} fontWeight={400}> | ||
Sealing | ||
</Text> | ||
</> | ||
); | ||
case 'FINISH': | ||
return <IconFont type="colored-success" w={16} mr={8} />; | ||
case 'ERROR': | ||
return <IconFont type="colored-error2" w={20} mr={6} />; | ||
case 'CANCEL': | ||
return <IconFont type="colored-error2" w={20} mr={6} />; | ||
default: | ||
return null; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
apps/dcellar-web-ui/src/modules/upload/UploadObjectsList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { DCTable } from '@/components/common/DCTable'; | ||
import { useAppDispatch, useAppSelector } from '@/store'; | ||
import { UploadObject, WaitObject, removeFromWaitQueue } from '@/store/slices/global'; | ||
import { ColumnProps } from 'antd/es/table'; | ||
import React, { use, useState } from 'react'; | ||
import { NameItem } from './NameItem'; | ||
import { PathItem } from './PathItem'; | ||
import { ObjectUploadStatus } from './ObjectUploadStatus'; | ||
import { useTableNav } from '@/components/common/DCTable/useTableNav'; | ||
import { useCreation } from 'ahooks'; | ||
import { chunk } from 'lodash-es'; | ||
import { Flex } from '@node-real/uikit'; | ||
import { IconFont } from '@/components/IconFont'; | ||
|
||
const uploadingPageSize = 10; | ||
|
||
export const UploadObjectsList = ({ path, data }: { path: string; data: WaitObject[] }) => { | ||
const dispatch = useAppDispatch(); | ||
const [pageSize, setPageSize] = useState(10); | ||
const [curPage, setCurPage] = useState(1); | ||
const chunks = useCreation(() => chunk(data, pageSize), [data, pageSize]); | ||
const page = chunks[curPage - 1] || []; | ||
const onRemove = (id: number) => { | ||
dispatch(removeFromWaitQueue({ id })); | ||
}; | ||
const columns: ColumnProps<UploadObject>[] = [ | ||
{ | ||
key: 'name', | ||
title: 'Name', | ||
render: (record) => { | ||
return ( | ||
<NameItem name={record.name} size={record.size} msg={record.msg} w={240} task={record} /> | ||
); | ||
}, | ||
}, | ||
{ | ||
key: 'path', | ||
title: 'Path', | ||
width: 170, | ||
render: (record) => { | ||
return ( | ||
<PathItem | ||
lineHeight="normal" | ||
path={`${path}/${record.relativePath ? record.relativePath + '/' : ''}`} | ||
textAlign="left" | ||
/> | ||
); | ||
}, | ||
}, | ||
{ | ||
key: 'status', | ||
title: 'Status', | ||
width: 70, | ||
render: (record) => { | ||
return ( | ||
<IconFont | ||
onClick={() => onRemove(record.id)} | ||
w={16} | ||
type="close" | ||
cursor="pointer" | ||
color={'readable.secondary'} | ||
_hover={{ | ||
color: 'readable.normal', | ||
}} | ||
/> | ||
); | ||
}, | ||
}, | ||
]; | ||
|
||
const onPageChange = (page: number) => { | ||
setCurPage(page); | ||
}; | ||
|
||
return ( | ||
<DCTable | ||
columns={columns} | ||
dataSource={page} | ||
current={curPage} | ||
total={data.length} | ||
pageSize={uploadingPageSize} | ||
showQuickJumper={true} | ||
pageChange={onPageChange} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.