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) {
2014-06-29 10:35:05 -07:00
$('#chkEnableServer', page).checked(config.EnableServer).checkboxradio("refresh");
$('#chkBlastAliveMessages', page).checked(config.BlastAliveMessages).checkboxradio("refresh");
$('#txtBlastInterval', page).val(config.BlastAliveMessageIntervalSeconds);
2014-04-19 22:21:08 -07:00
$('#chkEnableMovieFolders', page).checked(config.EnableMovieFolders).checkboxradio("refresh");
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;
2014-06-29 10:35:05 -07:00
ApiClient.getNamedConfiguration("dlna").done(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
2014-06-29 10:35:05 -07:00
ApiClient.updateNamedConfiguration("dlna", config).done(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();
$.when(promise1, promise2).done(function (response1, response2) {
loadPage(page, response1[0], response2[0]);
});
});
2014-04-19 22:21:08 -07:00
})(jQuery, document, window);