1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

#680 - episode organization

This commit is contained in:
Luke Pulverenti 2014-01-22 12:05:06 -05:00
parent 807141cbce
commit 9db90f464a
8 changed files with 283 additions and 46 deletions

View file

@ -30,14 +30,14 @@
})[0];
var message = 'The following file will be deleted:<p>' + item.OriginalPath + '</p><p>Are you sure you wish to proceed?</p>';
var message = 'The following file will be deleted:<p style="word-wrap:break-word;">' + item.OriginalPath + '</p><p>Are you sure you wish to proceed?</p>';
Dashboard.confirm(message, "Delete File", function (confirmResult) {
if (confirmResult) {
Dashboard.showLoadingMsg();
ApiClient.deleteOriginalFileFromOrganizationResult(id).done(function () {
Dashboard.hideLoadingMsg();
@ -50,6 +50,55 @@
});
}
function organizeEpsiodeWithCorrections(page, item) {
Dashboard.showLoadingMsg();
ApiClient.getItems({
recursive: true,
includeItemTypes: 'Series',
sortBy: 'SortName'
}).done(function (result) {
Dashboard.hideLoadingMsg();
showEpisodeCorrectionPopup(page, item, result.Items);
});
}
function showEpisodeCorrectionPopup(page, item, allSeries) {
var popup = $('.episodeCorrectionPopup', page).popup("open");
$('.inputFile', popup).html(item.OriginalFileName);
$('#txtSeason', popup).val(item.ExtractedSeasonNumber);
$('#txtEpisode', popup).val(item.ExtractedEpisodeNumber);
$('#txtEndingEpisode', popup).val(item.ExtractedEndingEpisodeNumber);
$('#hfResultId', popup).val(item.Id);
if (item.ExtractedName) {
$('#fldRememberCorrection', popup).hide();
} else {
$('#fldRememberCorrection', popup).hide();
}
$('#chkRememberEpisodeCorrection', popup).checked(false).checkboxradio('refresh');
var seriesHtml = allSeries.map(function (s) {
return '<option value="' + s.Id + '">' + s.Name + '</option>';
}).join('');
seriesHtml = '<option value=""></option>' + seriesHtml;
$('#selectSeries', popup).html(seriesHtml).selectmenu('refresh');
}
function organizeFile(page, id) {
var item = currentResult.Items.filter(function (i) {
@ -57,7 +106,16 @@
})[0];
var message = 'The following file will be moved from:<p>' + item.OriginalPath + '</p><p>to:</p><p>' + item.TargetPath + '</p><p>Are you sure you wish to proceed?</p>';
if (!item.TargetPath) {
if (item.Type == "Episode") {
organizeEpsiodeWithCorrections(page, item);
}
return;
}
var message = 'The following file will be moved from:<p style="word-wrap:break-word;">' + item.OriginalPath + '</p><p>to:</p><p style="word-wrap:break-word;">' + item.TargetPath + '</p><p>Are you sure you wish to proceed?</p>';
Dashboard.confirm(message, "Organize File", function (confirmResult) {
@ -76,7 +134,34 @@
}
});
}
function submitEpisodeForm(form) {
Dashboard.showLoadingMsg();
var page = $(form).parents('.page');
var resultId = $('#hfResultId', form).val();
var options = {
SeriesId: $('#selectSeries', form).val(),
SeasonNumber: $('#txtSeason', form).val(),
EpisodeNumber: $('#txtEpisode', form).val(),
EndingEpisodeNumber: $('#txtEndingEpisode', form).val(),
RememberCorrection: $('#chkRememberEpisodeCorrection', form).checked()
};
ApiClient.performEpisodeOrganization(resultId, options).done(function () {
Dashboard.hideLoadingMsg();
$('.episodeCorrectionPopup', page).popup("close");
reloadItems(page);
});
}
function reloadItems(page) {
@ -133,6 +218,16 @@
html += '<tr>';
html += '<td class="organizerButtonCell">';
if (item.Status != 'Success') {
html += '<button data-resultid="' + item.Id + '" type="button" data-inline="true" data-icon="delete" data-mini="true" data-iconpos="notext" class="btnDeleteResult organizerButton" title="Delete File">Delete File</button>';
html += '<button data-resultid="' + item.Id + '" type="button" data-inline="true" data-icon="action" data-mini="true" data-iconpos="notext" class="btnProcessResult organizerButton" title="Organize File">Process</button>';
}
html += '</td>';
html += '<td>';
var date = parseISO8601Date(item.Date, { toLocal: true });
@ -141,32 +236,28 @@
html += '</td>';
html += '<td>';
html += item.OriginalFileName || '';
var status = item.Status;
if (status == 'SkippedExisting') {
html += '<div style="color:blue;">';
html += item.OriginalFileName;
html += '</div>';
}
else if (status == 'Failure') {
html += '<a data-resultid="' + item.Id + '" style="color:red;" href="#" class="btnShowStatusMessage">';
html += item.OriginalFileName;
html += '</a>';
} else {
html += '<div style="color:green;">';
html += item.OriginalFileName;
html += '</div>';
}
html += '</td>';
html += '<td>';
html += item.TargetPath || '';
html += '</td>';
html += '<td>';
html += getStatusText(item, true);
html += '</td>';
html += '<td class="organizerButtonCell">';
if (item.Status == 'SkippedExisting') {
html += '<button data-resultid="' + item.Id + '" type="button" data-inline="true" data-icon="action" data-mini="true" data-iconpos="notext" class="btnProcessResult organizerButton" title="Organize File">Process</button>';
} else {
html += '<button style="visibility:hidden;" type="button" data-inline="true" data-icon="info" data-mini="true" data-iconpos="notext" class="organizerButton"></button>';
}
if (item.Status != 'Success') {
html += '<button data-resultid="' + item.Id + '" type="button" data-inline="true" data-icon="delete" data-mini="true" data-iconpos="notext" class="btnDeleteResult organizerButton" title="Delete">Delete File</button>';
}
html += '</td>';
html += '</tr>';
return html;
@ -218,9 +309,29 @@
query.StartIndex -= query.Limit;
reloadItems(page);
});
if (result.TotalRecordCount) {
$('.btnClearLog', page).show();
$('.legend', page).show();
} else {
$('.btnClearLog', page).hide();
$('.legend', page).hide();
}
}
$(document).on('pageshow', "#libraryFileOrganizerLogPage", function () {
$(document).on('pageinit', "#libraryFileOrganizerLogPage", function () {
var page = this;
$('.btnClearLog', page).on('click', function () {
ApiClient.clearOrganizationLog().done(function () {
reloadItems(page);
});
});
}).on('pageshow', "#libraryFileOrganizerLogPage", function () {
var page = this;
@ -231,4 +342,13 @@
currentResult = null;
});
window.OrganizerLogPage = {
onEpisodeCorrectionFormSubmit: function () {
submitEpisodeForm(this);
return false;
}
};
})(jQuery, document, window);