2016-03-19 05:26:17 +01:00
|
|
|
|
define(['jQuery'], function ($) {
|
2014-03-10 13:38:53 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
function loadPage(page, config, users) {
|
2014-03-10 13:38:53 -04:00
|
|
|
|
|
2016-02-09 12:19:55 -05:00
|
|
|
|
page.querySelector('#chkEnablePlayTo').checked = config.EnablePlayTo;
|
2016-02-11 23:33:14 -05:00
|
|
|
|
page.querySelector('#chkEnableDlnaDebugLogging').checked = config.EnableDebugLog;
|
2016-02-09 12:19:55 -05:00
|
|
|
|
|
2014-06-29 13:35:05 -04:00
|
|
|
|
$('#txtClientDiscoveryInterval', page).val(config.ClientDiscoveryIntervalSeconds);
|
2014-03-23 16:49:05 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04: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 13:38:53 -04:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onSubmit() {
|
2015-06-07 21:23:56 -04:00
|
|
|
|
|
2014-03-10 13:38:53 -04:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var form = this;
|
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
ApiClient.getNamedConfiguration("dlna").then(function (config) {
|
2014-03-10 13:38:53 -04:00
|
|
|
|
|
2016-02-09 12:19:55 -05:00
|
|
|
|
config.EnablePlayTo = form.querySelector('#chkEnablePlayTo').checked;
|
2016-02-11 23:33:14 -05:00
|
|
|
|
config.EnableDebugLog = form.querySelector('#chkEnableDlnaDebugLogging').checked;
|
2016-02-09 12:19:55 -05:00
|
|
|
|
|
2014-06-29 13:35:05 -04:00
|
|
|
|
config.ClientDiscoveryIntervalSeconds = $('#txtClientDiscoveryInterval', form).val();
|
2014-03-10 13:38:53 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04: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 10:43:03 -05:00
|
|
|
|
ApiClient.updateNamedConfiguration("dlna", config).then(Dashboard.processServerConfigurationUpdateResult);
|
2014-03-10 13:38:53 -04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Disable default form submission
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 10:01:59 -04:00
|
|
|
|
$(document).on('pageinit', "#dlnaSettingsPage", function () {
|
2015-06-07 21:23:56 -04:00
|
|
|
|
|
|
|
|
|
$('.dlnaSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
|
|
|
|
|
|
2015-09-24 13:08:10 -04:00
|
|
|
|
}).on('pageshow', "#dlnaSettingsPage", function () {
|
2015-06-07 21:23:56 -04:00
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
var promise1 = ApiClient.getNamedConfiguration("dlna");
|
|
|
|
|
var promise2 = ApiClient.getUsers();
|
|
|
|
|
|
|
|
|
|
Promise.all([promise1, promise2]).then(function (responses) {
|
2015-06-07 21:23:56 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
loadPage(page, responses[0], responses[1]);
|
2015-06-07 21:23:56 -04:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
2014-03-10 13:38:53 -04:00
|
|
|
|
|
2016-03-19 05:26:17 +01:00
|
|
|
|
});
|