1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

add channel downloading settings

This commit is contained in:
Luke Pulverenti 2014-06-02 15:32:41 -04:00
parent 18cd384168
commit c4cedff7b4
4 changed files with 115 additions and 10 deletions

View file

@ -1,22 +1,91 @@
(function ($, document, window) {
function loadPage(page, config) {
function populateDownloadList(page, config, downloadableList) {
if (downloadableList.length) {
$('.channelDownloading', page).show();
} else {
$('.channelDownloading', page).hide();
}
var html = '';
html += '<div data-role="controlgroup">';
for (var i = 0, length = downloadableList.length; i < length; i++) {
var channel = downloadableList[i];
var id = 'chkChannelDownload' + i;
var isChecked = config.ChannelOptions.DownloadingChannels.indexOf(channel.Id) != -1 ? ' checked="checked"' : '';
html += '<input class="chkChannelDownload" type="checkbox" name="' + id + '" id="' + id + '" data-channelid="' + channel.Id + '" data-mini="true"' + isChecked + '>';
html += '<label for="' + id + '">' + channel.Name + '</label>';
}
html += '</div>';
$('.channelDownloadingList', page).html(html).trigger('create');
}
function loadPage(page, config, allChannelFeatures) {
var downloadableList = allChannelFeatures.filter(function (i) {
return i.CanDownloadAllMedia;
});
populateDownloadList(page, config, downloadableList);
$('#selectChannelResolution', page).val(config.ChannelOptions.PreferredStreamingWidth || '')
.selectmenu("refresh");
$('#txtDownloadAge', page).val(config.ChannelOptions.MaxDownloadAge || '');
$('#txtCachePath', page).val(config.ChannelOptions.DownloadPath || '');
Dashboard.hideLoadingMsg();
}
$(document).on('pageshow', "#channelSettingsPage", function () {
$(document).on('pageinit', "#channelSettingsPage", function () {
var page = this;
$('#btnSelectCachePath', page).on("click.selectDirectory", function () {
var picker = new DirectoryBrowser(page);
picker.show({
callback: function (path) {
if (path) {
$('#txtCachePath', page).val(path);
}
picker.close();
},
header: Globalize.translate('HeaderSelectChannelDownloadPath'),
instruction: Globalize.translate('HeaderSelectChannelDownloadPathHelp')
});
});
}).on('pageshow', "#channelSettingsPage", function () {
Dashboard.showLoadingMsg();
var page = this;
ApiClient.getServerConfiguration().done(function (config) {
var promise1 = ApiClient.getServerConfiguration();
var promise2 = $.getJSON(ApiClient.getUrl("Channels/Features"));
loadPage(page, config);
$.when(promise1, promise2).done(function (response1, response2) {
var config = response1[0];
var allFeatures = response2[0];
loadPage(page, config, allFeatures);
});
@ -32,6 +101,15 @@
// This should be null if empty
config.ChannelOptions.PreferredStreamingWidth = $('#selectChannelResolution', form).val() || null;
config.ChannelOptions.MaxDownloadAge = $('#txtDownloadAge', form).val() || null;
config.ChannelOptions.DownloadPath = $('#txtCachePath', form).val() || null;
config.ChannelOptions.DownloadingChannels = $('.chkChannelDownload:checked', form)
.get()
.map(function(i) {
return i.getAttribute('data-channelid');
});
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
});