jellyfin-web/dashboard-ui/scripts/syncsettings.js

69 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-01-23 21:50:45 -07:00
(function ($, document, window) {
function loadPage(page, config) {
$('#txtSyncTempPath', page).val(config.TemporaryPath || '');
2015-04-09 14:11:57 -07:00
$('#txtUploadSpeedLimit', page).val((config.UploadSpeedLimitBytes / 1000000) || '');
2015-04-09 10:30:18 -07:00
$('#txtCpuCoreLimit', page).val(config.TranscodingCpuCoreLimit);
$('#chkEnableFullSpeedConversion', page).checked(config.EnableFullSpeedTranscoding).checkboxradio('refresh');
2015-01-23 21:50:45 -07:00
Dashboard.hideLoadingMsg();
}
2015-06-01 22:46:06 -07:00
function onSubmit() {
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getNamedConfiguration("sync").done(function (config) {
config.TemporaryPath = $('#txtSyncTempPath', form).val();
config.UploadSpeedLimitBytes = parseInt(parseFloat(($('#txtUploadSpeedLimit', form).val() || '0')) * 1000000);
config.TranscodingCpuCoreLimit = parseInt($('#txtCpuCoreLimit', form).val());
config.EnableFullSpeedTranscoding = $('#chkEnableFullSpeedConversion', form).checked();
ApiClient.updateNamedConfiguration("sync", config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
}
$(document).on('pageinitdepends', "#syncSettingsPage", function () {
2015-01-23 21:50:45 -07:00
var page = this;
$('#btnSelectSyncTempPath', page).on("click.selectDirectory", function () {
var picker = new DirectoryBrowser(page);
picker.show({
callback: function (path) {
if (path) {
$('#txtSyncTempPath', page).val(path);
}
picker.close();
}
});
});
2015-06-01 22:46:06 -07:00
$('.syncSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshowready', "#syncSettingsPage", function () {
2015-01-23 21:50:45 -07:00
Dashboard.showLoadingMsg();
var page = this;
ApiClient.getNamedConfiguration("sync").done(function (config) {
loadPage(page, config);
});
});
})(jQuery, document, window);