Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
prettier progress count
zadamcaa7dd9619dc
diff --git a/src/public/javascripts/dialogs/export.js b/src/public/javascripts/dialogs/export.jsindex 332a362f6d..abb408009e 100644--- a/src/public/javascripts/dialogs/export.js+++ b/src/public/javascripts/dialogs/export.js@@ -12,8 +12,8 @@ const $subtreeFormats = $("#export-subtree-formats");const $singleFormats = $("#export-single-formats");const $subtreeType = $("#export-type-subtree");const $singleType = $("#export-type-single");-const $exportNoteCountWrapper = $("#export-progress-count-wrapper");-const $exportNoteCount = $("#export-progress-count");+const $exportProgressWrapper = $("#export-progress-count-wrapper");+const $exportProgressCount = $("#export-progress-count");const $exportButton = $("#export-button");let exportId = '';@@ -22,8 +22,8 @@ async function showDialog(defaultType) {// each opening of the dialog resets the exportId so we don't associate it with previous exports anymoreexportId = '';$exportButton.removeAttr("disabled");- $exportNoteCountWrapper.hide();- $exportNoteCount.text('0');+ $exportProgressWrapper.hide();+ $exportProgressCount.text('0');if (defaultType === 'subtree') {$subtreeType.prop("checked", true).change();@@ -108,9 +108,9 @@ messagingService.subscribeToMessages(async message => {}if (message.type === 'export-progress-count') {- $exportNoteCountWrapper.show();+ $exportProgressWrapper.slideDown();- $exportNoteCount.text(message.progressCount);+ $exportProgressCount.text(message.progressCount);}else if (message.type === 'export-finished') {$dialog.modal('hide');diff --git a/src/public/javascripts/dialogs/import.js b/src/public/javascripts/dialogs/import.jsindex 905d178e32..d94a1fc0b0 100644--- a/src/public/javascripts/dialogs/import.js+++ b/src/public/javascripts/dialogs/import.js@@ -9,8 +9,8 @@ const $dialog = $("#import-dialog");const $form = $("#import-form");const $noteTitle = $dialog.find(".note-title");const $fileUploadInput = $("#import-file-upload-input");-const $importNoteCountWrapper = $("#import-progress-count-wrapper");-const $importNoteCount = $("#import-progress-count");+const $importProgressCountWrapper = $("#import-progress-count-wrapper");+const $importProgressCount = $("#import-progress-count");const $importButton = $("#import-button");let importId;@@ -18,8 +18,8 @@ let importId;async function showDialog() {// each opening of the dialog resets the importId so we don't associate it with previous imports anymoreimportId = '';- $importNoteCountWrapper.hide();- $importNoteCount.text('0');+ $importProgressCountWrapper.hide();+ $importProgressCount.text('0');$fileUploadInput.val('').change(); // to trigger Import button disabling listener belowglob.activeDialog = $dialog;@@ -75,9 +75,9 @@ messagingService.subscribeToMessages(async message => {}if (message.type === 'import-progress-count') {- $importNoteCountWrapper.show();+ $importProgressCountWrapper.slideDown();- $importNoteCount.text(message.progressCount);+ $importProgressCount.text(message.progressCount);}else if (message.type === 'import-finished') {$dialog.modal('hide');diff --git a/src/routes/api/export.js b/src/routes/api/export.jsindex 304c5b920c..5215872673 100644--- a/src/routes/api/export.js+++ b/src/routes/api/export.js@@ -20,7 +20,7 @@ class ExportContext {async increaseProgressCount() {this.progressCount++;- if (Date.now() - this.lastSentCountTs >= 200) {+ if (Date.now() - this.lastSentCountTs >= 500) {this.lastSentCountTs = Date.now();await messagingService.sendMessageToAllClients({diff --git a/src/routes/api/import.js b/src/routes/api/import.jsindex ec63abd8f3..23c7eaa14a 100644--- a/src/routes/api/import.js+++ b/src/routes/api/import.js@@ -17,20 +17,20 @@ class ImportContext {// to have multiple imports going at the same timethis.importId = importId;// // count is mean to represent count of exported notes where practical, otherwise it's just some measure of progress- this.count = 0;+ this.progressCount = 0;this.lastSentCountTs = Date.now();}async increaseProgressCount() {- this.count++;+ this.progressCount++;- if (Date.now() - this.lastSentCountTs >= 200) {+ if (Date.now() - this.lastSentCountTs >= 500) {this.lastSentCountTs = Date.now();await messagingService.sendMessageToAllClients({importId: this.importId,type: 'import-progress-count',- count: this.count+ progressCount: this.progressCount});}}diff --git a/src/services/import/tar.js b/src/services/import/tar.jsindex 98483e3225..cca223e2d6 100644--- a/src/services/import/tar.js+++ b/src/services/import/tar.js@@ -24,7 +24,6 @@ let lastSentCountTs = Date.now();*/async function importTar(importContext, fileBuffer, importRootNote) {importNoteCount = 0;- throw new Error("Hello");// maps from original noteId (in tar file) to newly generated noteIdconst noteIdMap = {};const attributes = [];diff --git a/src/views/dialogs/export.ejs b/src/views/dialogs/export.ejsindex 9f31007a64..30c9337560 100644--- a/src/views/dialogs/export.ejs+++ b/src/views/dialogs/export.ejs@@ -9,6 +9,10 @@</div><form id="export-form"><div class="modal-body">+ <div id="export-progress-count-wrapper" class="alert alert-primary" style="padding: 15px;">+ <strong>Note export progress count:</strong> <span id="export-progress-count"></span>+ </div>+<div class="form-check"><input class="form-check-input" type="radio" name="export-type" id="export-type-subtree" value="subtree"><label class="form-check-label" for="export-type-subtree">this note and all of its descendants</label>@@ -57,10 +61,6 @@</label></div></div>-- <div id="export-progress-count-wrapper">- <strong>Note export progress count:</strong> <span id="export-progress-count"></span>- </div></div><div class="modal-footer"><button class="btn btn-primary" id="export-button">Export</button>diff --git a/src/views/dialogs/import.ejs b/src/views/dialogs/import.ejsindex 0f84b1a697..786ca292df 100644--- a/src/views/dialogs/import.ejs+++ b/src/views/dialogs/import.ejs@@ -9,6 +9,10 @@</div><form id="import-form"><div class="modal-body">+ <div id="import-progress-count-wrapper" class="alert alert-primary" style="padding: 15px;">+ <strong>Note import progress count:</strong> <span id="import-progress-count"></span>+ </div>+<div class="form-group"><label for="import-file-upload-input"><strong>Choose import file</strong></label>@@ -27,10 +31,6 @@Trilium <code>.tar</code> export files can contain executable scripts which may contain harmful behavior. Safe import will deactivate automatic execution of all imported scripts. Uncheck "Safe import" only if the imported tar archive is supposed to contain executable scripts and you completely trust the contents of the import file.</div></div>-- <div id="import-progress-count-wrapper">- <strong>Note import progress count:</strong> <span id="import-progress-count"></span>- </div></div><div class="modal-footer"><button class="btn btn-primary" id="import-button">Import</button>