2018-03-26 01:41:29 +08:00
|
|
|
import linkService from '../services/link.js';
|
2018-03-26 01:02:39 +08:00
|
|
|
import utils from '../services/utils.js';
|
2018-03-26 02:49:20 +08:00
|
|
|
import server from '../services/server.js';
|
2017-11-04 11:00:35 +08:00
|
|
|
|
2018-03-25 23:09:17 +08:00
|
|
|
const $dialog = $("#event-log-dialog");
|
|
|
|
const $list = $("#event-log-list");
|
2017-11-05 05:03:15 +08:00
|
|
|
|
2018-03-25 23:09:17 +08:00
|
|
|
async function showDialog() {
|
|
|
|
glob.activeDialog = $dialog;
|
2017-11-04 11:00:35 +08:00
|
|
|
|
2018-03-25 23:09:17 +08:00
|
|
|
$dialog.dialog({
|
|
|
|
modal: true,
|
|
|
|
width: 800,
|
|
|
|
height: 700
|
|
|
|
});
|
2017-11-04 11:00:35 +08:00
|
|
|
|
2018-03-25 23:09:17 +08:00
|
|
|
const result = await server.get('event-log');
|
2017-11-04 11:00:35 +08:00
|
|
|
|
2018-03-25 23:09:17 +08:00
|
|
|
$list.html('');
|
2017-11-04 11:00:35 +08:00
|
|
|
|
2018-03-25 23:09:17 +08:00
|
|
|
for (const event of result) {
|
2018-05-27 00:38:25 +08:00
|
|
|
const dateTime = utils.formatDateTime(utils.parseDate(event.dateCreated));
|
2017-11-04 11:00:35 +08:00
|
|
|
|
2018-03-25 23:09:17 +08:00
|
|
|
if (event.noteId) {
|
2018-04-20 08:59:44 +08:00
|
|
|
const noteLink = await linkService.createNoteLink(event.noteId).prop('outerHTML');
|
2017-11-04 11:00:35 +08:00
|
|
|
|
2018-03-25 23:09:17 +08:00
|
|
|
event.comment = event.comment.replace('<note>', noteLink);
|
2017-11-05 02:02:43 +08:00
|
|
|
}
|
2018-03-25 23:09:17 +08:00
|
|
|
|
|
|
|
const eventEl = $('<li>').html(dateTime + " - " + event.comment);
|
|
|
|
|
|
|
|
$list.append(eventEl);
|
2017-11-04 11:00:35 +08:00
|
|
|
}
|
2018-03-25 23:09:17 +08:00
|
|
|
}
|
2017-11-04 11:00:35 +08:00
|
|
|
|
2018-03-25 23:09:17 +08:00
|
|
|
export default {
|
|
|
|
showDialog
|
|
|
|
};
|