From ef37bac2e7e398b914d670408bd333e8de5d223b Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 19 Oct 2018 18:38:35 +0200 Subject: [PATCH] Add UI for the CryptDrive export --- www/common/sframe-common-outer.js | 2 +- www/common/sframe-common.js | 2 +- www/common/translations/messages.js | 16 +++ www/settings/app-settings.less | 89 +++++++++++++ www/settings/inner.js | 200 +++++++++++++++++++++------- www/settings/make-backup.js | 156 +++++++++++++--------- 6 files changed, 353 insertions(+), 112 deletions(-) diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index aff66dddc..a35c2dfe0 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -769,7 +769,7 @@ define([ i = 0; cgNetwork = undefined; } - i++ + i++; if (!cgNetwork) { cgNetwork = true; return void Cryptpad.makeNetwork(function (err, nw) { diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index 3a37b8999..8b048a70a 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -483,7 +483,7 @@ define([ }); ctx.sframeChan.on('EV_LOADING_INFO', function (data) { - UI.updateLoadingProgress(data, true); + UI.updateLoadingProgress(data, 'drive'); }); ctx.sframeChan.on('EV_NEW_VERSION', function () { diff --git a/www/common/translations/messages.js b/www/common/translations/messages.js index 2c2addc8f..b8ced6b9f 100644 --- a/www/common/translations/messages.js +++ b/www/common/translations/messages.js @@ -566,6 +566,22 @@ define(function () { out.settings_backup2 = "Download my CryptDrive"; out.settings_restore = "Restore"; + // XXX + out.settings_backup2Confirm = "This will download all the pads and files from your CryptDrive. If you want to continue, pick a name and press OK"; + out.settings_exportTitle = "Export your CryptDrive"; + out.settings_exportDescription = "Please wait while we're downloading and decrypting your documents, this may take a few minutes. Closing the tab will interrupt the process."; + out.settings_exportWarning = "For better performances, it is recommended to leave this tab focused."; + out.settings_exportCancel = "Are you sure you want to cancel the export? You will have to start again from the beginning for your next export."; + out.settings_export_reading = "Reading your CryptDrive..."; + out.settings_export_download = "Decrypting and downloading your documents..."; + out.settings_export_compressing = "Compressing the data..."; + out.settings_export_done = "Export is ready!"; + out.settings_exportError = "View errors"; + out.settings_exportErrorDescription = "We weren't able to add the following documents into the export:"; + out.settings_exportErrorEmpty = "The document can't be exported (empty or invalid content)."; + out.settings_exportErrorMissing = "The document is missing from our servers (expired or deleted by its owner)"; + out.settings_exportErrorOther = "An error occured while trying to export the document: {0}"; + out.settings_resetNewTitle = "Clean CryptDrive"; out.settings_resetButton = "Remove"; out.settings_reset = "Remove all the files and folders from your CryptDrive"; diff --git a/www/settings/app-settings.less b/www/settings/app-settings.less index 67a31ed40..14eb216f8 100644 --- a/www/settings/app-settings.less +++ b/www/settings/app-settings.less @@ -16,6 +16,95 @@ display: flex; flex-flow: column; font: @colortheme_app-font; + + #cp-export-container { + font-size: 16px; + display: flex; + flex: 1; + min-height: 0; + align-items: center; + justify-content: center; + .cp-export-block { + width: 800px; + max-width: 90vw; + .cp-export-progress-bar-container { + height: 24px; + background: white; + border: 1px solid #DDD; + width: 80%; + margin: auto; + position: relative; + .cp-export-progress-bar { + height: 100%; + background: #5cb85c; // Same color as loading screen bar + width: 0%; + display: inline-block; + } + .cp-export-progress-text { + position: absolute; + top: 0; + right: 0; + left: 0; + bottom: 0; + text-align: center; + font-weight: bold; + } + } + & > p { + color: #777; + } + .cp-export-progress { + margin-bottom: 1rem; + p { + margin-bottom: 0; + display: flex; + align-items: center; + padding: 5px 0; + .fa { + width: 25px; + } + } + } + .cp-export-actions { + display: flex; + flex-flow: row-reverse; + .btn-default, .btn-primary { + margin-left: 20px; + } + } + .cp-export-errors { + display: none; + overflow-x: auto; + max-height: 300px; + background: #ededed; + border: 1px solid #777; + padding: 5px 20px; + margin-top: 1rem; + & > p { + margin: 0; + } + .cp-export-errors-list { + & > div { + padding: 5px 10px; + margin: 5px 0; + background: #dedede; + .title { + font-weight: bold; + } + .link { + padding: 0 20px; + font-size: 14px; + } + .reason { + padding: 0 20px; + color: #777; + } + } + } + } + } + } + #cp-sidebarlayout-container { #cp-sidebarlayout-rightside { input[type="checkbox"] { diff --git a/www/settings/inner.js b/www/settings/inner.js index 26d7f54a0..618d76364 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -32,7 +32,7 @@ define([ Cred, AppConfig, ApiConfig, - Backup, + Backup ) { var saveAs = window.saveAs; @@ -303,45 +303,6 @@ define([ return $div; }; - create['backup'] = function () { - if (!common.isLoggedIn()) { return; } - var $div = $('
', { 'class': 'cp-settings-backup cp-sidebarlayout-element'}); - - $('', {'class': 'label'}).text(Messages.settings_backupTitle || 'TODO BACKUP').appendTo($div); // XXX - - $('', {'class': 'cp-sidebarlayout-description'}) - .append(Messages.settings_backupHint || 'TODO').appendTo($div); // XXX - - var $ok = $('', {'class': 'fa fa-check', title: Messages.saved}); - var $spinner = $('', {'class': 'fa fa-spinner fa-pulse'}); - - var $button = $('