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

104 lines
3.0 KiB
JavaScript
Raw Normal View History

define(['jQuery'], function ($) {
2015-04-08 22:20:23 -07:00
function loadPage(page, config) {
$('#txtRemoteClientBitrateLimit', page).val((config.RemoteClientBitrateLimit / 1000000) || '');
2016-03-27 20:37:33 -07:00
ApiClient.getNamedConfiguration("channels").then(function (channelConfig) {
$('#selectChannelResolution', page).val(channelConfig.PreferredStreamingWidth || '');
});
2015-04-08 22:20:23 -07:00
Dashboard.hideLoadingMsg();
}
2015-05-17 18:27:48 -07:00
function onSubmit() {
Dashboard.showLoadingMsg();
var form = this;
2015-12-14 08:43:03 -07:00
ApiClient.getServerConfiguration().then(function (config) {
2015-05-17 18:27:48 -07:00
config.RemoteClientBitrateLimit = parseInt(parseFloat(($('#txtRemoteClientBitrateLimit', form).val() || '0')) * 1000000);
2015-12-14 08:43:03 -07:00
ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult);
2015-05-17 18:27:48 -07:00
});
2016-03-27 20:37:33 -07:00
ApiClient.getNamedConfiguration("channels").then(function (config) {
// This should be null if empty
config.PreferredStreamingWidth = $('#selectChannelResolution', form).val() || null;
ApiClient.updateNamedConfiguration("channels", config).then(Dashboard.processServerConfigurationUpdateResult);
});
2015-05-17 18:27:48 -07:00
// Disable default form submission
return false;
}
2016-04-12 22:28:45 -07:00
function getTabs() {
return [
{
href: 'cinemamodeconfiguration.html',
name: Globalize.translate('TabCinemaMode')
},
{
href: 'playbackconfiguration.html',
name: Globalize.translate('TabResumeSettings')
},
{
href: 'streamingsettings.html',
name: Globalize.translate('TabStreaming')
},
{
href: 'encodingsettings.html',
name: Globalize.translate('TabTranscoding')
}];
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#streamingSettingsPage", function () {
2015-04-08 22:20:23 -07:00
var page = this;
$('#btnSelectTranscodingTempPath', page).on("click.selectDirectory", function () {
2015-10-13 12:22:45 -07:00
require(['directorybrowser'], function (directoryBrowser) {
2015-04-08 22:20:23 -07:00
2015-10-13 12:22:45 -07:00
var picker = new directoryBrowser();
2015-04-08 22:20:23 -07:00
2015-10-13 12:22:45 -07:00
picker.show({
2015-04-08 22:20:23 -07:00
2015-10-13 12:22:45 -07:00
callback: function (path) {
2015-04-08 22:20:23 -07:00
2015-10-13 12:22:45 -07:00
if (path) {
$('#txtTranscodingTempPath', page).val(path);
}
picker.close();
},
2015-04-08 22:20:23 -07:00
2015-10-13 12:22:45 -07:00
header: Globalize.translate('HeaderSelectTranscodingPath'),
instruction: Globalize.translate('HeaderSelectTranscodingPathHelp')
});
2015-04-08 22:20:23 -07:00
});
});
2015-05-17 18:27:48 -07:00
$('.streamingSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#streamingSettingsPage", function () {
2015-04-08 22:20:23 -07:00
Dashboard.showLoadingMsg();
2016-04-12 22:28:45 -07:00
LibraryMenu.setTabs('playback', 2, getTabs);
2015-04-08 22:20:23 -07:00
var page = this;
2015-12-14 08:43:03 -07:00
ApiClient.getServerConfiguration().then(function (config) {
2015-04-08 22:20:23 -07:00
loadPage(page, config);
});
});
});