From b4bf7351de3a9f19843c34f3cbd710e5f41d9abb Mon Sep 17 00:00:00 2001 From: Grady Ward Date: Sat, 9 Dec 2023 06:28:38 -0700 Subject: [PATCH] Addresses Review Comments --- frontend/lib/filesize/index.ts | 4 ++-- frontend/pages/portfolios.vue | 1 + frontend/pages/upload.vue | 24 ++++++++++++------------ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/frontend/lib/filesize/index.ts b/frontend/lib/filesize/index.ts index bd63c96..f1604fe 100644 --- a/frontend/lib/filesize/index.ts +++ b/frontend/lib/filesize/index.ts @@ -1,8 +1,8 @@ export const formatFileSize = (bytes: number): string => { if (bytes === 0) return 'Empty' - const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'] + const sizes = ['Bytes', 'kB', 'MB', 'GB', 'TB'] - const k = 1024 + const k = 1000 const i = Math.floor(Math.log(bytes) / Math.log(k)) return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i] diff --git a/frontend/pages/portfolios.vue b/frontend/pages/portfolios.vue index 2449ddd..52bd2e1 100644 --- a/frontend/pages/portfolios.vue +++ b/frontend/pages/portfolios.vue @@ -134,6 +134,7 @@ const saveChanges = (id: string) => { to="/upload" label="Upload New Portfolios" /> + (() => { icon = 'pi pi-circle' } let otherError: string | undefined - // TODO(grady) validate this server side too. + // TODO(#79) validate this server side too. if (fileState.file.name.length > 1000) { otherError = 'Filename is too long (1000 characters max).' } else if (fileState.file.size > 1028 * 1028 * 100) { @@ -156,9 +156,7 @@ const startUpload = async () => { const startPortfolioUploadResp = await pactaClient.startPortfolioUpload({ items: fileStates.value.map((fileState: FileState) => ({ file_name: fileState.file.name, - // TODO(grady) consider adding file size here as a validation step. - // TODO(grady) consider adding file type validation here. - // TODO(grady) consider adding duplicate file checking here. + // TODO(#79) consider adding file size here as a validation step. })), holdings_date: { time: holdingsDate.value.toISOString(), @@ -255,18 +253,18 @@ const waitForValidationToCompleteOrTimeout = async () => { const refreshStateFromIncompleteUploads = async () => { const resp = await pactaClient.listIncompleteUploads() - console.log('resp', resp) const incompleteUploads = resp.items for (const incompleteUpload of incompleteUploads) { const idx = fileStates.value.findIndex((fileState) => fileState.incompleteUploadId === incompleteUpload.id) // Note - this item might not be in the list if the user hasn't cleaned up prior incomplete portfolios. - if (idx >= 0) { - if (incompleteUpload.failureCode) { - fileStates.value[idx].status = FileStatus.Error - fileStates.value[idx].errorMessage = incompleteUpload.failureMessage - } else if (incompleteUpload.completedAt) { - fileStates.value[idx].status = FileStatus.CleanUp - } + if (idx < 0) { + continue + } + if (incompleteUpload.failureCode) { + fileStates.value[idx].status = FileStatus.Error + fileStates.value[idx].errorMessage = incompleteUpload.failureMessage + } else if (incompleteUpload.completedAt) { + fileStates.value[idx].status = FileStatus.CleanUp } } } @@ -286,6 +284,7 @@ const cleanUpIncompleteUploads = async () => {