diff --git a/dashboard-ui/scripts/sync.js b/dashboard-ui/scripts/sync.js index dbabe18bb8..f28ef6d170 100644 --- a/dashboard-ui/scripts/sync.js +++ b/dashboard-ui/scripts/sync.js @@ -24,30 +24,17 @@ return; } - var quality = $('#selectQuality', form).val(); - - if (quality == 'custom') { - quality = parseFloat($('#txtBitrate', form).val()) * 1000000; - } - var options = { userId: userId, TargetId: target, - Profile: $('#selectProfile', form).val() || null, - Quality: quality || null, - - Name: $('#txtSyncJobName', form).val(), - - SyncNewContent: $('#chkSyncNewContent', form).checked(), - UnwatchedOnly: $('#chkUnwatchedOnly', form).checked(), - ItemLimit: $('#txtItemLimit').val() || null, - ParentId: syncOptions.ParentId, Category: syncOptions.Category }; + setJobValues(options, form); + if (syncOptions.items && syncOptions.items.length) { options.ItemIds = (syncOptions.items || []).map(function (i) { return i.Id || i; @@ -69,6 +56,23 @@ }); } + function setJobValues(job, form) { + + var bitrate = $('#txtBitrate', form).val() || null; + + if (bitrate) { + bitrate = parseFloat(bitrate) * 1000000; + } + + job.Name = $('#txtSyncJobName', form).val(); + job.Quality = $('#selectQuality', form).val() || null; + job.Profile = $('#selectProfile', form).val() || null; + job.Bitrate = bitrate; + job.ItemLimit = $('#txtItemLimit', form).val() || null; + job.SyncNewContent = $('#chkSyncNewContent', form).checked(); + job.UnwatchedOnly = $('#chkUnwatchedOnly', form).checked(); + } + function renderForm(options) { var elem = options.elem; @@ -288,7 +292,7 @@ $('#txtBitrate', form).attr('required', 'required'); } else { $('.fldBitrate', form).hide(); - $('#txtBitrate', form).removeAttr('required'); + $('#txtBitrate', form).removeAttr('required').val(''); } } @@ -349,8 +353,8 @@ showMenu: showSyncMenu, isAvailable: isAvailable, - renderForm: renderForm - + renderForm: renderForm, + setJobValues: setJobValues }; function showSyncButtonsPerUser(page) { diff --git a/dashboard-ui/scripts/syncjob.js b/dashboard-ui/scripts/syncjob.js index 3bf4e49959..bb34b88aaa 100644 --- a/dashboard-ui/scripts/syncjob.js +++ b/dashboard-ui/scripts/syncjob.js @@ -261,6 +261,12 @@ $('#chkSyncNewContent', page).checked(job.SyncNewContent).checkboxradio('refresh'); $('#txtItemLimit', page).val(job.ItemLimit); + if (job.Bitrate) { + $('#txtBitrate', page).val(job.Bitrate / 1000000); + } else { + $('#txtBitrate', page).val(''); + } + var target = editOptions.Targets.filter(function (t) { return t.Id == job.TargetId; })[0]; @@ -320,18 +326,7 @@ ApiClient.getJSON(ApiClient.getUrl('Sync/Jobs/' + id)).done(function (job) { - var quality = $('#selectQuality', page).val(); - - if (quality == 'custom') { - quality = parseFloat($('#txtBitrate', page).val()) * 1000000; - } - - job.Name = $('#txtSyncJobName', page).val(); - job.Quality = quality || null; - job.Profile = $('#selectProfile', page).val() || null; - job.ItemLimit = $('#txtItemLimit', page).val() || job.ItemLimit; - job.SyncNewContent = $('#chkSyncNewContent', page).checked(); - job.UnwatchedOnly = $('#chkUnwatchedOnly', page).checked(); + SyncManager.setJobValues(job, page); ApiClient.ajax({