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

78 lines
2.4 KiB
JavaScript
Raw Normal View History

2016-05-05 19:55:15 -07:00
define(['datetime', 'jQuery', 'paper-fab', 'paper-item-body', 'paper-icon-item'], 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 = '';
logHtml += '<paper-icon-item>';
2013-02-20 18:33:05 -07:00
2016-02-07 14:16:02 -07:00
logHtml += '<a item-icon class="clearLink" href="' + logUrl + '" target="_blank">';
logHtml += '<paper-fab mini icon="schedule" class="blue" item-icon></paper-fab>';
logHtml += "</a>";
2013-02-20 18:33:05 -07:00
2016-02-07 14:16:02 -07:00
logHtml += '<paper-item-body two-line>';
logHtml += '<a class="clearLink" href="' + logUrl + '" target="_blank">';
2013-02-20 18:33:05 -07:00
2016-02-07 14:16:02 -07:00
logHtml += "<div>" + log.Name + "</div>";
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-02-07 14:16:02 -07:00
logHtml += '<div secondary>' + text + '</div>';
2013-02-20 18:33:05 -07:00
2016-02-07 14:16:02 -07:00
logHtml += "</a>";
logHtml += '</paper-item-body>';
2013-02-20 18:33:05 -07:00
2016-02-07 14:16:02 -07:00
logHtml += '</paper-icon-item>';
return logHtml;
})
.join('');
html += '</div>';
2016-03-27 20:37:33 -07:00
$('.serverLogs', view).html(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
};
});