mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-05-03 18:59:09 -05:00
renamed "attachment" to "file" for consistency
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import utils from "./utils.js";
|
||||
import treeService from "./tree.js";
|
||||
import linkService from "./link.js";
|
||||
import attachmentService from "./attachment.js";
|
||||
import fileService from "./file.js";
|
||||
import noteRevisionsDialog from "../dialogs/note_revisions.js";
|
||||
import settingsDialog from "../dialogs/settings.js";
|
||||
import addLinkDialog from "../dialogs/add_link.js";
|
||||
@@ -125,7 +125,7 @@ function registerEntrypoints() {
|
||||
|
||||
$("#note-title").bind('keydown', 'return', () => $("#note-detail-text").focus());
|
||||
|
||||
$("#upload-attachment-button").click(attachmentService.uploadAttachment);
|
||||
$("#upload-file-button").click(fileService.uploadFile);
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
+5
-5
@@ -2,16 +2,16 @@ import noteDetailService from "./note_detail.js";
|
||||
import treeService from "./tree.js";
|
||||
import server from "./server.js";
|
||||
|
||||
function uploadAttachment() {
|
||||
$("#attachment-upload").trigger('click');
|
||||
function uploadFile() {
|
||||
$("#file-upload").trigger('click');
|
||||
}
|
||||
|
||||
$("#attachment-upload").change(async function() {
|
||||
$("#file-upload").change(async function() {
|
||||
const formData = new FormData();
|
||||
formData.append('upload', this.files[0]);
|
||||
|
||||
const resp = await $.ajax({
|
||||
url: baseApiUrl + 'attachments/upload/' + noteDetailService.getCurrentNoteId(),
|
||||
url: baseApiUrl + 'files/upload/' + noteDetailService.getCurrentNoteId(),
|
||||
headers: server.getHeaders(),
|
||||
data: formData,
|
||||
type: 'POST',
|
||||
@@ -25,5 +25,5 @@ $("#attachment-upload").change(async function() {
|
||||
});
|
||||
|
||||
export default {
|
||||
uploadAttachment
|
||||
uploadFile
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import treeCache from "./tree_cache.js";
|
||||
import NoteFull from "../entities/note_full.js";
|
||||
import noteDetailCode from './note_detail_code.js';
|
||||
import noteDetailText from './note_detail_text.js';
|
||||
import noteDetailAttachment from './note_detail_attachment.js';
|
||||
import noteDetailFile from './note_detail_file.js';
|
||||
import noteDetailSearch from './note_detail_search.js';
|
||||
import noteDetailRender from './note_detail_render.js';
|
||||
|
||||
@@ -34,7 +34,7 @@ let isNoteChanged = false;
|
||||
const components = {
|
||||
'code': noteDetailCode,
|
||||
'text': noteDetailText,
|
||||
'file': noteDetailAttachment,
|
||||
'file': noteDetailFile,
|
||||
'search': noteDetailSearch,
|
||||
'render': noteDetailRender
|
||||
};
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
import utils from "./utils.js";
|
||||
import server from "./server.js";
|
||||
import protectedSessionHolder from "./protected_session_holder.js";
|
||||
import noteDetailService from "./note_detail.js";
|
||||
|
||||
const $noteDetailAttachment = $('#note-detail-attachment');
|
||||
|
||||
const $attachmentFileName = $("#attachment-filename");
|
||||
const $attachmentFileType = $("#attachment-filetype");
|
||||
const $attachmentFileSize = $("#attachment-filesize");
|
||||
const $attachmentDownload = $("#attachment-download");
|
||||
const $attachmentOpen = $("#attachment-open");
|
||||
|
||||
async function show() {
|
||||
const currentNote = noteDetailService.getCurrentNote();
|
||||
|
||||
const labels = await server.get('notes/' + currentNote.noteId + '/labels');
|
||||
const labelMap = utils.toObject(labels, l => [l.name, l.value]);
|
||||
|
||||
$noteDetailAttachment.show();
|
||||
|
||||
$attachmentFileName.text(labelMap.original_file_name);
|
||||
$attachmentFileSize.text(labelMap.file_size + " bytes");
|
||||
$attachmentFileType.text(currentNote.mime);
|
||||
}
|
||||
|
||||
$attachmentDownload.click(() => utils.download(getAttachmentUrl()));
|
||||
|
||||
$attachmentOpen.click(() => {
|
||||
if (utils.isElectron()) {
|
||||
const open = require("open");
|
||||
|
||||
open(getAttachmentUrl());
|
||||
}
|
||||
else {
|
||||
window.location.href = getAttachmentUrl();
|
||||
}
|
||||
});
|
||||
|
||||
function getAttachmentUrl() {
|
||||
// electron needs absolute URL so we extract current host, port, protocol
|
||||
return utils.getHost() + "/api/attachments/download/" + noteDetailService.getCurrentNoteId()
|
||||
+ "?protectedSessionId=" + encodeURIComponent(protectedSessionHolder.getProtectedSessionId());
|
||||
}
|
||||
|
||||
export default {
|
||||
show,
|
||||
getContent: () => null,
|
||||
focus: () => null
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import utils from "./utils.js";
|
||||
import server from "./server.js";
|
||||
import protectedSessionHolder from "./protected_session_holder.js";
|
||||
import noteDetailService from "./note_detail.js";
|
||||
|
||||
const $noteDetailFile = $('#note-detail-file');
|
||||
|
||||
const $fileFileName = $("#file-filename");
|
||||
const $fileFileType = $("#file-filetype");
|
||||
const $fileFileSize = $("#file-filesize");
|
||||
const $fileDownload = $("#file-download");
|
||||
const $fileOpen = $("#file-open");
|
||||
|
||||
async function show() {
|
||||
const currentNote = noteDetailService.getCurrentNote();
|
||||
|
||||
const labels = await server.get('notes/' + currentNote.noteId + '/labels');
|
||||
const labelMap = utils.toObject(labels, l => [l.name, l.value]);
|
||||
|
||||
$noteDetailFile.show();
|
||||
|
||||
$fileFileName.text(labelMap.original_file_name);
|
||||
$fileFileSize.text(labelMap.file_size + " bytes");
|
||||
$fileFileType.text(currentNote.mime);
|
||||
}
|
||||
|
||||
$fileDownload.click(() => utils.download(getFileUrl()));
|
||||
|
||||
$fileOpen.click(() => {
|
||||
if (utils.isElectron()) {
|
||||
const open = require("open");
|
||||
|
||||
open(getFileUrl());
|
||||
}
|
||||
else {
|
||||
window.location.href = getFileUrl();
|
||||
}
|
||||
});
|
||||
|
||||
function getFileUrl() {
|
||||
// electron needs absolute URL so we extract current host, port, protocol
|
||||
return utils.getHost() + "/api/files/download/" + noteDetailService.getCurrentNoteId()
|
||||
+ "?protectedSessionId=" + encodeURIComponent(protectedSessionHolder.getProtectedSessionId());
|
||||
}
|
||||
|
||||
export default {
|
||||
show,
|
||||
getContent: () => null,
|
||||
focus: () => null
|
||||
}
|
||||
@@ -69,7 +69,7 @@ function NoteTypeModel() {
|
||||
return 'Render HTML note';
|
||||
}
|
||||
else if (type === 'file') {
|
||||
return 'Attachment';
|
||||
return 'File';
|
||||
}
|
||||
else if (type === 'search') {
|
||||
// ignore and do nothing, "type" will be hidden since it's not possible to switch to and from search
|
||||
|
||||
Reference in New Issue
Block a user