Existing series looks like add new series now

pull/4/head
Mark McDowall 12 years ago
parent 91cc65bae2
commit 900122c265

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource.Trakt;
@ -60,7 +61,7 @@ namespace NzbDrone.Core.MetadataSource
series.TitleSlug = show.url.ToLower().Replace("http://trakt.tv/show/", "");
series.Images.Add(new MediaCover.MediaCover { CoverType = MediaCoverTypes.Banner, Url = show.images.banner });
series.Images.Add(new MediaCover.MediaCover { CoverType = MediaCoverTypes.Poster, Url = show.images.poster });
series.Images.Add(new MediaCover.MediaCover { CoverType = MediaCoverTypes.Poster, Url = GetPosterThumbnailUrl(show.images.poster) });
series.Images.Add(new MediaCover.MediaCover { CoverType = MediaCoverTypes.Fanart, Url = show.images.fanart });
return series;
}
@ -79,6 +80,11 @@ namespace NzbDrone.Core.MetadataSource
return episode;
}
private static string GetPosterThumbnailUrl(string posterUrl)
{
var extension = Path.GetExtension(posterUrl);
var withoutExtension = posterUrl.Substring(0, posterUrl.Length - extension.Length);
return withoutExtension + "-138" + extension;
}
}
}

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="PROJECT" libraries="{jQuery-1.9.1, libraries}" />
<file url="PROJECT" libraries="{libraries}" />
</component>
</project>

@ -1,9 +0,0 @@
<div class="line row folder-match-result-view">
<div class="span6">
{{title}} {{seriesYear}}
</div>
<div class="btn btn-success x-btn-add">
<icon class="icon-plus "></icon>
</div>
</div>

