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