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

87 lines
2.8 KiB
JavaScript
Raw Normal View History

define(['jQuery'], function ($) {
2014-03-10 10:38:53 -07:00
2016-03-27 20:37:33 -07:00
function loadPage(page, config, users) {
2014-03-10 10:38:53 -07:00
2016-02-09 10:19:55 -07:00
page.querySelector('#chkEnablePlayTo').checked = config.EnablePlayTo;
2016-02-11 21:33:14 -07:00
page.querySelector('#chkEnableDlnaDebugLogging').checked = config.EnableDebugLog;
2016-02-09 10:19:55 -07:00
2014-06-29 10:35:05 -07:00
$('#txtClientDiscoveryInterval', page).val(config.ClientDiscoveryIntervalSeconds);
2014-03-23 13:49:05 -07:00
2016-03-27 20:37:33 -07:00
$('#chkEnableServer', page).checked(config.EnableServer);
$('#chkBlastAliveMessages', page).checked(config.BlastAliveMessages);
$('#txtBlastInterval', page).val(config.BlastAliveMessageIntervalSeconds);
$('#chkEnableMovieFolders', page).checked(config.EnableMovieFolders);
var usersHtml = users.map(function (u) {
return '<option value="' + u.Id + '">' + u.Name + '</option>';
}).join('');
$('#selectUser', page).html(usersHtml).val(config.DefaultUserId || '');
2014-03-10 10:38:53 -07:00
Dashboard.hideLoadingMsg();
}
function onSubmit() {
2015-06-07 18:23:56 -07:00
2014-03-10 10:38:53 -07:00
Dashboard.showLoadingMsg();
var form = this;
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration("dlna").then(function (config) {
2014-03-10 10:38:53 -07:00
2016-02-09 10:19:55 -07:00
config.EnablePlayTo = form.querySelector('#chkEnablePlayTo').checked;
2016-02-11 21:33:14 -07:00
config.EnableDebugLog = form.querySelector('#chkEnableDlnaDebugLogging').checked;
2016-02-09 10:19:55 -07:00
2014-06-29 10:35:05 -07:00
config.ClientDiscoveryIntervalSeconds = $('#txtClientDiscoveryInterval', form).val();
2014-03-10 10:38:53 -07:00
2016-03-27 20:37:33 -07:00
config.EnableServer = $('#chkEnableServer', form).checked();
config.BlastAliveMessages = $('#chkBlastAliveMessages', form).checked();
config.BlastAliveMessageIntervalSeconds = $('#txtBlastInterval', form).val();
config.DefaultUserId = $('#selectUser', form).val();
config.EnableMovieFolders = $('#chkEnableMovieFolders', form).checked();
2015-12-14 08:43:03 -07:00
ApiClient.updateNamedConfiguration("dlna", config).then(Dashboard.processServerConfigurationUpdateResult);
2014-03-10 10:38:53 -07:00
});
// Disable default form submission
return false;
}
2016-04-12 23:02:07 -07:00
function getTabs() {
return [
{
href: 'dlnasettings.html',
name: Globalize.translate('TabSettings')
},
{
href: 'dlnaprofiles.html',
name: Globalize.translate('TabProfiles')
}];
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#dlnaSettingsPage", function () {
2015-06-07 18:23:56 -07:00
$('.dlnaSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#dlnaSettingsPage", function () {
2015-06-07 18:23:56 -07:00
2016-04-12 23:02:07 -07:00
LibraryMenu.setTabs('dlna', 0, getTabs);
2015-06-07 18:23:56 -07:00
Dashboard.showLoadingMsg();
var page = this;
2016-03-27 20:37:33 -07:00
var promise1 = ApiClient.getNamedConfiguration("dlna");
var promise2 = ApiClient.getUsers();
Promise.all([promise1, promise2]).then(function (responses) {
2015-06-07 18:23:56 -07:00
2016-03-27 20:37:33 -07:00
loadPage(page, responses[0], responses[1]);
2015-06-07 18:23:56 -07:00
});
});
2014-03-10 10:38:53 -07:00
});