mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
39 lines
978 B
JavaScript
39 lines
978 B
JavaScript
import treeService from './tree.js';
|
|
import protectedSessionService from './protected_session.js';
|
|
import utils from './utils.js';
|
|
|
|
function exportSubTree(noteId) {
|
|
const url = utils.getHost() + "/api/export/" + noteId + "?protectedSessionId="
|
|
+ encodeURIComponent(protectedSessionService.getProtectedSessionId());
|
|
|
|
utils.download(url);
|
|
}
|
|
|
|
let importNoteId;
|
|
|
|
function importSubTree(noteId) {
|
|
importNoteId = noteId;
|
|
|
|
$("#import-upload").trigger('click');
|
|
}
|
|
|
|
$("#import-upload").change(async function() {
|
|
const formData = new FormData();
|
|
formData.append('upload', this.files[0]);
|
|
|
|
await $.ajax({
|
|
url: baseApiUrl + 'import/' + importNoteId,
|
|
headers: server.getHeaders(),
|
|
data: formData,
|
|
type: 'POST',
|
|
contentType: false, // NEEDED, DON'T OMIT THIS
|
|
processData: false, // NEEDED, DON'T OMIT THIS
|
|
});
|
|
|
|
await treeService.reload();
|
|
});
|
|
|
|
export default {
|
|
exportSubTree,
|
|
importSubTree
|
|
}; |