mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
auto-organize - support new series
This commit is contained in:
parent
9cadc0ddff
commit
57684befac
3 changed files with 165 additions and 36 deletions
|
@ -1,5 +1,10 @@
|
||||||
define(['paperdialoghelper', 'paper-checkbox', 'paper-input', 'paper-button'], function (paperDialogHelper) {
|
define(['paperdialoghelper', 'paper-checkbox', 'paper-input', 'paper-button'], function (paperDialogHelper) {
|
||||||
|
|
||||||
|
var extractedName;
|
||||||
|
var extractedYear;
|
||||||
|
var currentNewItem;
|
||||||
|
var existingSeriesHtml;
|
||||||
|
|
||||||
function onApiFailure(e) {
|
function onApiFailure(e) {
|
||||||
|
|
||||||
Dashboard.hideLoadingMsg();
|
Dashboard.hideLoadingMsg();
|
||||||
|
@ -24,6 +29,10 @@
|
||||||
$('#txtSeason', context).val(item.ExtractedSeasonNumber);
|
$('#txtSeason', context).val(item.ExtractedSeasonNumber);
|
||||||
$('#txtEpisode', context).val(item.ExtractedEpisodeNumber);
|
$('#txtEpisode', context).val(item.ExtractedEpisodeNumber);
|
||||||
$('#txtEndingEpisode', context).val(item.ExtractedEndingEpisodeNumber);
|
$('#txtEndingEpisode', context).val(item.ExtractedEndingEpisodeNumber);
|
||||||
|
$('.extractedName', context).html(item.ExtractedName);
|
||||||
|
|
||||||
|
extractedName = item.ExtractedName;
|
||||||
|
extractedYear = item.ExtractedYear;
|
||||||
|
|
||||||
$('#chkRememberCorrection', context).val(false);
|
$('#chkRememberCorrection', context).val(false);
|
||||||
|
|
||||||
|
@ -36,15 +45,15 @@
|
||||||
|
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
|
|
||||||
var seriesHtml = result.Items.map(function (s) {
|
existingSeriesHtml = result.Items.map(function (s) {
|
||||||
|
|
||||||
return '<option value="' + s.Id + '">' + s.Name + '</option>';
|
return '<option value="' + s.Id + '">' + s.Name + '</option>';
|
||||||
|
|
||||||
}).join('');
|
}).join('');
|
||||||
|
|
||||||
seriesHtml = '<option value=""></option>' + seriesHtml;
|
existingSeriesHtml = '<option value=""></option>' + existingSeriesHtml;
|
||||||
|
|
||||||
$('#selectSeries', context).html(seriesHtml);
|
$('#selectSeries', context).html(existingSeriesHtml);
|
||||||
|
|
||||||
}, onApiFailure);
|
}, onApiFailure);
|
||||||
}
|
}
|
||||||
|
@ -74,10 +83,35 @@
|
||||||
}, onApiFailure);
|
}, onApiFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showNewSeriesDialog(dlg) {
|
||||||
|
|
||||||
|
require(['components/itemidentifier/itemidentifier'], function (itemidentifier) {
|
||||||
|
|
||||||
|
itemidentifier.showFindNew(extractedName, extractedYear, 'Series').then(function (newItem) {
|
||||||
|
|
||||||
|
currentNewItem = newItem;
|
||||||
|
|
||||||
|
var seriesHtml = existingSeriesHtml;
|
||||||
|
|
||||||
|
if (currentNewItem != null) {
|
||||||
|
seriesHtml = seriesHtml + '<option selected value="##NEW##">' + currentNewItem.Name + '</option>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#selectSeries', dlg).html(seriesHtml);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
show: function (item) {
|
show: function (item) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
|
||||||
|
extractedName = null;
|
||||||
|
extractedYear = null;
|
||||||
|
currentNewItem = null;
|
||||||
|
existingSeriesHtml = null;
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open('GET', 'components/fileorganizer/fileorganizer.template.html', true);
|
xhr.open('GET', 'components/fileorganizer/fileorganizer.template.html', true);
|
||||||
|
|
||||||
|
@ -127,6 +161,11 @@
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dlg.querySelector('#btnNewSeries').addEventListener('click', function (e) {
|
||||||
|
|
||||||
|
showNewSeriesDialog(dlg);
|
||||||
|
});
|
||||||
|
|
||||||
initEpisodeForm(dlg, item);
|
initEpisodeForm(dlg, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,13 @@
|
||||||
|
|
||||||
<p><span class="inputFile"></span></p>
|
<p><span class="inputFile"></span></p>
|
||||||
|
|
||||||
<div style="margin: 1em 0 1em; min-width: 250px;">
|
<div style="margin: 1em 0 1em;">
|
||||||
|
<div style="width:85%;display:inline-block;">
|
||||||
<label for="selectSeries" class="selectLabel">${LabelSeries}</label>
|
<label for="selectSeries" class="selectLabel">${LabelSeries}</label>
|
||||||
<select id="selectSeries" data-mini="true" required="required"></select>
|
<select id="selectSeries" data-mini="true" required="required"></select>
|
||||||
</div>
|
</div>
|
||||||
|
<paper-icon-button id="btnNewSeries" icon="add" title="${ButtonNew}"></paper-icon-button>
|
||||||
|
</div>
|
||||||
<div style="margin: 1em 0;">
|
<div style="margin: 1em 0;">
|
||||||
<paper-input id="txtSeason" type="number" pattern="[0-9]*" required min="0" label="${LabelSeasonNumber}"></paper-input>
|
<paper-input id="txtSeason" type="number" pattern="[0-9]*" required min="0" label="${LabelSeasonNumber}"></paper-input>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,18 +1,11 @@
|
||||||
define(['paperdialoghelper', 'paper-dialog', 'paper-fab', 'paper-input', 'paper-checkbox'], function (paperDialogHelper) {
|
define(['paperdialoghelper', 'paper-dialog', 'paper-fab', 'paper-input', 'paper-checkbox'], function (paperDialogHelper) {
|
||||||
|
|
||||||
var currentItem;
|
var currentItem;
|
||||||
|
var currentItemType;
|
||||||
var currentDeferred;
|
var currentDeferred;
|
||||||
var hasChanges = false;
|
var hasChanges = false;
|
||||||
var currentSearchResult;
|
var currentSearchResult;
|
||||||
|
|
||||||
function onIdentificationFormSubmitted() {
|
|
||||||
|
|
||||||
var page = $(this).parents('paper-dialog');
|
|
||||||
|
|
||||||
searchForIdentificationResults(page);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function searchForIdentificationResults(page) {
|
function searchForIdentificationResults(page) {
|
||||||
|
|
||||||
var lookupInfo = {
|
var lookupInfo = {
|
||||||
|
@ -54,7 +47,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentItem.GameSystem) {
|
if (currentItem && currentItem.GameSystem) {
|
||||||
lookupInfo.GameSystem = currentItem.GameSystem;
|
lookupInfo.GameSystem = currentItem.GameSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +60,7 @@
|
||||||
|
|
||||||
ApiClient.ajax({
|
ApiClient.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: ApiClient.getUrl("Items/RemoteSearch/" + currentItem.Type),
|
url: ApiClient.getUrl("Items/RemoteSearch/" + currentItemType),
|
||||||
data: JSON.stringify(lookupInfo),
|
data: JSON.stringify(lookupInfo),
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
|
@ -102,10 +95,24 @@
|
||||||
|
|
||||||
var currentResult = results[index];
|
var currentResult = results[index];
|
||||||
|
|
||||||
|
if (currentItem != null) {
|
||||||
|
|
||||||
showIdentifyOptions(page, currentResult);
|
showIdentifyOptions(page, currentResult);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
finishFindNewDialog(page, currentResult);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function finishFindNewDialog(dlg, identifyResult) {
|
||||||
|
currentSearchResult = identifyResult;
|
||||||
|
hasChanges = true;
|
||||||
|
Dashboard.hideLoadingMsg();
|
||||||
|
|
||||||
|
paperDialogHelper.close(dlg);
|
||||||
|
}
|
||||||
|
|
||||||
function showIdentifyOptions(page, identifyResult) {
|
function showIdentifyOptions(page, identifyResult) {
|
||||||
|
|
||||||
$('.popupIdentifyForm', page).hide();
|
$('.popupIdentifyForm', page).hide();
|
||||||
|
@ -143,10 +150,10 @@
|
||||||
var html = '';
|
var html = '';
|
||||||
var cssClass = "card";
|
var cssClass = "card";
|
||||||
|
|
||||||
if (currentItem.Type == "Episode") {
|
if (currentItemType == "Episode") {
|
||||||
cssClass += " backdropCard";
|
cssClass += " backdropCard";
|
||||||
}
|
}
|
||||||
else if (currentItem.Type == "MusicAlbum" || currentItem.Type == "MusicArtist") {
|
else if (currentItemType == "MusicAlbum" || currentItemType == "MusicArtist") {
|
||||||
cssClass += " squareCard";
|
cssClass += " squareCard";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -193,14 +200,6 @@
|
||||||
return ApiClient.getUrl("Items/RemoteSearch/Image", { imageUrl: url, ProviderName: provider });
|
return ApiClient.getUrl("Items/RemoteSearch/Image", { imageUrl: url, ProviderName: provider });
|
||||||
}
|
}
|
||||||
|
|
||||||
function onIdentificationOptionsSubmit() {
|
|
||||||
|
|
||||||
var page = $(this).parents('paper-dialog');
|
|
||||||
|
|
||||||
submitIdentficationResult(page);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function submitIdentficationResult(page) {
|
function submitIdentficationResult(page) {
|
||||||
|
|
||||||
Dashboard.showLoadingMsg();
|
Dashboard.showLoadingMsg();
|
||||||
|
@ -220,22 +219,16 @@
|
||||||
hasChanges = true;
|
hasChanges = true;
|
||||||
Dashboard.hideLoadingMsg();
|
Dashboard.hideLoadingMsg();
|
||||||
|
|
||||||
paperDialogHelper.close(document.querySelector('.identifyDialog'));
|
paperDialogHelper.close(page);
|
||||||
|
|
||||||
}, function () {
|
}, function () {
|
||||||
|
|
||||||
Dashboard.hideLoadingMsg();
|
Dashboard.hideLoadingMsg();
|
||||||
|
|
||||||
paperDialogHelper.close(document.querySelector('.identifyDialog'));
|
paperDialogHelper.close(page);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initEditor(page) {
|
|
||||||
|
|
||||||
$('.popupIdentifyForm', page).off('submit', onIdentificationFormSubmitted).on('submit', onIdentificationFormSubmitted);
|
|
||||||
$('.identifyOptionsForm', page).off('submit', onIdentificationOptionsSubmit).on('submit', onIdentificationOptionsSubmit);
|
|
||||||
}
|
|
||||||
|
|
||||||
function showIdentificationForm(page, item) {
|
function showIdentificationForm(page, item) {
|
||||||
|
|
||||||
ApiClient.getJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).then(function (idList) {
|
ApiClient.getJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).then(function (idList) {
|
||||||
|
@ -292,6 +285,7 @@
|
||||||
ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).then(function (item) {
|
ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).then(function (item) {
|
||||||
|
|
||||||
currentItem = item;
|
currentItem = item;
|
||||||
|
currentItemType = currentItem.Type;
|
||||||
|
|
||||||
var dlg = paperDialogHelper.createDialog({
|
var dlg = paperDialogHelper.createDialog({
|
||||||
size: 'medium'
|
size: 'medium'
|
||||||
|
@ -311,7 +305,19 @@
|
||||||
|
|
||||||
paperDialogHelper.open(dlg);
|
paperDialogHelper.open(dlg);
|
||||||
|
|
||||||
initEditor(dlg);
|
dlg.querySelector('.popupIdentifyForm').addEventListener('submit', function (e) {
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
searchForIdentificationResults(dlg);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
dlg.querySelector('.identifyOptionsForm').addEventListener('submit', function (e) {
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
submitIdentficationResult(dlg);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
$('.btnCancel', dlg).on('click', function () {
|
$('.btnCancel', dlg).on('click', function () {
|
||||||
|
|
||||||
|
@ -335,6 +341,79 @@
|
||||||
currentDeferred.resolveWith(null, [hasChanges]);
|
currentDeferred.resolveWith(null, [hasChanges]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showEditorFindNew(itemName, itemYear, itemType, resolveFunc) {
|
||||||
|
|
||||||
|
currentItem = null;
|
||||||
|
currentItemType = itemType;
|
||||||
|
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('GET', 'components/itemidentifier/itemidentifier.template.html', true);
|
||||||
|
|
||||||
|
xhr.onload = function (e) {
|
||||||
|
|
||||||
|
var template = this.response;
|
||||||
|
|
||||||
|
var dlg = paperDialogHelper.createDialog({
|
||||||
|
size: 'medium'
|
||||||
|
});
|
||||||
|
|
||||||
|
dlg.classList.add('ui-body-a');
|
||||||
|
dlg.classList.add('background-theme-a');
|
||||||
|
|
||||||
|
var html = '';
|
||||||
|
html += Globalize.translateDocument(template);
|
||||||
|
|
||||||
|
dlg.innerHTML = html;
|
||||||
|
document.body.appendChild(dlg);
|
||||||
|
|
||||||
|
paperDialogHelper.open(dlg);
|
||||||
|
|
||||||
|
dlg.querySelector('.btnCancel').addEventListener('click', function (e) {
|
||||||
|
|
||||||
|
paperDialogHelper.close(dlg);
|
||||||
|
});
|
||||||
|
|
||||||
|
dlg.querySelector('.popupIdentifyForm').addEventListener('submit', function (e) {
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
searchForIdentificationResults(dlg);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
dlg.addEventListener('iron-overlay-closed', function () {
|
||||||
|
|
||||||
|
Dashboard.hideLoadingMsg();
|
||||||
|
var foundItem = hasChanges ? currentSearchResult : null;
|
||||||
|
|
||||||
|
resolveFunc(foundItem);
|
||||||
|
});
|
||||||
|
|
||||||
|
dlg.classList.add('identifyDialog');
|
||||||
|
|
||||||
|
showIdentificationFormFindNew(dlg, itemName, itemYear, itemType);
|
||||||
|
}
|
||||||
|
|
||||||
|
xhr.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showIdentificationFormFindNew(dlg, itemName, itemYear, itemType) {
|
||||||
|
|
||||||
|
dlg.querySelector('#txtLookupName').value = itemName;
|
||||||
|
|
||||||
|
if (itemType == "Person" || itemType == "BoxSet") {
|
||||||
|
|
||||||
|
dlg.querySelector('.fldLookupYear').classList.add('hide');
|
||||||
|
dlg.querySelector('#txtLookupYear').value = '';
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
dlg.querySelector('.fldLookupYear').classList.remove('hide');
|
||||||
|
dlg.querySelector('#txtLookupYear').value = itemYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
dlg.querySelector('.dialogHeaderTitle').innerHTML = Globalize.translate('HeaderSearch');
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
show: function (itemId) {
|
show: function (itemId) {
|
||||||
|
|
||||||
|
@ -345,6 +424,14 @@
|
||||||
|
|
||||||
showEditor(itemId);
|
showEditor(itemId);
|
||||||
return deferred.promise();
|
return deferred.promise();
|
||||||
|
},
|
||||||
|
|
||||||
|
showFindNew: function (itemName, itemYear, itemType) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
|
||||||
|
hasChanges = false;
|
||||||
|
showEditorFindNew(itemName, itemYear, itemType, resolve);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
Loading…
Add table
Add a link
Reference in a new issue