Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #185 from mgilangjanuar/staging
Browse files Browse the repository at this point in the history
Release v1.6.1
  • Loading branch information
mgilangjanuar authored Jan 10, 2022
2 parents 31d0d9a + b140c25 commit 80394c4
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "teledrive",
"version": "1.6.0",
"version": "1.6.1",
"repository": "git@github.com:mgilangjanuar/teledrive.git",
"author": "M Gilang Januar <mgilangjanuar@gmail.com>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "server",
"version": "1.6.0",
"version": "1.6.1",
"main": "dist/index.js",
"license": "MIT",
"private": true,
Expand Down
1 change: 1 addition & 0 deletions server/src/api/v1/Files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export class Files {
@Endpoint.POST('/upload/:id?', { middlewares: [Auth, multer().single('upload')] })
public async upload(req: Request, res: Response): Promise<any> {
const { name, size, mime_type: mimetype, parent_id: parentId, total_part: totalPart, part } = req.query as Record<string, string>

if (!name || !size || !mimetype || !part || !totalPart) {
throw { status: 400, body: { error: 'Name, size, mimetype, part, and total part are required' } }
}
Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web",
"version": "1.6.0",
"version": "1.6.1",
"private": true,
"dependencies": {
"@craco/craco": "^6.3.0",
Expand Down
26 changes: 25 additions & 1 deletion web/src/pages/dashboard/components/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,33 @@ const Upload: React.FC<Props> = ({ dataFileList: [fileList, setFileList], parent
const data = new FormData()
data.append('upload', blobPart)

let parentId = parent?.id
if (file.webkitRelativePath) {
const paths = file.webkitRelativePath.split('/').slice(0, -1) || []
for (const path of paths) {
const { data: findFolder } = await req.get('/files', { params: {
type: 'folder',
name: path,
...parentId ? { parent_id: parentId } : { 'parent_id.is': 'null' },
} })
if (!findFolder?.length) {
const { data: newFolder } = await req.post('/files/addFolder', {
file: {
name: path,
...parentId ? { parent_id: parentId } : {},
}
})
parentId = newFolder.file.id
} else {
parentId = findFolder.files[0].id
}
}
}

const { data: response } = await req.post(`/files/upload${i > 0 && firstResponse?.file?.id ? `/${firstResponse?.file.id}` : ''}`, data, {
params: {
...parent?.id ? { parent_id: parent.link_id || parent.id || undefined } : {},
// ...parent?.id ? { parent_id: parent.link_id || parent.id || undefined } : {},
...parentId ? { parent_id: parentId } : {},
name: `${file.name}${fileParts > 1 ? `.part${j + 1}` : ''}`,
size: fileBlob.size,
mime_type: file.type || mime.lookup(file.name) || 'application/octet-stream',
Expand Down
14 changes: 9 additions & 5 deletions web/src/pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const Dashboard: React.FC<PageProps & { me?: any, errorMe?: any }> = ({ match })
useEffect(() => {
if (filesUpload?.files) {
const list = fileList?.map(file => {
if (!file.response?.file.id) return file
if (!file.response?.file?.id) return file
const found = filesUpload.files.find((f: any) => f.id === file.response?.file.id)
if (!found) return null
return {
Expand All @@ -160,9 +160,14 @@ const Dashboard: React.FC<PageProps & { me?: any, errorMe?: any }> = ({ match })
}
}).filter(file => file && file.status !== 'success')
setFileList(list)
setData([...filesUpload.files?.map((file: any) => ({ ...file, key: file.id })), ...data].reduce((res, row) => [
...res, !res.filter(Boolean).find((r: any) => r.id === row.id) ? row : null
], []).filter(Boolean))
// setData([...filesUpload.files?.map((file: any) => ({ ...file, key: file.id })), ...data].reduce((res, row) => [
// ...res, !res.filter(Boolean).find((r: any) => r.id === row.id) ? row : null
// ], []).filter(Boolean))
if ((dataChanges?.pagination?.current || 0) > 1) {
change({ ...dataChanges?.pagination, current: 1 }, dataChanges?.filters, dataChanges?.sorter)
} else {
refetch()
}
}
}, [filesUpload])

Expand All @@ -173,7 +178,6 @@ const Dashboard: React.FC<PageProps & { me?: any, errorMe?: any }> = ({ match })
...keyword ? { 'name.ilike': `'%${keyword}%'` } : {},
...tab === 'shared' ? { shared: 1, 'parent_id.is': undefined } : {},
limit: PAGE_SIZE,
// skip: ((pagination?.current || 1) - 1) * PAGE_SIZE,
offset: pagination?.current === 1 || actions?.action || keyword && params?.offset ? 0 : data?.length,
...Object.keys(filters || {})?.reduce((res, key: string) => {
if (!filters) return res
Expand Down

0 comments on commit 80394c4

Please sign in to comment.