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

74 lines
2.1 KiB
JavaScript
Raw Normal View History

2014-04-25 13:47:56 -07:00
(function () {
function reload(page) {
2014-04-26 20:42:05 -07:00
Dashboard.showLoadingMsg();
2014-04-25 13:47:56 -07:00
2015-12-14 08:43:03 -07:00
ApiClient.getJSON(ApiClient.getUrl("Notifications/Types")).then(function (list) {
2014-04-25 19:55:07 -07:00
2015-09-22 10:09:29 -07:00
var html = '';
2014-04-25 13:47:56 -07:00
2014-04-26 20:42:05 -07:00
var lastCategory = "";
2014-04-25 13:47:56 -07:00
2014-04-26 20:42:05 -07:00
html += list.map(function (i) {
2014-04-25 13:47:56 -07:00
2014-04-26 20:42:05 -07:00
var itemHtml = '';
2014-04-25 13:47:56 -07:00
2014-04-26 20:42:05 -07:00
if (i.Category != lastCategory) {
lastCategory = i.Category;
2015-09-22 10:09:29 -07:00
if (lastCategory) {
itemHtml += '</div>';
}
itemHtml += '<h1>';
2014-04-26 20:42:05 -07:00
itemHtml += i.Category;
2015-09-22 10:09:29 -07:00
itemHtml += '</h1>';
itemHtml += '<div class="paperList" style="margin-bottom:2em;">';
2014-04-26 20:42:05 -07:00
}
2014-04-25 13:47:56 -07:00
2015-09-22 10:09:29 -07:00
itemHtml += '<a class="clearLink" href="notificationsetting.html?type=' + i.Type + '">';
itemHtml += '<paper-icon-item>';
2014-04-25 19:55:07 -07:00
2014-04-26 20:42:05 -07:00
if (i.Enabled) {
2015-10-26 11:55:46 -07:00
itemHtml += '<paper-fab mini class="blue" icon="notifications-active" item-icon></paper-fab>';
2015-09-22 10:09:29 -07:00
}
else {
2015-10-26 11:55:46 -07:00
itemHtml += '<paper-fab mini style="background-color:#999;" icon="notifications-off" item-icon></paper-fab>';
2014-04-26 20:42:05 -07:00
}
2014-04-25 13:47:56 -07:00
2015-09-22 10:09:29 -07:00
itemHtml += '<paper-item-body two-line>';
itemHtml += '<div>' + i.Name + '</div>';
itemHtml += '</paper-item-body>';
itemHtml += '<paper-icon-button icon="mode-edit"></paper-icon-button>';
itemHtml += '</paper-icon-item>';
2014-04-26 20:42:05 -07:00
itemHtml += '</a>';
return itemHtml;
}).join('');
2015-10-12 12:09:56 -07:00
if (list.length) {
html += '</div>';
}
2014-04-25 13:47:56 -07:00
2014-04-26 20:42:05 -07:00
$('.notificationList', page).html(html).trigger('create');
Dashboard.hideLoadingMsg();
});
2014-04-25 13:47:56 -07:00
}
2015-09-24 10:08:10 -07:00
$(document).on('pageshow', "#notificationSettingsPage", function () {
2014-04-25 13:47:56 -07:00
var page = this;
2015-12-14 08:43:03 -07:00
require(['paper-fab', 'paper-item-body', 'paper-icon-item'], function () {
reload(page);
});
2014-04-25 13:47:56 -07:00
});
})(jQuery, window);