mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
note revisions widget shows content length
This commit is contained in:
parent
521a9b0b2c
commit
2dae9b9621
@ -20,7 +20,7 @@ class NoteRevisionsWidget extends StandardWidget {
|
||||
}
|
||||
|
||||
async doRenderBody() {
|
||||
const revisionItems = await server.get(`notes/${this.ctx.note.noteId}/revisions`);
|
||||
const revisionItems = await server.get(`notes/${this.ctx.note.noteId}/revision-list`);
|
||||
|
||||
if (revisionItems.length === 0) {
|
||||
this.$body.text("No revisions yet...");
|
||||
@ -32,12 +32,18 @@ class NoteRevisionsWidget extends StandardWidget {
|
||||
const $list = this.$body.find('.note-revision-list');
|
||||
|
||||
for (const item of revisionItems) {
|
||||
$list.append($('<li>').append($("<a>", {
|
||||
const $listItem = $('<li>').append($("<a>", {
|
||||
'data-action': 'note-revision',
|
||||
'data-note-path': this.ctx.note.noteId,
|
||||
'data-note-revision-id': item.noteRevisionId,
|
||||
href: 'javascript:'
|
||||
}).text(item.dateModifiedFrom.substr(0, 16))));
|
||||
}).text(item.dateModifiedFrom.substr(0, 16)));
|
||||
|
||||
if (item.contentLength !== null) {
|
||||
$listItem.append($("<span>").text(` (${item.contentLength} characters)`))
|
||||
}
|
||||
|
||||
$list.append($listItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,32 @@ const noteCacheService = require('../../services/note_cache');
|
||||
|
||||
async function getNoteRevisions(req) {
|
||||
const noteId = req.params.noteId;
|
||||
return await repository.getEntities("SELECT * FROM note_revisions WHERE noteId = ? order by utcDateModifiedTo desc", [noteId]);
|
||||
|
||||
return await repository.getEntities(`
|
||||
SELECT note_revisions.*
|
||||
FROM note_revisions
|
||||
WHERE noteId = ?
|
||||
ORDER BY utcDateModifiedTo DESC`, [noteId]);
|
||||
}
|
||||
|
||||
async function getNoteRevisionList(req) {
|
||||
const noteId = req.params.noteId;
|
||||
|
||||
return await repository.getEntities(`
|
||||
SELECT noteRevisionId,
|
||||
noteId,
|
||||
title,
|
||||
isProtected,
|
||||
utcDateModifiedFrom,
|
||||
utcDateModifiedTo,
|
||||
dateModifiedFrom,
|
||||
dateModifiedTo,
|
||||
type,
|
||||
mime,
|
||||
CASE isProtected WHEN 1 THEN null ELSE LENGTH(content) END AS contentLength
|
||||
FROM note_revisions
|
||||
WHERE noteId = ?
|
||||
ORDER BY utcDateModifiedTo DESC`, [noteId]);
|
||||
}
|
||||
|
||||
async function getEditedNotesOnDate(req) {
|
||||
@ -30,5 +55,6 @@ async function getEditedNotesOnDate(req) {
|
||||
|
||||
module.exports = {
|
||||
getNoteRevisions,
|
||||
getNoteRevisionList,
|
||||
getEditedNotesOnDate
|
||||
};
|
@ -132,6 +132,7 @@ function register(app) {
|
||||
apiRoute(PUT, '/api/notes/:noteId/protect/:isProtected', notesApiRoute.protectSubtree);
|
||||
apiRoute(PUT, /\/api\/notes\/(.*)\/type\/(.*)\/mime\/(.*)/, notesApiRoute.setNoteTypeMime);
|
||||
apiRoute(GET, '/api/notes/:noteId/revisions', noteRevisionsApiRoute.getNoteRevisions);
|
||||
apiRoute(GET, '/api/notes/:noteId/revision-list', noteRevisionsApiRoute.getNoteRevisionList);
|
||||
apiRoute(POST, '/api/notes/relation-map', notesApiRoute.getRelationMap);
|
||||
apiRoute(PUT, '/api/notes/:noteId/change-title', notesApiRoute.changeTitle);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user