2018-11-08 17:11:00 +08:00
|
|
|
import utils from "./utils.js";
|
|
|
|
import server from "./server.js";
|
|
|
|
import protectedSessionHolder from "./protected_session_holder.js";
|
|
|
|
import noteDetailService from "./note_detail.js";
|
|
|
|
|
2018-11-08 17:30:35 +08:00
|
|
|
const $component = $('#note-detail-image');
|
|
|
|
const $imageView = $('#note-detail-image-view');
|
2018-11-08 17:11:00 +08:00
|
|
|
|
2018-11-08 17:30:35 +08:00
|
|
|
const $imageDownload = $("#image-download");
|
2018-11-08 17:11:00 +08:00
|
|
|
|
|
|
|
async function show() {
|
|
|
|
const currentNote = noteDetailService.getCurrentNote();
|
|
|
|
|
2018-11-08 17:30:35 +08:00
|
|
|
$component.show();
|
2018-11-08 17:11:00 +08:00
|
|
|
|
2018-11-08 17:30:35 +08:00
|
|
|
$imageView.prop("src", `/api/images/${currentNote.noteId}/${currentNote.title}`);
|
2018-11-08 17:11:00 +08:00
|
|
|
}
|
|
|
|
|
2018-11-08 17:30:35 +08:00
|
|
|
$imageDownload.click(() => utils.download(getFileUrl()));
|
2018-11-08 17:11:00 +08:00
|
|
|
|
|
|
|
function getFileUrl() {
|
|
|
|
// electron needs absolute URL so we extract current host, port, protocol
|
|
|
|
return utils.getHost() + "/api/notes/" + noteDetailService.getCurrentNoteId()
|
|
|
|
+ "/download?protectedSessionId=" + encodeURIComponent(protectedSessionHolder.getProtectedSessionId());
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
show,
|
|
|
|
getContent: () => null,
|
|
|
|
focus: () => null,
|
|
|
|
onNoteChange: () => null,
|
|
|
|
cleanup: () => null
|
|
|
|
}
|