2020-05-25 14:59:57 +09:00
|
|
|
define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, libraryMenu, globalize) {
|
2020-05-04 12:44:12 +02:00
|
|
|
'use strict';
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function loadPage(page, config, users) {
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('#chkEnablePlayTo').checked = config.EnablePlayTo;
|
|
|
|
page.querySelector('#chkEnableDlnaDebugLogging').checked = config.EnableDebugLog;
|
|
|
|
$('#txtClientDiscoveryInterval', page).val(config.ClientDiscoveryIntervalSeconds);
|
2020-05-25 14:59:57 +09:00
|
|
|
$('#chkEnableServer', page).checked = config.EnableServer;
|
|
|
|
$('#chkBlastAliveMessages', page).checked = config.BlastAliveMessages;
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#txtBlastInterval', page).val(config.BlastAliveMessageIntervalSeconds);
|
2019-11-06 13:43:39 +03:00
|
|
|
var usersHtml = users.map(function (u) {
|
2020-05-04 12:44:12 +02:00
|
|
|
return '<option value="' + u.Id + '">' + u.Name + '</option>';
|
|
|
|
}).join('');
|
|
|
|
$('#selectUser', page).html(usersHtml).val(config.DefaultUserId || '');
|
2019-11-06 13:43:39 +03:00
|
|
|
loading.hide();
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function onSubmit() {
|
|
|
|
loading.show();
|
|
|
|
var form = this;
|
2020-05-04 12:44:12 +02:00
|
|
|
ApiClient.getNamedConfiguration('dlna').then(function (config) {
|
|
|
|
config.EnablePlayTo = form.querySelector('#chkEnablePlayTo').checked;
|
|
|
|
config.EnableDebugLog = form.querySelector('#chkEnableDlnaDebugLogging').checked;
|
|
|
|
config.ClientDiscoveryIntervalSeconds = $('#txtClientDiscoveryInterval', form).val();
|
2020-05-25 15:06:21 +09:00
|
|
|
config.EnableServer = $('#chkEnableServer', form).checked;
|
2020-05-25 14:59:57 +09:00
|
|
|
config.BlastAliveMessages = $('#chkBlastAliveMessages', form).checked;
|
2020-05-04 12:44:12 +02:00
|
|
|
config.BlastAliveMessageIntervalSeconds = $('#txtBlastInterval', form).val();
|
|
|
|
config.DefaultUserId = $('#selectUser', form).val();
|
|
|
|
ApiClient.updateNamedConfiguration('dlna', config).then(Dashboard.processServerConfigurationUpdateResult);
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
|
|
|
return false;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getTabs() {
|
|
|
|
return [{
|
2020-05-04 12:44:12 +02:00
|
|
|
href: 'dlnasettings.html',
|
|
|
|
name: globalize.translate('TabSettings')
|
2018-10-23 01:05:09 +03:00
|
|
|
}, {
|
2020-05-04 12:44:12 +02:00
|
|
|
href: 'dlnaprofiles.html',
|
|
|
|
name: globalize.translate('TabProfiles')
|
2019-11-06 13:43:39 +03:00
|
|
|
}];
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
$(document).on('pageinit', '#dlnaSettingsPage', function () {
|
|
|
|
$('.dlnaSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
|
|
|
|
}).on('pageshow', '#dlnaSettingsPage', function () {
|
|
|
|
libraryMenu.setTabs('dlna', 0, getTabs);
|
2019-11-06 13:43:39 +03:00
|
|
|
loading.show();
|
|
|
|
var page = this;
|
2020-05-04 12:44:12 +02:00
|
|
|
var promise1 = ApiClient.getNamedConfiguration('dlna');
|
2019-11-06 13:43:39 +03:00
|
|
|
var promise2 = ApiClient.getUsers();
|
|
|
|
Promise.all([promise1, promise2]).then(function (responses) {
|
|
|
|
loadPage(page, responses[0], responses[1]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|