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

64 lines
2.0 KiB
JavaScript
Raw Normal View History

2014-04-19 22:21:08 -07:00
(function ($, document, window) {
function loadPage(page, config, users) {
2016-02-16 10:39:09 -07:00
$('#chkEnableServer', page).checked(config.EnableServer);
$('#chkBlastAliveMessages', page).checked(config.BlastAliveMessages);
2014-06-29 10:35:05 -07:00
$('#txtBlastInterval', page).val(config.BlastAliveMessageIntervalSeconds);
2014-04-19 22:21:08 -07:00
2016-02-16 10:39:09 -07:00
$('#chkEnableMovieFolders', page).checked(config.EnableMovieFolders);
2015-03-04 21:13:08 -07:00
2014-04-19 22:21:08 -07:00
var usersHtml = users.map(function (u) {
return '<option value="' + u.Id + '">' + u.Name + '</option>';
}).join('');
2015-09-03 10:01:51 -07:00
$('#selectUser', page).html(usersHtml).val(config.DefaultUserId || '');
2014-04-19 22:21:08 -07:00
Dashboard.hideLoadingMsg();
}
function onSubmit() {
Dashboard.showLoadingMsg();
var form = this;
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration("dlna").then(function (config) {
2014-04-19 22:21:08 -07:00
2014-06-29 10:35:05 -07:00
config.EnableServer = $('#chkEnableServer', form).checked();
config.BlastAliveMessages = $('#chkBlastAliveMessages', form).checked();
config.BlastAliveMessageIntervalSeconds = $('#txtBlastInterval', form).val();
config.DefaultUserId = $('#selectUser', form).val();
2014-04-19 22:21:08 -07:00
config.EnableMovieFolders = $('#chkEnableMovieFolders', form).checked();
2015-03-04 21:13:08 -07:00
2015-12-14 08:43:03 -07:00
ApiClient.updateNamedConfiguration("dlna", config).then(Dashboard.processServerConfigurationUpdateResult);
2014-04-19 22:21:08 -07:00
});
// Disable default form submission
return false;
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#dlnaServerSettingsPage", function () {
2015-06-07 18:23:56 -07:00
$('.dlnaServerSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#dlnaServerSettingsPage", function () {
2015-06-07 18:23:56 -07:00
Dashboard.showLoadingMsg();
var page = this;
var promise1 = ApiClient.getNamedConfiguration("dlna");
var promise2 = ApiClient.getUsers();
2015-12-14 08:43:03 -07:00
Promise.all([promise1, promise2]).then(function (responses) {
2015-06-07 18:23:56 -07:00
2015-12-14 08:43:03 -07:00
loadPage(page, responses[0], responses[1]);
2015-06-07 18:23:56 -07:00
});
});
2014-04-19 22:21:08 -07:00
})(jQuery, document, window);