UI for export of OPML v2, WIP

This commit is contained in:
zadam
2019-02-16 23:33:40 +01:00
parent 1359dd86c2
commit 6fd8e73150
6 changed files with 41 additions and 7 deletions

View File

@@ -15,6 +15,7 @@ const $singleType = $("#export-type-single");
const $exportProgressWrapper = $("#export-progress-count-wrapper");
const $exportProgressCount = $("#export-progress-count");
const $exportButton = $("#export-button");
const $opmlVersions = $("#opml-versions");
let exportId = '';
@@ -27,6 +28,9 @@ async function showDialog(defaultType) {
if (defaultType === 'subtree') {
$subtreeType.prop("checked", true).change();
// to show/hide OPML versions
$("input[name=export-subtree-format]:checked").change();
}
else if (defaultType === 'single') {
$singleType.prop("checked", true).change();
@@ -61,17 +65,19 @@ $form.submit(() => {
? $("input[name=export-subtree-format]:checked").val()
: $("input[name=export-single-format]:checked").val();
const exportVersion = exportFormat === 'opml' ? $dialog.find("input[name='opml-version']:checked").val() : "1.0";
const currentNode = treeService.getCurrentNode();
exportBranch(currentNode.data.branchId, exportType, exportFormat);
exportBranch(currentNode.data.branchId, exportType, exportFormat, exportVersion);
return false;
});
function exportBranch(branchId, type, format) {
function exportBranch(branchId, type, format, version) {
exportId = utils.randomString(10);
const url = utils.getHost() + `/api/notes/${branchId}/export/${type}/${format}/${exportId}?protectedSessionId=` + encodeURIComponent(protectedSessionHolder.getProtectedSessionId());
const url = utils.getHost() + `/api/notes/${branchId}/export/${type}/${format}/${version}/${exportId}?protectedSessionId=` + encodeURIComponent(protectedSessionHolder.getProtectedSessionId());
utils.download(url);
}
@@ -95,6 +101,15 @@ $('input[name=export-type]').change(function () {
}
});
$('input[name=export-subtree-format]').change(function () {
if (this.value === 'opml') {
$opmlVersions.slideDown();
}
else {
$opmlVersions.slideUp();
}
});
messagingService.subscribeToMessages(async message => {
if (message.type === 'export-error') {
infoService.showError(message.message);