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) {
|
||||
|
||||
var extractedName;
|
||||
var extractedYear;
|
||||
var currentNewItem;
|
||||
var existingSeriesHtml;
|
||||
|
||||
function onApiFailure(e) {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
@ -24,6 +29,10 @@
|
|||
$('#txtSeason', context).val(item.ExtractedSeasonNumber);
|
||||
$('#txtEpisode', context).val(item.ExtractedEpisodeNumber);
|
||||
$('#txtEndingEpisode', context).val(item.ExtractedEndingEpisodeNumber);
|
||||
$('.extractedName', context).html(item.ExtractedName);
|
||||
|
||||
extractedName = item.ExtractedName;
|
||||
extractedYear = item.ExtractedYear;
|
||||
|
||||
$('#chkRememberCorrection', context).val(false);
|
||||
|
||||
|
@ -36,15 +45,15 @@
|
|||
|
||||
}).then(function (result) {
|
||||
|
||||
var seriesHtml = result.Items.map(function (s) {
|
||||
existingSeriesHtml = result.Items.map(function (s) {
|
||||
|
||||
return '<option value="' + s.Id + '">' + s.Name + '</option>';
|
||||
|
||||
}).join('');
|
||||
|
||||
seriesHtml = '<option value=""></option>' + seriesHtml;
|
||||
existingSeriesHtml = '<option value=""></option>' + existingSeriesHtml;
|
||||
|
||||
$('#selectSeries', context).html(seriesHtml);
|
||||
$('#selectSeries', context).html(existingSeriesHtml);
|
||||
|
||||
}, onApiFailure);
|
||||
}
|
||||
|
@ -74,10 +83,35 @@
|
|||
}, 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 {
|
||||
show: function (item) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
extractedName = null;
|
||||
extractedYear = null;
|
||||
currentNewItem = null;
|
||||
existingSeriesHtml = null;
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'components/fileorganizer/fileorganizer.template.html', true);
|
||||
|
||||
|
@ -127,6 +161,11 @@
|
|||
return false;
|
||||
});
|
||||
|
||||
dlg.querySelector('#btnNewSeries').addEventListener('click', function (e) {
|
||||
|
||||
showNewSeriesDialog(dlg);
|
||||
});
|
||||
|
||||
initEpisodeForm(dlg, item);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,12 @@
|
|||
|
||||
<p><span class="inputFile"></span></p>
|
||||
|
||||
<div style="margin: 1em 0 1em; min-width: 250px;">
|
||||
<label for="selectSeries" class="selectLabel">${LabelSeries}</label>
|
||||
<select id="selectSeries" data-mini="true" required="required"></select>
|
||||
<div style="margin: 1em 0 1em;">
|
||||
<div style="width:85%;display:inline-block;">
|
||||
<label for="selectSeries" class="selectLabel">${LabelSeries}</label>
|
||||
<select id="selectSeries" data-mini="true" required="required"></select>
|
||||
</div>
|
||||
<paper-icon-button id="btnNewSeries" icon="add" title="${ButtonNew}"></paper-icon-button>
|
||||
</div>
|
||||
<div style="margin: 1em 0;">
|
||||
<paper-input id="txtSeason" type="number" pattern="[0-9]*" required min="0" label="${LabelSeasonNumber}"></paper-input>
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
define(['paperdialoghelper', 'paper-dialog', 'paper-fab', 'paper-input', 'paper-checkbox'], function (paperDialogHelper) {
|
||||
|
||||
var currentItem;
|
||||
var currentItemType;
|
||||
var currentDeferred;
|
||||
var hasChanges = false;
|
||||
var currentSearchResult;
|
||||
|
||||
function onIdentificationFormSubmitted() {
|
||||
|
||||
var page = $(this).parents('paper-dialog');
|
||||
|
||||
searchForIdentificationResults(page);
|
||||
return false;
|
||||
}
|
||||
|
||||
function searchForIdentificationResults(page) {
|
||||
|
||||
var lookupInfo = {
|
||||
|
@ -54,7 +47,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if (currentItem.GameSystem) {
|
||||
if (currentItem && currentItem.GameSystem) {
|
||||
lookupInfo.GameSystem = currentItem.GameSystem;
|
||||
}
|
||||
|
||||
|
@ -67,7 +60,7 @@
|
|||
|
||||
ApiClient.ajax({
|
||||
type: "POST",
|
||||
url: ApiClient.getUrl("Items/RemoteSearch/" + currentItem.Type),
|
||||
url: ApiClient.getUrl("Items/RemoteSearch/" + currentItemType),
|
||||
data: JSON.stringify(lookupInfo),
|
||||
contentType: "application/json",
|
||||
dataType: 'json'
|
||||
|
@ -102,10 +95,24 @@
|
|||
|
||||
var currentResult = results[index];
|
||||
|
||||
showIdentifyOptions(page, currentResult);
|
||||
if (currentItem != null) {
|
||||
|
||||
showIdentifyOptions(page, currentResult);
|
||||
} else {
|
||||
|
||||
finishFindNewDialog(page, currentResult);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function finishFindNewDialog(dlg, identifyResult) {
|
||||
currentSearchResult = identifyResult;
|
||||
hasChanges = true;
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
paperDialogHelper.close(dlg);
|
||||
}
|
||||
|
||||
function showIdentifyOptions(page, identifyResult) {
|
||||
|
||||
$('.popupIdentifyForm', page).hide();
|
||||
|
@ -143,10 +150,10 @@
|
|||
var html = '';
|
||||
var cssClass = "card";
|
||||
|
||||
if (currentItem.Type == "Episode") {
|
||||
if (currentItemType == "Episode") {
|
||||
cssClass += " backdropCard";
|
||||
}
|
||||
else if (currentItem.Type == "MusicAlbum" || currentItem.Type == "MusicArtist") {
|
||||
else if (currentItemType == "MusicAlbum" || currentItemType == "MusicArtist") {
|
||||
cssClass += " squareCard";
|
||||
}
|
||||
else {
|
||||
|
@ -193,14 +200,6 @@
|
|||
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) {
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
@ -220,22 +219,16 @@
|
|||
hasChanges = true;
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
paperDialogHelper.close(document.querySelector('.identifyDialog'));
|
||||
paperDialogHelper.close(page);
|
||||
|
||||
}, function () {
|
||||
|
||||
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) {
|
||||
|
||||
ApiClient.getJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).then(function (idList) {
|
||||
|
@ -292,6 +285,7 @@
|
|||
ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).then(function (item) {
|
||||
|
||||
currentItem = item;
|
||||
currentItemType = currentItem.Type;
|
||||
|
||||
var dlg = paperDialogHelper.createDialog({
|
||||
size: 'medium'
|
||||
|
@ -311,7 +305,19 @@
|
|||
|
||||
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 () {
|
||||
|
||||
|
@ -335,6 +341,79 @@
|
|||
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 {
|
||||
show: function (itemId) {
|
||||
|
||||
|
@ -345,6 +424,14 @@
|
|||
|
||||
showEditor(itemId);
|
||||
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