Skip to content

Commit

Permalink
Organize Movies #2
Browse files Browse the repository at this point in the history
  • Loading branch information
softworkz committed Oct 2, 2015
1 parent 16e1a5c commit 506ee8a
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 64 deletions.
39 changes: 20 additions & 19 deletions MediaBrowser.WebDashboard/dashboard-ui/autoorganizelog.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/metadataeditor.css">
<title>${TitleAutoOrganize}</title>
</head>
<body>
Expand Down Expand Up @@ -54,21 +55,17 @@
</div>

<div data-role="popup" class="popup episodeCorrectionPopup">

<div class="ui-bar-a" style="text-align: center; padding: 0 20px;">
<h3>Organize Manually</h3>
</div>
<div data-role="controlgroup" data-type="horizontal" class="" data-mini="true" style="margin-left: 14px">
<a href="#" data-role="button" id="popupTab1" class="ui-btn ui-btn-active popup-tab">TV Episode</a>
<a href="#" data-role="button" id="popupTab2" class="ui-btn popup-tab">Movie</a>
</div>

<paper-tabs hidescrollbuttons>
<paper-tab class="episodeTabButton">TV Episode</paper-tab>
<paper-tab class="movieTabButton">Movie</paper-tab>
</paper-tabs>

<div class="editorTab" data-role="content">
<div class="popupTabPage" data-role="content">
<form class="episodeCorrectionForm">

<p><span class="inputFile"></span></p>

<div style="margin: 1em 0 1em; min-width: 350px;">
<label for="selectSeries">${LabelSeries}</label>
<select id="selectSeries" data-mini="true" required="required"></select>
Expand All @@ -91,7 +88,6 @@ <h3>Organize Manually</h3>
<input type="checkbox" id="chkRememberCorrection" name="chkRememberCorrection" data-mini="true" />
<label for="chkRememberCorrection">${LabelOrganizeSmartMatchOption} '<span class="extractedName" />' </label>
</div>

<p>
<button type="submit" data-theme="b" data-icon="check" data-mini="true">
${ButtonOk}
Expand All @@ -103,12 +99,9 @@ <h3>Organize Manually</h3>
<input id="hfResultId" type="hidden" />
</form>
</div>

<div class="editorTab" data-role="content">
<div class="popupTabPage hide" data-role="content">
<form class="organizeMovieForm">

<p><span class="inputFile"></span></p>

<div style="margin: 1em 0 1em; min-width: 350px;">
<label for="txtVideoName">Movie</label>
<input id="txtVideoName" required="required" min="0" />
Expand All @@ -117,18 +110,15 @@ <h3>Organize Manually</h3>
<label for="txtVideoYear">Year</label>
<input id="txtVideoYear" type="number" pattern="[0-9]*" min="0" />
</div>

<div style="margin: 1em 0;">
<button type="button" data-icon="info" onclick="$(this).parents('.popup').popup('close');" data-mini="true">
<button type="button" data-icon="info" id="btnIdentify" data-mini="true">
${ButtonIdentify}
</button>
</div>

<div style="margin: 1em 0 1em;">
<label for="txtSelectedVideo">Selected Movie</label>
<input id="txtSelectedVideo" required="required" min="0" />
</div>

<p>
<button type="submit" data-theme="b" data-icon="check" data-mini="true">
${ButtonOk}
Expand All @@ -139,8 +129,19 @@ <h3>Organize Manually</h3>
</p>
<input id="hfResultId" type="hidden" />
</form>
</div>

<form class="identificationResultForm">

<div class="identificationSearchResults" style="height:auto">
<div class="identificationSearchResultList"></div>
</div>
<p>
<button type="button" data-icon="delete" onclick="$(this).parents('.popup').popup('close');" data-mini="true">
${ButtonCancel}
</button>
</p>
</form>
</div>
</div>
</div>
</body>
Expand Down
155 changes: 110 additions & 45 deletions MediaBrowser.WebDashboard/dashboard-ui/scripts/autoorganizelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@

function showEpisodeCorrectionPopup(page, item, allSeries) {

$('.organizeMovieForm', page).show();
$('.identificationResultForm', page).hide();
showTab(page, 0);

var popup = $('.episodeCorrectionPopup', page).popup("open");

$('.inputFile', popup).html(item.OriginalFileName);
Expand Down Expand Up @@ -170,6 +174,102 @@
});
}

