mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
prettier progress count
This commit is contained in:
parent
8aa7e2d0a0
commit
caa7dd9619
@ -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 anymore
|
||||
exportId = '';
|
||||
$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');
|
||||
|
@ -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 anymore
|
||||
importId = '';
|
||||
$importNoteCountWrapper.hide();
|
||||
$importNoteCount.text('0');
|
||||
$importProgressCountWrapper.hide();
|
||||
$importProgressCount.text('0');
|
||||
$fileUploadInput.val('').change(); // to trigger Import button disabling listener below
|
||||
|
||||
glob.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');
|
||||
|
@ -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({
|
||||
|
@ -17,20 +17,20 @@ class ImportContext {
|
||||
// to have multiple imports going at the same time
|
||||
this.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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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 noteId
|
||||
const noteIdMap = {};
|
||||
const attributes = [];
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user