mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
delete progress
This commit is contained in:
parent
b890859025
commit
9f4ca279aa
@ -117,14 +117,18 @@ function makeToast(id, message) {
|
||||
}
|
||||
|
||||
ws.subscribeToMessages(async message => {
|
||||
if (message.type === 'task-error' && message.taskType === 'export') {
|
||||
if (message.taskType !== 'export') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.type === 'task-error') {
|
||||
infoService.closePersistent(message.taskId);
|
||||
infoService.showError(message.message);
|
||||
}
|
||||
else if (message.type === 'task-progress-count' && message.taskType === 'export') {
|
||||
else if (message.type === 'task-progress-count') {
|
||||
infoService.showPersistent(makeToast(message.taskId, "Export in progress: " + message.progressCount));
|
||||
}
|
||||
else if (message.type === 'task-succeeded' && message.taskType === 'export') {
|
||||
else if (message.type === 'task-succeeded') {
|
||||
const toast = makeToast(message.taskId, "Import finished successfully.");
|
||||
toast.closeAfter = 5000;
|
||||
|
||||
|
@ -6,6 +6,7 @@ import treeCache from "./tree_cache.js";
|
||||
import treeUtils from "./tree_utils.js";
|
||||
import hoistedNoteService from "./hoisted_note.js";
|
||||
import noteDetailService from "./note_detail.js";
|
||||
import ws from "./ws.js";
|
||||
|
||||
async function moveBeforeNode(nodesToMove, beforeNode) {
|
||||
nodesToMove = await filterRootNote(nodesToMove);
|
||||
@ -105,14 +106,16 @@ async function deleteNodes(nodes) {
|
||||
|
||||
const deleteClones = $deleteClonesCheckbox.find("input").is(":checked");
|
||||
|
||||
const taskId = utils.randomString(10);
|
||||
|
||||
for (const node of nodes) {
|
||||
if (deleteClones) {
|
||||
await server.remove('notes/' + node.data.noteId);
|
||||
await server.remove('notes/' + node.data.noteId + '?taskId=' + taskId);
|
||||
|
||||
noteDetailService.noteDeleted(node.data.noteId);
|
||||
}
|
||||
else {
|
||||
const {noteDeleted} = await server.remove('branches/' + node.data.branchId);
|
||||
const {noteDeleted} = await server.remove('branches/' + node.data.branchId + '?taskId=' + taskId);
|
||||
|
||||
if (noteDeleted) {
|
||||
noteDetailService.noteDeleted(node.data.noteId);
|
||||
@ -249,6 +252,33 @@ async function filterRootNote(nodes) {
|
||||
&& node.data.noteId !== hoistedNoteId);
|
||||
}
|
||||
|
||||
function makeToast(id, message) {
|
||||
return {
|
||||
id: id,
|
||||
title: "Delete status",
|
||||
message: message,
|
||||
icon: "trash"
|
||||
};
|
||||
}
|
||||
|
||||
ws.subscribeToMessages(async message => {
|
||||
if (message.taskType !== 'delete-notes') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.type === 'task-error') {
|
||||
infoService.closePersistent(message.taskId);
|
||||
infoService.showError(message.message);
|
||||
} else if (message.type === 'task-progress-count') {
|
||||
infoService.showPersistent(makeToast(message.taskId, "Delete notes in progress: " + message.progressCount));
|
||||
} else if (message.type === 'task-succeeded') {
|
||||
const toast = makeToast(message.taskId, "Delete finished successfully.");
|
||||
toast.closeAfter = 5000;
|
||||
|
||||
infoService.showPersistent(toast);
|
||||
}
|
||||
});
|
||||
|
||||
export default {
|
||||
moveBeforeNode,
|
||||
moveAfterNode,
|
||||
|
@ -48,14 +48,16 @@ function makeToast(id, message) {
|
||||
}
|
||||
|
||||
ws.subscribeToMessages(async message => {
|
||||
if (message.type === 'task-error' && message.taskType === 'import') {
|
||||
if (message.taskType !== 'import') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.type === 'task-error') {
|
||||
infoService.closePersistent(message.taskId);
|
||||
infoService.showError(message.message);
|
||||
}
|
||||
else if (message.type === 'task-progress-count' && message.taskType === 'import') {
|
||||
} else if (message.type === 'task-progress-count') {
|
||||
infoService.showPersistent(makeToast(message.taskId, "Import in progress: " + message.progressCount));
|
||||
}
|
||||
else if (message.type === 'task-succeeded' && message.taskType === 'import') {
|
||||
} else if (message.type === 'task-succeeded') {
|
||||
const toast = makeToast(message.taskId, "Import finished successfully.");
|
||||
toast.closeAfter = 5000;
|
||||
|
||||
|
@ -6,6 +6,7 @@ const sync_table = require('../../services/sync_table');
|
||||
const tree = require('../../services/tree');
|
||||
const notes = require('../../services/notes');
|
||||
const repository = require('../../services/repository');
|
||||
const TaskContext = require('../../services/task_context');
|
||||
|
||||
/**
|
||||
* Code in this file deals with moving and cloning branches. Relationship between note and parent note is unique
|
||||
@ -101,9 +102,10 @@ async function setExpanded(req) {
|
||||
|
||||
async function deleteBranch(req) {
|
||||
const branch = await repository.getBranch(req.params.branchId);
|
||||
const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes');
|
||||
|
||||
return {
|
||||
noteDeleted: await notes.deleteBranch(branch)
|
||||
noteDeleted: await notes.deleteBranch(branch, taskContext)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ async function importToBranch(req) {
|
||||
|
||||
let note; // typically root of the import - client can show it after finishing the import
|
||||
|
||||
const taskContext = TaskContext.getInstance(taskId, options);
|
||||
const taskContext = TaskContext.getInstance(taskId, 'import', options);
|
||||
|
||||
try {
|
||||
if (extension === '.tar' && options.explodeArchives) {
|
||||
|
@ -78,7 +78,7 @@ async function deleteNote(req) {
|
||||
|
||||
const note = await repository.getNote(noteId);
|
||||
|
||||
const taskContext = new TaskContext(utils.randomString(10), 'delete-note');
|
||||
const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes');
|
||||
|
||||
for (const branch of await note.getBranches()) {
|
||||
await noteService.deleteBranch(branch, taskContext);
|
||||
|
@ -17,9 +17,9 @@ class TaskContext {
|
||||
}
|
||||
|
||||
/** @return {TaskContext} */
|
||||
static getInstance(taskId, data) {
|
||||
static getInstance(taskId, taskType, data) {
|
||||
if (!taskContexts[taskId]) {
|
||||
taskContexts[taskId] = new TaskContext(taskId, 'import', data);
|
||||
taskContexts[taskId] = new TaskContext(taskId, taskType, data);
|
||||
}
|
||||
|
||||
return taskContexts[taskId];
|
||||
|
Loading…
x
Reference in New Issue
Block a user