function searchForIdentificationResults(page) {

var popup = $('.episodeCorrectionPopup', page);

var lookupInfo = {
Name: $('#txtVideoName', popup).val(),
Year: $('#txtVideoYear', popup).val(),
};

if (!lookupInfo.Name) {
Dashboard.alert(Globalize.translate('MessagePleaseEnterNameOrId'));
return;
}

lookupInfo = {
SearchInfo: lookupInfo,
IncludeDisabledProviders: true
};

Dashboard.showLoadingMsg();

ApiClient.ajax({
type: "POST",
url: ApiClient.getUrl("Items/RemoteSearch/Movie"),
data: JSON.stringify(lookupInfo),
contentType: "application/json"

}).done(function (results) {

Dashboard.hideLoadingMsg();
showIdentificationSearchResults(page, results);
});
}

function showIdentificationSearchResults(page, results) {

$('.organizeMovieForm', page).hide();
$('.identificationResultForm', page).show();
//$('.identifyOptionsForm', page).hide();

var html = '';

for (var i = 0, length = results.length; i < length; i++) {

var result = results[i];

html += getSearchResultHtml(result, i);
}

var elem = $('.identificationSearchResultList', page).html(html).trigger('create');

$('.searchImage', elem).on('click', function () {

//var index = parseInt(this.getAttribute('data-index'));

//var currentResult = results[index];

//showIdentifyOptions(page, currentResult);
});
}

function getSearchImageDisplayUrl(url, provider) {
return ApiClient.getUrl("Items/RemoteSearch/Image", { imageUrl: url, ProviderName: provider });
}

function getSearchResultHtml(result, index) {

var html = '';
var cssClass = "searchImageContainer remoteImageContainer";

cssClass += " searchPosterImageContainer";

html += '<div class="' + cssClass + '">';

if (result.ImageUrl) {
var displayUrl = getSearchImageDisplayUrl(result.ImageUrl, result.SearchProviderName);

html += '<a href="#" class="searchImage" data-index="' + index + '" style="background-image:url(\'' + displayUrl + '\');">';
} else {

html += '<a href="#" class="searchImage" data-index="' + index + '" style="background-image:url(\'css/images/items/list/remotesearch.png\');background-position: center center;">';
}
html += '</a>';

html += '<div class="remoteImageDetails" style="background-color: transparent">';
html += result.Name;
html += '</div>';

html += '<div class="remoteImageDetails" style="background-color: transparent">';
html += result.ProductionYear || '&nbsp;';
html += '</div>';

html += '</div>';
return html;
}

function reloadItems(page) {

Dashboard.showLoadingMsg();
Expand Down Expand Up @@ -350,37 +450,10 @@
return false;
}

function configurePaperLibraryTabs(ownerpage, tabs) {

tabs.hideScrollButtons = true;
tabs.noSlide = true;

// Unfortunately we can't disable this because it causes iron-select to not fire in IE and Safari.
//tabs.noink = true;

$(ownerpage).on('pageshowready', function () {

var selected = tabs.selected;

if (selected == null) {

Logger.log('selected tab is null, checking query string');

selected = parseInt(getParameterByName('tab') || '0');

Logger.log('selected tab will be ' + selected);

tabs.selected = selected;

} else {
Events.trigger(tabs, 'tabchange');
}
});
}

function showTab(page, index) {

$('.editorTab', page).addClass('hide')[index].classList.remove('hide');
$('.popupTabPage', page).addClass('hide')[index].classList.remove('hide');
$('.popup-tab', page).removeClass('ui-btn-active')[index].classList.add('ui-btn-active');
}

$(document).on('pageinit', "#libraryFileOrganizerLogPage", function () {
Expand All @@ -398,25 +471,17 @@
$('.episodeCorrectionForm').off('submit', onEpisodeCorrectionFormSubmit).on('submit', onEpisodeCorrectionFormSubmit);
$('.organizeMovieForm').off('submit', onOrganizeMovieFormFormSubmit).on('submit', onOrganizeMovieFormFormSubmit);

var tabs = page.querySelector('paper-tabs');

configurePaperLibraryTabs(page, tabs);

$(tabs).on('iron-select', function () {

var self = this;

setTimeout(function () {
Events.trigger(self, 'tabchange');
}, 400);

}).on('tabchange', function () {
var selected = this.selected;

showTab(page, selected);
$('#popupTab1', page).on('click', function () {
showTab(page, 0);
});

$('#popupTab2', page).on('click', function () {
showTab(page, 1);
});

$('#btnIdentify', page).on('click', function () {
searchForIdentificationResults(page);
});

}).on('pageshow', "#libraryFileOrganizerLogPage", function () {

Expand Down

0 comments on commit 506ee8a

Please sign in to comment.