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

Apply suggestions from JustAMan code review

https://www.youtube.com/watch?v=-CmadmM5cOk

Co-Authored-By: LogicalPhallacy <44458166+LogicalPhallacy@users.noreply.github.com>
This commit is contained in:
Vasily 2019-03-19 23:12:23 -07:00 committed by GitHub
parent dab41fe6e1
commit 22649b66a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 54 deletions

View file

@ -22,42 +22,52 @@ define(["jQuery", "loading", "libraryMenu", "fnchecked"], function($, loading, l
} }
function loadUser(page, user) { function loadUser(page, user) {
currentUser = user, currentUser = user;
ApiClient.getJSON(ApiClient.getUrl("Auth/Providers")).then(function(providers) { ApiClient.getJSON(ApiClient.getUrl("Auth/Providers")).then(function(providers) {
loadAuthProviders(page, user, providers) loadAuthProviders(page, user, providers)
}), });
ApiClient.getJSON(ApiClient.getUrl("Library/MediaFolders", { ApiClient.getJSON(ApiClient.getUrl("Library/MediaFolders", {
IsHidden: !1 IsHidden: false
})).then(function(folders) { })).then(function(folders) {
loadDeleteFolders(page, user, folders.Items) loadDeleteFolders(page, user, folders.Items)
}), });
user.Policy.IsDisabled ? $(".disabledUserBanner", page).show() : $(".disabledUserBanner", page).hide(), if (user.Policy.IsDisabled) {
$(".disabledUserBanner", page).show();
} else {
$(".disabledUserBanner", page).hide();
}
"Guest" == user.ConnectLinkType ? ($("#fldConnectInfo", page).hide(), "Guest" == user.ConnectLinkType ? ($("#fldConnectInfo", page).hide(),
$("#txtUserName", page).prop("disabled", "disabled")) : ($("#txtUserName", page).prop("disabled", "").removeAttr("disabled"), $("#txtUserName", page).prop("disabled", "disabled")) : ($("#txtUserName", page).prop("disabled", "").removeAttr("disabled"),
$("#fldConnectInfo", page).show()), if ("Guest" == user.ConnectLinkType) {
$(".lnkEditUserPreferences", page).attr("href", "mypreferencesmenu.html?userId=" + user.Id), $("#fldConnectInfo", page).hide();
libraryMenu.setTitle(user.Name), $("#txtUserName", page).prop("disabled", "disabled");
page.querySelector(".username").innerHTML = user.Name, } else {
$("#txtUserName", page).val(user.Name), $("#txtUserName", page).prop("disabled", "").removeAttr("disabled");
$("#chkIsAdmin", page).checked(user.Policy.IsAdministrator), $("#fldConnectInfo", page).show();
$("#chkDisabled", page).checked(user.Policy.IsDisabled), }
$("#chkIsHidden", page).checked(user.Policy.IsHidden), $(".lnkEditUserPreferences", page).attr("href", "mypreferencesmenu.html?userId=" + user.Id);
$("#chkRemoteControlSharedDevices", page).checked(user.Policy.EnableSharedDeviceControl), libraryMenu.setTitle(user.Name);
$("#chkEnableRemoteControlOtherUsers", page).checked(user.Policy.EnableRemoteControlOfOtherUsers), page.querySelector(".username").innerHTML = user.Name;
$("#chkEnableDownloading", page).checked(user.Policy.EnableContentDownloading), $("#txtUserName", page).val(user.Name);
$("#chkManageLiveTv", page).checked(user.Policy.EnableLiveTvManagement), $("#chkIsAdmin", page).checked(user.Policy.IsAdministrator);
$("#chkEnableLiveTvAccess", page).checked(user.Policy.EnableLiveTvAccess), $("#chkDisabled", page).checked(user.Policy.IsDisabled);
$("#chkEnableMediaPlayback", page).checked(user.Policy.EnableMediaPlayback), $("#chkIsHidden", page).checked(user.Policy.IsHidden);
$("#chkEnableAudioPlaybackTranscoding", page).checked(user.Policy.EnableAudioPlaybackTranscoding), $("#chkRemoteControlSharedDevices", page).checked(user.Policy.EnableSharedDeviceControl);
$("#chkEnableVideoPlaybackTranscoding", page).checked(user.Policy.EnableVideoPlaybackTranscoding), $("#chkEnableRemoteControlOtherUsers", page).checked(user.Policy.EnableRemoteControlOfOtherUsers);
$("#chkEnableVideoPlaybackRemuxing", page).checked(user.Policy.EnablePlaybackRemuxing), $("#chkEnableDownloading", page).checked(user.Policy.EnableContentDownloading);
$("#chkRemoteAccess", page).checked(null == user.Policy.EnableRemoteAccess || user.Policy.EnableRemoteAccess), $("#chkManageLiveTv", page).checked(user.Policy.EnableLiveTvManagement);
$("#chkEnableSyncTranscoding", page).checked(user.Policy.EnableSyncTranscoding), $("#chkEnableLiveTvAccess", page).checked(user.Policy.EnableLiveTvAccess);
$("#chkEnableConversion", page).checked(user.Policy.EnableMediaConversion || !1), $("#chkEnableMediaPlayback", page).checked(user.Policy.EnableMediaPlayback);
$("#chkEnableSharing", page).checked(user.Policy.EnablePublicSharing), $("#chkEnableAudioPlaybackTranscoding", page).checked(user.Policy.EnableAudioPlaybackTranscoding);
$("#txtRemoteClientBitrateLimit", page).val(user.Policy.RemoteClientBitrateLimit / 1e6 || ""), $("#chkEnableVideoPlaybackTranscoding", page).checked(user.Policy.EnableVideoPlaybackTranscoding);
$("#txtLoginAttemptsBeforeLockout", page).val(user.Policy.LoginAttemptsBeforeLockout || "0"), $("#chkEnableVideoPlaybackRemuxing", page).checked(user.Policy.EnablePlaybackRemuxing);
loading.hide() $("#chkRemoteAccess", page).checked(null == user.Policy.EnableRemoteAccess || user.Policy.EnableRemoteAccess);
$("#chkEnableSyncTranscoding", page).checked(user.Policy.EnableSyncTranscoding);
$("#chkEnableConversion", page).checked(user.Policy.EnableMediaConversion || false);
$("#chkEnableSharing", page).checked(user.Policy.EnablePublicSharing);
$("#txtRemoteClientBitrateLimit", page).val(user.Policy.RemoteClientBitrateLimit / 1e6 || "");
$("#txtLoginAttemptsBeforeLockout", page).val(user.Policy.LoginAttemptsBeforeLockout || "0");
loading.hide();
} }
function onSaveComplete(page, user) { function onSaveComplete(page, user) {
@ -69,32 +79,32 @@ define(["jQuery", "loading", "libraryMenu", "fnchecked"], function($, loading, l
} }
function saveUser(user, page) { function saveUser(user, page) {
user.Name = $("#txtUserName", page).val(), user.Name = $("#txtUserName", page).val();
user.Policy.IsAdministrator = $("#chkIsAdmin", page).checked(), user.Policy.IsAdministrator = $("#chkIsAdmin", page).checked();
user.Policy.IsHidden = $("#chkIsHidden", page).checked(), user.Policy.IsHidden = $("#chkIsHidden", page).checked();
user.Policy.IsDisabled = $("#chkDisabled", page).checked(), user.Policy.IsDisabled = $("#chkDisabled", page).checked();
user.Policy.EnableRemoteControlOfOtherUsers = $("#chkEnableRemoteControlOtherUsers", page).checked(), user.Policy.EnableRemoteControlOfOtherUsers = $("#chkEnableRemoteControlOtherUsers", page).checked();
user.Policy.EnableLiveTvManagement = $("#chkManageLiveTv", page).checked(), user.Policy.EnableLiveTvManagement = $("#chkManageLiveTv", page).checked();
user.Policy.EnableLiveTvAccess = $("#chkEnableLiveTvAccess", page).checked(), user.Policy.EnableLiveTvAccess = $("#chkEnableLiveTvAccess", page).checked();
user.Policy.EnableSharedDeviceControl = $("#chkRemoteControlSharedDevices", page).checked(), user.Policy.EnableSharedDeviceControl = $("#chkRemoteControlSharedDevices", page).checked();
user.Policy.EnableMediaPlayback = $("#chkEnableMediaPlayback", page).checked(), user.Policy.EnableMediaPlayback = $("#chkEnableMediaPlayback", page).checked();
user.Policy.EnableAudioPlaybackTranscoding = $("#chkEnableAudioPlaybackTranscoding", page).checked(), user.Policy.EnableAudioPlaybackTranscoding = $("#chkEnableAudioPlaybackTranscoding", page).checked();
user.Policy.EnableVideoPlaybackTranscoding = $("#chkEnableVideoPlaybackTranscoding", page).checked(), user.Policy.EnableVideoPlaybackTranscoding = $("#chkEnableVideoPlaybackTranscoding", page).checked();
user.Policy.EnablePlaybackRemuxing = $("#chkEnableVideoPlaybackRemuxing", page).checked(), user.Policy.EnablePlaybackRemuxing = $("#chkEnableVideoPlaybackRemuxing", page).checked();
user.Policy.EnableContentDownloading = $("#chkEnableDownloading", page).checked(), user.Policy.EnableContentDownloading = $("#chkEnableDownloading", page).checked();
user.Policy.EnableSyncTranscoding = $("#chkEnableSyncTranscoding", page).checked(), user.Policy.EnableSyncTranscoding = $("#chkEnableSyncTranscoding", page).checked();
user.Policy.EnableMediaConversion = $("#chkEnableConversion", page).checked(), user.Policy.EnableMediaConversion = $("#chkEnableConversion", page).checked();
user.Policy.EnablePublicSharing = $("#chkEnableSharing", page).checked(), user.Policy.EnablePublicSharing = $("#chkEnableSharing", page).checked();
user.Policy.EnableRemoteAccess = $("#chkRemoteAccess", page).checked(), user.Policy.EnableRemoteAccess = $("#chkRemoteAccess", page).checked();
user.Policy.RemoteClientBitrateLimit = parseInt(1e6 * parseFloat($("#txtRemoteClientBitrateLimit", page).val() || "0")), user.Policy.RemoteClientBitrateLimit = parseInt(1e6 * parseFloat($("#txtRemoteClientBitrateLimit", page).val() || "0"));
user.Policy.LoginAttemptsBeforeLockout = parseInt($("#txtLoginAttemptsBeforeLockout", page).val() || "0"), user.Policy.LoginAttemptsBeforeLockout = parseInt($("#txtLoginAttemptsBeforeLockout", page).val() || "0");
user.Policy.AuthenticationProviderId = page.querySelector(".selectLoginProvider").value, user.Policy.AuthenticationProviderId = page.querySelector(".selectLoginProvider").value;
user.Policy.EnableContentDeletion = $("#chkEnableDeleteAllFolders", page).checked(), user.Policy.EnableContentDeletion = $("#chkEnableDeleteAllFolders", page).checked();
user.Policy.EnableContentDeletionFromFolders = user.Policy.EnableContentDeletion ? [] : $(".chkFolder", page).get().filter(function(c) { user.Policy.EnableContentDeletionFromFolders = user.Policy.EnableContentDeletion ? [] : $(".chkFolder", page).get().filter(function(c) {
return c.checked return c.checked
}).map(function(c) { }).map(function(c) {
return c.getAttribute("data-id") return c.getAttribute("data-id")
}), });
ApiClient.updateUser(user).then(function() { ApiClient.updateUser(user).then(function() {
ApiClient.updateUserPolicy(user.Id, user.Policy).then(function() { ApiClient.updateUserPolicy(user.Id, user.Policy).then(function() {
onSaveComplete(page, user) onSaveComplete(page, user)

View file

@ -1300,7 +1300,7 @@
"LabelUserAgent": "User agent:", "LabelUserAgent": "User agent:",
"LabelUserLibrary": "User library:", "LabelUserLibrary": "User library:",
"LabelUserLibraryHelp": "Select which user library to display to the device. Leave empty to inherit the default setting.", "LabelUserLibraryHelp": "Select which user library to display to the device. Leave empty to inherit the default setting.",
"LabelUserLoginAttemptsBeforeLockout": "Failed Logins before Lockout:", "LabelUserLoginAttemptsBeforeLockout": "Failed login attempts before user is locked out:",
"LabelUserRemoteClientBitrateLimitHelp": "This will override the default global value set in server playback settings.", "LabelUserRemoteClientBitrateLimitHelp": "This will override the default global value set in server playback settings.",
"LabelUsername": "Username:", "LabelUsername": "Username:",
"LabelVaapiDevice": "VA API Device:", "LabelVaapiDevice": "VA API Device:",
@ -1697,8 +1697,8 @@
"OptionLikes": "Likes", "OptionLikes": "Likes",
"OptionList": "List", "OptionList": "List",
"OptionLocked": "Locked", "OptionLocked": "Locked",
"OptionLoginAttemptsBeforeLockout": "Determines how many incorrect password attempts can be made before lockout occurs.", "OptionLoginAttemptsBeforeLockout": "Determines how many incorrect login attempts can be made before lockout occurs.",
"OptionLoginAttemptsBeforeLockoutHelp":"0 inherits the old default of 3 for non admin and 5 for admin, -1 to disable lockout", "OptionLoginAttemptsBeforeLockoutHelp": "0 means inheriting the default of 3 for non-admin and 5 for admin, -1 disables lockout",
"OptionLogo": "Logo", "OptionLogo": "Logo",
"OptionMax": "Max", "OptionMax": "Max",
"OptionMenu": "Menu", "OptionMenu": "Menu",