restore ability to edit user preferences from admin screen

This commit is contained in:
Luke Pulverenti 2016-07-11 15:25:27 -04:00
parent 65a75eb894
commit b90d8515b1
8 changed files with 203 additions and 196 deletions

View File

@ -15,12 +15,12 @@
}, },
"devDependencies": {}, "devDependencies": {},
"ignore": [], "ignore": [],
"version": "1.4.76", "version": "1.4.77",
"_release": "1.4.76", "_release": "1.4.77",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "1.4.76", "tag": "1.4.77",
"commit": "6221303e81236b1cc47ccc4fd81b536d4c09f752" "commit": "22897eca3cd924d46ea6b612b8959b6bc8912f7c"
}, },
"_source": "https://github.com/MediaBrowser/emby-webcomponents.git", "_source": "https://github.com/MediaBrowser/emby-webcomponents.git",
"_target": "^1.2.0", "_target": "^1.2.0",

View File

@ -0,0 +1,4 @@
define(['userSettingsBuilder'], function (userSettingsBuilder) {
return new userSettingsBuilder();
});

View File

@ -1,20 +1,24 @@
define(['appSettings', 'apiClientResolver', 'events'], function (appsettings, apiClientResolver, events) { define(['appSettings', 'apiClientResolver', 'events'], function (appsettings, apiClientResolver, events) {
function getUserId() { return function (configuredUserId) {
var apiClient = apiClientResolver();
if (apiClient) {
return apiClient.getCurrentUserId();
}
return null;
}
return new function () {
var self = this; var self = this;
function getUserId() {
if (configuredUserId) {
return configuredUserId;
}
var apiClient = apiClientResolver();
if (apiClient) {
return apiClient.getCurrentUserId();
}
return null;
}
self.set = function (name, value) { self.set = function (name, value) {
var userId = getUserId(); var userId = getUserId();
@ -94,5 +98,5 @@ define(['appSettings', 'apiClientResolver', 'events'], function (appsettings, ap
}); });
} }
}; };
}(); };
}); });

View File

