2022-01-30 00:27:26 +03:00
|
|
|
import escapeHtml from 'escape-html';
|
2020-08-14 08:46:34 +02:00
|
|
|
import 'jquery';
|
|
|
|
import loading from '../../../components/loading/loading';
|
|
|
|
import libraryMenu from '../../../scripts/libraryMenu';
|
|
|
|
import globalize from '../../../scripts/globalize';
|
2022-04-10 02:22:13 -04:00
|
|
|
import Dashboard from '../../../utils/dashboard';
|
2020-07-11 16:54:20 +01:00
|
|
|
|
|
|
|
/* eslint-disable indent */
|
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-06-07 17:14:01 -06:00
|
|
|
$('#chkEnableServer', page).prop('checked', config.EnableServer);
|
|
|
|
$('#chkBlastAliveMessages', page).prop('checked', config.BlastAliveMessages);
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#txtBlastInterval', page).val(config.BlastAliveMessageIntervalSeconds);
|
2020-07-11 16:54:20 +01:00
|
|
|
const usersHtml = users.map(function (u) {
|
2022-01-30 00:27:26 +03:00
|
|
|
return '<option value="' + u.Id + '">' + escapeHtml(u.Name) + '</option>';
|
2020-05-04 12:44:12 +02:00
|
|
|
}).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();
|
2020-07-11 16:54:20 +01:00
|
|
|
const 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-06-07 17:14:01 -06:00
|
|
|
config.EnableServer = $('#chkEnableServer', form).is(':checked');
|
|
|
|
config.BlastAliveMessages = $('#chkBlastAliveMessages', form).is(':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-12-03 16:13:27 -05:00
|
|
|
href: '#!/dlnasettings.html',
|
2020-08-24 08:20:29 +09:00
|
|
|
name: globalize.translate('Settings')
|
2018-10-23 01:05:09 +03:00
|
|
|
}, {
|
2020-12-03 16:13:27 -05:00
|
|
|
href: '#!/dlnaprofiles.html',
|
2020-05-04 12:44:12 +02:00
|
|
|
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();
|
2020-07-11 16:54:20 +01:00
|
|
|
const page = this;
|
|
|
|
const promise1 = ApiClient.getNamedConfiguration('dlna');
|
|
|
|
const promise2 = ApiClient.getUsers();
|
2019-11-06 13:43:39 +03:00
|
|
|
Promise.all([promise1, promise2]).then(function (responses) {
|
|
|
|
loadPage(page, responses[0], responses[1]);
|
|
|
|
});
|
|
|
|
});
|
2020-07-11 16:54:20 +01:00
|
|
|
|
|
|
|
/* eslint-enable indent */
|