@ -2,9 +2,9 @@
define([
'app', 'AddSeries/RootFolders/RootFolderCollection', 'Quality/QualityProfileCollection', 'Shared/NotificationCollection', 'AddSeries/Existing/UnmappedFolderModel', 'AddSeries/SearchResultCollection', 'Series/SeriesModel'], function (app, rootFolders, qualityProfileCollection, notificationCollection) {
NzbDrone.AddSeries.Existing.FolderMatchResultView = Backbone.Marionette.ItemView.extend({
template: 'AddSeries/Existing/FolderMatchResultViewTemplate',
template: 'AddSeries/SearchResultTemplate',
className: 'search-item',
events: {
'click .x-btn-add': 'addSeries'
@ -26,7 +26,6 @@ define([
path : path
});
var seriesCollection = new NzbDrone.Series.SeriesCollection();
seriesCollection.add(model);
@ -44,17 +43,18 @@ define([
}
});
}
});
NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView = Backbone.Marionette.CompositeView.extend({
template : 'AddSeries/Existing/UnmappedFolderCompositeViewTemplate',
itemViewContainer: '.x-folder-name-match-results',
className : 'unmapped-folder-view',
itemView : NzbDrone.AddSeries.Existing.FolderMatchResultView,
events: {
'click .x-btn-search': 'search'
'click .x-btn-search': 'search',
'keydown .x-txt-search': 'keydown'
},
ui: {
@ -64,20 +64,25 @@ define([
},
initialize: function () {
this.collection = new NzbDrone.AddSeries.SearchResultCollection();
this.collection = new NzbDrone.Series.SeriesCollection();
this.collection.bind('reset', this.collectionReset, this);
},
search: function () {
onRender: function () {
this.collection.url = NzbDrone.Constants.ApiRoot + '/series/lookup';
this.resultView = new NzbDrone.AddSeries.SearchResultView({ collection: this.collection });
},
search: function () {
var icon = this.ui.searchButton.find('icon');
this.collection.reset();
icon.removeClass('icon-search').addClass('icon-spin icon-spinner disabled');
this.collection.fetch({
data : { term: this.ui.searchText.val() },
success: function () {
success: function (collection) {
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
},
fail : function () {
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
@ -85,6 +90,19 @@ define([
});
},
keydown: function (e) {
var code = (e.keyCode ? e.keyCode : e.which);
if(code === 13) {
this.search();
}
},
collectionReset: function () {
_.each(this.collection.models, function (model){
model.set('isExisting', true);
});
},
itemViewOptions: function () {
return {
qualityProfile: this.ui.profileList,
@ -92,15 +110,13 @@ define([
folder : this.model.get('folder')
};
}
});
NzbDrone.AddSeries.Existing.RootFolderCompositeView = Backbone.Marionette.CompositeView.extend({
template : "AddSeries/Existing/RootFolderCompositeViewTemplate",
itemViewContainer: ".x-existing-folder-container",
className : 'row',
itemView : NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView,
initialize: function () {
@ -117,9 +133,6 @@ define([
refreshItems: function () {
this.collection.importItems(this.model);
}
});
NzbDrone.AddSeries.Existing.ImportSeriesView = Backbone.Marionette.CollectionView.extend({
@ -129,6 +142,5 @@ define([
initialize: function () {
this.collection = rootFolders;
}
});
});

@ -1,7 +1,6 @@
<div class="row">
<div class="accordion result-list span12 existing-root-folder-view">
<h1>{{path}}</h1>

<div class="result-list span12 existing-root-folder-view">
<h1>{{path}}</h1>
<div class="x-existing-folder-container"/>
</div>
<div class="x-existing-folder-container"/>
</div>

@ -1,21 +1,15 @@
"use strict";
<div class="row unmapped-folder-view">
<div class="span11">
<div class="row folder-header">
<div class="row">
<div class="folder-header span11">
<div class="input-prepend">
<i class="add-on icon-search"></i>
<input class="x-txt-search input-xlarge" type="text" value="{{folder.name}}" placeholder="{{folder.name}}">
<select class="span2 x-lst-quality-profile">
{{#each quality.models}}
<option value="{{id}}">{{attributes.name}}</option>
{{/each}}
</select>
<div class="btn btn-primary x-btn-search pull-right">
<icon class="icon-search "></icon>
</div>
<div class="row">
<div class="x-folder-name-match-results folder-name-matches span11"/>
</div>
</div>
<div class="btn btn-primary x-btn-search pull-right">
<icon class="icon-search "></icon>
</div>
</div>
</div>
<div class="row">
<div class="x-folder-name-match-results folder-name-matches"/>
</div>

@ -1,11 +1,9 @@
<div class="tab-pane" id="add-new">
<div class="row">
<div class="input-prepend nz-input-large search span11">
<i class="add-on icon-search"></i>
<input type="text" class="input-block-level" placeholder="Start typing the name of series you want to add ...">
</div>
</div>
<div class="row">
<div id="search-result" class="result-list span12"/>
<div class="row">
<div class="input-prepend nz-input-large search span11">
<i class="add-on icon-search"></i>
<input type="text" class="input-block-level" placeholder="Start typing the name of series you want to add ...">
</div>
</div>
<div class="row">
<div id="search-result" class="result-list span12"/>
</div>

@ -47,7 +47,6 @@ define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'AddSeries/New/Sear
context.searchResult.show(context.resultView);
}
});
}
},

@ -3,7 +3,7 @@ define(['app', 'Shared/NotificationCollection', 'AddSeries/SearchResultCollectio
NzbDrone.AddSeries.New.SearchItemView = Backbone.Marionette.ItemView.extend({
template : "AddSeries/New/SearchResultTemplate",
template : "AddSeries/SearchResultTemplate",
className: 'search-item',
ui: {
@ -51,7 +51,6 @@ define(['app', 'Shared/NotificationCollection', 'AddSeries/SearchResultCollectio
NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.CollectionView.extend({
itemView : NzbDrone.AddSeries.New.SearchItemView,
className : 'accordion',
initialize: function () {
this.listenTo(this.collection, 'reset', this.render);
}

@ -1,10 +0,0 @@
"use strict";
define(['app', 'AddSeries/SearchResultModel'], function () {
NzbDrone.AddSeries.SearchResultCollection = Backbone.Collection.extend({
url : NzbDrone.Constants.ApiRoot + '/series/lookup',
model: NzbDrone.AddSeries.SearchResultModel
});
});

@ -1,36 +0,0 @@
"use strict";
define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'Quality/QualityProfileCollection'],
function (app, rootFolderCollection, qualityProfileCollection) {
NzbDrone.AddSeries.SearchResultModel = Backbone.Model.extend({
mutators: {
seriesYear: function () {
var date = Date.utc.create(this.get('firstAired')).format('({yyyy})');
//don't append year, if the series name already has the name appended.
if (this.get('title').endsWith(date)) {
return "";
} else {
return date;
}
},
banner : function () {
var banner = _.find(this.get('images'), function (image) {
return image.coverType === 1;
});
return banner.url;
},
traktUrl : function () {
return "http://trakt.tv/show/" + this.get('titleSlug');
}
},
defaults: {
qualityProfiles: qualityProfileCollection,
rootFolders : rootFolderCollection
}
});
});

@ -1,17 +1,19 @@
<div class="row">
<div class="span2">
<a href="{{traktUrl}}" target="_blank">
<img class="series-poster img-polaroid" src="{{smallPoster}}">
<img class="series-poster img-polaroid" src="{{poster}}">
</a>
</div>
<div class="span9">
<div class="row">
<select class="span6 x-root-folder">
{{#each rootFolders.models}}
<option value="{{id}}">{{attributes.path}}</option>
{{/each}}
</select>
{{#unless isExisting}}
<select class="span6 x-root-folder">
{{#each rootFolders.models}}
<option value="{{id}}">{{attributes.path}}</option>
{{/each}}
</select>
{{/unless}}
<select class="span2 x-quality-profile">
{{#each qualityProfiles.models}}
<option value="{{id}}">{{attributes.name}}</option>

@ -22,7 +22,6 @@
}
.search-item {
padding-right: 5px;
padding-bottom: 20px;
}
@ -47,7 +46,6 @@
.unmapped-folder-view .folder-header {
font-weight: 300;
padding-left: 20px;
}
.unmapped-folder-view .folder-header input {

@ -1,7 +1,4 @@
<!--<div class="alert alert-info">
<strong>Heads up!</strong> you need to add at least one TV folder.
</div>-->
<ul class="nav nav-tabs" id="myTab">
<ul class="nav nav-tabs" id="myTab">
<li><a href="#add-new" class="x-add-new-tab">Add New Series</a></li>
<li><a href="#import-existing" class="x-import-existing-tab">Import Existing Series</a></li>
<li><a href="#root-folders" class="x-root-folders-tab">TV Folders</a></li>

@ -31,13 +31,6 @@
return undefined;
},
smallPoster : function () {
var poster = this.get('poster');
var extension = '.' + poster.split('.').pop();
var withoutExtension = poster.substring(0, poster.length - extension.length);
return withoutExtension + '-138' + extension;
},
traktUrl : function () {
return "http://trakt.tv/show/" + this.get('titleSlug');
}
@ -47,7 +40,8 @@
episodeFileCount: 0,
episodeCount : 0,
qualityProfiles : qualityProfileCollection,
rootFolders : rootFolders
rootFolders : rootFolders,
isExisting : false
}
});

Loading…
Cancel
Save