1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/controllers/dashboard/notifications/notifications.js

61 lines
2.8 KiB
JavaScript
Raw Normal View History

2020-05-04 12:44:12 +02:00
define(['loading', 'libraryMenu', 'globalize', 'listViewStyle', 'emby-button'], function(loading, libraryMenu, globalize) {
'use strict';
2018-10-23 01:05:09 +03:00
function reload(page) {
loading.show();
2020-05-04 12:44:12 +02:00
ApiClient.getJSON(ApiClient.getUrl('Notifications/Types')).then(function(list) {
var html = '';
var lastCategory = '';
var showHelp = true;
2019-03-09 11:37:40 +09:00
html += list.map(function(notification) {
2020-05-04 12:44:12 +02:00
var itemHtml = '';
2019-03-09 11:37:40 +09:00
if (notification.Category !== lastCategory) {
lastCategory = notification.Category;
if (lastCategory) {
2020-05-04 12:44:12 +02:00
itemHtml += '</div>';
itemHtml += '</div>';
}
itemHtml += '<div class="verticalSection verticalSection-extrabottompadding">';
itemHtml += '<div class="sectionTitleContainer" style="margin-bottom:1em;">';
itemHtml += '<h2 class="sectionTitle">';
2019-03-09 11:37:40 +09:00
itemHtml += notification.Category;
2020-05-04 12:44:12 +02:00
itemHtml += '</h2>';
if (showHelp) {
showHelp = false;
2019-10-04 14:34:50 -04:00
itemHtml += '<a is="emby-linkbutton" class="raised button-alt headerHelpButton" target="_blank" href="https://docs.jellyfin.org/general/server/notifications.html">';
2020-05-04 12:44:12 +02:00
itemHtml += globalize.translate('Help');
itemHtml += '</a>';
}
2020-05-04 12:44:12 +02:00
itemHtml += '</div>';
itemHtml += '<div class="paperList">';
}
2019-03-09 11:37:40 +09:00
itemHtml += '<a class="listItem listItem-border" is="emby-linkbutton" data-ripple="false" href="notificationsetting.html?type=' + notification.Type + '">';
if (notification.Enabled) {
2020-04-26 02:37:28 +03:00
itemHtml += '<span class="listItemIcon material-icons notifications_active"></span>';
} else {
2020-04-26 02:37:28 +03:00
itemHtml += '<span class="listItemIcon material-icons notifications_off" style="background-color:#999;"></span>';
}
itemHtml += '<div class="listItemBody">';
2020-05-04 12:44:12 +02:00
itemHtml += '<div class="listItemBodyText">' + notification.Name + '</div>';
itemHtml += '</div>';
2020-04-26 02:37:28 +03:00
itemHtml += '<button type="button" is="paper-icon-button-light"><span class="material-icons mode_edit"></span></button>';
2020-05-04 12:44:12 +02:00
itemHtml += '</a>';
return itemHtml;
2020-05-04 12:44:12 +02:00
}).join('');
if (list.length) {
2020-05-04 12:44:12 +02:00
html += '</div>';
html += '</div>';
}
2020-05-04 12:44:12 +02:00
page.querySelector('.notificationList').innerHTML = html;
loading.hide();
});
2018-10-23 01:05:09 +03:00
}
return function(view, params) {
2020-05-04 12:44:12 +02:00
view.addEventListener('viewshow', function() {
reload(view);
});
};
});