diff --git a/package.json b/package.json index 824e521f5b..579e5e85d7 100644 --- a/package.json +++ b/package.json @@ -179,6 +179,12 @@ "src/controllers/dashboard/networking.js", "src/controllers/dashboard/playback.js", "src/controllers/dashboard/plugins/repositories.js", + "src/controllers/dashboard/users/useredit.js", + "src/controllers/dashboard/users/userlibraryaccess.js", + "src/controllers/dashboard/users/usernew.js", + "src/controllers/dashboard/users/userparentalcontrol.js", + "src/controllers/dashboard/users/userpasswordpage.js", + "src/controllers/dashboard/users/userprofilespage.js", "src/controllers/wizard/finish.js", "src/controllers/wizard/remoteaccess.js", "src/controllers/wizard/settings.js", diff --git a/src/controllers/dashboard/users/useredit.js b/src/controllers/dashboard/users/useredit.js index af187412d0..ba14cbe1b2 100644 --- a/src/controllers/dashboard/users/useredit.js +++ b/src/controllers/dashboard/users/useredit.js @@ -1,25 +1,27 @@ -define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, libraryMenu, globalize) { - 'use strict'; +import $ from 'jQuery'; +import loading from 'loading'; +import libraryMenu from 'libraryMenu'; +import globalize from 'globalize'; + +/* eslint-disable indent */ function loadDeleteFolders(page, user, mediaFolders) { ApiClient.getJSON(ApiClient.getUrl('Channels', { SupportsMediaDeletion: true })).then(function (channelsResult) { - var i; - var length; - var folder; - var isChecked; - var checkedAttribute; - var html = ''; + let folder; + let isChecked; + let checkedAttribute; + let html = ''; - for (i = 0, length = mediaFolders.length; i < length; i++) { + for (let i = 0, length = mediaFolders.length; i < length; i++) { folder = mediaFolders[i]; isChecked = user.Policy.EnableContentDeletion || -1 != user.Policy.EnableContentDeletionFromFolders.indexOf(folder.Id); checkedAttribute = isChecked ? ' checked="checked"' : ''; html += ''; } - for (i = 0, length = channelsResult.Items.length; i < length; i++) { + for (let i = 0, length = channelsResult.Items.length; i < length; i++) { folder = channelsResult.Items[i]; isChecked = user.Policy.EnableContentDeletion || -1 != user.Policy.EnableContentDeletionFromFolders.indexOf(folder.Id); checkedAttribute = isChecked ? ' checked="checked"' : ''; @@ -38,9 +40,9 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, page.querySelector('.fldSelectLoginProvider').classList.add('hide'); } - var currentProviderId = user.Policy.AuthenticationProviderId; + const currentProviderId = user.Policy.AuthenticationProviderId; page.querySelector('.selectLoginProvider').innerHTML = providers.map(function (provider) { - var selected = provider.Id === currentProviderId || providers.length < 2 ? ' selected' : ''; + const selected = provider.Id === currentProviderId || providers.length < 2 ? ' selected' : ''; return ''; }); } @@ -52,15 +54,14 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, page.querySelector('.fldSelectPasswordResetProvider').classList.add('hide'); } - var currentProviderId = user.Policy.PasswordResetProviderId; + const currentProviderId = user.Policy.PasswordResetProviderId; page.querySelector('.selectPasswordResetProvider').innerHTML = providers.map(function (provider) { - var selected = provider.Id === currentProviderId || providers.length < 2 ? ' selected' : ''; + const selected = provider.Id === currentProviderId || providers.length < 2 ? ' selected' : ''; return ''; }); } function loadUser(page, user) { - currentUser = user; ApiClient.getJSON(ApiClient.getUrl('Auth/Providers')).then(function (providers) { loadAuthProviders(page, user, providers); }); @@ -112,7 +113,7 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, Dashboard.navigate('userprofiles.html'); loading.hide(); - require(['toast'], function (toast) { + import('toast').then(({default: toast}) => { toast(globalize.translate('SettingsSaved')); }); } @@ -155,7 +156,7 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, } function onSubmit() { - var page = $(this).parents('.page')[0]; + const page = $(this).parents('.page')[0]; loading.show(); getUser().then(function (result) { saveUser(result, page); @@ -164,7 +165,7 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, } function getUser() { - var userId = getParameterByName('userId'); + const userId = getParameterByName('userId'); return ApiClient.getUser(userId); } @@ -175,11 +176,10 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, }); } - var currentUser; $(document).on('pageinit', '#editUserPage', function () { $('.editUserProfileForm').off('submit', onSubmit).on('submit', onSubmit); this.querySelector('.sharingHelp').innerHTML = globalize.translate('OptionAllowLinkSharingHelp', 30); - var page = this; + const page = this; $('#chkEnableDeleteAllFolders', this).on('change', function () { if (this.checked) { $('.deleteAccess', page).hide(); @@ -197,4 +197,5 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, }).on('pagebeforeshow', '#editUserPage', function () { loadData(this); }); -}); + +/* eslint-enable indent */ diff --git a/src/controllers/dashboard/users/userlibraryaccess.js b/src/controllers/dashboard/users/userlibraryaccess.js index 5ea24e3da3..df42733f0c 100644 --- a/src/controllers/dashboard/users/userlibraryaccess.js +++ b/src/controllers/dashboard/users/userlibraryaccess.js @@ -1,40 +1,44 @@ -define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, libraryMenu, globalize) { - 'use strict'; +import $ from 'jQuery'; +import loading from 'loading'; +import libraryMenu from 'libraryMenu'; +import globalize from 'globalize'; + +/* eslint-disable indent */ function triggerChange(select) { - var evt = document.createEvent('HTMLEvents'); + const evt = document.createEvent('HTMLEvents'); evt.initEvent('change', false, true); select.dispatchEvent(evt); } function loadMediaFolders(page, user, mediaFolders) { - var html = ''; + let html = ''; html += '

' + globalize.translate('HeaderLibraries') + '

'; html += '
'; - for (var i = 0, length = mediaFolders.length; i < length; i++) { - var folder = mediaFolders[i]; - var isChecked = user.Policy.EnableAllFolders || -1 != user.Policy.EnabledFolders.indexOf(folder.Id); - var checkedAttribute = isChecked ? ' checked="checked"' : ''; + for (let i = 0, length = mediaFolders.length; i < length; i++) { + const folder = mediaFolders[i]; + const isChecked = user.Policy.EnableAllFolders || -1 != user.Policy.EnabledFolders.indexOf(folder.Id); + const checkedAttribute = isChecked ? ' checked="checked"' : ''; html += ''; } html += '
'; page.querySelector('.folderAccess').innerHTML = html; - var chkEnableAllFolders = page.querySelector('#chkEnableAllFolders'); + const chkEnableAllFolders = page.querySelector('#chkEnableAllFolders'); chkEnableAllFolders.checked = user.Policy.EnableAllFolders; triggerChange(chkEnableAllFolders); } function loadChannels(page, user, channels) { - var html = ''; + let html = ''; html += '

' + globalize.translate('HeaderChannels') + '

'; html += '
'; - for (var i = 0, length = channels.length; i < length; i++) { - var folder = channels[i]; - var isChecked = user.Policy.EnableAllChannels || -1 != user.Policy.EnabledChannels.indexOf(folder.Id); - var checkedAttribute = isChecked ? ' checked="checked"' : ''; + for (let i = 0, length = channels.length; i < length; i++) { + const folder = channels[i]; + const isChecked = user.Policy.EnableAllChannels || -1 != user.Policy.EnabledChannels.indexOf(folder.Id); + const checkedAttribute = isChecked ? ' checked="checked"' : ''; html += ''; } @@ -51,13 +55,13 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, } function loadDevices(page, user, devices) { - var html = ''; + let html = ''; html += '

' + globalize.translate('HeaderDevices') + '

'; html += '
'; - for (var i = 0, length = devices.length; i < length; i++) { - var device = devices[i]; - var checkedAttribute = user.Policy.EnableAllDevices || -1 != user.Policy.EnabledDevices.indexOf(device.Id) ? ' checked="checked"' : ''; + for (let i = 0, length = devices.length; i < length; i++) { + const device = devices[i]; + const checkedAttribute = user.Policy.EnableAllDevices || -1 != user.Policy.EnabledDevices.indexOf(device.Id) ? ' checked="checked"' : ''; html += ''; } @@ -84,7 +88,7 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, function onSaveComplete(page) { loading.hide(); - require(['toast'], function (toast) { + import('toast').then(({default: toast}) => { toast(globalize.translate('SettingsSaved')); }); } @@ -116,9 +120,9 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, } function onSubmit() { - var page = $(this).parents('.page'); + const page = $(this).parents('.page'); loading.show(); - var userId = getParameterByName('userId'); + const userId = getParameterByName('userId'); ApiClient.getUser(userId).then(function (result) { saveUser(result, page); }); @@ -126,7 +130,7 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, } $(document).on('pageinit', '#userLibraryAccessPage', function () { - var page = this; + const page = this; $('#chkEnableAllDevices', page).on('change', function () { if (this.checked) { $('.deviceAccessListContainer', page).hide(); @@ -150,29 +154,30 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, }); $('.userLibraryAccessForm').off('submit', onSubmit).on('submit', onSubmit); }).on('pageshow', '#userLibraryAccessPage', function () { - var page = this; + const page = this; loading.show(); - var promise1; - var userId = getParameterByName('userId'); + let promise1; + const userId = getParameterByName('userId'); if (userId) { promise1 = ApiClient.getUser(userId); } else { - var deferred = $.Deferred(); + const deferred = $.Deferred(); deferred.resolveWith(null, [{ Configuration: {} }]); promise1 = deferred.promise(); } - var promise2 = Dashboard.getCurrentUser(); - var promise4 = ApiClient.getJSON(ApiClient.getUrl('Library/MediaFolders', { + const promise2 = Dashboard.getCurrentUser(); + const promise4 = ApiClient.getJSON(ApiClient.getUrl('Library/MediaFolders', { IsHidden: false })); - var promise5 = ApiClient.getJSON(ApiClient.getUrl('Channels')); - var promise6 = ApiClient.getJSON(ApiClient.getUrl('Devices')); + const promise5 = ApiClient.getJSON(ApiClient.getUrl('Channels')); + const promise6 = ApiClient.getJSON(ApiClient.getUrl('Devices')); Promise.all([promise1, promise2, promise4, promise5, promise6]).then(function (responses) { loadUser(page, responses[0], responses[1], responses[2].Items, responses[3].Items, responses[4].Items); }); }); -}); + +/* eslint-enable indent */ diff --git a/src/controllers/dashboard/users/usernew.js b/src/controllers/dashboard/users/usernew.js index ef4cd74f86..f45cbf8ca8 100644 --- a/src/controllers/dashboard/users/usernew.js +++ b/src/controllers/dashboard/users/usernew.js @@ -1,13 +1,17 @@ -define(['jQuery', 'loading', 'globalize', 'emby-checkbox'], function ($, loading, globalize) { - 'use strict'; +import $ from 'jQuery'; +import loading from 'loading'; +import globalize from 'globalize'; +import 'emby-checkbox'; + +/* eslint-disable indent */ function loadMediaFolders(page, mediaFolders) { - var html = ''; + let html = ''; html += '

' + globalize.translate('HeaderLibraries') + '

'; html += '
'; - for (var i = 0; i < mediaFolders.length; i++) { - var folder = mediaFolders[i]; + for (let i = 0; i < mediaFolders.length; i++) { + const folder = mediaFolders[i]; html += ''; } @@ -17,12 +21,12 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox'], function ($, loading } function loadChannels(page, channels) { - var html = ''; + let html = ''; html += '

' + globalize.translate('HeaderChannels') + '

'; html += '
'; - for (var i = 0; i < channels.length; i++) { - var folder = channels[i]; + for (let i = 0; i < channels.length; i++) { + const folder = channels[i]; html += ''; } @@ -42,10 +46,10 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox'], function ($, loading $('#txtUsername', page).val(''); $('#txtPassword', page).val(''); loading.show(); - var promiseFolders = ApiClient.getJSON(ApiClient.getUrl('Library/MediaFolders', { + const promiseFolders = ApiClient.getJSON(ApiClient.getUrl('Library/MediaFolders', { IsHidden: false })); - var promiseChannels = ApiClient.getJSON(ApiClient.getUrl('Channels')); + const promiseChannels = ApiClient.getJSON(ApiClient.getUrl('Channels')); Promise.all([promiseFolders, promiseChannels]).then(function (responses) { loadMediaFolders(page, responses[0].Items); loadChannels(page, responses[1].Items); @@ -54,7 +58,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox'], function ($, loading } function saveUser(page) { - var user = {}; + const user = {}; user.Name = $('#txtUsername', page).val(); user.Password = $('#txtPassword', page).val(); ApiClient.createUser(user).then(function (user) { @@ -84,7 +88,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox'], function ($, loading Dashboard.navigate('useredit.html?userId=' + user.Id); }); }, function (response) { - require(['toast'], function (toast) { + import('toast').then(({default: toast}) => { toast(globalize.translate('DefaultErrorMessage')); }); @@ -93,7 +97,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox'], function ($, loading } function onSubmit() { - var page = $(this).parents('.page')[0]; + const page = $(this).parents('.page')[0]; loading.show(); saveUser(page); return false; @@ -104,7 +108,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox'], function ($, loading } $(document).on('pageinit', '#newUserPage', function () { - var page = this; + const page = this; $('#chkEnableAllChannels', page).on('change', function () { if (this.checked) { $('.channelAccessListContainer', page).hide(); @@ -123,4 +127,5 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox'], function ($, loading }).on('pageshow', '#newUserPage', function () { loadData(this); }); -}); + +/* eslint-enable indent */ diff --git a/src/controllers/dashboard/users/userparentalcontrol.js b/src/controllers/dashboard/users/userparentalcontrol.js index f5d4e70afd..3fba3fc2b2 100644 --- a/src/controllers/dashboard/users/userparentalcontrol.js +++ b/src/controllers/dashboard/users/userparentalcontrol.js @@ -1,17 +1,22 @@ -define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewStyle', 'paper-icon-button-light'], function ($, datetime, loading, libraryMenu, globalize) { - 'use strict'; +import $ from 'jQuery'; +import datetime from 'datetime'; +import loading from 'loading'; +import libraryMenu from 'libraryMenu'; +import globalize from 'globalize'; +import 'listViewStyle'; +import 'paper-icon-button-light'; + +/* eslint-disable indent */ function populateRatings(allParentalRatings, page) { - var html = ''; + let html = ''; html += ""; - var i; - var length; - var rating; - var ratings = []; + let rating; + const ratings = []; - for (i = 0, length = allParentalRatings.length; i < length; i++) { + for (let i = 0, length = allParentalRatings.length; i < length; i++) { if (rating = allParentalRatings[i], ratings.length) { - var lastRating = ratings[ratings.length - 1]; + const lastRating = ratings[ratings.length - 1]; if (lastRating.Value === rating.Value) { lastRating.Name += '/' + rating.Name; @@ -25,7 +30,7 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt }); } - for (i = 0, length = ratings.length; i < length; i++) { + for (let i = 0, length = ratings.length; i < length; i++) { rating = ratings[i]; html += "'; } @@ -34,7 +39,7 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt } function loadUnratedItems(page, user) { - var items = [{ + const items = [{ name: globalize.translate('OptionBlockBooks'), value: 'Book' }, { @@ -56,13 +61,13 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt name: globalize.translate('OptionBlockTvShows'), value: 'Series' }]; - var html = ''; + let html = ''; html += '

' + globalize.translate('HeaderBlockItemsWithNoRating') + '

'; html += '
'; - for (var i = 0, length = items.length; i < length; i++) { - var item = items[i]; - var checkedAttribute = -1 != user.Policy.BlockUnratedItems.indexOf(item.value) ? ' checked="checked"' : ''; + for (let i = 0, length = items.length; i < length; i++) { + const item = items[i]; + const checkedAttribute = -1 != user.Policy.BlockUnratedItems.indexOf(item.value) ? ' checked="checked"' : ''; html += ''; } @@ -76,11 +81,11 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt loadUnratedItems(page, user); loadBlockedTags(page, user.Policy.BlockedTags); populateRatings(allParentalRatings, page); - var ratingValue = ''; + let ratingValue = ''; if (user.Policy.MaxParentalRating) { - for (var i = 0, length = allParentalRatings.length; i < length; i++) { - var rating = allParentalRatings[i]; + for (let i = 0, length = allParentalRatings.length; i < length; i++) { + const rating = allParentalRatings[i]; if (user.Policy.MaxParentalRating >= rating.Value) { ratingValue = rating.Value; @@ -101,8 +106,8 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt } function loadBlockedTags(page, tags) { - var html = tags.map(function (h) { - var li = '
'; + let html = tags.map(function (h) { + let li = '
'; li += '
'; li += '

'; li += h; @@ -116,10 +121,10 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt html = '
' + html + '
'; } - var elem = $('.blockedTags', page).html(html).trigger('create'); + const elem = $('.blockedTags', page).html(html).trigger('create'); $('.btnDeleteTag', elem).on('click', function () { - var tag = this.getAttribute('data-tag'); - var newTags = tags.filter(function (t) { + const tag = this.getAttribute('data-tag'); + const newTags = tags.filter(function (t) { return t != tag; }); loadBlockedTags(page, newTags); @@ -132,10 +137,10 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt } function renderAccessSchedule(page, schedules) { - var html = ''; - var index = 0; + let html = ''; + let index = 0; html += schedules.map(function (a) { - var itemHtml = ''; + let itemHtml = ''; itemHtml += '
'; itemHtml += '
'; itemHtml += '

'; @@ -148,7 +153,7 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt index++; return itemHtml; }).join(''); - var accessScheduleList = page.querySelector('.accessScheduleList'); + const accessScheduleList = page.querySelector('.accessScheduleList'); accessScheduleList.innerHTML = html; $('.btnDelete', accessScheduleList).on('click', function () { deleteAccessSchedule(page, schedules, parseInt(this.getAttribute('data-index'))); @@ -158,7 +163,7 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt function onSaveComplete(page) { loading.hide(); - require(['toast'], function (toast) { + import('toast').then(({default: toast}) => { toast(globalize.translate('SettingsSaved')); }); } @@ -178,8 +183,8 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt } function getDisplayTime(hours) { - var minutes = 0; - var pct = hours % 1; + let minutes = 0; + const pct = hours % 1; if (pct) { minutes = parseInt(60 * pct); @@ -190,12 +195,11 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt function showSchedulePopup(page, schedule, index) { schedule = schedule || {}; - - require(['components/accessSchedule/accessSchedule'], function (accessschedule) { + import('components/accessSchedule/accessSchedule').then(({default: accessschedule}) => { accessschedule.show({ schedule: schedule }).then(function (updatedSchedule) { - var schedules = getSchedulesFromPage(page); + const schedules = getSchedulesFromPage(page); if (-1 == index) { index = schedules.length; @@ -224,11 +228,12 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt } function showBlockedTagPopup(page) { - require(['prompt'], function (prompt) { - prompt.default({ + + import('prompt').then(({default: prompt}) => { + prompt({ label: globalize.translate('LabelTag') }).then(function (value) { - var tags = getBlockedTagsFromPage(page); + const tags = getBlockedTagsFromPage(page); if (-1 == tags.indexOf(value)) { tags.push(value); @@ -240,9 +245,9 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt window.UserParentalControlPage = { onSubmit: function () { - var page = $(this).parents('.page'); + const page = $(this).parents('.page'); loading.show(); - var userId = getParameterByName('userId'); + const userId = getParameterByName('userId'); ApiClient.getUser(userId).then(function (result) { saveUser(result, page); }); @@ -250,7 +255,7 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt } }; $(document).on('pageinit', '#userParentalControlPage', function () { - var page = this; + const page = this; $('.btnAddSchedule', page).on('click', function () { showSchedulePopup(page, {}, -1); }); @@ -259,13 +264,14 @@ define(['jQuery', 'datetime', 'loading', 'libraryMenu', 'globalize', 'listViewSt }); $('.userParentalControlForm').off('submit', UserParentalControlPage.onSubmit).on('submit', UserParentalControlPage.onSubmit); }).on('pageshow', '#userParentalControlPage', function () { - var page = this; + const page = this; loading.show(); - var userId = getParameterByName('userId'); - var promise1 = ApiClient.getUser(userId); - var promise2 = ApiClient.getParentalRatings(); + const userId = getParameterByName('userId'); + const promise1 = ApiClient.getUser(userId); + const promise2 = ApiClient.getParentalRatings(); Promise.all([promise1, promise2]).then(function (responses) { loadUser(page, responses[0], responses[1]); }); }); -}); + +/* eslint-enable indent */ diff --git a/src/controllers/dashboard/users/userpasswordpage.js b/src/controllers/dashboard/users/userpasswordpage.js index 9061c00c7f..d694bb2c5d 100644 --- a/src/controllers/dashboard/users/userpasswordpage.js +++ b/src/controllers/dashboard/users/userpasswordpage.js @@ -1,14 +1,18 @@ -define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading, libraryMenu, globalize) { - 'use strict'; +import loading from 'loading'; +import libraryMenu from 'libraryMenu'; +import globalize from 'globalize'; +import 'emby-button'; + +/* eslint-disable indent */ function loadUser(page, params) { - var userid = params.userId; + const userid = params.userId; ApiClient.getUser(userid).then(function (user) { Dashboard.getCurrentUser().then(function (loggedInUser) { libraryMenu.setTitle(user.Name); page.querySelector('.username').innerHTML = user.Name; - var showPasswordSection = true; - var showLocalAccessSection = false; + let showPasswordSection = true; + let showLocalAccessSection = false; if ('Guest' == user.ConnectLinkType) { page.querySelector('.localAccessSection').classList.add('hide'); @@ -34,7 +38,7 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading page.querySelector('.localAccessSection').classList.add('hide'); } - var txtEasyPassword = page.querySelector('#txtEasyPassword'); + const txtEasyPassword = page.querySelector('#txtEasyPassword'); txtEasyPassword.value = ''; if (user.HasConfiguredEasyPassword) { @@ -48,7 +52,7 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading page.querySelector('.chkEnableLocalEasyPassword').checked = user.Configuration.EnableLocalPassword; - require(['autoFocuser'], function (autoFocuser) { + import('autoFocuser').then(({default: autoFocuser}) => { autoFocuser.autoFocus(page); }); }); @@ -58,10 +62,10 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading page.querySelector('#txtNewPasswordConfirm').value = ''; } - return function (view, params) { + export default function (view, params) { function saveEasyPassword() { - var userId = params.userId; - var easyPassword = view.querySelector('#txtEasyPassword').value; + const userId = params.userId; + const easyPassword = view.querySelector('#txtEasyPassword').value; if (easyPassword) { ApiClient.updateEasyPassword(userId, easyPassword).then(function () { @@ -78,7 +82,7 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading ApiClient.updateUserConfiguration(user.Id, user.Configuration).then(function () { loading.hide(); - require(['toast'], function (toast) { + import('toast').then(({default: toast}) => { toast(globalize.translate('MessageSettingsSaved')); }); @@ -88,9 +92,9 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading } function savePassword() { - var userId = params.userId; - var currentPassword = view.querySelector('#txtCurrentPassword').value; - var newPassword = view.querySelector('#txtNewPassword').value; + const userId = params.userId; + let currentPassword = view.querySelector('#txtCurrentPassword').value; + const newPassword = view.querySelector('#txtNewPassword').value; if (view.querySelector('#fldCurrentPassword').classList.contains('hide')) { // Firefox does not respect autocomplete=off, so clear it if the field is supposed to be hidden (and blank) @@ -101,7 +105,7 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading ApiClient.updateUserPassword(userId, currentPassword, newPassword).then(function () { loading.hide(); - require(['toast'], function (toast) { + import('toast').then(({default: toast}) => { toast(globalize.translate('PasswordSaved')); }); @@ -116,10 +120,10 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading } function onSubmit(e) { - var form = this; + const form = this; if (form.querySelector('#txtNewPassword').value != form.querySelector('#txtNewPasswordConfirm').value) { - require(['toast'], function (toast) { + import('toast').then(({default: toast}) => { toast(globalize.translate('PasswordMatchError')); }); } else { @@ -139,11 +143,10 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading } function resetPassword() { - var msg = globalize.translate('PasswordResetConfirmation'); - - require(['confirm'], function (confirm) { - confirm.default(msg, globalize.translate('PasswordResetHeader')).then(function () { - var userId = params.userId; + const msg = globalize.translate('PasswordResetConfirmation'); + import('confirm').then(({default: confirm}) => { + confirm(msg, globalize.translate('PasswordResetHeader')).then(function () { + const userId = params.userId; loading.show(); ApiClient.resetUserPassword(userId).then(function () { loading.hide(); @@ -158,11 +161,11 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading } function resetEasyPassword() { - var msg = globalize.translate('PinCodeResetConfirmation'); + const msg = globalize.translate('PinCodeResetConfirmation'); - require(['confirm'], function (confirm) { - confirm.default(msg, globalize.translate('HeaderPinCodeReset')).then(function () { - var userId = params.userId; + import('confirm').then(({default: confirm}) => { + confirm(msg, globalize.translate('HeaderPinCodeReset')).then(function () { + const userId = params.userId; loading.show(); ApiClient.resetEasyPassword(userId).then(function () { loading.hide(); @@ -183,5 +186,6 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading view.addEventListener('viewshow', function () { loadUser(view, params); }); - }; -}); + } + +/* eslint-enable indent */ diff --git a/src/controllers/dashboard/users/userprofilespage.js b/src/controllers/dashboard/users/userprofilespage.js index f04c7ad082..dbdec4f752 100644 --- a/src/controllers/dashboard/users/userprofilespage.js +++ b/src/controllers/dashboard/users/userprofilespage.js @@ -1,11 +1,21 @@ -define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-button-light', 'cardStyle', 'emby-button', 'indicators', 'flexStyles'], function (loading, dom, globalize, datefns, dfnshelper) { - 'use strict'; +import loading from 'loading'; +import dom from 'dom'; +import globalize from 'globalize'; +import * as datefns from 'date-fns'; +import dfnshelper from 'dfnshelper'; +import 'paper-icon-button-light'; +import 'cardStyle'; +import 'emby-button'; +import 'indicators'; +import 'flexStyles'; + +/* eslint-disable indent */ function deleteUser(page, id) { - var msg = globalize.translate('DeleteUserConfirmation'); + const msg = globalize.translate('DeleteUserConfirmation'); - require(['confirm'], function (confirm) { - confirm.default({ + import('confirm').then(({default: confirm}) => { + confirm({ title: globalize.translate('DeleteUser'), text: msg, confirmText: globalize.translate('ButtonDelete'), @@ -20,10 +30,10 @@ define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-but } function showUserMenu(elem) { - var card = dom.parentWithClass(elem, 'card'); - var page = dom.parentWithClass(card, 'page'); - var userId = card.getAttribute('data-userid'); - var menuItems = []; + const card = dom.parentWithClass(elem, 'card'); + const page = dom.parentWithClass(card, 'page'); + const userId = card.getAttribute('data-userid'); + const menuItems = []; menuItems.push({ name: globalize.translate('ButtonOpen'), id: 'open', @@ -45,7 +55,7 @@ define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-but icon: 'delete' }); - require(['actionsheet'], function (actionsheet) { + import('actionsheet').then(({default: actionsheet}) => { actionsheet.show({ items: menuItems, positionTo: card, @@ -72,8 +82,8 @@ define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-but } function getUserHtml(user, addConnectIndicator) { - var html = ''; - var cssClass = 'card squareCard scalableCard squareCard-scalable'; + let html = ''; + let cssClass = 'card squareCard scalableCard squareCard-scalable'; if (user.Policy.IsDisabled) { cssClass += ' grayscale'; @@ -84,7 +94,7 @@ define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-but html += ''; html += '
'; - var lastSeen = getLastSeenText(user.LastActivityDate); + const lastSeen = getLastSeenText(user.LastActivityDate); html += '' != lastSeen ? lastSeen : ' '; html += '
'; html += '

'; @@ -146,17 +156,17 @@ define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-but } function showPendingUserMenu(elem) { - var menuItems = []; + const menuItems = []; menuItems.push({ name: globalize.translate('ButtonCancel'), id: 'delete', icon: 'delete' }); - require(['actionsheet'], function (actionsheet) { - var card = dom.parentWithClass(elem, 'card'); - var page = dom.parentWithClass(card, 'page'); - var id = card.getAttribute('data-id'); + import('actionsheet').then(({default: actionsheet}) => { + const card = dom.parentWithClass(elem, 'card'); + const page = dom.parentWithClass(card, 'page'); + const id = card.getAttribute('data-id'); actionsheet.show({ items: menuItems, positionTo: card, @@ -171,7 +181,7 @@ define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-but } function getPendingUserHtml(user) { - var html = ''; + let html = ''; html += "
"; html += '
'; html += '
'; @@ -236,7 +246,7 @@ define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-but } function showInvitePopup(page) { - require(['components/guestinviter/guestinviter'], function (guestinviter) { + import('components/guestinviter/guestinviter').then(({default: guestinviter}) => { guestinviter.show().then(function () { loadData(page); }); @@ -244,19 +254,19 @@ define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-but } pageIdOn('pageinit', 'userProfilesPage', function () { - var page = this; + const page = this; page.querySelector('.btnAddUser').addEventListener('click', function() { Dashboard.navigate('usernew.html'); }); page.querySelector('.localUsers').addEventListener('click', function (e__e) { - var btnUserMenu = dom.parentWithClass(e__e.target, 'btnUserMenu'); + const btnUserMenu = dom.parentWithClass(e__e.target, 'btnUserMenu'); if (btnUserMenu) { showUserMenu(btnUserMenu); } }); page.querySelector('.pending').addEventListener('click', function (e__r) { - var btnUserMenu = dom.parentWithClass(e__r.target, 'btnUserMenu'); + const btnUserMenu = dom.parentWithClass(e__r.target, 'btnUserMenu'); if (btnUserMenu) { showPendingUserMenu(btnUserMenu); @@ -266,4 +276,5 @@ define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-but pageIdOn('pagebeforeshow', 'userProfilesPage', function () { loadData(this); }); -}); + +/* eslint-enable indent */