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

71 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);
2015-09-05 21:53:37 -07:00
$('#chkEnableFullSpeedConversion', page).checked(config.EnableFullSpeedTranscoding);
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;
2015-11-28 01:07:44 -07:00
ApiClient.getNamedConfiguration("sync").then(function (config) {
2015-06-01 22:46:06 -07:00
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();
2015-11-28 01:07:44 -07:00
ApiClient.updateNamedConfiguration("sync", config).then(Dashboard.processServerConfigurationUpdateResult);
2015-06-01 22:46:06 -07:00
});
// Disable default form submission
return false;
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#syncSettingsPage", function () {
2015-01-23 21:50:45 -07:00
var page = this;
$('#btnSelectSyncTempPath', page).on("click.selectDirectory", function () {
2015-10-13 12:22:45 -07:00
require(['directorybrowser'], function (directoryBrowser) {
2015-01-23 21:50:45 -07:00
2015-10-13 12:22:45 -07:00
var picker = new directoryBrowser();
2015-01-23 21:50:45 -07:00
2015-10-13 12:22:45 -07:00
picker.show({
2015-01-23 21:50:45 -07:00
2015-10-13 12:22:45 -07:00
callback: function (path) {
if (path) {
$('#txtSyncTempPath', page).val(path);
}
picker.close();
2015-01-23 21:50:45 -07:00
}
2015-10-13 12:22:45 -07:00
});
2015-01-23 21:50:45 -07:00
});
});
2015-06-01 22:46:06 -07:00
$('.syncSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#syncSettingsPage", function () {
2015-01-23 21:50:45 -07:00
Dashboard.showLoadingMsg();
var page = this;
2015-11-28 01:07:44 -07:00
ApiClient.getNamedConfiguration("sync").then(function (config) {
2015-01-23 21:50:45 -07:00
loadPage(page, config);
});
});
})(jQuery, document, window);