mirror of https://github.com/lidarr/Lidarr
added quality profile support to add series.
This commit is contained in:
parent
1024e0f83d
commit
f3e601d4ed
|
@ -195,6 +195,10 @@
|
||||||
<Content Include="_backboneApp\AddSeries\SearchResultModel.js" />
|
<Content Include="_backboneApp\AddSeries\SearchResultModel.js" />
|
||||||
<Content Include="_backboneApp\AddSeries\SearchResultCollection.js" />
|
<Content Include="_backboneApp\AddSeries\SearchResultCollection.js" />
|
||||||
<Content Include="_backboneApp\Content\Intelisense\bootstrap.css" />
|
<Content Include="_backboneApp\Content\Intelisense\bootstrap.css" />
|
||||||
|
<Content Include="_backboneApp\Quality\qualityProfileModel.js" />
|
||||||
|
<Content Include="_backboneApp\Quality\qualityProfileCollection.js" />
|
||||||
|
<Content Include="_backboneApp\Quality\qualityTypeModel.js" />
|
||||||
|
<Content Include="_backboneApp\Quality\qualityTypeCollection.js" />
|
||||||
<Content Include="_backboneApp\nzbdrone.logging.js" />
|
<Content Include="_backboneApp\nzbdrone.logging.js" />
|
||||||
<Content Include="_backboneApp\JsLibraries\backbone.marionette.extend.js" />
|
<Content Include="_backboneApp\JsLibraries\backbone.marionette.extend.js" />
|
||||||
<Compile Include="_backboneApp\CassetteConfiguration.cs" />
|
<Compile Include="_backboneApp\CassetteConfiguration.cs" />
|
||||||
|
|
|
@ -15,12 +15,17 @@ NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({
|
||||||
|
|
||||||
collection: new NzbDrone.AddSeries.SearchResultCollection(),
|
collection: new NzbDrone.AddSeries.SearchResultCollection(),
|
||||||
|
|
||||||
initialize: function (rootFolders) {
|
initialize: function (options) {
|
||||||
if (rootFolders === undefined) {
|
if (options.rootFolders === undefined) {
|
||||||
throw "rootFolder arg is required.";
|
throw "rootFolder arg is required.";
|
||||||
}
|
}
|
||||||
|
|
||||||
this.rootFoldersCollection = rootFolders;
|
if (options.qualityProfiles === undefined) {
|
||||||
|
throw "qualityProfiles arg is required.";
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rootFoldersCollection = options.rootFolders;
|
||||||
|
this.qualityProfilesCollection = options.qualityProfiles;
|
||||||
},
|
},
|
||||||
|
|
||||||
onRender: function () {
|
onRender: function () {
|
||||||
|
@ -61,7 +66,8 @@ NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({
|
||||||
|
|
||||||
resultUpdated: function (options, context) {
|
resultUpdated: function (options, context) {
|
||||||
_.each(options.models, function (model) {
|
_.each(options.models, function (model) {
|
||||||
model.set('rootFolders', context.rootFoldersCollection.rootFolders.models);
|
model.set('rootFolders', context.rootFoldersCollection.models);
|
||||||
|
model.set('qualityProfiles', context.qualityProfilesCollection.models);
|
||||||
});
|
});
|
||||||
|
|
||||||
context.searchResult.show(context.resultView);
|
context.searchResult.show(context.resultView);
|
||||||
|
|
|
@ -4,16 +4,15 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="{{id}}" class="accordion-body collapse">
|
<div id="{{id}}" class="accordion-body collapse">
|
||||||
<div class="accordion-inner">
|
<div class="accordion-inner">
|
||||||
<select class="root-dir-input span7" name="rootFolders">
|
<select class="root-dir-input span7">
|
||||||
{{#each rootFolders}}
|
{{#each rootFolders}}
|
||||||
<option value="{{id}}">{{attributes.path}}</option>
|
<option value="{{id}}">{{attributes.path}}</option>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</select>
|
</select>
|
||||||
<select class="quality-profile-input span2">
|
<select class="quality-profile-input span2">
|
||||||
<option value="volvo">Volvo</option>
|
{{#each qualityProfiles}}
|
||||||
<option value="saab">Saab</option>
|
<option value="{{id}}">{{attributes.name}}</option>
|
||||||
<option value="mercedes">Mercedes</option>
|
{{/each}}
|
||||||
<option value="audi">Audi</option>
|
|
||||||
</select>
|
</select>
|
||||||
<div class="btn btn-success pull-right icon-plus">
|
<div class="btn btn-success pull-right icon-plus">
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,6 +8,8 @@ NzbDrone.AddSeries.SearchItemView = Backbone.Marionette.ItemView.extend({
|
||||||
className: 'search-item accordion-group',
|
className: 'search-item accordion-group',
|
||||||
onRender: function () {
|
onRender: function () {
|
||||||
this.listenTo(this.model, 'change', this.render);
|
this.listenTo(this.model, 'change', this.render);
|
||||||
|
//this.listenTo(this.model.get('rootFolders'), 'reset', this.render);
|
||||||
|
//this.listenTo(this.model.get('qualityProfiles'), 'reset', this.render);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/// <reference path="../app.js" />
|
/// <reference path="../app.js" />
|
||||||
/// <reference path="AddNewSeries/AddNewSeriesView.js" />
|
/// <reference path="AddNewSeries/AddNewSeriesView.js" />
|
||||||
/// <reference path="RootDir/RootDirView.js" />
|
/// <reference path="RootDir/RootDirView.js" />
|
||||||
|
/// <reference path="../Quality/qualityProfileCollection.js" />
|
||||||
/// <reference path="../Shared/SpinnerView.js" />
|
/// <reference path="../Shared/SpinnerView.js" />
|
||||||
|
|
||||||
NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
|
NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
|
||||||
|
@ -21,6 +22,7 @@ NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
|
||||||
|
|
||||||
|
|
||||||
rootFolderCollection: new NzbDrone.AddSeries.RootDirCollection(),
|
rootFolderCollection: new NzbDrone.AddSeries.RootDirCollection(),
|
||||||
|
qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(),
|
||||||
|
|
||||||
onRender: function () {
|
onRender: function () {
|
||||||
this.$('#myTab a').click(function (e) {
|
this.$('#myTab a').click(function (e) {
|
||||||
|
@ -28,7 +30,9 @@ NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
|
||||||
$(this).tab('show');
|
$(this).tab('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addNew.show(new NzbDrone.AddSeries.AddNewSeriesView({ rootFolders: this.rootFolderCollection }));
|
this.qualityProfileCollection.fetch();
|
||||||
|
|
||||||
|
this.addNew.show(new NzbDrone.AddSeries.AddNewSeriesView({ rootFolders: this.rootFolderCollection, qualityProfiles: this.qualityProfileCollection }));
|
||||||
//this.importExisting.show(new NzbDrone.ImportExistingView());
|
//this.importExisting.show(new NzbDrone.ImportExistingView());
|
||||||
this.rootFolders.show(new NzbDrone.AddSeries.RootDirView({ collection: this.rootFolderCollection }));
|
this.rootFolders.show(new NzbDrone.AddSeries.RootDirView({ collection: this.rootFolderCollection }));
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
/// <reference path="../../app.js" />
|
/// <reference path="../../app.js" />
|
||||||
|
/// <reference path="RootDirModel.js" />
|
||||||
|
|
||||||
NzbDrone.AddSeries.RootDirCollection = Backbone.Collection.extend({
|
NzbDrone.AddSeries.RootDirCollection = Backbone.Collection.extend({
|
||||||
url: NzbDrone.Constants.ApiRoot + 'rootdir/',
|
url: NzbDrone.Constants.ApiRoot + '/rootdir',
|
||||||
model: NzbDrone.AddSeries.RootDirModel,
|
model: NzbDrone.AddSeries.RootDirModel,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/// <reference path="SearchResultModel.js" />
|
/// <reference path="SearchResultModel.js" />
|
||||||
|
|
||||||
NzbDrone.AddSeries.SearchResultCollection = Backbone.Collection.extend({
|
NzbDrone.AddSeries.SearchResultCollection = Backbone.Collection.extend({
|
||||||
url: NzbDrone.Constants.ApiRoot + 'series/lookup',
|
url: NzbDrone.Constants.ApiRoot + '/series/lookup',
|
||||||
model: NzbDrone.AddSeries.SearchResultModel,
|
model: NzbDrone.AddSeries.SearchResultModel,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
/// <reference path="../app.js" />
|
/// <reference path="../app.js" />
|
||||||
|
/// <reference path="RootDir/RootDirCollection.js" />
|
||||||
|
/// <reference path="../Quality/qualityProfileCollection.js" />
|
||||||
NzbDrone.AddSeries.SearchResultModel = Backbone.Model.extend({
|
NzbDrone.AddSeries.SearchResultModel = Backbone.Model.extend({
|
||||||
mutators: {
|
mutators: {
|
||||||
seriesYear: function () {
|
seriesYear: function () {
|
||||||
|
@ -11,5 +13,11 @@ NzbDrone.AddSeries.SearchResultModel = Backbone.Model.extend({
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
defaults: {
|
||||||
|
qualityProfiles: new NzbDrone.Quality.QualityProfileCollection(),
|
||||||
|
rootFolders: new NzbDrone.AddSeries.RootDirCollection()
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
/// <reference path="../app.js" />
|
||||||
|
/// <reference path="qualityProfileModel.js" />
|
||||||
|
|
||||||
|
NzbDrone.Quality.QualityProfileCollection = Backbone.Collection.extend({
|
||||||
|
model: NzbDrone.Quality.QualityProfileModel,
|
||||||
|
url: NzbDrone.Constants.ApiRoot + '/qualityprofiles'
|
||||||
|
});
|
|
@ -0,0 +1,47 @@
|
||||||
|
/// <reference path="../app.js" />
|
||||||
|
|
||||||
|
NzbDrone.Quality.QualityProfileModel = Backbone.Model.extend({
|
||||||
|
initialize: function () {
|
||||||
|
this.validators = {};
|
||||||
|
|
||||||
|
this.validators.name = function (value) {
|
||||||
|
return value.length > 0 ? { isValid: true } : { isValid: false, message: 'You must enter a name' };
|
||||||
|
};
|
||||||
|
|
||||||
|
//this.validators.allowed = function (value) {
|
||||||
|
// return value.length > 0 ? { isValid: true } : { isValid: false, message: 'You must have allowed qualities' };
|
||||||
|
//};
|
||||||
|
//Todo: Cutoff should be something that is allowed (double check)
|
||||||
|
this.validators.cutoff = function (value) {
|
||||||
|
return value != null ? { isValid: true } : { isValid: false, message: 'You must have a valid cutoff' };
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
validateItem: function (key) {
|
||||||
|
return (this.validators[key]) ? this.validators[key](this.get(key)) : { isValid: true };
|
||||||
|
},
|
||||||
|
|
||||||
|
// TODO: Implement Backbone's standard validate() method instead.
|
||||||
|
validateAll: function () {
|
||||||
|
|
||||||
|
var messages = {};
|
||||||
|
|
||||||
|
for (var key in this.validators) {
|
||||||
|
if (this.validators.hasOwnProperty(key)) {
|
||||||
|
var check = this.validators[key](this.get(key));
|
||||||
|
if (check.isValid === false) {
|
||||||
|
messages[key] = check.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _.size(messages) > 0 ? { isValid: false, messages: messages } : { isValid: true };
|
||||||
|
},
|
||||||
|
|
||||||
|
defaults: {
|
||||||
|
Id: null,
|
||||||
|
Name: '',
|
||||||
|
//allowed: {},
|
||||||
|
Cutoff: null
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,4 @@
|
||||||
|
NzbDrone.Quality.QualityTypeCollection = Backbone.Collection.extend({
|
||||||
|
model: NzbDrone.Quality.QualityTypeModel,
|
||||||
|
url: NzbDrone.Constants.ApiRoot + '/qualitytypes'
|
||||||
|
});
|
|
@ -0,0 +1,34 @@
|
||||||
|
NzbDrone.Quality.QualityTypeModel = Backbone.Model.extend({
|
||||||
|
|
||||||
|
initialize: function () {
|
||||||
|
this.validators = {};
|
||||||
|
},
|
||||||
|
|
||||||
|
validateItem: function (key) {
|
||||||
|
return (this.validators[key]) ? this.validators[key](this.get(key)) : { isValid: true };
|
||||||
|
},
|
||||||
|
|
||||||
|
// TODO: Implement Backbone's standard validate() method instead.
|
||||||
|
validateAll: function () {
|
||||||
|
|
||||||
|
var messages = {};
|
||||||
|
|
||||||
|
for (var key in this.validators) {
|
||||||
|
if (this.validators.hasOwnProperty(key)) {
|
||||||
|
var check = this.validators[key](this.get(key));
|
||||||
|
if (check.isValid === false) {
|
||||||
|
messages[key] = check.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _.size(messages) > 0 ? { isValid: false, messages: messages } : { isValid: true };
|
||||||
|
},
|
||||||
|
|
||||||
|
defaults: {
|
||||||
|
Id: null,
|
||||||
|
Name: '',
|
||||||
|
MaxSize: 100,
|
||||||
|
MinSize: 0
|
||||||
|
}
|
||||||
|
});
|
|
@ -57,7 +57,7 @@ $(document).ajaxError(function (event, xmlHttpRequest, ajaxOptions) {
|
||||||
var errorView = NzbDrone.Shared.ErrorView.instance;
|
var errorView = NzbDrone.Shared.ErrorView.instance;
|
||||||
|
|
||||||
var model = new NzbDrone.Shared.ErrorModel();
|
var model = new NzbDrone.Shared.ErrorModel();
|
||||||
model.set('title', ajaxOptions.url + " : " + xmlHttpRequest.statusText);
|
model.set('title', ajaxOptions.type + " " + ajaxOptions.url + " : " + xmlHttpRequest.statusText);
|
||||||
model.set('message', xmlHttpRequest.responseText);
|
model.set('message', xmlHttpRequest.responseText);
|
||||||
errorView.collection.add(model);
|
errorView.collection.add(model);
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ if (typeof console == "undefined") {
|
||||||
|
|
||||||
NzbDrone = new Backbone.Marionette.Application();
|
NzbDrone = new Backbone.Marionette.Application();
|
||||||
NzbDrone.AddSeries = NzbDrone.module("AddSeries");
|
NzbDrone.AddSeries = NzbDrone.module("AddSeries");
|
||||||
|
NzbDrone.Quality = NzbDrone.module("Quality");
|
||||||
NzbDrone.Shared = NzbDrone.module("Shared");
|
NzbDrone.Shared = NzbDrone.module("Shared");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -31,7 +32,7 @@ NzbDrone.ModelBinder = new Backbone.ModelBinder();
|
||||||
|
|
||||||
|
|
||||||
NzbDrone.Constants = {
|
NzbDrone.Constants = {
|
||||||
ApiRoot: '/api/'
|
ApiRoot: '/api'
|
||||||
};
|
};
|
||||||
|
|
||||||
NzbDrone.Events = {
|
NzbDrone.Events = {
|
||||||
|
|
Loading…
Reference in New Issue