jellyfin-web/dashboard-ui/dashboard/librarysettings.js

174 lines
6.2 KiB
JavaScript
Raw Normal View History

2016-09-11 08:30:04 -07:00
define(['jQuery', 'fnchecked', 'emby-checkbox'], function ($) {
2016-10-22 22:11:46 -07:00
'use strict';
2013-05-21 13:36:26 -07:00
function loadPage(page, config) {
if (config.MergeMetadataAndImagesByName) {
$('.fldImagesByName', page).hide();
} else {
$('.fldImagesByName', page).show();
}
$('#txtSeasonZeroName', page).val(config.SeasonZeroDisplayName);
2016-03-27 20:37:33 -07:00
$('#chkSaveMetadataHidden', page).checked(config.SaveMetadataHidden);
$('#txtMetadataPath', page).val(config.MetadataPath || '');
2016-09-27 10:51:01 -07:00
$('#txtMetadataNetworkPath', page).val(config.MetadataNetworkPath || '');
2016-03-27 20:37:33 -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);
2013-05-21 13:36:26 -07:00
Dashboard.hideLoadingMsg();
}
2016-03-27 20:37:33 -07:00
function loadMetadataConfig(page, config) {
$('#selectDateAdded', page).val((config.UseFileCreationTimeForDateAdded ? '1' : '0'));
}
function loadFanartConfig(page, config) {
$('#txtFanartApiKey', page).val(config.UserApiKey || '');
}
function saveFanart(form) {
ApiClient.getNamedConfiguration("fanart").then(function (config) {
config.UserApiKey = $('#txtFanartApiKey', form).val();
ApiClient.updateNamedConfiguration("fanart", config);
});
}
function saveMetadata(form) {
ApiClient.getNamedConfiguration("metadata").then(function (config) {
config.UseFileCreationTimeForDateAdded = $('#selectDateAdded', form).val() == '1';
ApiClient.updateNamedConfiguration("metadata", config);
});
}
2015-06-07 18:23:56 -07:00
function onSubmit() {
Dashboard.showLoadingMsg();
var form = this;
2015-12-14 08:43:03 -07:00
ApiClient.getServerConfiguration().then(function (config) {
2015-06-07 18:23:56 -07:00
config.SeasonZeroDisplayName = $('#txtSeasonZeroName', form).val();
2016-03-27 20:37:33 -07:00
config.SaveMetadataHidden = $('#chkSaveMetadataHidden', form).checked();
config.EnableTvDbUpdates = $('#chkEnableTvdbUpdates', form).checked();
config.EnableTmdbUpdates = $('#chkEnableTmdbUpdates', form).checked();
config.EnableFanArtUpdates = $('#chkEnableFanartUpdates', form).checked();
config.MetadataPath = $('#txtMetadataPath', form).val();
2016-09-27 10:51:01 -07:00
config.MetadataNetworkPath = $('#txtMetadataNetworkPath', form).val();
2016-03-27 20:37:33 -07:00
config.FanartApiKey = $('#txtFanartApiKey', form).val();
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);
2015-06-07 18:23:56 -07:00
});
2016-03-27 20:37:33 -07:00
saveMetadata(form);
saveFanart(form);
2015-06-07 18:23:56 -07:00
// Disable default form submission
return false;
}
2016-04-14 19:39:39 -07:00
function getTabs() {
return [
{
href: 'library.html',
2016-09-24 10:58:17 -07:00
name: Globalize.translate('HeaderLibraries')
2016-04-14 19:39:39 -07:00
},
2016-06-03 22:51:33 -07:00
{
href: 'librarydisplay.html',
name: Globalize.translate('TabDisplay')
},
2016-04-14 19:39:39 -07:00
{
href: 'librarypathmapping.html',
name: Globalize.translate('TabPathSubstitution')
},
{
href: 'librarysettings.html',
name: Globalize.translate('TabAdvanced')
}];
}
2016-06-04 10:14:03 -07:00
return function (view, params) {
2013-05-21 13:36:26 -07:00
2016-06-04 10:14:03 -07:00
var self = this;
2014-07-19 21:46:29 -07:00
2016-06-04 10:14:03 -07:00
$('#btnSelectMetadataPath', view).on("click.selectDirectory", function () {
2016-03-27 20:37:33 -07:00
require(['directorybrowser'], function (directoryBrowser) {
var picker = new directoryBrowser();
picker.show({
2016-09-27 10:51:01 -07:00
path: $('#txtMetadataPath', view).val(),
2016-09-29 05:55:49 -07:00
networkSharePath: $('#txtMetadataNetworkPath', view).val(),
2016-09-27 10:51:01 -07:00
callback: function (path, networkPath) {
2016-03-27 20:37:33 -07:00
if (path) {
2016-06-04 10:14:03 -07:00
$('#txtMetadataPath', view).val(path);
2016-09-27 10:51:01 -07:00
$('#txtMetadataNetworkPath', view).val(networkPath);
2016-03-27 20:37:33 -07:00
}
picker.close();
},
header: Globalize.translate('HeaderSelectMetadataPath'),
2016-09-27 10:51:01 -07:00
instruction: Globalize.translate('HeaderSelectMetadataPathHelp'),
enableNetworkSharePath: true
2016-03-27 20:37:33 -07:00
});
});
});
2015-06-07 18:23:56 -07:00
$('.librarySettingsForm').off('submit', onSubmit).on('submit', onSubmit);
2016-06-04 10:14:03 -07:00
view.addEventListener('viewshow', function () {
LibraryMenu.setTabs('librarysetup', 3, getTabs);
Dashboard.showLoadingMsg();
var page = this;
ApiClient.getServerConfiguration().then(function (config) {
loadPage(page, config);
});
ApiClient.getNamedConfiguration("metadata").then(function (metadata) {
loadMetadataConfig(page, metadata);
});
ApiClient.getNamedConfiguration("fanart").then(function (metadata) {
loadFanartConfig(page, metadata);
});
});
};
2013-05-21 13:36:26 -07:00
});