2016-09-15 16:17:50 -07:00
|
|
|
|
define(['jQuery', 'dom', 'listViewStyle'], function ($, dom) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-02-02 12:31:56 -07:00
|
|
|
|
var currentType;
|
|
|
|
|
|
2014-02-02 06:36:31 -07:00
|
|
|
|
function loadTabs(page, tabs) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = tabs.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var tab = tabs[i];
|
|
|
|
|
|
2014-05-12 11:04:25 -07:00
|
|
|
|
var isChecked = i == 0 ? ' selected="selected"' : '';
|
2014-02-02 12:31:56 -07:00
|
|
|
|
|
2014-08-15 09:35:41 -07:00
|
|
|
|
html += '<option value="' + tab.type + '"' + isChecked + '>' + Globalize.translate(tab.name) + '</option>';
|
2014-02-02 06:36:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-03 10:01:51 -07:00
|
|
|
|
$('#selectItemType', page).html(html).trigger('change');
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadType(page, type) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2014-02-02 12:31:56 -07:00
|
|
|
|
currentType = type;
|
|
|
|
|
|
2014-02-02 06:36:31 -07:00
|
|
|
|
var promise1 = ApiClient.getServerConfiguration();
|
2014-07-01 22:16:59 -07:00
|
|
|
|
var promise2 = ApiClient.getJSON(ApiClient.getUrl("System/Configuration/MetadataPlugins"));
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
Promise.all([promise1, promise2]).then(function (responses) {
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
var config = responses[0];
|
|
|
|
|
var metadataPlugins = responses[1];
|
2014-02-02 12:31:56 -07:00
|
|
|
|
|
|
|
|
|
config = config.MetadataOptions.filter(function (c) {
|
|
|
|
|
return c.ItemType == type;
|
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
|
|
if (config) {
|
|
|
|
|
|
|
|
|
|
renderType(page, type, config, metadataPlugins);
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getJSON(ApiClient.getUrl("System/Configuration/MetadataOptions/Default")).then(function (defaultConfig) {
|
2014-02-02 12:31:56 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config = defaultConfig;
|
|
|
|
|
|
|
|
|
|
renderType(page, type, config, metadataPlugins);
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
});
|
2013-10-15 08:29:19 -07:00
|
|
|
|
|
2014-02-02 06:36:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-02 12:31:56 -07:00
|
|
|
|
function setVisibilityOfBackdrops(elem, visible) {
|
|
|
|
|
|
|
|
|
|
if (visible) {
|
|
|
|
|
elem.show();
|
|
|
|
|
|
|
|
|
|
$('input', elem).attr('required', 'required');
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
elem.hide();
|
|
|
|
|
|
|
|
|
|
$('input', elem).attr('required', '').removeAttr('required');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-02 06:36:31 -07:00
|
|
|
|
function renderType(page, type, config, metadataPlugins) {
|
|
|
|
|
|
|
|
|
|
var metadataInfo = metadataPlugins.filter(function (f) {
|
|
|
|
|
|
|
|
|
|
return type == f.ItemType;
|
|
|
|
|
})[0];
|
|
|
|
|
|
2014-02-02 12:31:56 -07:00
|
|
|
|
setVisibilityOfBackdrops($('.backdropFields', page), metadataInfo.SupportedImageTypes.indexOf('Backdrop') != -1);
|
|
|
|
|
setVisibilityOfBackdrops($('.screenshotFields', page), metadataInfo.SupportedImageTypes.indexOf('Screenshot') != -1);
|
2014-02-02 09:59:14 -07:00
|
|
|
|
|
2014-02-02 06:36:31 -07:00
|
|
|
|
$('.imageType', page).each(function () {
|
|
|
|
|
|
|
|
|
|
var imageType = this.getAttribute('data-imagetype');
|
2016-09-15 16:17:50 -07:00
|
|
|
|
var container = dom.parentWithTag(this, 'LABEL');
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
|
|
|
|
if (metadataInfo.SupportedImageTypes.indexOf(imageType) == -1) {
|
2016-09-15 16:17:50 -07:00
|
|
|
|
container.classList.add('hide');
|
2014-02-02 06:36:31 -07:00
|
|
|
|
} else {
|
2016-09-15 16:17:50 -07:00
|
|
|
|
container.classList.remove('hide');
|
2014-02-02 06:36:31 -07:00
|
|
|
|
}
|
2014-02-02 12:31:56 -07:00
|
|
|
|
|
|
|
|
|
if (getImageConfig(config, imageType).Limit) {
|
|
|
|
|
|
2016-02-18 22:03:00 -07:00
|
|
|
|
this.checked = true;
|
2014-02-02 12:31:56 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
2016-02-18 22:03:00 -07:00
|
|
|
|
this.checked = false;
|
2014-02-02 12:31:56 -07:00
|
|
|
|
}
|
2014-02-02 06:36:31 -07:00
|
|
|
|
});
|
|
|
|
|
|
2014-02-02 12:31:56 -07:00
|
|
|
|
var backdropConfig = getImageConfig(config, 'Backdrop');
|
|
|
|
|
|
|
|
|
|
$('#txtMaxBackdrops', page).val(backdropConfig.Limit);
|
|
|
|
|
$('#txtMinBackdropDownloadWidth', page).val(backdropConfig.MinWidth);
|
|
|
|
|
|
|
|
|
|
var screenshotConfig = getImageConfig(config, 'Screenshot');
|
|
|
|
|
|
|
|
|
|
$('#txtMaxScreenshots', page).val(screenshotConfig.Limit);
|
|
|
|
|
$('#txtMinScreenshotDownloadWidth', page).val(screenshotConfig.MinWidth);
|
|
|
|
|
|
2014-02-02 06:36:31 -07:00
|
|
|
|
renderMetadataLocals(page, type, config, metadataInfo);
|
|
|
|
|
renderMetadataFetchers(page, type, config, metadataInfo);
|
|
|
|
|
renderMetadataSavers(page, type, config, metadataInfo);
|
|
|
|
|
renderImageFetchers(page, type, config, metadataInfo);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-02 12:31:56 -07:00
|
|
|
|
function getImageConfig(config, type) {
|
|
|
|
|
|
|
|
|
|
return config.ImageOptions.filter(function (i) {
|
|
|
|
|
|
|
|
|
|
return i.Type == type;
|
|
|
|
|
|
|
|
|
|
})[0] || {
|
|
|
|
|
|
|
|
|
|
Type: type,
|
|
|
|
|
MinWidth: type == 'Backdrop' ? 1280 : 0,
|
|
|
|
|
Limit: type == 'Backdrop' ? 3 : 1
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-02 06:36:31 -07:00
|
|
|
|
function renderImageFetchers(page, type, config, metadataInfo) {
|
|
|
|
|
|
|
|
|
|
var plugins = metadataInfo.Plugins.filter(function (p) {
|
|
|
|
|
return p.Type == 'ImageFetcher';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
if (!plugins.length) {
|
2016-04-15 19:23:01 -07:00
|
|
|
|
$('.imageFetchers', page).html(html).hide();
|
2014-02-02 06:36:31 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 21:55:01 -07:00
|
|
|
|
var i, length, plugin, id;
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2016-09-15 16:17:50 -07:00
|
|
|
|
html += '<h3 class="checkboxListLabel">' + Globalize.translate('LabelImageFetchers') + '</h3>';
|
|
|
|
|
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
2014-02-10 21:55:01 -07:00
|
|
|
|
|
|
|
|
|
for (i = 0, length = plugins.length; i < length; i++) {
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2014-02-10 21:55:01 -07:00
|
|
|
|
plugin = plugins[i];
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2014-02-10 21:55:01 -07:00
|
|
|
|
var isChecked = config.DisabledImageFetchers.indexOf(plugin.Name) == -1 ? ' checked="checked"' : '';
|
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '<div class="listItem imageFetcherItem" data-pluginname="' + plugin.Name + '">';
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2016-09-15 16:17:50 -07:00
|
|
|
|
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkImageFetcher" data-pluginname="' + plugin.Name + '" ' + isChecked + '><span></span></label>';
|
2014-02-10 21:55:01 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '<div class="listItemBody">';
|
2014-02-10 21:55:01 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '<h3 class="listItemBodyText">';
|
2016-04-15 19:23:01 -07:00
|
|
|
|
html += plugin.Name;
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '</h3>';
|
2014-02-10 21:55:01 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '</div>';
|
2015-09-06 12:09:36 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '<button type="button" is="paper-icon-button-light" title="' + Globalize.translate('ButtonUp') + '" class="btnUp" style="padding:3px 8px;"><i class="md-icon">keyboard_arrow_up</i></button>';
|
|
|
|
|
html += '<button type="button" is="paper-icon-button-light" title="' + Globalize.translate('ButtonDown') + '" class="btnDown" style="padding:3px 8px;"><i class="md-icon">keyboard_arrow_down</i></button>';
|
2015-09-06 12:09:36 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '</div>';
|
2014-02-10 21:55:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
2016-04-15 12:57:54 -07:00
|
|
|
|
html += '<div class="fieldDescription">' + Globalize.translate('LabelImageFetchersHelp') + '</div>';
|
2014-02-11 14:41:01 -07:00
|
|
|
|
|
2016-04-15 19:23:01 -07:00
|
|
|
|
var elem = $('.imageFetchers', page).html(html).show();
|
2014-02-11 14:41:01 -07:00
|
|
|
|
|
|
|
|
|
$('.btnDown', elem).on('click', function () {
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2016-04-15 19:23:01 -07:00
|
|
|
|
var elemToMove = $(this).parents('.imageFetcherItem')[0];
|
2014-02-11 14:41:01 -07:00
|
|
|
|
|
2016-04-15 19:23:01 -07:00
|
|
|
|
var insertAfter = $(elemToMove).next('.imageFetcherItem')[0];
|
2014-02-11 14:41:01 -07:00
|
|
|
|
|
2016-04-15 19:23:01 -07:00
|
|
|
|
if (insertAfter) {
|
|
|
|
|
elemToMove.parentNode.removeChild(elemToMove);
|
|
|
|
|
$(elemToMove).insertAfter(insertAfter);
|
|
|
|
|
}
|
2014-02-11 14:41:01 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnUp', elem).on('click', function () {
|
|
|
|
|
|
2016-04-15 19:23:01 -07:00
|
|
|
|
var elemToMove = $(this).parents('.imageFetcherItem')[0];
|
2014-02-11 14:41:01 -07:00
|
|
|
|
|
2016-04-15 19:23:01 -07:00
|
|
|
|
var insertBefore = $(elemToMove).prev('.imageFetcherItem')[0];
|
2014-02-11 14:41:01 -07:00
|
|
|
|
|
2016-04-15 19:23:01 -07:00
|
|
|
|
if (insertBefore) {
|
|
|
|
|
elemToMove.parentNode.removeChild(elemToMove);
|
|
|
|
|
$(elemToMove).insertBefore(insertBefore);
|
|
|
|
|
}
|
2014-02-11 14:41:01 -07:00
|
|
|
|
});
|
2014-02-02 06:36:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderMetadataSavers(page, type, config, metadataInfo) {
|
|
|
|
|
|
|
|
|
|
var plugins = metadataInfo.Plugins.filter(function (p) {
|
|
|
|
|
return p.Type == 'MetadataSaver';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
if (!plugins.length) {
|
2016-04-15 19:23:01 -07:00
|
|
|
|
$('.metadataSavers', page).html(html).hide();
|
2014-02-02 06:36:31 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-15 16:17:50 -07:00
|
|
|
|
html += '<h3 class="checkboxListLabel">' + Globalize.translate('LabelMetadataSavers') + '</h3>';
|
|
|
|
|
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
|
|
|
|
for (var i = 0, length = plugins.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var plugin = plugins[i];
|
|
|
|
|
|
2014-02-02 12:31:56 -07:00
|
|
|
|
var isChecked = config.DisabledMetadataSavers.indexOf(plugin.Name) == -1 ? ' checked="checked"' : '';
|
|
|
|
|
|
2016-09-15 16:17:50 -07:00
|
|
|
|
html += '<label><input type="checkbox" is="emby-checkbox" class="chkMetadataSaver" data-pluginname="' + plugin.Name + '" ' + isChecked + '><span>' + plugin.Name + '</span></label>';
|
2014-02-02 06:36:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-23 13:06:45 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '<div class="fieldDescription" style="margin-top:.25em;">' + Globalize.translate('LabelMetadataSaversHelp') + '</div>';
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2016-02-23 13:06:45 -07:00
|
|
|
|
page.querySelector('.metadataSavers').innerHTML = html;
|
2014-02-02 06:36:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderMetadataFetchers(page, type, config, metadataInfo) {
|
|
|
|
|
|
|
|
|
|
var plugins = metadataInfo.Plugins.filter(function (p) {
|
|
|
|
|
return p.Type == 'MetadataFetcher';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
if (!plugins.length) {
|
2016-04-15 19:23:01 -07:00
|
|
|
|
$('.metadataFetchers', page).html(html).hide();
|
2014-02-02 06:36:31 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-15 19:23:01 -07:00
|
|
|
|
var i, length, plugin;
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2016-09-15 16:17:50 -07:00
|
|
|
|
html += '<h3 class="checkboxListLabel">' + Globalize.translate('LabelMetadataDownloaders') + '</h3>';
|
|
|
|
|
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
2014-02-10 21:55:01 -07:00
|
|
|
|
|
|
|
|
|
for (i = 0, length = plugins.length; i < length; i++) {
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2014-02-10 21:55:01 -07:00
|
|
|
|
plugin = plugins[i];
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2014-02-10 21:55:01 -07:00
|
|
|
|
var isChecked = config.DisabledMetadataFetchers.indexOf(plugin.Name) == -1 ? ' checked="checked"' : '';
|
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '<div class="listItem metadataFetcherItem" data-pluginname="' + plugin.Name + '">';
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2016-09-15 16:17:50 -07:00
|
|
|
|
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkMetadataFetcher" data-pluginname="' + plugin.Name + '" ' + isChecked + '><span></span></label>';
|
2014-02-10 21:55:01 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '<div class="listItemBody">';
|
2014-02-10 21:55:01 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '<h3 class="listItemBodyText">';
|
2016-04-15 19:18:40 -07:00
|
|
|
|
html += plugin.Name;
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '</h3>';
|
2014-02-10 21:55:01 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '</div>';
|
2015-09-06 12:09:36 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '<button type="button" is="paper-icon-button-light" title="' + Globalize.translate('ButtonUp') + '" class="btnUp" style="padding:3px 8px;"><i class="md-icon">keyboard_arrow_up</i></button>';
|
|
|
|
|
html += '<button type="button" is="paper-icon-button-light" title="' + Globalize.translate('ButtonDown') + '" class="btnDown" style="padding:3px 8px;"><i class="md-icon">keyboard_arrow_down</i></button>';
|
2015-09-06 12:09:36 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '</div>';
|
2014-02-10 21:55:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
2016-04-15 12:57:54 -07:00
|
|
|
|
html += '<div class="fieldDescription">' + Globalize.translate('LabelMetadataDownloadersHelp') + '</div>';
|
2014-02-11 14:41:01 -07:00
|
|
|
|
|
2016-04-15 19:23:01 -07:00
|
|
|
|
var elem = $('.metadataFetchers', page).html(html).show();
|
2014-02-11 14:41:01 -07:00
|
|
|
|
|
|
|
|
|
$('.btnDown', elem).on('click', function () {
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2016-04-15 19:18:40 -07:00
|
|
|
|
var elemToMove = $(this).parents('.metadataFetcherItem')[0];
|
2014-02-11 14:41:01 -07:00
|
|
|
|
|
2016-04-15 19:18:40 -07:00
|
|
|
|
var insertAfter = $(elemToMove).next('.metadataFetcherItem')[0];
|
2014-02-11 14:41:01 -07:00
|
|
|
|
|
2016-04-15 19:18:40 -07:00
|
|
|
|
if (insertAfter) {
|
|
|
|
|
elemToMove.parentNode.removeChild(elemToMove);
|
|
|
|
|
$(elemToMove).insertAfter(insertAfter);
|
|
|
|
|
}
|
2014-02-11 14:41:01 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnUp', elem).on('click', function () {
|
|
|
|
|
|
2016-04-15 19:18:40 -07:00
|
|
|
|
var elemToMove = $(this).parents('.metadataFetcherItem')[0];
|
2014-02-11 14:41:01 -07:00
|
|
|
|
|
2016-04-15 19:18:40 -07:00
|
|
|
|
var insertBefore = $(elemToMove).prev('.metadataFetcherItem')[0];
|
2014-02-11 14:41:01 -07:00
|
|
|
|
|
2016-04-15 19:18:40 -07:00
|
|
|
|
if (insertBefore) {
|
|
|
|
|
elemToMove.parentNode.removeChild(elemToMove);
|
|
|
|
|
$(elemToMove).insertBefore(insertBefore);
|
|
|
|
|
}
|
2014-02-11 14:41:01 -07:00
|
|
|
|
});
|
2014-02-02 06:36:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderMetadataLocals(page, type, config, metadataInfo) {
|
|
|
|
|
|
|
|
|
|
var plugins = metadataInfo.Plugins.filter(function (p) {
|
|
|
|
|
return p.Type == 'LocalMetadataProvider';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
2014-02-10 21:55:01 -07:00
|
|
|
|
if (plugins.length < 2) {
|
2016-04-15 19:23:01 -07:00
|
|
|
|
$('.metadataReaders', page).html(html).hide();
|
2014-02-02 06:36:31 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-15 16:17:50 -07:00
|
|
|
|
html += '<h3 class="checkboxListLabel">' + Globalize.translate('LabelMetadataReaders') + '</h3>';
|
|
|
|
|
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
|
|
|
|
for (var i = 0, length = plugins.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var plugin = plugins[i];
|
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '<div class="listItem localReaderOption" data-pluginname="' + plugin.Name + '">';
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '<i class="listItemIcon md-icon">live_tv</i>';
|
2014-02-10 11:39:41 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '<div class="listItemBody">';
|
2014-02-10 11:39:41 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '<h3 class="listItemBodyText">';
|
2016-04-15 12:37:34 -07:00
|
|
|
|
html += plugin.Name;
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '</h3>';
|
2014-02-10 11:39:41 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '</div>';
|
2014-02-10 11:39:41 -07:00
|
|
|
|
|
2016-04-15 12:37:34 -07:00
|
|
|
|
if (i > 0) {
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '<button type="button" is="paper-icon-button-light" title="' + Globalize.translate('ButtonUp') + '" class="btnLocalReaderUp btnLocalReaderMove" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_up</i></button>';
|
2016-04-15 12:37:34 -07:00
|
|
|
|
}
|
|
|
|
|
else if (plugins.length > 1) {
|
2014-02-10 11:39:41 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '<button type="button" is="paper-icon-button-light" title="' + Globalize.translate('ButtonDown') + '" class="btnLocalReaderDown btnLocalReaderMove" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_down</i></button>';
|
2014-02-10 11:39:41 -07:00
|
|
|
|
}
|
2016-04-15 12:37:34 -07:00
|
|
|
|
|
2016-08-05 13:25:09 -07:00
|
|
|
|
html += '</div>';
|
2014-02-02 06:36:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-15 12:37:34 -07:00
|
|
|
|
html += '</div>';
|
2014-08-15 09:35:41 -07:00
|
|
|
|
html += '<div class="fieldDescription">' + Globalize.translate('LabelMetadataReadersHelp') + '</div>';
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2016-04-15 12:37:34 -07:00
|
|
|
|
$('.metadataReaders', page).html(html).show();
|
2014-02-02 06:36:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadPage(page) {
|
|
|
|
|
|
2014-05-12 11:04:25 -07:00
|
|
|
|
loadTabs(page, [
|
|
|
|
|
|
2014-08-15 09:35:41 -07:00
|
|
|
|
{ name: 'OptionMovies', type: 'Movie' },
|
2014-07-13 17:57:32 -07:00
|
|
|
|
//{ name: 'Trailers', type: 'Trailer' },
|
2014-08-15 09:35:41 -07:00
|
|
|
|
{ name: 'OptionCollections', type: 'BoxSet' },
|
|
|
|
|
{ name: 'OptionSeries', type: 'Series' },
|
|
|
|
|
{ name: 'OptionSeasons', type: 'Season' },
|
|
|
|
|
{ name: 'OptionEpisodes', type: 'Episode' },
|
|
|
|
|
{ name: 'OptionGames', type: 'Game' },
|
|
|
|
|
{ name: 'OptionGameSystems', type: 'GameSystem' },
|
2014-07-13 17:57:32 -07:00
|
|
|
|
//{ name: 'Game Genres', type: 'GameGenre' },
|
2014-08-15 09:35:41 -07:00
|
|
|
|
{ name: 'OptionMusicArtists', type: 'MusicArtist' },
|
|
|
|
|
{ name: 'OptionMusicAlbums', type: 'MusicAlbum' },
|
|
|
|
|
{ name: 'OptionMusicVideos', type: 'MusicVideo' },
|
2014-07-13 17:57:32 -07:00
|
|
|
|
//{ name: 'Music Genres', type: 'MusicGenre' },
|
2014-08-15 09:35:41 -07:00
|
|
|
|
{ name: 'OptionSongs', type: 'Audio' },
|
|
|
|
|
{ name: 'OptionHomeVideos', type: 'Video' },
|
|
|
|
|
{ name: 'OptionBooks', type: 'Book' },
|
|
|
|
|
{ name: 'OptionPeople', type: 'Person' }
|
2014-07-13 17:57:32 -07:00
|
|
|
|
//{ name: 'Genres', type: 'Genre' },
|
|
|
|
|
//{ name: 'Studios', type: 'Studio' }
|
2014-05-12 11:04:25 -07:00
|
|
|
|
]);
|
2014-02-02 06:36:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-02 12:31:56 -07:00
|
|
|
|
function saveSettingsIntoConfig(form, config) {
|
|
|
|
|
|
2016-02-23 13:06:45 -07:00
|
|
|
|
config.DisabledMetadataSavers = $('.chkMetadataSaver', form).get().filter(function (c) {
|
|
|
|
|
|
|
|
|
|
return !c.checked;
|
|
|
|
|
|
|
|
|
|
}).map(function (c) {
|
2014-02-02 12:31:56 -07:00
|
|
|
|
|
|
|
|
|
return c.getAttribute('data-pluginname');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2014-02-10 21:55:01 -07:00
|
|
|
|
config.LocalMetadataReaderOrder = $('.localReaderOption', form).get().map(function (c) {
|
|
|
|
|
|
|
|
|
|
return c.getAttribute('data-pluginname');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2016-04-15 19:18:40 -07:00
|
|
|
|
config.DisabledMetadataFetchers = $('.chkMetadataFetcher', form).get().filter(function (c) {
|
|
|
|
|
return !c.checked;
|
|
|
|
|
}).map(function (c) {
|
2014-02-10 21:55:01 -07:00
|
|
|
|
|
|
|
|
|
return c.getAttribute('data-pluginname');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
config.MetadataFetcherOrder = $('.chkMetadataFetcher', form).get().map(function (c) {
|
|
|
|
|
|
|
|
|
|
return c.getAttribute('data-pluginname');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2016-04-15 19:23:01 -07:00
|
|
|
|
config.DisabledImageFetchers = $('.chkImageFetcher', form).get().filter(function (c) {
|
|
|
|
|
return !c.checked;
|
|
|
|
|
}).map(function (c) {
|
2014-02-10 21:55:01 -07:00
|
|
|
|
|
|
|
|
|
return c.getAttribute('data-pluginname');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
config.ImageFetcherOrder = $('.chkImageFetcher', form).get().map(function (c) {
|
2014-02-10 11:39:41 -07:00
|
|
|
|
|
|
|
|
|
return c.getAttribute('data-pluginname');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2016-02-18 22:03:00 -07:00
|
|
|
|
config.ImageOptions = $('.imageType:not(.hide)', form).get().map(function (c) {
|
2014-02-02 12:31:56 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
2016-02-18 22:03:00 -07:00
|
|
|
|
Type: c.getAttribute('data-imagetype'),
|
2014-02-02 12:31:56 -07:00
|
|
|
|
Limit: c.checked ? 1 : 0,
|
|
|
|
|
MinWidth: 0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2014-02-17 14:35:08 -07:00
|
|
|
|
config.ImageOptions.push({
|
|
|
|
|
Type: 'Backdrop',
|
|
|
|
|
Limit: $('#txtMaxBackdrops', form).val(),
|
|
|
|
|
MinWidth: $('#txtMinBackdropDownloadWidth', form).val()
|
|
|
|
|
});
|
2014-02-02 12:31:56 -07:00
|
|
|
|
|
2014-02-17 14:35:08 -07:00
|
|
|
|
config.ImageOptions.push({
|
|
|
|
|
Type: 'Screenshot',
|
|
|
|
|
Limit: $('#txtMaxScreenshots', form).val(),
|
|
|
|
|
MinWidth: $('#txtMinScreenshotDownloadWidth', form).val()
|
|
|
|
|
});
|
2014-02-02 12:31:56 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-02 06:36:31 -07:00
|
|
|
|
function onSubmit() {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
var form = this;
|
|
|
|
|
|
2013-04-16 21:58:32 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getServerConfiguration().then(function (config) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-02-02 12:31:56 -07:00
|
|
|
|
var type = currentType;
|
|
|
|
|
|
|
|
|
|
var metadataOptions = config.MetadataOptions.filter(function (c) {
|
|
|
|
|
return c.ItemType == type;
|
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
|
|
if (metadataOptions) {
|
|
|
|
|
|
|
|
|
|
saveSettingsIntoConfig(form, metadataOptions);
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult);
|
2014-02-02 12:31:56 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getJSON(ApiClient.getUrl("System/Configuration/MetadataOptions/Default")).then(function (defaultOptions) {
|
2014-02-02 12:31:56 -07:00
|
|
|
|
|
|
|
|
|
defaultOptions.ItemType = type;
|
|
|
|
|
config.MetadataOptions.push(defaultOptions);
|
|
|
|
|
saveSettingsIntoConfig(form, defaultOptions);
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult);
|
2014-02-02 12:31:56 -07:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Disable default form submission
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-12 23:02:07 -07:00
|
|
|
|
function getTabs() {
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
href: 'metadata.html',
|
|
|
|
|
name: Globalize.translate('TabSettings')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
href: 'metadataimages.html',
|
|
|
|
|
name: Globalize.translate('TabServices')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
href: 'metadatanfo.html',
|
|
|
|
|
name: Globalize.translate('TabNfoSettings')
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 07:01:59 -07:00
|
|
|
|
$(document).on('pageinit', "#metadataImagesConfigurationPage", function () {
|
2014-02-23 20:27:13 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('.metadataReaders', page).on('click', '.btnLocalReaderMove', function () {
|
|
|
|
|
|
|
|
|
|
var li = $(this).parents('.localReaderOption');
|
2016-04-15 12:37:34 -07:00
|
|
|
|
var list = li.parents('.paperList');
|
2014-02-23 20:27:13 -07:00
|
|
|
|
|
|
|
|
|
if ($(this).hasClass('btnLocalReaderDown')) {
|
|
|
|
|
|
|
|
|
|
var next = li.next();
|
|
|
|
|
|
|
|
|
|
li.remove().insertAfter(next);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
var prev = li.prev();
|
|
|
|
|
|
|
|
|
|
li.remove().insertBefore(prev);
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-15 12:37:34 -07:00
|
|
|
|
$('.localReaderOption', list).each(function () {
|
2014-02-23 20:27:13 -07:00
|
|
|
|
|
|
|
|
|
if ($(this).prev('.localReaderOption').length) {
|
2016-04-15 12:37:34 -07:00
|
|
|
|
$('.btnLocalReaderMove', this).addClass('btnLocalReaderUp').removeClass('btnLocalReaderDown').attr('icon', 'keyboard-arrow-up');
|
2014-02-23 20:27:13 -07:00
|
|
|
|
} else {
|
2016-04-15 12:37:34 -07:00
|
|
|
|
$('.btnLocalReaderMove', this).addClass('btnLocalReaderDown').removeClass('btnLocalReaderUp').attr('icon', 'keyboard-arrow-down');
|
2014-02-23 20:27:13 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
2014-05-12 11:04:25 -07:00
|
|
|
|
|
|
|
|
|
$('#selectItemType', page).on('change', function () {
|
|
|
|
|
|
|
|
|
|
loadType(page, this.value);
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
$('.metadataImagesConfigurationForm').off('submit', onSubmit).on('submit', onSubmit);
|
|
|
|
|
|
2015-09-24 10:08:10 -07:00
|
|
|
|
}).on('pageshow', "#metadataImagesConfigurationPage", function () {
|
2014-02-02 06:36:31 -07:00
|
|
|
|
|
2016-04-12 23:02:07 -07:00
|
|
|
|
LibraryMenu.setTabs('metadata', 1, getTabs);
|
2014-02-02 06:36:31 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
loadPage(page);
|
|
|
|
|
});
|
|
|
|
|
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|