attachment upload and download now works for browser

This commit is contained in:
azivner
2018-02-18 21:28:24 -05:00
parent fda4146150
commit 78e8c15786
10 changed files with 98 additions and 19 deletions

View File

@@ -14,6 +14,10 @@ const noteEditor = (function() {
const $noteIdDisplay = $("#note-id-display");
const $attributeList = $("#attribute-list");
const $attributeListInner = $("#attribute-list-inner");
const $attachmentFileName = $("#attachment-filename");
const $attachmentFileType = $("#attachment-filetype");
const $attachmentFileSize = $("#attachment-filesize");
const $attachmentDownload = $("#attachment-download");
let editor = null;
let codeEditor = null;
@@ -83,7 +87,7 @@ const noteEditor = (function() {
else if (note.detail.type === 'code') {
note.detail.content = codeEditor.getValue();
}
else if (note.detail.type === 'render') {
else if (note.detail.type === 'render' || note.detail.type === 'file') {
// nothing
}
else {
@@ -185,6 +189,10 @@ const noteEditor = (function() {
}
else if (currentNote.detail.type === 'file') {
$noteDetailAttachment.show();
$attachmentFileName.text(currentNote.attributes.original_file_name);
$attachmentFileSize.text(currentNote.attributes.file_size + " bytes");
$attachmentFileType.text(currentNote.detail.mime);
}
else {
setContent(currentNote.detail.content);
@@ -237,7 +245,7 @@ const noteEditor = (function() {
else if (note.detail.type === 'code') {
codeEditor.focus();
}
else if (note.detail.type === 'render') {
else if (note.detail.type === 'render' || note.detail.type === 'file') {
// do nothing
}
else {
@@ -262,6 +270,10 @@ const noteEditor = (function() {
}
}
$attachmentDownload.click(() => {
window.location.href = "/api/attachments/download/" + getCurrentNoteId();
});
$(document).ready(() => {
$noteTitle.on('input', () => {
noteChanged();