42 lines
1.0 KiB
JavaScript
Raw Normal View History

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