2015-01-23 23:50:45 -05:00
|
|
|
|
(function ($, document, window) {
|
|
|
|
|
|
|
|
|
|
function loadPage(page, config) {
|
|
|
|
|
|
|
|
|
|
$('#txtSyncTempPath', page).val(config.TemporaryPath || '');
|
2015-04-09 17:11:57 -04:00
|
|
|
|
$('#txtUploadSpeedLimit', page).val((config.UploadSpeedLimitBytes / 1000000) || '');
|
2015-04-09 13:30:18 -04:00
|
|
|
|
$('#txtCpuCoreLimit', page).val(config.TranscodingCpuCoreLimit);
|
2015-09-06 00:53:37 -04:00
|
|
|
|
$('#chkEnableFullSpeedConversion', page).checked(config.EnableFullSpeedTranscoding);
|
2015-01-23 23:50:45 -05:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-02 01:46:06 -04: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;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 10:01:59 -04:00
|
|
|
|
$(document).on('pageinit', "#syncSettingsPage", function () {
|
2015-01-23 23:50:45 -05:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('#btnSelectSyncTempPath', page).on("click.selectDirectory", function () {
|
|
|
|
|
|
2015-10-13 15:22:45 -04:00
|
|
|
|
require(['directorybrowser'], function (directoryBrowser) {
|
2015-01-23 23:50:45 -05:00
|
|
|
|
|
2015-10-13 15:22:45 -04:00
|
|
|
|
var picker = new directoryBrowser();
|
2015-01-23 23:50:45 -05:00
|
|
|
|
|
2015-10-13 15:22:45 -04:00
|
|
|
|
picker.show({
|
2015-01-23 23:50:45 -05:00
|
|
|
|
|
2015-10-13 15:22:45 -04:00
|
|
|
|
callback: function (path) {
|
|
|
|
|
if (path) {
|
|
|
|
|
$('#txtSyncTempPath', page).val(path);
|
|
|
|
|
}
|
|
|
|
|
picker.close();
|
2015-01-23 23:50:45 -05:00
|
|
|
|
}
|
2015-10-13 15:22:45 -04:00
|
|
|
|
});
|
2015-01-23 23:50:45 -05:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-02 01:46:06 -04:00
|
|
|
|
$('.syncSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
|
|
|
|
|
|
|
|
|
|
|
2015-09-24 13:08:10 -04:00
|
|
|
|
}).on('pageshow', "#syncSettingsPage", function () {
|
2015-01-23 23:50:45 -05:00
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
ApiClient.getNamedConfiguration("sync").done(function (config) {
|
|
|
|
|
|
|
|
|
|
loadPage(page, config);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, window);
|