From 9c3fa826d1d2a299529b7086951834aa09430579 Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 18 Jul 2021 18:48:10 +0530 Subject: [PATCH 1/9] made the folder select button smaller --- src/components/ExportModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ExportModal.tsx b/src/components/ExportModal.tsx index 483d3e210..6b3fe7ca7 100644 --- a/src/components/ExportModal.tsx +++ b/src/components/ExportModal.tsx @@ -266,7 +266,7 @@ export default function ExportModal(props: Props) { {!exportFolder ? - () : + () : (<> {exportFolder} From d177d2f6c26713a463f642d311d1bd14c94e9392 Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 18 Jul 2021 20:31:52 +0530 Subject: [PATCH 2/9] pass complete exportRecord path --- src/services/exportService.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/services/exportService.ts b/src/services/exportService.ts index 18c67d76b..2ff5f7fa0 100644 --- a/src/services/exportService.ts +++ b/src/services/exportService.ts @@ -49,6 +49,9 @@ export enum ExportType { PENDING, RETRY_FAILED } + +const ExportRecordFileName='export_status.json'; + class ExportService { ElectronAPIs: any; @@ -222,7 +225,7 @@ class ExportService { } const exportRecord = await this.getExportRecord(folder); const newRecord = { ...exportRecord, ...newData }; - await this.ElectronAPIs.setExportRecord(folder, JSON.stringify(newRecord, null, 2)); + await this.ElectronAPIs.setExportRecord(`${folder}/${ExportRecordFileName}`, JSON.stringify(newRecord, null, 2)); } catch (e) { logError(e, 'error updating Export Record'); } @@ -235,7 +238,7 @@ class ExportService { if (!folder) { folder = getData(LS_KEYS.EXPORT)?.folder; } - const recordFile = await this.ElectronAPIs.getExportRecord(folder); + const recordFile = await this.ElectronAPIs.getExportRecord(`${folder}/${ExportRecordFileName}`); if (recordFile) { return JSON.parse(recordFile); } else { From 1d48ca79c28e7e94252ed92c416304e65bb930c9 Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 18 Jul 2021 20:34:52 +0530 Subject: [PATCH 3/9] hide 0 failed files --- src/components/ExportFinished.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/ExportFinished.tsx b/src/components/ExportFinished.tsx index 2a22d718f..f2f0faf97 100644 --- a/src/components/ExportFinished.tsx +++ b/src/components/ExportFinished.tsx @@ -32,12 +32,13 @@ export default function ExportFinished(props: Props) { {props.exportStats.success} / {totalFiles} + {props.exportStats.failed>0 && {props.exportStats.failed} / {totalFiles} - + }
From 7eee36ab49ee28b18fa0667bc8d40cec40952c6a Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 18 Jul 2021 20:41:02 +0530 Subject: [PATCH 4/9] changed export again text --- src/utils/strings/englishConstants.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/strings/englishConstants.tsx b/src/utils/strings/englishConstants.tsx index 876537af3..08c66836b 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -441,7 +441,7 @@ const englishConstants = { LAST_EXPORT_TIME: 'last export time', SUCCESSFULLY_EXPORTED_FILES: 'successfully exported files', FAILED_EXPORTED_FILES: 'failed file export', - EXPORT_AGAIN: 'export new data ', + EXPORT_AGAIN: 'resync', RETRY_EXPORT_: 'retry failed files ', LOCAL_STORAGE_NOT_ACCESSIBLE: 'local storage not accessible', LOCAL_STORAGE_NOT_ACCESSIBLE_MESSAGE: 'your browser or an addon is blocking ente from saving data into local storage. please try loading this page after switching your browsing mode.', From b5886480ec56872e6e6d11fe6235f0ddf41868af Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 18 Jul 2021 21:16:51 +0530 Subject: [PATCH 5/9] store metadata in a subfolder --- src/components/ExportModal.tsx | 1 - src/services/exportService.ts | 20 ++++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/ExportModal.tsx b/src/components/ExportModal.tsx index 6b3fe7ca7..b515f5bbf 100644 --- a/src/components/ExportModal.tsx +++ b/src/components/ExportModal.tsx @@ -88,7 +88,6 @@ export default function ExportModal(props: Props) { updateExportProgress({ current: exportedFileCnt + failedFilesCnt, total: syncedFilesCnt }); const exportFileUIDs = new Set([...exportRecord.exportedFiles, ...exportRecord.failedFiles]); const unExportedFiles = localFiles.filter((file) => !exportFileUIDs.has(getFileUID(file))); - console.log(exportedFileCnt + failedFilesCnt + unExportedFiles.length, syncedFilesCnt); exportService.addFilesQueuedRecord(exportFolder, unExportedFiles); updateExportStage(ExportStage.PAUSED); } diff --git a/src/services/exportService.ts b/src/services/exportService.ts index 2ff5f7fa0..5e2c4a61b 100644 --- a/src/services/exportService.ts +++ b/src/services/exportService.ts @@ -51,6 +51,7 @@ export enum ExportType { } const ExportRecordFileName='export_status.json'; +const MetadataFolderName='metadata'; class ExportService { ElectronAPIs: any; @@ -127,6 +128,9 @@ class ExportService { await this.ElectronAPIs.checkExistsAndCreateCollectionDir( collectionFolderPath, ); + await this.ElectronAPIs.checkExistsAndCreateCollectionDir( + `${collectionFolderPath}/${MetadataFolderName}`, + ); collectionIDMap.set(collection.id, collectionFolderPath); } for (const [index, file] of files.entries()) { @@ -140,12 +144,9 @@ class ExportService { } break; } - const uid = `${file.id}_${this.sanitizeName( - file.metadata.title, - )}`; - const filePath = `${collectionIDMap.get(file.collectionID)}/${uid}`; + const collectionPath = collectionIDMap.get(file.collectionID); try { - await this.downloadAndSave(file, filePath); + await this.downloadAndSave(file, collectionPath); await this.addFileExportRecord(dir, file, RecordType.SUCCESS); } catch (e) { await this.addFileExportRecord(dir, file, RecordType.FAILED); @@ -249,11 +250,14 @@ class ExportService { } } - async downloadAndSave(file: File, path) { + async downloadAndSave(file: File, collectionPath:string) { + const uid = `${file.id}_${this.sanitizeName( + file.metadata.title, + )}`; const fileStream = await retryPromise(downloadManager.downloadFile(file)); - this.ElectronAPIs.saveStreamToDisk(path, fileStream); + this.ElectronAPIs.saveStreamToDisk(`${collectionPath}/${uid}`, fileStream); this.ElectronAPIs.saveFileToDisk( - `${path}.json`, + `${collectionPath}/${MetadataFolderName}/${uid}.json`, JSON.stringify(file.metadata, null, 2), ); } From 93a6c498a59d18e344ea63a03af78b22d6567017 Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 18 Jul 2021 21:25:29 +0530 Subject: [PATCH 6/9] text change --- src/utils/export/index.ts | 2 +- src/utils/strings/englishConstants.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/export/index.ts b/src/utils/export/index.ts index 49ee4a07c..4aa551cca 100644 --- a/src/utils/export/index.ts +++ b/src/utils/export/index.ts @@ -2,7 +2,7 @@ import { ExportRecord } from 'services/exportService'; import { File } from 'services/fileService'; -export const getFileUID = (file: File) => `${file.id}_${file.collectionID}`; +export const getFileUID = (file: File) => `${file.id}_${file.collectionID}_${file.updationTime}`; export const getExportPendingFiles = async (allFiles: File[], exportRecord: ExportRecord) => { diff --git a/src/utils/strings/englishConstants.tsx b/src/utils/strings/englishConstants.tsx index 08c66836b..349157579 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -442,7 +442,7 @@ const englishConstants = { SUCCESSFULLY_EXPORTED_FILES: 'successfully exported files', FAILED_EXPORTED_FILES: 'failed file export', EXPORT_AGAIN: 'resync', - RETRY_EXPORT_: 'retry failed files ', + RETRY_EXPORT_: 'retry failed exports', LOCAL_STORAGE_NOT_ACCESSIBLE: 'local storage not accessible', LOCAL_STORAGE_NOT_ACCESSIBLE_MESSAGE: 'your browser or an addon is blocking ente from saving data into local storage. please try loading this page after switching your browsing mode.', RETRY: 'retry', From a372c50483b5adb86919cb3d9e0604409a31df39 Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 18 Jul 2021 21:40:11 +0530 Subject: [PATCH 7/9] bshow better human readable usage --- src/services/billingService.ts | 4 ++-- src/utils/billingUtil.ts | 8 ++++++++ src/utils/strings/englishConstants.tsx | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/services/billingService.ts b/src/services/billingService.ts index 89b352b9c..189e550e0 100644 --- a/src/services/billingService.ts +++ b/src/services/billingService.ts @@ -2,7 +2,7 @@ import { getEndpoint } from 'utils/common/apiUtil'; import { getStripePublishableKey, getToken } from 'utils/common/key'; import { checkConnectivity, runningInBrowser } from 'utils/common/'; import { setData, LS_KEYS } from 'utils/storage/localStorage'; -import { convertBytesToGBs } from 'utils/billingUtil'; +import { convertToHumanReadable } from 'utils/billingUtil'; import { loadStripe, Stripe } from '@stripe/stripe-js'; import { SUBSCRIPTION_VERIFICATION_ERROR } from 'utils/common/errorUtil'; import HTTPService from './HTTPService'; @@ -242,7 +242,7 @@ class billingService { 'X-Auth-Token': getToken(), }, ); - return convertBytesToGBs(response.data.usage); + return convertToHumanReadable(response.data.usage); } catch (e) { logError(e, 'error getting usage'); } diff --git a/src/utils/billingUtil.ts b/src/utils/billingUtil.ts index 0c20cc7c0..b773deaa9 100644 --- a/src/utils/billingUtil.ts +++ b/src/utils/billingUtil.ts @@ -16,6 +16,14 @@ const STRIPE = 'stripe'; export function convertBytesToGBs(bytes, precision?): string { return (bytes / (1024 * 1024 * 1024)).toFixed(precision ?? 2); } + +export function convertToHumanReadable(bytes:number, precision=2): string { + const i = Math.floor(Math.log(bytes) / Math.log(1024)); + const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + + return (bytes / Math.pow(1024, i)).toFixed(precision)+ ' ' + sizes[i]; +} + export function hasPaidSubscription(subscription?: Subscription) { subscription = subscription ?? getUserSubscription(); return ( diff --git a/src/utils/strings/englishConstants.tsx b/src/utils/strings/englishConstants.tsx index 349157579..b3f4a7832 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -260,7 +260,7 @@ const englishConstants = {

you have used {usage} {' '} - GB out of your {quota} + out of your {quota} {' '} GB quota

From 67d5989d628f84f73211d32394e1e9d20e9a77ce Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 18 Jul 2021 21:50:47 +0530 Subject: [PATCH 8/9] ellipse export folder path --- src/components/ExportModal.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/ExportModal.tsx b/src/components/ExportModal.tsx index b515f5bbf..c2a080477 100644 --- a/src/components/ExportModal.tsx +++ b/src/components/ExportModal.tsx @@ -26,7 +26,18 @@ const FolderIconWrapper = styled.div` &:hover{ background-color:#444; } - `; +`; + +const ExportFolderPathContainer =styled.span` + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + width: 200px; + + /* Beginning of string */ + direction: rtl; + text-align: left; +`; interface Props { show: boolean @@ -267,9 +278,11 @@ export default function ExportModal(props: Props) { {!exportFolder ? () : (<> - + {/* */} + {exportFolder} - + + {/* */} {(exportStage === ExportStage.FINISHED || exportStage === ExportStage.INIT) && ( From 9e40a6c8031e79021679c7412ed3be659747af40 Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 18 Jul 2021 21:57:52 +0530 Subject: [PATCH 9/9] update strings --- src/utils/strings/englishConstants.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/strings/englishConstants.tsx b/src/utils/strings/englishConstants.tsx index b3f4a7832..3c94c6fd3 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -439,8 +439,8 @@ const englishConstants = { RESUME: 'resume', MINIMIZE: 'minimize', LAST_EXPORT_TIME: 'last export time', - SUCCESSFULLY_EXPORTED_FILES: 'successfully exported files', - FAILED_EXPORTED_FILES: 'failed file export', + SUCCESSFULLY_EXPORTED_FILES: 'successful exports', + FAILED_EXPORTED_FILES: 'failed exports', EXPORT_AGAIN: 'resync', RETRY_EXPORT_: 'retry failed exports', LOCAL_STORAGE_NOT_ACCESSIBLE: 'local storage not accessible',