mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
made the main save and load methods that I modified more legible
This commit is contained in:
parent
570161efbd
commit
dab41fe6e1
1 changed files with 57 additions and 6 deletions
|
@ -22,13 +22,42 @@ define(["jQuery", "loading", "libraryMenu", "fnchecked"], function($, loading, l
|
|||
}
|
||||
|
||||
function loadUser(page, user) {
|
||||
currentUser = user, ApiClient.getJSON(ApiClient.getUrl("Auth/Providers")).then(function(providers) {
|
||||
currentUser = user,
|
||||
ApiClient.getJSON(ApiClient.getUrl("Auth/Providers")).then(function(providers) {
|
||||
loadAuthProviders(page, user, providers)
|
||||
}), ApiClient.getJSON(ApiClient.getUrl("Library/MediaFolders", {
|
||||
}),
|
||||
ApiClient.getJSON(ApiClient.getUrl("Library/MediaFolders", {
|
||||
IsHidden: !1
|
||||
})).then(function(folders) {
|
||||
loadDeleteFolders(page, user, folders.Items)
|
||||
}), user.Policy.IsDisabled ? $(".disabledUserBanner", page).show() : $(".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()
|
||||
}),
|
||||
user.Policy.IsDisabled ? $(".disabledUserBanner", page).show() : $(".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()
|
||||
}
|
||||
|
||||
function onSaveComplete(page, user) {
|
||||
|
@ -40,11 +69,33 @@ 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.Policy.EnableContentDeletionFromFolders = user.Policy.EnableContentDeletion ? [] : $(".chkFolder", page).get().filter(function(c) {
|
||||
return c.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.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