mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
further refactoring of export notifications
This commit is contained in:
parent
56e4f4f5ac
commit
b890859025
@ -10,8 +10,6 @@ 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 $exportProgressWrapper = $("#export-progress-count-wrapper");
|
|
||||||
const $exportProgressCount = $("#export-progress-count");
|
|
||||||
const $exportButton = $("#export-button");
|
const $exportButton = $("#export-button");
|
||||||
const $opmlVersions = $("#opml-versions");
|
const $opmlVersions = $("#opml-versions");
|
||||||
|
|
||||||
@ -24,8 +22,6 @@ export async function showDialog(node, defaultType) {
|
|||||||
// each opening of the dialog resets the taskId so we don't associate it with previous exports anymore
|
// each opening of the dialog resets the taskId so we don't associate it with previous exports anymore
|
||||||
taskId = '';
|
taskId = '';
|
||||||
$exportButton.removeAttr("disabled");
|
$exportButton.removeAttr("disabled");
|
||||||
$exportProgressWrapper.hide();
|
|
||||||
$exportProgressCount.text('0');
|
|
||||||
|
|
||||||
if (defaultType === 'subtree') {
|
if (defaultType === 'subtree') {
|
||||||
$subtreeType.prop("checked", true).change();
|
$subtreeType.prop("checked", true).change();
|
||||||
@ -54,8 +50,7 @@ export async function showDialog(node, defaultType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$form.submit(() => {
|
$form.submit(() => {
|
||||||
// disabling so export can't be triggered again
|
$dialog.modal('hide');
|
||||||
$exportButton.attr("disabled", "disabled");
|
|
||||||
|
|
||||||
const exportType = $dialog.find("input[name='export-type']:checked").val();
|
const exportType = $dialog.find("input[name='export-type']:checked").val();
|
||||||
|
|
||||||
@ -112,26 +107,27 @@ $('input[name=export-subtree-format]').change(function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function makeToast(id, message) {
|
||||||
|
return {
|
||||||
|
id: id,
|
||||||
|
title: "Export status",
|
||||||
|
message: message,
|
||||||
|
icon: "arrow-square-up-right"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
ws.subscribeToMessages(async message => {
|
ws.subscribeToMessages(async message => {
|
||||||
if (message.type === 'task-error' && message.taskType === 'export') {
|
if (message.type === 'task-error' && message.taskType === 'export') {
|
||||||
|
infoService.closePersistent(message.taskId);
|
||||||
infoService.showError(message.message);
|
infoService.showError(message.message);
|
||||||
$dialog.modal('hide');
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (message.type === 'task-progress-count' && message.taskType === 'export') {
|
||||||
if (!message.taskId || message.taskId !== taskId) {
|
infoService.showPersistent(makeToast(message.taskId, "Export in progress: " + message.progressCount));
|
||||||
// incoming messages must correspond to this export instance
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.type === 'task-progress-count' && message.taskType === 'export') {
|
|
||||||
$exportProgressWrapper.slideDown();
|
|
||||||
|
|
||||||
$exportProgressCount.text(message.progressCount);
|
|
||||||
}
|
}
|
||||||
else if (message.type === 'task-succeeded' && message.taskType === 'export') {
|
else if (message.type === 'task-succeeded' && message.taskType === 'export') {
|
||||||
$dialog.modal('hide');
|
const toast = makeToast(message.taskId, "Import finished successfully.");
|
||||||
|
toast.closeAfter = 5000;
|
||||||
|
|
||||||
infoService.showMessage("Export finished successfully.");
|
infoService.showPersistent(toast);
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -51,14 +51,11 @@ ws.subscribeToMessages(async message => {
|
|||||||
if (message.type === 'task-error' && message.taskType === 'import') {
|
if (message.type === 'task-error' && message.taskType === 'import') {
|
||||||
infoService.closePersistent(message.taskId);
|
infoService.closePersistent(message.taskId);
|
||||||
infoService.showError(message.message);
|
infoService.showError(message.message);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (message.type === 'task-progress-count' && message.taskType === 'import') {
|
||||||
if (message.type === 'task-progress-count' && message.taskType === 'import') {
|
|
||||||
infoService.showPersistent(makeToast(message.taskId, "Import in progress: " + message.progressCount));
|
infoService.showPersistent(makeToast(message.taskId, "Import in progress: " + message.progressCount));
|
||||||
}
|
}
|
||||||
|
else if (message.type === 'task-succeeded' && message.taskType === 'import') {
|
||||||
if (message.type === 'task-succeeded' && message.taskType === 'import') {
|
|
||||||
const toast = makeToast(message.taskId, "Import finished successfully.");
|
const toast = makeToast(message.taskId, "Import finished successfully.");
|
||||||
toast.closeAfter = 5000;
|
toast.closeAfter = 5000;
|
||||||
|
|
||||||
|
@ -9,10 +9,6 @@
|
|||||||
</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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user