diff --git a/src/NzbDrone.Api/NetImport/NetImportModule.cs b/src/NzbDrone.Api/NetImport/NetImportModule.cs index 2e9390561..0149a44e7 100644 --- a/src/NzbDrone.Api/NetImport/NetImportModule.cs +++ b/src/NzbDrone.Api/NetImport/NetImportModule.cs @@ -18,19 +18,8 @@ namespace NzbDrone.Api.NetImport base.MapToResource(resource, definition); resource.Enabled = definition.Enabled; - Field theField = null; - int index = 0; - foreach (var field in resource.Fields) - { - if (field.Label == "Quality Profile") - { - index = resource.Fields.FindIndex(f => f.Label == field.Label); - field.SelectOptions = - _profileService.All().ConvertAll(p => new SelectOption {Name = p.Name, Value = p.Id}); - - theField = field; - } - } + resource.EnableAuto = definition.EnableAuto; + resource.ProfileId = definition.ProfileId; } @@ -38,7 +27,9 @@ namespace NzbDrone.Api.NetImport { base.MapToModel(definition, resource); - resource.Enabled = definition.Enabled; + definition.Enabled = resource.Enabled; + definition.EnableAuto = resource.EnableAuto; + definition.ProfileId = resource.ProfileId; } protected override void Validate(NetImportDefinition definition, bool includeWarnings) diff --git a/src/NzbDrone.Api/NetImport/NetImportResource.cs b/src/NzbDrone.Api/NetImport/NetImportResource.cs index 880b95ef0..b65f736ad 100644 --- a/src/NzbDrone.Api/NetImport/NetImportResource.cs +++ b/src/NzbDrone.Api/NetImport/NetImportResource.cs @@ -5,6 +5,7 @@ namespace NzbDrone.Api.NetImport public class NetImportResource : ProviderResource { public bool Enabled { get; set; } - public bool EnableSearch { get; set; } + public bool EnableAuto { get; set; } + public int ProfileId { get; set; } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Datastore/Migration/123_create_netimport_table.cs b/src/NzbDrone.Core/Datastore/Migration/123_create_netimport_table.cs index 619be4381..2fa8bd65a 100644 --- a/src/NzbDrone.Core/Datastore/Migration/123_create_netimport_table.cs +++ b/src/NzbDrone.Core/Datastore/Migration/123_create_netimport_table.cs @@ -16,7 +16,8 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("Implementation").AsString() .WithColumn("ConfigContract").AsString().Nullable() .WithColumn("Settings").AsString().Nullable() - .WithColumn("EnableAuto").AsInt32(); + .WithColumn("EnableAuto").AsInt32() + .WithColumn("ProfileId").AsInt32(); } } } diff --git a/src/NzbDrone.Core/Datastore/TableMapping.cs b/src/NzbDrone.Core/Datastore/TableMapping.cs index 64e068fc0..28bf15948 100644 --- a/src/NzbDrone.Core/Datastore/TableMapping.cs +++ b/src/NzbDrone.Core/Datastore/TableMapping.cs @@ -57,7 +57,9 @@ namespace NzbDrone.Core.Datastore .Ignore(i => i.SupportsSearch); Mapper.Entity().RegisterDefinition("NetImport") - .Ignore(i => i.Enable); + .Ignore(i => i.Enable) + .Relationship() + .HasOne(n => n.Profile, n => n.ProfileId); Mapper.Entity().RegisterDefinition("Notifications") .Ignore(i => i.SupportsOnGrab) diff --git a/src/NzbDrone.Core/NetImport/NetImportBase.cs b/src/NzbDrone.Core/NetImport/NetImportBase.cs index 164da2572..68b73e36f 100644 --- a/src/NzbDrone.Core/NetImport/NetImportBase.cs +++ b/src/NzbDrone.Core/NetImport/NetImportBase.cs @@ -45,6 +45,8 @@ namespace NzbDrone.Core.NetImport { Name = this.Name, Enabled = config.Validate().IsValid && Enabled, + EnableAuto = true, + ProfileId = 1, Implementation = GetType().Name, Settings = config }; diff --git a/src/NzbDrone.Core/NetImport/NetImportBaseSettings.cs b/src/NzbDrone.Core/NetImport/NetImportBaseSettings.cs index b9a0cf798..0c9365151 100644 --- a/src/NzbDrone.Core/NetImport/NetImportBaseSettings.cs +++ b/src/NzbDrone.Core/NetImport/NetImportBaseSettings.cs @@ -21,15 +21,11 @@ namespace NzbDrone.Core.NetImport public NetImportBaseSettings() { Link = "http://rss.imdb.com/list/"; - ProfileId = 1; } [FieldDefinition(0, Label = "Link", HelpText = "Link to the list of movies.")] public string Link { get; set; } - [FieldDefinition(1, Label = "Quality Profile", Type = FieldType.Select, SelectOptions = typeof(Profile), HelpText = "Quality Profile of all added movies")] - public int ProfileId { get; set; } - public bool IsValid => !string.IsNullOrWhiteSpace(Link); public NzbDroneValidationResult Validate() diff --git a/src/NzbDrone.Core/NetImport/NetImportDefinition.cs b/src/NzbDrone.Core/NetImport/NetImportDefinition.cs index fb2313353..bd0628656 100644 --- a/src/NzbDrone.Core/NetImport/NetImportDefinition.cs +++ b/src/NzbDrone.Core/NetImport/NetImportDefinition.cs @@ -1,10 +1,15 @@ -using NzbDrone.Core.ThingiProvider; +using Marr.Data; +using NzbDrone.Core.Profiles; +using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.NetImport { public class NetImportDefinition : ProviderDefinition { public bool Enabled { get; set; } + public bool EnableAuto { get; set; } + public int ProfileId { get; set; } + public LazyLoaded Profile { get; set; } public override bool Enable => Enabled; } } diff --git a/src/NzbDrone.Core/NetImport/RSSImport/RSSImport.cs b/src/NzbDrone.Core/NetImport/RSSImport/RSSImport.cs index acca1a9ff..c5f9da7de 100644 --- a/src/NzbDrone.Core/NetImport/RSSImport/RSSImport.cs +++ b/src/NzbDrone.Core/NetImport/RSSImport/RSSImport.cs @@ -33,6 +33,8 @@ namespace NzbDrone.Core.NetImport.RSSImport { Name = "IMDb Watchlist", Enabled = config.Validate().IsValid && Enabled, + EnableAuto = true, + ProfileId = 1, Implementation = GetType().Name, Settings = config }; diff --git a/src/UI/Settings/NetImport/Add/NetImportAddItemView.js b/src/UI/Settings/NetImport/Add/NetImportAddItemView.js index c5b5b4ed1..38fce07fb 100644 --- a/src/UI/Settings/NetImport/Add/NetImportAddItemView.js +++ b/src/UI/Settings/NetImport/Add/NetImportAddItemView.js @@ -38,8 +38,7 @@ module.exports = Marionette.ItemView.extend({ _openEdit : function() { this.model.set({ id : undefined, - enableRss : this.model.get('supportsRss'), - enableSearch : this.model.get('supportsSearch') + enableAuto : this.model.get('enableAuto') }); var editView = new EditView({ diff --git a/src/UI/Settings/NetImport/Edit/NetImportEditView.js b/src/UI/Settings/NetImport/Edit/NetImportEditView.js index a17b81a95..ce97dd3b6 100644 --- a/src/UI/Settings/NetImport/Edit/NetImportEditView.js +++ b/src/UI/Settings/NetImport/Edit/NetImportEditView.js @@ -3,6 +3,7 @@ var $ = require('jquery'); var vent = require('vent'); var Marionette = require('marionette'); var DeleteView = require('../Delete/IndexerDeleteView'); +var Profiles = require('../../../Profile/ProfileCollection'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsEditModalView = require('../../../Mixins/AsEditModalView'); @@ -22,6 +23,8 @@ var view = Marionette.ItemView.extend({ initialize : function(options) { this.targetCollection = options.targetCollection; + this.templateHelpers = {}; + this.templateHelpers.profiles = Profiles.toJSON(); }, _onAfterSave : function() { diff --git a/src/UI/Settings/NetImport/Edit/NetImportEditViewTemplate.hbs b/src/UI/Settings/NetImport/Edit/NetImportEditViewTemplate.hbs index f481b9bdf..ae480bf51 100644 --- a/src/UI/Settings/NetImport/Edit/NetImportEditViewTemplate.hbs +++ b/src/UI/Settings/NetImport/Edit/NetImportEditViewTemplate.hbs @@ -23,7 +23,7 @@
+ +
+ + +
+ {{> ProfileSelectionPartial profiles}} +
+
+ {{formBuilder}}