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() {
|
|
|
|
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',
|
|
|
|
error: () => error("Error getting event log.")
|
|
|
|
});
|
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) {
|
|
|
|
const noteLink = $("<a>", {
|
|
|
|
href: 'app#' + event.note_id,
|
|
|
|
text: getFullName(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
|
|
|
$(document).on('click', '#event-log-dialog a', e => {
|
|
|
|
goToInternalNote(e, () => {
|
|
|
|
dialogEl.dialog('close');
|
|
|
|
});
|
2017-11-04 11:00:35 +08:00
|
|
|
});
|
2017-11-05 02:02:43 +08:00
|
|
|
|
|
|
|
return {
|
|
|
|
showDialog
|
|
|
|
};
|
|
|
|
})();
|