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

48 lines
2.3 KiB
JavaScript
Raw Normal View History

2018-10-23 01:05:09 +03:00
define(["jQuery", "loading", "libraryMenu", "fnchecked", "emby-select"], function($, loading, libraryMenu) {
"use strict";
function loadPage(page, config) {
$("#txtSyncTempPath", page).val(config.TemporaryPath || ""), $("#txtUploadSpeedLimit", page).val(config.UploadSpeedLimitBytes / 1e6 || ""), $("#selectThreadCount", page).val(config.TranscodingCpuCoreLimit), $("#chkEnableFullSpeedConversion", page).checked(config.EnableFullSpeedTranscoding), loading.hide()
}
function onSubmit() {
loading.show();
var form = this;
return ApiClient.getNamedConfiguration("sync").then(function(config) {
config.TemporaryPath = $("#txtSyncTempPath", form).val(), config.UploadSpeedLimitBytes = parseInt(1e6 * parseFloat($("#txtUploadSpeedLimit", form).val() || "0")), config.TranscodingCpuCoreLimit = parseInt($("#selectThreadCount", form).val()), config.EnableFullSpeedTranscoding = $("#chkEnableFullSpeedConversion", form).checked(), ApiClient.updateNamedConfiguration("sync", config).then(Dashboard.processServerConfigurationUpdateResult)
}), !1
}
function getTabs() {
return [{
href: "syncactivity.html",
name: Globalize.translate("TabSyncJobs")
}, {
href: "appservices.html?context=sync",
name: Globalize.translate("TabServices")
}, {
href: "syncsettings.html",
name: Globalize.translate("TabSettings")
}]
}
$(document).on("pageinit", "#syncSettingsPage", function() {
var page = this;
$("#btnSelectSyncTempPath", page).on("click.selectDirectory", function() {
require(["directorybrowser"], function(directoryBrowser) {
var picker = new directoryBrowser;
picker.show({
callback: function(path) {
path && $("#txtSyncTempPath", page).val(path), picker.close()
},
validateWriteable: !0
})
})
}), $(".syncSettingsForm").off("submit", onSubmit).on("submit", onSubmit)
}).on("pageshow", "#syncSettingsPage", function() {
loading.show(), libraryMenu.setTabs("syncadmin", 2, getTabs);
var page = this;
ApiClient.getNamedConfiguration("sync").then(function(config) {
loadPage(page, config)
})
})
});