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

Merge pull request #1649 from Camc314/migrate-to-ES6-40

Migration of notification and notifications to ES6 modules
This commit is contained in:
dkanada 2020-08-04 01:21:08 +09:00 committed by GitHub
commit a6cd54b661
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 167 additions and 166 deletions

View file

@ -193,6 +193,8 @@
"src/controllers/dashboard/metadataImages.js", "src/controllers/dashboard/metadataImages.js",
"src/controllers/dashboard/metadatanfo.js", "src/controllers/dashboard/metadatanfo.js",
"src/controllers/dashboard/networking.js", "src/controllers/dashboard/networking.js",
"src/controllers/dashboard/notifications/notification.js",
"src/controllers/dashboard/notifications/notifications.js",
"src/controllers/dashboard/playback.js", "src/controllers/dashboard/playback.js",
"src/controllers/dashboard/plugins/repositories/index.js", "src/controllers/dashboard/plugins/repositories/index.js",
"src/controllers/dashboard/scheduledtasks/scheduledtask.js", "src/controllers/dashboard/scheduledtasks/scheduledtask.js",

View file

@ -1,11 +1,11 @@
define(['jQuery', 'emby-checkbox'], function ($) { import $ from 'jQuery';
'use strict'; import 'emby-checkbox';
function fillItems(elem, items, cssClass, idPrefix, currentList, isEnabledList) { function fillItems(elem, items, cssClass, idPrefix, currentList, isEnabledList) {
var html = '<div class="checkboxList paperList" style="padding: .5em 1em;">'; let html = '<div class="checkboxList paperList" style="padding: .5em 1em;">';
html += items.map(function (u) { html += items.map(function (u) {
var isChecked = isEnabledList ? currentList.indexOf(u.Id) != -1 : currentList.indexOf(u.Id) == -1; const isChecked = isEnabledList ? currentList.indexOf(u.Id) != -1 : currentList.indexOf(u.Id) == -1;
var checkedHtml = isChecked ? ' checked="checked"' : ''; const checkedHtml = isChecked ? ' checked="checked"' : '';
return '<label><input is="emby-checkbox" class="' + cssClass + '" type="checkbox" data-itemid="' + u.Id + '"' + checkedHtml + '/><span>' + u.Name + '</span></label>'; return '<label><input is="emby-checkbox" class="' + cssClass + '" type="checkbox" data-itemid="' + u.Id + '"' + checkedHtml + '/><span>' + u.Name + '</span></label>';
}).join(''); }).join('');
html += '</div>'; html += '</div>';
@ -13,20 +13,20 @@ define(['jQuery', 'emby-checkbox'], function ($) {
} }
function reload(page) { function reload(page) {
var type = getParameterByName('type'); const type = getParameterByName('type');
var promise1 = ApiClient.getUsers(); const promise1 = ApiClient.getUsers();
var promise2 = ApiClient.getNamedConfiguration(notificationsConfigurationKey); const promise2 = ApiClient.getNamedConfiguration(notificationsConfigurationKey);
var promise3 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Types')); const promise3 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Types'));
var promise4 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Services')); const promise4 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Services'));
Promise.all([promise1, promise2, promise3, promise4]).then(function (responses) { Promise.all([promise1, promise2, promise3, promise4]).then(function (responses) {
var users = responses[0]; const users = responses[0];
var notificationOptions = responses[1]; const notificationOptions = responses[1];
var types = responses[2]; const types = responses[2];
var services = responses[3]; const services = responses[3];
var notificationConfig = notificationOptions.Options.filter(function (n) { let notificationConfig = notificationOptions.Options.filter(function (n) {
return n.Type == type; return n.Type == type;
})[0]; })[0];
var typeInfo = types.filter(function (n) { const typeInfo = types.filter(function (n) {
return n.Type == type; return n.Type == type;
})[0] || {}; })[0] || {};
@ -56,13 +56,13 @@ define(['jQuery', 'emby-checkbox'], function ($) {
} }
function save(page) { function save(page) {
var type = getParameterByName('type'); const type = getParameterByName('type');
var promise1 = ApiClient.getNamedConfiguration(notificationsConfigurationKey); const promise1 = ApiClient.getNamedConfiguration(notificationsConfigurationKey);
// TODO: Check if this promise is really needed, as it's unused. // TODO: Check if this promise is really needed, as it's unused.
var promise2 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Types')); const promise2 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Types'));
Promise.all([promise1, promise2]).then(function (responses) { Promise.all([promise1, promise2]).then(function (responses) {
var notificationOptions = responses[0]; const notificationOptions = responses[0];
var notificationConfig = notificationOptions.Options.filter(function (n) { let notificationConfig = notificationOptions.Options.filter(function (n) {
return n.Type == type; return n.Type == type;
})[0]; })[0];
@ -102,9 +102,9 @@ define(['jQuery', 'emby-checkbox'], function ($) {
return false; return false;
} }
var notificationsConfigurationKey = 'notifications'; const notificationsConfigurationKey = 'notifications';
$(document).on('pageinit', '#notificationSettingPage', function () { $(document).on('pageinit', '#notificationSettingPage', function () {
var page = this; const page = this;
$('#selectUsers', page).on('change', function () { $('#selectUsers', page).on('change', function () {
if (this.value == 'Custom') { if (this.value == 'Custom') {
$('.selectCustomUsers', page).show(); $('.selectCustomUsers', page).show();
@ -116,4 +116,3 @@ define(['jQuery', 'emby-checkbox'], function ($) {
}).on('pageshow', '#notificationSettingPage', function () { }).on('pageshow', '#notificationSettingPage', function () {
reload(this); reload(this);
}); });
});

View file

@ -1,16 +1,17 @@
define(['loading', 'libraryMenu', 'globalize', 'listViewStyle', 'emby-button'], function(loading, libraryMenu, globalize) { import loading from 'loading';
'use strict'; import libraryMenu from 'libraryMenu';
import globalize from 'globalize';
loading = loading.default || loading; import 'listViewStyle';
import 'emby-button';
function reload(page) { function reload(page) {
loading.show(); loading.show();
ApiClient.getJSON(ApiClient.getUrl('Notifications/Types')).then(function (list) { ApiClient.getJSON(ApiClient.getUrl('Notifications/Types')).then(function (list) {
var html = ''; let html = '';
var lastCategory = ''; let lastCategory = '';
var showHelp = true; let showHelp = true;
html += list.map(function (notification) { html += list.map(function (notification) {
var itemHtml = ''; let itemHtml = '';
if (notification.Category !== lastCategory) { if (notification.Category !== lastCategory) {
lastCategory = notification.Category; lastCategory = notification.Category;
if (lastCategory) { if (lastCategory) {
@ -54,9 +55,8 @@ define(['loading', 'libraryMenu', 'globalize', 'listViewStyle', 'emby-button'],
}); });
} }
return function(view, params) { export default function (view, params) {
view.addEventListener('viewshow', function () { view.addEventListener('viewshow', function () {
reload(view); reload(view);
}); });
}; }
});