renamed notefull to notecomplement

This commit is contained in:
zadam 2020-02-01 11:15:58 +01:00
parent eeedb91ef7
commit f6f7836b8e
19 changed files with 49 additions and 51 deletions

6
package-lock.json generated
View file

@ -7268,9 +7268,9 @@
"integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=" "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k="
}, },
"open": { "open": {
"version": "7.0.1", "version": "7.0.2",
"resolved": "https://registry.npmjs.org/open/-/open-7.0.1.tgz", "resolved": "https://registry.npmjs.org/open/-/open-7.0.2.tgz",
"integrity": "sha512-/fVm742AZt6bZ3NpbmBzGpZksDiGbo+xz8RylegKSAnTCgT5u5tvJe0cre3QxICphqHhJHc0OFtFyvU7rNx8+Q==", "integrity": "sha512-70E/pFTPr7nZ9nLDPNTcj3IVqnNvKuP4VsBmoKV9YGTnChe0mlS3C4qM7qKarhZ8rGaHKLfo+vBTHXDp6ZSyLQ==",
"requires": { "requires": {
"is-docker": "^2.0.0", "is-docker": "^2.0.0",
"is-wsl": "^2.1.1" "is-wsl": "^2.1.1"

View file

@ -54,7 +54,7 @@
"mime-types": "2.1.26", "mime-types": "2.1.26",
"multer": "1.4.2", "multer": "1.4.2",
"node-abi": "2.13.0", "node-abi": "2.13.0",
"open": "7.0.1", "open": "7.0.2",
"pngjs": "3.4.0", "pngjs": "3.4.0",
"portscanner": "2.2.0", "portscanner": "2.2.0",
"rand-token": "0.4.0", "rand-token": "0.4.0",

View file

@ -16,11 +16,11 @@ export function showDialog() {
$dialog.modal(); $dialog.modal();
const {note, noteFull} = appContext.getActiveTabContext(); const {note, noteComplement} = appContext.getActiveTabContext();
$noteId.text(note.noteId); $noteId.text(note.noteId);
$dateCreated.text(noteFull.dateCreated); $dateCreated.text(noteComplement.dateCreated);
$dateModified.text(noteFull.dateModified); $dateModified.text(noteComplement.dateModified);
$type.text(note.type); $type.text(note.type);
$mime.text(note.mime); $mime.text(note.mime);
} }

View file

@ -1,10 +1,11 @@
import NoteShort from './note_short.js';
/** /**
* Represents full note, specifically including note's content. * Complements the NoteShort with the main note content and other extra attributes
*/ */
class NoteFull { class NoteComplement {
constructor(row) { constructor(row) {
/** @param {string} */
this.noteId = row.noteId;
/** @param {string} */ /** @param {string} */
this.content = row.content; this.content = row.content;
@ -22,4 +23,4 @@ class NoteFull {
} }
} }
export default NoteFull; export default NoteComplement;

View file

@ -171,7 +171,7 @@ class AppContext {
return activeContext ? activeContext.notePath : null; return activeContext ? activeContext.notePath : null;
} }
/** @return {NoteFull} */ /** @return {NoteShort} */
getActiveTabNote() { getActiveTabNote() {
const activeContext = this.getActiveTabContext(); const activeContext = this.getActiveTabContext();
return activeContext ? activeContext.note : null; return activeContext ? activeContext.note : null;

View file

@ -289,7 +289,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
/** /**
* @method * @method
* @returns {NoteFull} active note (loaded into right pane) * @returns {NoteShort} active note (loaded into right pane)
*/ */
this.getActiveTabNote = appContext.getActiveTabNote; this.getActiveTabNote = appContext.getActiveTabNote;

View file

@ -1,7 +1,7 @@
import server from './server.js'; import server from './server.js';
import ws from "./ws.js"; import ws from "./ws.js";
import treeCache from "./tree_cache.js"; import treeCache from "./tree_cache.js";
import NoteFull from "../entities/note_full.js"; import NoteComplement from "../entities/note_full.js";
import appContext from "./app_context.js"; import appContext from "./app_context.js";
function getActiveEditor() { function getActiveEditor() {
@ -15,10 +15,10 @@ function getActiveEditor() {
} }
} }
async function loadNoteFull(noteId) { async function loadNoteComplement(noteId) {
const row = await server.get('notes/' + noteId); const row = await server.get('notes/' + noteId);
return new NoteFull(row); return new NoteComplement(row);
} }
function focusOnTitle() { function focusOnTitle() {
@ -45,7 +45,7 @@ $(window).on('beforeunload', () => {
}); });
export default { export default {
loadNoteFull, loadNoteComplement,
focusOnTitle, focusOnTitle,
focusAndSelectTitle, focusAndSelectTitle,
getActiveEditor, getActiveEditor,

View file

@ -44,9 +44,9 @@ async function mouseEnterHandler() {
const noteId = treeService.getNoteIdFromNotePath(notePath); const noteId = treeService.getNoteIdFromNotePath(notePath);
const note = await treeCache.getNote(noteId); const note = await treeCache.getNote(noteId);
const noteFull = await noteDetailService.loadNoteFull(noteId); const noteComplement = await noteDetailService.loadNoteComplement(noteId);
const html = await renderTooltip(note, noteFull); const html = await renderTooltip(note, noteComplement);
// we need to check if we're still hovering over the element // we need to check if we're still hovering over the element
// since the operation to get tooltip content was async, it is possible that // since the operation to get tooltip content was async, it is possible that
@ -71,7 +71,7 @@ function mouseLeaveHandler() {
$(this).tooltip('dispose'); $(this).tooltip('dispose');
} }
async function renderTooltip(note, noteFull) { async function renderTooltip(note, noteComplement) {
const attributes = await note.getAttributes(); const attributes = await note.getAttributes();
let content = ''; let content = '';
@ -117,11 +117,11 @@ async function renderTooltip(note, noteFull) {
if (note.type === 'text') { if (note.type === 'text') {
// surround with <div> for a case when note's content is pure text (e.g. "[protected]") which // surround with <div> for a case when note's content is pure text (e.g. "[protected]") which
// then fails the jquery non-empty text test // then fails the jquery non-empty text test
content += '<div>' + noteFull.content + '</div>'; content += '<div>' + noteComplement.content + '</div>';
} }
else if (note.type === 'code') { else if (note.type === 'code') {
content += $("<pre>") content += $("<pre>")
.text(noteFull.content) .text(noteComplement.content)
.prop('outerHTML'); .prop('outerHTML');
} }
else if (note.type === 'image') { else if (note.type === 'image') {

View file

@ -51,8 +51,8 @@ class TabContext extends Component {
/** @property {NoteShort} */ /** @property {NoteShort} */
this.note = await treeCache.getNote(noteId); this.note = await treeCache.getNote(noteId);
/** @property {NoteFull} */ /** @property {NoteComplement} */
this.noteFull = await noteDetailService.loadNoteFull(noteId); this.noteComplement = await noteDetailService.loadNoteComplement(noteId);
//this.cleanup(); // esp. on windows autocomplete is not getting closed automatically //this.cleanup(); // esp. on windows autocomplete is not getting closed automatically

View file

@ -1,7 +1,9 @@
import utils from '../services/utils.js';
export default class Component { export default class Component {
/** @param {AppContext} appContext */ /** @param {AppContext} appContext */
constructor(appContext) { constructor(appContext) {
this.componentId = `component-${this.constructor.name}`; this.componentId = `comp-${this.constructor.name}-` + utils.randomString(10);
this.appContext = appContext; this.appContext = appContext;
/** @type Component[] */ /** @type Component[] */
this.children = []; this.children = [];

View file

@ -37,18 +37,17 @@ export default class NoteDetailWidget extends TabAwareWidget {
this.typeWidgetPromises = {}; this.typeWidgetPromises = {};
this.spacedUpdate = new SpacedUpdate(async () => { this.spacedUpdate = new SpacedUpdate(async () => {
const {noteFull, note} = this.tabContext; const {noteComplement, note} = this.tabContext;
const {noteId} = note; const {noteId} = note;
// FIXME hack // FIXME hack
const dto = note.dto; const dto = note.dto;
dto.content = noteFull.content = this.getTypeWidget().getContent(); dto.content = noteComplement.content = this.getTypeWidget().getContent();
const resp = await server.put('notes/' + noteId, dto, this.componentId); const resp = await server.put('notes/' + noteId, dto, this.componentId);
// FIXME: minor - does not propagate to other tab contexts with this note though noteComplement.dateModified = resp.dateModified;
noteFull.dateModified = resp.dateModified; noteComplement.utcDateModified = resp.utcDateModified;
noteFull.utcDateModified = resp.utcDateModified;
this.trigger('noteChangesSaved', {noteId}) this.trigger('noteChangesSaved', {noteId})
}); });
@ -161,7 +160,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
let type = note.type; let type = note.type;
if (type === 'text' && !disableAutoBook if (type === 'text' && !disableAutoBook
&& utils.isHtmlEmpty(this.tabContext.noteFull.content) && utils.isHtmlEmpty(this.tabContext.noteComplement.content)
&& note.hasChildren()) { && note.hasChildren()) {
type = 'book'; type = 'book';
@ -223,9 +222,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
async entitiesReloadedListener({loadResults}) { async entitiesReloadedListener({loadResults}) {
if (loadResults.isNoteContentReloaded(this.noteId, this.componentId)) { if (loadResults.isNoteContentReloaded(this.noteId, this.componentId)) {
this.tabContext.noteFull = await noteDetailService.loadNoteFull(this.noteId); this.tabContext.noteComplement = await noteDetailService.loadNoteComplement(this.noteId);
console.log("Reloaded", this.tabContext.noteFull);
this.refreshWithNote(this.note, this.notePath); this.refreshWithNote(this.note, this.notePath);
} }

View file

@ -49,16 +49,16 @@ class NoteInfoWidget extends StandardWidget {
const $type = this.$body.find(".note-info-type"); const $type = this.$body.find(".note-info-type");
const $mime = this.$body.find(".note-info-mime"); const $mime = this.$body.find(".note-info-mime");
const {noteFull} = this.tabContext; const {noteComplement} = this.tabContext;
$noteId.text(note.noteId); $noteId.text(note.noteId);
$dateCreated $dateCreated
.text(noteFull.dateCreated) .text(noteComplement.dateCreated)
.attr("title", noteFull.dateCreated); .attr("title", noteComplement.dateCreated);
$dateModified $dateModified
.text(noteFull.dateModified) .text(noteComplement.dateModified)
.attr("title", noteFull.dateCreated); .attr("title", noteComplement.dateCreated);
$type.text(note.type); $type.text(note.type);

View file

@ -75,7 +75,7 @@ export default class CodeTypeWidget extends TypeWidget {
this.spacedUpdate.allowUpdateWithoutChange(() => { this.spacedUpdate.allowUpdateWithoutChange(() => {
// CodeMirror breaks pretty badly on null so even though it shouldn't happen (guarded by consistency check) // CodeMirror breaks pretty badly on null so even though it shouldn't happen (guarded by consistency check)
// we provide fallback // we provide fallback
this.codeEditor.setValue(this.tabContext.noteFull.content || ""); this.codeEditor.setValue(this.tabContext.noteComplement.content || "");
const info = CodeMirror.findModeByMIME(note.mime); const info = CodeMirror.findModeByMIME(note.mime);

View file

@ -128,9 +128,9 @@ export default class FileTypeWidget extends TypeWidget {
this.$fileSize.text(note.contentLength + " bytes"); this.$fileSize.text(note.contentLength + " bytes");
this.$fileType.text(note.mime); this.$fileType.text(note.mime);
if (this.tabContext.noteFull.content) { if (this.tabContext.noteComplement.content) {
this.$previewContent.show(); this.$previewContent.show();
this.$previewContent.text(this.tabContext.noteFull.content); this.$previewContent.text(this.tabContext.noteComplement.content);
} }
else { else {
this.$previewContent.empty().hide(); this.$previewContent.empty().hide();

View file

@ -132,7 +132,7 @@ class NoteDetailImage extends TypeWidget {
this.$fileSize.text(note.contentLength + " bytes"); this.$fileSize.text(note.contentLength + " bytes");
this.$fileType.text(note.mime); this.$fileType.text(note.mime);
const imageHash = this.tabContext.noteFull.utcDateModified.replace(" ", "_"); const imageHash = this.tabContext.noteComplement.utcDateModified.replace(" ", "_");
this.$imageView.prop("src", `api/images/${note.noteId}/${note.title}?${imageHash}`); this.$imageView.prop("src", `api/images/${note.noteId}/${note.title}?${imageHash}`);
} }

View file

@ -254,9 +254,9 @@ export default class RelationMapTypeWidget extends TypeWidget {
} }
}; };
if (this.tabContext.noteFull.content) { if (this.tabContext.noteComplement.content) {
try { try {
this.mapData = JSON.parse(this.tabContext.noteFull.content); this.mapData = JSON.parse(this.tabContext.noteComplement.content);
} catch (e) { } catch (e) {
console.log("Could not parse content: ", e); console.log("Could not parse content: ", e);
} }

View file

@ -45,7 +45,7 @@ export default class SearchTypeWidget extends TypeWidget {
this.$component.show(); this.$component.show();
try { try {
const json = JSON.parse(this.tabContext.noteFull.content); const json = JSON.parse(this.tabContext.noteComplement.content);
this.$searchString.val(json.searchString); this.$searchString.val(json.searchString);
} }

View file

@ -140,7 +140,7 @@ export default class TextTypeWidget extends TypeWidget {
this.textEditor.isReadOnly = await note.hasLabel('readOnly'); this.textEditor.isReadOnly = await note.hasLabel('readOnly');
this.spacedUpdate.allowUpdateWithoutChange(() => { this.spacedUpdate.allowUpdateWithoutChange(() => {
this.textEditor.setData(this.tabContext.noteFull.content); this.textEditor.setData(this.tabContext.noteComplement.content);
}); });
} }

View file

@ -1,5 +1,3 @@
import * as syncService from "../services/sync.js";
const setupRoute = require('./setup'); const setupRoute = require('./setup');
const loginRoute = require('./login'); const loginRoute = require('./login');
const indexRoute = require('./index'); const indexRoute = require('./index');
@ -46,7 +44,7 @@ const auth = require('../services/auth');
const cls = require('../services/cls'); const cls = require('../services/cls');
const sql = require('../services/sql'); const sql = require('../services/sql');
const protectedSessionService = require('../services/protected_session'); const protectedSessionService = require('../services/protected_session');
const syncTableService = require('../services/sync_table'); const syncService = require('../services/sync');
const csurf = require('csurf'); const csurf = require('csurf');
const csrfMiddleware = csurf({ const csrfMiddleware = csurf({