2016-03-18 21:26:17 -07:00
|
|
|
|
define(['jQuery'], function ($) {
|
2015-01-23 21:50:45 -07:00
|
|
|
|
|
|
|
|
|
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-12-14 08:43:03 -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-12-14 08:43:03 -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-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getNamedConfiguration("sync").then(function (config) {
|
2015-01-23 21:50:45 -07:00
|
|
|
|
|
|
|
|
|
loadPage(page, config);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|