trilium/public/javascripts/dialogs/event_log.js

42 lines
1 KiB
JavaScript
Raw Normal View History

"use strict";
2017-11-05 02:02:43 +08:00
const eventLog = (function() {
const dialogEl = $("#event-log-dialog");
const listEl = $("#event-log-list");
2017-11-04 11:00:35 +08:00
2017-11-05 02:02:43 +08:00
async function showDialog() {
2017-11-05 05:03:15 +08:00
glob.activeDialog = dialogEl;
2017-11-05 02:02:43 +08:00
dialogEl.dialog({
modal: true,
width: 800,
height: 700
});
2017-11-04 11:00:35 +08:00
2017-11-05 02:02:43 +08:00
const result = await $.ajax({
url: baseApiUrl + 'event-log',
type: 'GET',
2017-11-09 11:33:08 +08:00
error: () => showError("Error getting event log.")
2017-11-05 02:02:43 +08:00
});
2017-11-04 11:00:35 +08:00
2017-11-05 02:02:43 +08:00
listEl.html('');
2017-11-04 11:00:35 +08:00
2017-11-05 02:02:43 +08:00
for (const event of result) {
const dateTime = formatDateTime(getDateFromTS(event.date_added));
2017-11-04 11:00:35 +08:00
2017-11-05 02:02:43 +08:00
if (event.note_id) {
2017-11-05 05:07:03 +08:00
const noteLink = link.createNoteLink(event.note_id).prop('outerHTML');
2017-11-04 11:00:35 +08:00
2017-11-05 02:02:43 +08:00
event.comment = event.comment.replace('<note>', noteLink);
}
2017-11-04 11:00:35 +08:00
2017-11-05 02:02:43 +08:00
const eventEl = $('<li>').html(dateTime + " - " + event.comment);
2017-11-04 11:00:35 +08:00
2017-11-05 02:02:43 +08:00
listEl.append(eventEl);
}
2017-11-04 11:00:35 +08:00
}
2017-11-05 02:02:43 +08:00
return {
showDialog
};
})();