added modular configuration

This commit is contained in:
Luke Pulverenti 2014-06-29 13:35:05 -04:00
parent 0a3876a9b1
commit 6c602e1ad7
5 changed files with 72 additions and 39 deletions

View File

@ -2,15 +2,15 @@
function loadPage(page, config, users) {
$('#chkEnableServer', page).checked(config.DlnaOptions.EnableServer).checkboxradio("refresh");
$('#chkBlastAliveMessages', page).checked(config.DlnaOptions.BlastAliveMessages).checkboxradio("refresh");
$('#txtBlastInterval', page).val(config.DlnaOptions.BlastAliveMessageIntervalSeconds);
$('#chkEnableServer', page).checked(config.EnableServer).checkboxradio("refresh");
$('#chkBlastAliveMessages', page).checked(config.BlastAliveMessages).checkboxradio("refresh");
$('#txtBlastInterval', page).val(config.BlastAliveMessageIntervalSeconds);
var usersHtml = users.map(function (u) {
return '<option value="' + u.Id + '">' + u.Name + '</option>';
}).join('');
$('#selectUser', page).html(usersHtml).val(config.DlnaOptions.DefaultUserId || '').selectmenu("refresh");
$('#selectUser', page).html(usersHtml).val(config.DefaultUserId || '').selectmenu("refresh");
Dashboard.hideLoadingMsg();
}
@ -21,7 +21,7 @@
var page = this;
var promise1 = ApiClient.getServerConfiguration();
var promise1 = ApiClient.getNamedConfiguration("dlna");
var promise2 = ApiClient.getUsers();
$.when(promise1, promise2).done(function (response1, response2) {
@ -38,14 +38,14 @@
var form = this;
ApiClient.getServerConfiguration().done(function (config) {
ApiClient.getNamedConfiguration("dlna").done(function (config) {
config.DlnaOptions.EnableServer = $('#chkEnableServer', form).checked();
config.DlnaOptions.BlastAliveMessages = $('#chkBlastAliveMessages', form).checked();
config.DlnaOptions.BlastAliveMessageIntervalSeconds = $('#txtBlastInterval', form).val();
config.DlnaOptions.DefaultUserId = $('#selectUser', form).val();
config.EnableServer = $('#chkEnableServer', form).checked();
config.BlastAliveMessages = $('#chkBlastAliveMessages', form).checked();
config.BlastAliveMessageIntervalSeconds = $('#txtBlastInterval', form).val();
config.DefaultUserId = $('#selectUser', form).val();
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
ApiClient.updateNamedConfiguration("dlna", config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission

View File

@ -2,9 +2,9 @@
function loadPage(page, config) {
$('#chkEnablePlayTo', page).checked(config.DlnaOptions.EnablePlayTo).checkboxradio("refresh");
$('#chkEnableDlnaDebugLogging', page).checked(config.DlnaOptions.EnableDebugLogging).checkboxradio("refresh");
$('#txtClientDiscoveryInterval', page).val(config.DlnaOptions.ClientDiscoveryIntervalSeconds);
$('#chkEnablePlayTo', page).checked(config.EnablePlayTo).checkboxradio("refresh");
$('#chkEnableDlnaDebugLogging', page).checked(config.EnableDebugLogging).checkboxradio("refresh");
$('#txtClientDiscoveryInterval', page).val(config.ClientDiscoveryIntervalSeconds);
Dashboard.hideLoadingMsg();
}
@ -15,7 +15,7 @@
var page = this;
ApiClient.getServerConfiguration().done(function (config) {
ApiClient.getNamedConfiguration("dlna").done(function (config) {
loadPage(page, config);
@ -29,13 +29,13 @@
var form = this;
ApiClient.getServerConfiguration().done(function (config) {
ApiClient.getNamedConfiguration("dlna").done(function (config) {
config.DlnaOptions.EnablePlayTo = $('#chkEnablePlayTo', form).checked();
config.DlnaOptions.EnableDebugLogging = $('#chkEnableDlnaDebugLogging', form).checked();
config.DlnaOptions.ClientDiscoveryIntervalSeconds = $('#txtClientDiscoveryInterval', form).val();
config.EnablePlayTo = $('#chkEnablePlayTo', form).checked();
config.EnableDebugLogging = $('#chkEnableDlnaDebugLogging', form).checked();
config.ClientDiscoveryIntervalSeconds = $('#txtClientDiscoveryInterval', form).val();
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
ApiClient.updateNamedConfiguration("dlna", config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission

View File

@ -10,12 +10,12 @@
$('.chapterDownloadSettings', page).hide();
}
$('#chkChaptersMovies', page).checked(config.ChapterOptions.EnableMovieChapterImageExtraction).checkboxradio("refresh");
$('#chkChaptersEpisodes', page).checked(config.ChapterOptions.EnableEpisodeChapterImageExtraction).checkboxradio("refresh");
$('#chkChaptersOtherVideos', page).checked(config.ChapterOptions.EnableOtherVideoChapterImageExtraction).checkboxradio("refresh");
$('#chkChaptersMovies', page).checked(config.EnableMovieChapterImageExtraction).checkboxradio("refresh");
$('#chkChaptersEpisodes', page).checked(config.EnableEpisodeChapterImageExtraction).checkboxradio("refresh");
$('#chkChaptersOtherVideos', page).checked(config.EnableOtherVideoChapterImageExtraction).checkboxradio("refresh");
$('#chkDownloadChapterMovies', page).checked(config.ChapterOptions.DownloadMovieChapters).checkboxradio("refresh");
$('#chkDownloadChapterEpisodes', page).checked(config.ChapterOptions.DownloadEpisodeChapters).checkboxradio("refresh");
$('#chkDownloadChapterMovies', page).checked(config.DownloadMovieChapters).checkboxradio("refresh");
$('#chkDownloadChapterEpisodes', page).checked(config.DownloadEpisodeChapters).checkboxradio("refresh");
renderChapterFetchers(page, config, providers);
@ -46,7 +46,7 @@
id = 'chkChapterFetcher' + i;
var isChecked = config.ChapterOptions.DisabledFetchers.indexOf(plugin.Name) == -1 ? ' checked="checked"' : '';
var isChecked = config.DisabledFetchers.indexOf(plugin.Name) == -1 ? ' checked="checked"' : '';
html += '<input class="chkChapterFetcher" type="checkbox" name="' + id + '" id="' + id + '" data-pluginname="' + plugin.Name + '" data-mini="true"' + isChecked + '>';
html += '<label for="' + id + '">' + plugin.Name + '</label>';
@ -116,7 +116,7 @@
var page = this;
var promise1 = ApiClient.getServerConfiguration();
var promise1 = ApiClient.getNamedConfiguration("chapters");
var promise2 = $.getJSON(ApiClient.getUrl("Providers/Chapters"));
$.when(promise1, promise2).done(function (response1, response2) {
@ -134,28 +134,28 @@
var form = this;
ApiClient.getServerConfiguration().done(function (config) {
ApiClient.getNamedConfiguration("chapters").done(function (config) {
config.ChapterOptions.EnableMovieChapterImageExtraction = $('#chkChaptersMovies', form).checked();
config.ChapterOptions.EnableEpisodeChapterImageExtraction = $('#chkChaptersEpisodes', form).checked();
config.ChapterOptions.EnableOtherVideoChapterImageExtraction = $('#chkChaptersOtherVideos', form).checked();
config.EnableMovieChapterImageExtraction = $('#chkChaptersMovies', form).checked();
config.EnableEpisodeChapterImageExtraction = $('#chkChaptersEpisodes', form).checked();
config.EnableOtherVideoChapterImageExtraction = $('#chkChaptersOtherVideos', form).checked();
config.ChapterOptions.DownloadMovieChapters = $('#chkDownloadChapterMovies', form).checked();
config.ChapterOptions.DownloadEpisodeChapters = $('#chkDownloadChapterEpisodes', form).checked();
config.DownloadMovieChapters = $('#chkDownloadChapterMovies', form).checked();
config.DownloadEpisodeChapters = $('#chkDownloadChapterEpisodes', form).checked();
config.ChapterOptions.DisabledFetchers = $('.chkChapterFetcher:not(:checked)', form).get().map(function (c) {
config.DisabledFetchers = $('.chkChapterFetcher:not(:checked)', form).get().map(function (c) {
return c.getAttribute('data-pluginname');
});
config.ChapterOptions.FetcherOrder = $('.chkChapterFetcher', form).get().map(function (c) {
config.FetcherOrder = $('.chkChapterFetcher', form).get().map(function (c) {
return c.getAttribute('data-pluginname');
});
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
ApiClient.updateNamedConfiguration("chapters", config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission

View File

@ -14,14 +14,20 @@
// After saving chapter task, now save server config
ApiClient.getServerConfiguration().done(function (config) {
config.ChapterOptions.EnableMovieChapterImageExtraction = $('#chkMovies', page).checked();
config.EnableUPnP = $('#chkEnableUpnp', page).checked();
ApiClient.updateServerConfiguration(config).done(function (result) {
navigateToNextPage();
ApiClient.getNamedConfiguration("chapters").done(function (chapterConfig) {
chapterConfig.EnableMovieChapterImageExtraction = $('#chkMovies', page).checked();
ApiClient.updateNamedConfiguration("chapters", chapterConfig).done(function () {
navigateToNextPage();
});
});
});
});
});

View File

@ -1310,6 +1310,17 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
dataType: "json"
});
};
self.getNamedConfiguration = function (name) {
var url = self.getUrl("System/Configuration/" + name);
return self.ajax({
type: "GET",
url: url,
dataType: "json"
});
};
/**
* Gets the server's scheduled tasks
@ -2393,6 +2404,22 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
});
};
self.updateNamedConfiguration = function (name, configuration) {
if (!configuration) {
throw new Error("null configuration");
}
var url = self.getUrl("System/Configuration/" + name);
return self.ajax({
type: "POST",
url: url,
data: JSON.stringify(configuration),
contentType: "application/json"
});
};
self.updateItem = function (item) {
if (!item) {