mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	note revisions widget shows content length
This commit is contained in:
		| @@ -20,7 +20,7 @@ class NoteRevisionsWidget extends StandardWidget { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     async doRenderBody() { |     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) { |         if (revisionItems.length === 0) { | ||||||
|             this.$body.text("No revisions yet..."); |             this.$body.text("No revisions yet..."); | ||||||
| @@ -32,12 +32,18 @@ class NoteRevisionsWidget extends StandardWidget { | |||||||
|         const $list = this.$body.find('.note-revision-list'); |         const $list = this.$body.find('.note-revision-list'); | ||||||
|  |  | ||||||
|         for (const item of revisionItems) { |         for (const item of revisionItems) { | ||||||
|             $list.append($('<li>').append($("<a>", { |             const $listItem = $('<li>').append($("<a>", { | ||||||
|                 'data-action': 'note-revision', |                 'data-action': 'note-revision', | ||||||
|                 'data-note-path': this.ctx.note.noteId, |                 'data-note-path': this.ctx.note.noteId, | ||||||
|                 'data-note-revision-id': item.noteRevisionId, |                 'data-note-revision-id': item.noteRevisionId, | ||||||
|                 href: 'javascript:' |                 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) { | async function getNoteRevisions(req) { | ||||||
|     const noteId = req.params.noteId; |     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) { | async function getEditedNotesOnDate(req) { | ||||||
| @@ -30,5 +55,6 @@ async function getEditedNotesOnDate(req) { | |||||||
|  |  | ||||||
| module.exports = { | module.exports = { | ||||||
|     getNoteRevisions, |     getNoteRevisions, | ||||||
|  |     getNoteRevisionList, | ||||||
|     getEditedNotesOnDate |     getEditedNotesOnDate | ||||||
| }; | }; | ||||||
| @@ -132,6 +132,7 @@ function register(app) { | |||||||
|     apiRoute(PUT, '/api/notes/:noteId/protect/:isProtected', notesApiRoute.protectSubtree); |     apiRoute(PUT, '/api/notes/:noteId/protect/:isProtected', notesApiRoute.protectSubtree); | ||||||
|     apiRoute(PUT, /\/api\/notes\/(.*)\/type\/(.*)\/mime\/(.*)/, notesApiRoute.setNoteTypeMime); |     apiRoute(PUT, /\/api\/notes\/(.*)\/type\/(.*)\/mime\/(.*)/, notesApiRoute.setNoteTypeMime); | ||||||
|     apiRoute(GET, '/api/notes/:noteId/revisions', noteRevisionsApiRoute.getNoteRevisions); |     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(POST, '/api/notes/relation-map', notesApiRoute.getRelationMap); | ||||||
|     apiRoute(PUT, '/api/notes/:noteId/change-title', notesApiRoute.changeTitle); |     apiRoute(PUT, '/api/notes/:noteId/change-title', notesApiRoute.changeTitle); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user