@ -1,59 +1,60 @@
define(['userSettings', 'appStorage'], function (userSettings, appStorage) { define(['userSettingsBuilder', 'appStorage'], function (userSettingsBuilder, appStorage) {
function loadForm(page, user) {
page.querySelector('.chkDisplayMissingEpisodes').checked = user.Configuration.DisplayMissingEpisodes || false;
page.querySelector('.chkDisplayUnairedEpisodes').checked = user.Configuration.DisplayUnairedEpisodes || false;
page.querySelector('#selectThemeSong').value = appStorage.getItem('enableThemeSongs-' + user.Id) || '';
page.querySelector('#selectBackdrop').value = appStorage.getItem('enableBackdrops-' + user.Id) || '';
page.querySelector('#selectLanguage').value = userSettings.language() || '';
Dashboard.hideLoadingMsg();
}
function saveUser(page, user) {
user.Configuration.DisplayMissingEpisodes = page.querySelector('.chkDisplayMissingEpisodes').checked;
user.Configuration.DisplayUnairedEpisodes = page.querySelector('.chkDisplayUnairedEpisodes').checked;
userSettings.language(page.querySelector('#selectLanguage').value);
appStorage.setItem('enableThemeSongs-' + user.Id, page.querySelector('#selectThemeSong').value);
appStorage.setItem('enableBackdrops-' + user.Id, page.querySelector('#selectBackdrop').value);
return ApiClient.updateUserConfiguration(user.Id, user.Configuration);
}
function save(page) {
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
if (!AppInfo.enableAutoSave) {
Dashboard.showLoadingMsg();
}
ApiClient.getUser(userId).then(function (user) {
saveUser(page, user).then(function () {
Dashboard.hideLoadingMsg();
if (!AppInfo.enableAutoSave) {
require(['toast'], function (toast) {
toast(Globalize.translate('SettingsSaved'));
});
}
}, function () {
Dashboard.hideLoadingMsg();
});
});
}
return function (view, params) { return function (view, params) {
var userId = params.userId || Dashboard.getCurrentUserId();
var userSettings = new userSettingsBuilder(userId);
function loadForm(page, user) {
page.querySelector('.chkDisplayMissingEpisodes').checked = user.Configuration.DisplayMissingEpisodes || false;
page.querySelector('.chkDisplayUnairedEpisodes').checked = user.Configuration.DisplayUnairedEpisodes || false;
page.querySelector('#selectThemeSong').value = appStorage.getItem('enableThemeSongs-' + user.Id) || '';
page.querySelector('#selectBackdrop').value = appStorage.getItem('enableBackdrops-' + user.Id) || '';
page.querySelector('#selectLanguage').value = userSettings.language() || '';
Dashboard.hideLoadingMsg();
}
function saveUser(page, user) {
user.Configuration.DisplayMissingEpisodes = page.querySelector('.chkDisplayMissingEpisodes').checked;
user.Configuration.DisplayUnairedEpisodes = page.querySelector('.chkDisplayUnairedEpisodes').checked;
userSettings.language(page.querySelector('#selectLanguage').value);
appStorage.setItem('enableThemeSongs-' + user.Id, page.querySelector('#selectThemeSong').value);
appStorage.setItem('enableBackdrops-' + user.Id, page.querySelector('#selectBackdrop').value);
return ApiClient.updateUserConfiguration(user.Id, user.Configuration);
}
function save(page) {
if (!AppInfo.enableAutoSave) {
Dashboard.showLoadingMsg();
}
ApiClient.getUser(userId).then(function (user) {
saveUser(page, user).then(function () {
Dashboard.hideLoadingMsg();
if (!AppInfo.enableAutoSave) {
require(['toast'], function (toast) {
toast(Globalize.translate('SettingsSaved'));
});
}
}, function () {
Dashboard.hideLoadingMsg();
});
});
}
view.querySelector('.displayPreferencesForm').addEventListener('submit', function (e) { view.querySelector('.displayPreferencesForm').addEventListener('submit', function (e) {
save(view); save(view);
e.preventDefault(); e.preventDefault();
@ -72,8 +73,6 @@
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
ApiClient.getUser(userId).then(function (user) { ApiClient.getUser(userId).then(function (user) {
loadForm(page, user); loadForm(page, user);

View File

@ -187,12 +187,10 @@
}); });
} }
function save(page) { function save(page, userId) {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
if (!AppInfo.enableAutoSave) { if (!AppInfo.enableAutoSave) {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
} }
@ -252,9 +250,11 @@
return function (view, params) { return function (view, params) {
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
function onSubmit(e) { function onSubmit(e) {
save(view); save(view, userId);
// Disable default form submission // Disable default form submission
e.preventDefault(); e.preventDefault();
@ -318,7 +318,7 @@
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId(); var userId = params.userId || Dashboard.getCurrentUserId();
ApiClient.getUser(userId).then(function (user) { ApiClient.getUser(userId).then(function (user) {
@ -334,7 +334,7 @@
var page = this; var page = this;
if (AppInfo.enableAutoSave) { if (AppInfo.enableAutoSave) {
save(page); save(page, userId);
} }
}); });
}; };

View File

@ -1,4 +1,4 @@
define(['appSettings', 'userSettings'], function (appSettings, userSettings) { define(['appSettings', 'userSettingsBuilder'], function (appSettings, userSettingsBuilder) {
function populateLanguages(select, languages) { function populateLanguages(select, languages) {
@ -16,128 +16,127 @@
select.innerHTML = html; select.innerHTML = html;
} }
function loadForm(page, user, loggedInUser, allCulturesPromise) { return function (view, params) {
allCulturesPromise.then(function (allCultures) { var userId = params.userId || Dashboard.getCurrentUserId();
var userSettings = new userSettingsBuilder(userId);
populateLanguages(page.querySelector('#selectAudioLanguage'), allCultures); function loadForm(page, user, loggedInUser, allCulturesPromise) {
populateLanguages(page.querySelector('#selectSubtitleLanguage'), allCultures);
page.querySelector('#selectAudioLanguage', page).value = user.Configuration.AudioLanguagePreference || ""; allCulturesPromise.then(function (allCultures) {
page.querySelector('#selectSubtitleLanguage', page).value = user.Configuration.SubtitleLanguagePreference || "";
page.querySelector('.chkEpisodeAutoPlay').checked = user.Configuration.EnableNextEpisodeAutoPlay || false;
});
page.querySelector('#selectSubtitlePlaybackMode').value = user.Configuration.SubtitleMode || ""; populateLanguages(page.querySelector('#selectAudioLanguage'), allCultures);
populateLanguages(page.querySelector('#selectSubtitleLanguage'), allCultures);
page.querySelector('.chkPlayDefaultAudioTrack').checked = user.Configuration.PlayDefaultAudioTrack || false; page.querySelector('#selectAudioLanguage', page).value = user.Configuration.AudioLanguagePreference || "";
page.querySelector('.chkEnableCinemaMode').checked = userSettings.enableCinemaMode(); page.querySelector('#selectSubtitleLanguage', page).value = user.Configuration.SubtitleLanguagePreference || "";
page.querySelector('.chkExternalVideoPlayer').checked = appSettings.enableExternalPlayers(); page.querySelector('.chkEpisodeAutoPlay').checked = user.Configuration.EnableNextEpisodeAutoPlay || false;
require(['qualityoptions'], function (qualityoptions) {
var bitrateOptions = qualityoptions.getVideoQualityOptions(appSettings.maxStreamingBitrate()).map(function (i) {
return '<option value="' + i.bitrate + '">' + i.name + '</option>';
}).join('');
bitrateOptions = '<option value="">' + Globalize.translate('OptionAutomatic') + '</option>' + bitrateOptions;
page.querySelector('#selectMaxBitrate').innerHTML = bitrateOptions;
page.querySelector('#selectMaxChromecastBitrate').innerHTML = bitrateOptions;
if (appSettings.enableAutomaticBitrateDetection()) {
page.querySelector('#selectMaxBitrate').value = '';
} else {
page.querySelector('#selectMaxBitrate').value = appSettings.maxStreamingBitrate();
}
page.querySelector('#selectMaxChromecastBitrate').value = appSettings.maxChromecastBitrate() || '';
Dashboard.hideLoadingMsg();
});
}
function loadPage(page) {
Dashboard.showLoadingMsg();
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
var promise1 = ApiClient.getUser(userId);
var promise2 = Dashboard.getCurrentUser();
var allCulturesPromise = ApiClient.getCultures();
Promise.all([promise1, promise2]).then(function (responses) {
loadForm(page, responses[1], responses[0], allCulturesPromise);
});
ApiClient.getNamedConfiguration("cinemamode").then(function (cinemaConfig) {
if (cinemaConfig.EnableIntrosForMovies || cinemaConfig.EnableIntrosForEpisodes) {
page.querySelector('.cinemaModeOptions').classList.remove('hide');
} else {
page.querySelector('.cinemaModeOptions').classList.add('hide');
}
});
}
function saveUser(page, user) {
user.Configuration.AudioLanguagePreference = page.querySelector('#selectAudioLanguage').value;
user.Configuration.SubtitleLanguagePreference = page.querySelector('#selectSubtitleLanguage').value;
user.Configuration.SubtitleMode = page.querySelector('#selectSubtitlePlaybackMode').value;
user.Configuration.PlayDefaultAudioTrack = page.querySelector('.chkPlayDefaultAudioTrack').checked;
user.Configuration.EnableNextEpisodeAutoPlay = page.querySelector('.chkEpisodeAutoPlay').checked;
userSettings.enableCinemaMode(page.querySelector('.chkEnableCinemaMode').checked);
return ApiClient.updateUserConfiguration(user.Id, user.Configuration);
}
function save(page) {
appSettings.enableExternalPlayers(page.querySelector('.chkExternalVideoPlayer').checked);
if (page.querySelector('#selectMaxBitrate').value) {
appSettings.maxStreamingBitrate(page.querySelector('#selectMaxBitrate').value);
appSettings.enableAutomaticBitrateDetection(false);
} else {
appSettings.enableAutomaticBitrateDetection(true);
}
appSettings.maxChromecastBitrate(page.querySelector('#selectMaxChromecastBitrate').value);
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
if (!AppInfo.enableAutoSave) {
Dashboard.showLoadingMsg();
}
ApiClient.getUser(userId).then(function (result) {
saveUser(page, result).then(function () {
Dashboard.hideLoadingMsg();
if (!AppInfo.enableAutoSave) {
require(['toast'], function (toast) {
toast(Globalize.translate('SettingsSaved'));
});
}
}, function () {
Dashboard.hideLoadingMsg();
}); });
}); page.querySelector('#selectSubtitlePlaybackMode').value = user.Configuration.SubtitleMode || "";
}
return function (view, params) { page.querySelector('.chkPlayDefaultAudioTrack').checked = user.Configuration.PlayDefaultAudioTrack || false;
page.querySelector('.chkEnableCinemaMode').checked = userSettings.enableCinemaMode();
page.querySelector('.chkExternalVideoPlayer').checked = appSettings.enableExternalPlayers();
require(['qualityoptions'], function (qualityoptions) {
var bitrateOptions = qualityoptions.getVideoQualityOptions(appSettings.maxStreamingBitrate()).map(function (i) {
return '<option value="' + i.bitrate + '">' + i.name + '</option>';
}).join('');
bitrateOptions = '<option value="">' + Globalize.translate('OptionAutomatic') + '</option>' + bitrateOptions;
page.querySelector('#selectMaxBitrate').innerHTML = bitrateOptions;
page.querySelector('#selectMaxChromecastBitrate').innerHTML = bitrateOptions;
if (appSettings.enableAutomaticBitrateDetection()) {
page.querySelector('#selectMaxBitrate').value = '';
} else {
page.querySelector('#selectMaxBitrate').value = appSettings.maxStreamingBitrate();
}
page.querySelector('#selectMaxChromecastBitrate').value = appSettings.maxChromecastBitrate() || '';
Dashboard.hideLoadingMsg();
});
}
function loadPage(page) {
Dashboard.showLoadingMsg();
var promise1 = ApiClient.getUser(userId);
var promise2 = Dashboard.getCurrentUser();
var allCulturesPromise = ApiClient.getCultures();
Promise.all([promise1, promise2]).then(function (responses) {
loadForm(page, responses[1], responses[0], allCulturesPromise);
});
ApiClient.getNamedConfiguration("cinemamode").then(function (cinemaConfig) {
if (cinemaConfig.EnableIntrosForMovies || cinemaConfig.EnableIntrosForEpisodes) {
page.querySelector('.cinemaModeOptions').classList.remove('hide');
} else {
page.querySelector('.cinemaModeOptions').classList.add('hide');
}
});
}
function saveUser(page, user) {
user.Configuration.AudioLanguagePreference = page.querySelector('#selectAudioLanguage').value;
user.Configuration.SubtitleLanguagePreference = page.querySelector('#selectSubtitleLanguage').value;
user.Configuration.SubtitleMode = page.querySelector('#selectSubtitlePlaybackMode').value;
user.Configuration.PlayDefaultAudioTrack = page.querySelector('.chkPlayDefaultAudioTrack').checked;
user.Configuration.EnableNextEpisodeAutoPlay = page.querySelector('.chkEpisodeAutoPlay').checked;
userSettings.enableCinemaMode(page.querySelector('.chkEnableCinemaMode').checked);
return ApiClient.updateUserConfiguration(user.Id, user.Configuration);
}
function save(page) {
appSettings.enableExternalPlayers(page.querySelector('.chkExternalVideoPlayer').checked);
if (page.querySelector('#selectMaxBitrate').value) {
appSettings.maxStreamingBitrate(page.querySelector('#selectMaxBitrate').value);
appSettings.enableAutomaticBitrateDetection(false);
} else {
appSettings.enableAutomaticBitrateDetection(true);
}
appSettings.maxChromecastBitrate(page.querySelector('#selectMaxChromecastBitrate').value);
if (!AppInfo.enableAutoSave) {
Dashboard.showLoadingMsg();
}
ApiClient.getUser(userId).then(function (result) {
saveUser(page, result).then(function () {
Dashboard.hideLoadingMsg();
if (!AppInfo.enableAutoSave) {
require(['toast'], function (toast) {
toast(Globalize.translate('SettingsSaved'));
});
}
}, function () {
Dashboard.hideLoadingMsg();
});
});
}
view.querySelector('#selectSubtitlePlaybackMode').addEventListener('change', function () { view.querySelector('#selectSubtitlePlaybackMode').addEventListener('change', function () {

View File

@ -1202,7 +1202,7 @@ var Dashboard = {
} }
if (browserInfo.mobile || browserInfo.tv) { if (browserInfo.mobile || browserInfo.tv) {
quality -= 30; quality -= 35;
} }
if (AppInfo.hasLowImageBandwidth) { if (AppInfo.hasLowImageBandwidth) {
@ -1976,7 +1976,8 @@ var AppInfo = {};
define("scrollHelper", [embyWebComponentsBowerPath + "/scrollhelper"], returnFirstDependency); define("scrollHelper", [embyWebComponentsBowerPath + "/scrollhelper"], returnFirstDependency);
define("appSettings", [embyWebComponentsBowerPath + "/appsettings"], updateAppSettings); define("appSettings", [embyWebComponentsBowerPath + "/appsettings"], updateAppSettings);
define("userSettings", [embyWebComponentsBowerPath + "/usersettings"], returnFirstDependency); define("userSettings", [embyWebComponentsBowerPath + "/usersettings/usersettings"], returnFirstDependency);
define("userSettingsBuilder", [embyWebComponentsBowerPath + "/usersettings/usersettingsbuilder"], returnFirstDependency);
define("material-icons", ['css!' + embyWebComponentsBowerPath + '/fonts/material-icons/style']); define("material-icons", ['css!' + embyWebComponentsBowerPath + '/fonts/material-icons/style']);
define("robotoFont", ['css!' + embyWebComponentsBowerPath + '/fonts/roboto/style']); define("robotoFont", ['css!' + embyWebComponentsBowerPath + '/fonts/roboto/style']);

View File

@ -9,7 +9,7 @@
<a href="#" data-role="button" onclick="Dashboard.navigate('userparentalcontrol.html', true);">${TabParentalControl}</a> <a href="#" data-role="button" onclick="Dashboard.navigate('userparentalcontrol.html', true);">${TabParentalControl}</a>
<a href="#" data-role="button" onclick="Dashboard.navigate('userpassword.html', true);">${TabPassword}</a> <a href="#" data-role="button" onclick="Dashboard.navigate('userpassword.html', true);">${TabPassword}</a>
</div> </div>
<p class="lnkEditUserPreferencesContainer hide"> <p class="lnkEditUserPreferencesContainer">
<a class="lnkEditUserPreferences" href="#" target="_blank">${ButtonEditOtherUserPreferences}</a> <a class="lnkEditUserPreferences" href="#" target="_blank">${ButtonEditOtherUserPreferences}</a>
</p> </p>
<form class="editUserProfileForm"> <form class="editUserProfileForm">