jellyfin-web/dashboard-ui/scripts/metadataadvanced.js

222 lines
7.7 KiB
JavaScript
Raw Normal View History

2014-07-21 18:29:06 -07:00
(function (window, $) {
2013-02-20 18:33:05 -07:00
2014-07-21 18:29:06 -07:00
function loadAdvancedConfig(page, config) {
2013-02-20 18:33:05 -07:00
2016-02-18 22:03:00 -07:00
$('#chkSaveMetadataHidden', page).checked(config.SaveMetadataHidden);
2014-07-21 18:29:06 -07:00
$('#txtMetadataPath', page).val(config.MetadataPath || '');
2013-02-20 18:33:05 -07:00
2016-02-18 22:03:00 -07:00
$('#chkPeopleActors', page).checked(config.PeopleMetadataOptions.DownloadActorMetadata);
$('#chkPeopleComposers', page).checked(config.PeopleMetadataOptions.DownloadComposerMetadata);
$('#chkPeopleDirectors', page).checked(config.PeopleMetadataOptions.DownloadDirectorMetadata);
$('#chkPeopleProducers', page).checked(config.PeopleMetadataOptions.DownloadProducerMetadata);
$('#chkPeopleWriters', page).checked(config.PeopleMetadataOptions.DownloadWriterMetadata);
$('#chkPeopleOthers', page).checked(config.PeopleMetadataOptions.DownloadOtherPeopleMetadata);
$('#chkPeopleGuestStars', page).checked(config.PeopleMetadataOptions.DownloadGuestStarMetadata);
2014-08-14 06:24:30 -07:00
2016-02-25 21:09:42 -07:00
$('#chkDownloadImagesInAdvance', page).checked(config.DownloadImagesInAdvance);
2014-07-21 18:29:06 -07:00
Dashboard.hideLoadingMsg();
}
2013-02-20 18:33:05 -07:00
2014-10-09 15:22:04 -07:00
function loadMetadataConfig(page, config) {
2015-09-20 10:56:26 -07:00
$('#selectDateAdded', page).val((config.UseFileCreationTimeForDateAdded ? '1' : '0'));
2015-01-17 22:45:10 -07:00
}
function loadTmdbConfig(page, config) {
2016-02-18 22:03:00 -07:00
$('#chkEnableTmdbUpdates', page).checked(config.EnableAutomaticUpdates);
2015-01-17 22:45:10 -07:00
}
function loadTvdbConfig(page, config) {
2016-02-18 22:03:00 -07:00
$('#chkEnableTvdbUpdates', page).checked(config.EnableAutomaticUpdates);
2015-01-17 22:45:10 -07:00
}
function loadFanartConfig(page, config) {
2014-10-09 15:22:04 -07:00
2016-02-18 22:03:00 -07:00
$('#chkEnableFanartUpdates', page).checked(config.EnableAutomaticUpdates);
2015-01-17 22:45:10 -07:00
$('#txtFanartApiKey', page).val(config.UserApiKey || '');
2014-10-09 15:22:04 -07:00
}
2014-07-21 18:29:06 -07:00
function loadChapters(page, config, providers) {
2016-02-18 22:03:00 -07:00
$('#chkChaptersMovies', page).checked(config.EnableMovieChapterImageExtraction);
$('#chkChaptersEpisodes', page).checked(config.EnableEpisodeChapterImageExtraction);
$('#chkChaptersOtherVideos', page).checked(config.EnableOtherVideoChapterImageExtraction);
2014-07-21 18:29:06 -07:00
2016-02-18 22:03:00 -07:00
$('#chkExtractChaptersDuringLibraryScan', page).checked(config.ExtractDuringLibraryScan);
2014-09-08 18:15:31 -07:00
2014-07-21 18:29:06 -07:00
Dashboard.hideLoadingMsg();
}
2015-05-19 12:15:40 -07:00
function onSubmit() {
var form = this;
Dashboard.showLoadingMsg();
saveAdvancedConfig(form);
saveChapters(form);
saveMetadata(form);
saveTmdb(form);
saveTvdb(form);
saveFanart(form);
// Disable default form submission
return false;
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#advancedMetadataConfigurationPage", function () {
2014-07-19 21:46:29 -07:00
var page = this;
$('#btnSelectMetadataPath', page).on("click.selectDirectory", function () {
2015-10-13 12:22:45 -07:00
require(['directorybrowser'], function (directoryBrowser) {
2014-07-19 21:46:29 -07:00
2015-10-13 12:22:45 -07:00
var picker = new directoryBrowser();
picker.show({
2014-07-19 21:46:29 -07:00
2015-10-13 12:22:45 -07:00
callback: function (path) {
if (path) {
$('#txtMetadataPath', page).val(path);
}
picker.close();
},
2014-07-19 21:46:29 -07:00
2015-10-13 12:22:45 -07:00
header: Globalize.translate('HeaderSelectMetadataPath'),
2014-07-19 21:46:29 -07:00
2015-10-13 12:22:45 -07:00
instruction: Globalize.translate('HeaderSelectMetadataPathHelp')
});
2014-07-19 21:46:29 -07:00
});
2015-10-13 12:22:45 -07:00
2014-07-19 21:46:29 -07:00
});
2015-05-19 12:15:40 -07:00
$('.advancedMetadataConfigurationForm').on('submit', onSubmit).on('submit', onSubmit);
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#advancedMetadataConfigurationPage", function () {
2013-12-17 21:39:44 -07:00
2014-07-21 18:29:06 -07:00
var page = this;
2013-02-20 18:33:05 -07:00
2015-12-14 08:43:03 -07:00
ApiClient.getServerConfiguration().then(function (configuration) {
2014-07-21 18:29:06 -07:00
loadAdvancedConfig(page, configuration);
});
2013-02-20 18:33:05 -07:00
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration("metadata").then(function (metadata) {
2014-10-09 15:22:04 -07:00
loadMetadataConfig(page, metadata);
});
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration("fanart").then(function (metadata) {
2015-01-17 22:45:10 -07:00
loadFanartConfig(page, metadata);
});
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration("themoviedb").then(function (metadata) {
2015-01-17 22:45:10 -07:00
loadTmdbConfig(page, metadata);
});
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration("tvdb").then(function (metadata) {
2015-01-17 22:45:10 -07:00
loadTvdbConfig(page, metadata);
});
2014-07-21 18:29:06 -07:00
var promise1 = ApiClient.getNamedConfiguration("chapters");
var promise2 = ApiClient.getJSON(ApiClient.getUrl("Providers/Chapters"));
2013-02-20 18:33:05 -07:00
2015-12-14 08:43:03 -07:00
Promise.all([promise1, promise2]).then(function (responses) {
2014-07-21 18:29:06 -07:00
2015-12-14 08:43:03 -07:00
loadChapters(page, responses[0], responses[1]);
2014-07-21 18:29:06 -07:00
});
});
2015-01-17 22:45:10 -07:00
function saveFanart(form) {
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration("fanart").then(function (config) {
2015-01-17 22:45:10 -07:00
config.EnableAutomaticUpdates = $('#chkEnableFanartUpdates', form).checked();
config.UserApiKey = $('#txtFanartApiKey', form).val();
ApiClient.updateNamedConfiguration("fanart", config);
});
}
function saveTvdb(form) {
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration("tvdb").then(function (config) {
2015-01-17 22:45:10 -07:00
config.EnableAutomaticUpdates = $('#chkEnableTvdbUpdates', form).checked();
ApiClient.updateNamedConfiguration("tvdb", config);
});
}
function saveTmdb(form) {
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration("themoviedb").then(function (config) {
2015-01-17 22:45:10 -07:00
config.EnableAutomaticUpdates = $('#chkEnableTmdbUpdates', form).checked();
ApiClient.updateNamedConfiguration("themoviedb", config);
});
}
2014-07-21 18:29:06 -07:00
function saveAdvancedConfig(form) {
2013-04-16 21:58:32 -07:00
2015-12-14 08:43:03 -07:00
ApiClient.getServerConfiguration().then(function (config) {
2013-02-20 18:33:05 -07:00
config.SaveMetadataHidden = $('#chkSaveMetadataHidden', form).checked();
2013-12-17 21:39:44 -07:00
config.EnableTvDbUpdates = $('#chkEnableTvdbUpdates', form).checked();
2015-01-17 22:45:10 -07:00
config.EnableTmdbUpdates = $('#chkEnableTmdbUpdates', form).checked();
2014-01-30 21:50:09 -07:00
config.EnableFanArtUpdates = $('#chkEnableFanartUpdates', form).checked();
2014-07-19 21:46:29 -07:00
config.MetadataPath = $('#txtMetadataPath', form).val();
config.FanartApiKey = $('#txtFanartApiKey', form).val();
2013-02-20 18:33:05 -07:00
2016-02-25 21:09:42 -07:00
config.DownloadImagesInAdvance = $('#chkDownloadImagesInAdvance', form).checked();
2014-08-14 06:24:30 -07:00
config.PeopleMetadataOptions.DownloadActorMetadata = $('#chkPeopleActors', form).checked();
config.PeopleMetadataOptions.DownloadComposerMetadata = $('#chkPeopleComposers', form).checked();
config.PeopleMetadataOptions.DownloadDirectorMetadata = $('#chkPeopleDirectors', form).checked();
config.PeopleMetadataOptions.DownloadGuestStarMetadata = $('#chkPeopleGuestStars', form).checked();
config.PeopleMetadataOptions.DownloadProducerMetadata = $('#chkPeopleProducers', form).checked();
config.PeopleMetadataOptions.DownloadWriterMetadata = $('#chkPeopleWriters', form).checked();
config.PeopleMetadataOptions.DownloadOtherPeopleMetadata = $('#chkPeopleOthers', form).checked();
2015-12-14 08:43:03 -07:00
ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult);
2013-02-20 18:33:05 -07:00
});
2014-07-21 18:29:06 -07:00
}
2013-02-20 18:33:05 -07:00
2014-10-09 15:22:04 -07:00
function saveMetadata(form) {
2015-05-19 12:15:40 -07:00
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration("metadata").then(function (config) {
2014-10-09 15:22:04 -07:00
config.UseFileCreationTimeForDateAdded = $('#selectDateAdded', form).val() == '1';
ApiClient.updateNamedConfiguration("metadata", config);
});
}
2014-07-21 18:29:06 -07:00
function saveChapters(form) {
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration("chapters").then(function (config) {
2014-07-21 18:29:06 -07:00
config.EnableMovieChapterImageExtraction = $('#chkChaptersMovies', form).checked();
config.EnableEpisodeChapterImageExtraction = $('#chkChaptersEpisodes', form).checked();
config.EnableOtherVideoChapterImageExtraction = $('#chkChaptersOtherVideos', form).checked();
2014-09-08 18:15:31 -07:00
config.ExtractDuringLibraryScan = $('#chkExtractChaptersDuringLibraryScan', form).checked();
2014-07-21 18:29:06 -07:00
ApiClient.updateNamedConfiguration("chapters", config);
});
2013-02-20 18:33:05 -07:00
}
2014-07-21 18:29:06 -07:00
})(window, jQuery);