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 $singleFormats = $("#export-single-formats");
|
||||||
const $subtreeType = $("#export-type-subtree");
|
const $subtreeType = $("#export-type-subtree");
|
||||||
const $singleType = $("#export-type-single");
|
const $singleType = $("#export-type-single");
|
||||||
const $exportNoteCountWrapper = $("#export-progress-count-wrapper");
|
const $exportProgressWrapper = $("#export-progress-count-wrapper");
|
||||||
const $exportNoteCount = $("#export-progress-count");
|
const $exportProgressCount = $("#export-progress-count");
|
||||||
const $exportButton = $("#export-button");
|
const $exportButton = $("#export-button");
|
||||||
|
|
||||||
let exportId = '';
|
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
|
// each opening of the dialog resets the exportId so we don't associate it with previous exports anymore
|
||||||
exportId = '';
|
exportId = '';
|
||||||
$exportButton.removeAttr("disabled");
|
$exportButton.removeAttr("disabled");
|
||||||
$exportNoteCountWrapper.hide();
|
$exportProgressWrapper.hide();
|
||||||
$exportNoteCount.text('0');
|
$exportProgressCount.text('0');
|
||||||
|
|
||||||
if (defaultType === 'subtree') {
|
if (defaultType === 'subtree') {
|
||||||
$subtreeType.prop("checked", true).change();
|
$subtreeType.prop("checked", true).change();
|
||||||
@ -108,9 +108,9 @@ messagingService.subscribeToMessages(async message => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (message.type === 'export-progress-count') {
|
if (message.type === 'export-progress-count') {
|
||||||
$exportNoteCountWrapper.show();
|
$exportProgressWrapper.slideDown();
|
||||||
|
|
||||||
$exportNoteCount.text(message.progressCount);
|
$exportProgressCount.text(message.progressCount);
|
||||||
}
|
}
|
||||||
else if (message.type === 'export-finished') {
|
else if (message.type === 'export-finished') {
|
||||||
$dialog.modal('hide');
|
$dialog.modal('hide');
|
||||||
|
@ -9,8 +9,8 @@ const $dialog = $("#import-dialog");
|
|||||||
const $form = $("#import-form");
|
const $form = $("#import-form");
|
||||||
const $noteTitle = $dialog.find(".note-title");
|
const $noteTitle = $dialog.find(".note-title");
|
||||||
const $fileUploadInput = $("#import-file-upload-input");
|
const $fileUploadInput = $("#import-file-upload-input");
|
||||||
const $importNoteCountWrapper = $("#import-progress-count-wrapper");
|
const $importProgressCountWrapper = $("#import-progress-count-wrapper");
|
||||||
const $importNoteCount = $("#import-progress-count");
|
const $importProgressCount = $("#import-progress-count");
|
||||||
const $importButton = $("#import-button");
|
const $importButton = $("#import-button");
|
||||||
|
|
||||||
let importId;
|
let importId;
|
||||||
@ -18,8 +18,8 @@ let importId;
|
|||||||
async function showDialog() {
|
async function showDialog() {
|
||||||
// each opening of the dialog resets the importId so we don't associate it with previous imports anymore
|
// each opening of the dialog resets the importId so we don't associate it with previous imports anymore
|
||||||
importId = '';
|
importId = '';
|
||||||
$importNoteCountWrapper.hide();
|
$importProgressCountWrapper.hide();
|
||||||
$importNoteCount.text('0');
|
$importProgressCount.text('0');
|
||||||
$fileUploadInput.val('').change(); // to trigger Import button disabling listener below
|
$fileUploadInput.val('').change(); // to trigger Import button disabling listener below
|
||||||
|
|
||||||
glob.activeDialog = $dialog;
|
glob.activeDialog = $dialog;
|
||||||
@ -75,9 +75,9 @@ messagingService.subscribeToMessages(async message => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (message.type === 'import-progress-count') {
|
if (message.type === 'import-progress-count') {
|
||||||
$importNoteCountWrapper.show();
|
$importProgressCountWrapper.slideDown();
|
||||||
|
|
||||||
$importNoteCount.text(message.progressCount);
|
$importProgressCount.text(message.progressCount);
|
||||||
}
|
}
|
||||||
else if (message.type === 'import-finished') {
|
else if (message.type === 'import-finished') {
|
||||||
$dialog.modal('hide');
|
$dialog.modal('hide');
|
||||||
|
@ -20,7 +20,7 @@ class ExportContext {
|
|||||||
async increaseProgressCount() {
|
async increaseProgressCount() {
|
||||||
this.progressCount++;
|
this.progressCount++;
|
||||||
|
|
||||||
if (Date.now() - this.lastSentCountTs >= 200) {
|
if (Date.now() - this.lastSentCountTs >= 500) {
|
||||||
this.lastSentCountTs = Date.now();
|
this.lastSentCountTs = Date.now();
|
||||||
|
|
||||||
await messagingService.sendMessageToAllClients({
|
await messagingService.sendMessageToAllClients({
|
||||||
|
@ -17,20 +17,20 @@ class ImportContext {
|
|||||||
// to have multiple imports going at the same time
|
// to have multiple imports going at the same time
|
||||||
this.importId = importId;
|
this.importId = importId;
|
||||||
// // count is mean to represent count of exported notes where practical, otherwise it's just some measure of progress
|
// // 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();
|
this.lastSentCountTs = Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
async increaseProgressCount() {
|
async increaseProgressCount() {
|
||||||
this.count++;
|
this.progressCount++;
|
||||||
|
|
||||||
if (Date.now() - this.lastSentCountTs >= 200) {
|
if (Date.now() - this.lastSentCountTs >= 500) {
|
||||||
this.lastSentCountTs = Date.now();
|
this.lastSentCountTs = Date.now();
|
||||||
|
|
||||||
await messagingService.sendMessageToAllClients({
|
await messagingService.sendMessageToAllClients({
|
||||||
importId: this.importId,
|
importId: this.importId,
|
||||||
type: 'import-progress-count',
|
type: 'import-progress-count',
|
||||||
count: this.count
|
progressCount: this.progressCount
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ let lastSentCountTs = Date.now();
|
|||||||
*/
|
*/
|
||||||
async function importTar(importContext, fileBuffer, importRootNote) {
|
async function importTar(importContext, fileBuffer, importRootNote) {
|
||||||
importNoteCount = 0;
|
importNoteCount = 0;
|
||||||
throw new Error("Hello");
|
|
||||||
// maps from original noteId (in tar file) to newly generated noteId
|
// maps from original noteId (in tar file) to newly generated noteId
|
||||||
const noteIdMap = {};
|
const noteIdMap = {};
|
||||||
const attributes = [];
|
const attributes = [];
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<form id="export-form">
|
<form id="export-form">
|
||||||
<div class="modal-body">
|
<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">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="radio" name="export-type" id="export-type-subtree" value="subtree">
|
<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>
|
<label class="form-check-label" for="export-type-subtree">this note and all of its descendants</label>
|
||||||
@ -57,10 +61,6 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="export-progress-count-wrapper">
|
|
||||||
<strong>Note export progress count:</strong> <span id="export-progress-count"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn btn-primary" id="export-button">Export</button>
|
<button class="btn btn-primary" id="export-button">Export</button>
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<form id="import-form">
|
<form id="import-form">
|
||||||
<div class="modal-body">
|
<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">
|
<div class="form-group">
|
||||||
<label for="import-file-upload-input"><strong>Choose import file</strong></label>
|
<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.
|
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>
|
</div>
|
||||||
|
|
||||||
<div id="import-progress-count-wrapper">
|
|
||||||
<strong>Note import progress count:</strong> <span id="import-progress-count"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn btn-primary" id="import-button">Import</button>
|
<button class="btn btn-primary" id="import-button">Import</button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user