jellyfin-web/dashboard-ui/dashboard/logpage.js

78 lines
2.4 KiB
JavaScript
Raw Normal View History

2016-07-22 12:48:47 -07:00
define(['datetime', 'listViewStyle'], function (datetime) {
2013-02-20 18:33:05 -07:00
2016-03-27 20:37:33 -07:00
return function (view, params) {
2013-02-20 18:33:05 -07:00
2016-03-27 20:37:33 -07:00
view.querySelector('#chkDebugLog').addEventListener('change', function () {
2013-02-20 18:33:05 -07:00
2016-03-27 20:37:33 -07:00
ApiClient.getServerConfiguration().then(function (config) {
config.EnableDebugLevelLogging = view.querySelector('#chkDebugLog').checked;
ApiClient.updateServerConfiguration(config);
});
});
view.addEventListener('viewbeforeshow', function () {
Dashboard.showLoadingMsg();
2013-02-20 18:33:05 -07:00
2016-02-07 14:16:02 -07:00
var apiClient = ApiClient;
2013-02-20 18:33:05 -07:00
2016-02-07 14:16:02 -07:00
apiClient.getJSON(apiClient.getUrl('System/Logs')).then(function (logs) {
2013-02-20 18:33:05 -07:00
2016-02-07 14:16:02 -07:00
var html = '';
2013-11-30 11:32:39 -07:00
2016-02-07 14:16:02 -07:00
html += '<div class="paperList">';
2014-11-14 19:31:03 -07:00
2016-02-07 14:16:02 -07:00
html += logs.map(function (log) {
2014-11-14 19:31:03 -07:00
2016-02-07 14:16:02 -07:00
var logUrl = apiClient.getUrl('System/Logs/Log', {
name: log.Name
});
2013-11-30 11:32:39 -07:00
2016-02-07 14:16:02 -07:00
logUrl += "&api_key=" + apiClient.accessToken();
2013-02-20 18:33:05 -07:00
2016-02-07 14:16:02 -07:00
var logHtml = '';
2016-07-22 12:48:47 -07:00
logHtml += '<div class="listItem">';
2013-02-20 18:33:05 -07:00
2016-08-05 12:34:10 -07:00
logHtml += '<a item-icon class="clearLink" href="' + logUrl + '" target="_blank">';
2016-07-22 12:48:47 -07:00
logHtml += '<i class="md-icon listItemIcon">schedule</i>';
2016-02-07 14:16:02 -07:00
logHtml += "</a>";
2013-02-20 18:33:05 -07:00
2016-08-05 12:34:10 -07:00
logHtml += '<div class="listItemBody two-line">';
2016-02-07 14:16:02 -07:00
logHtml += '<a class="clearLink" href="' + logUrl + '" target="_blank">';
2013-02-20 18:33:05 -07:00
2016-08-05 12:34:10 -07:00
logHtml += "<h3 class='listItemBodyText'>" + log.Name + "</h3>";
2013-02-20 18:33:05 -07:00
2016-05-05 21:50:06 -07:00
var date = datetime.parseISO8601Date(log.DateModified, true);
2013-02-20 18:33:05 -07:00
2016-02-07 14:16:02 -07:00
var text = date.toLocaleDateString();
2013-02-20 18:33:05 -07:00
2016-05-05 19:55:15 -07:00
text += ' ' + datetime.getDisplayTime(date);
2013-02-20 18:33:05 -07:00
2016-08-05 12:34:10 -07:00
logHtml += '<div class="listItemBodyText secondary">' + text + '</div>';
2013-02-20 18:33:05 -07:00
2016-02-07 14:16:02 -07:00
logHtml += "</a>";
2016-07-22 12:48:47 -07:00
logHtml += '</div>';
2013-02-20 18:33:05 -07:00
2016-07-22 12:48:47 -07:00
logHtml += '</div>';
2016-02-07 14:16:02 -07:00
return logHtml;
})
.join('');
html += '</div>';
2016-07-22 12:48:47 -07:00
view.querySelector('.serverLogs').innerHTML = html;
2016-02-07 14:48:08 -07:00
Dashboard.hideLoadingMsg();
2016-03-27 20:37:33 -07:00
});
apiClient.getServerConfiguration().then(function (config) {
2016-02-07 14:16:02 -07:00
2016-03-27 20:37:33 -07:00
view.querySelector('#chkDebugLog').checked = config.EnableDebugLevelLogging;
2016-02-07 14:16:02 -07:00
});
});
2013-02-20 18:33:05 -07:00
2016-03-27 20:37:33 -07:00
};
});