Rethought about where certain things are stored.

Profiles are now a component of the NetImportDefinition.
pull/2/head
Leonardo Galli 8 years ago
parent 9fffcfaea3
commit 94eccc6c14

@ -18,19 +18,8 @@ namespace NzbDrone.Api.NetImport
base.MapToResource(resource, definition); base.MapToResource(resource, definition);
resource.Enabled = definition.Enabled; resource.Enabled = definition.Enabled;
Field theField = null; resource.EnableAuto = definition.EnableAuto;
int index = 0; resource.ProfileId = definition.ProfileId;
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;
}
}
} }
@ -38,7 +27,9 @@ namespace NzbDrone.Api.NetImport
{ {
base.MapToModel(definition, resource); 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) protected override void Validate(NetImportDefinition definition, bool includeWarnings)

@ -5,6 +5,7 @@ namespace NzbDrone.Api.NetImport
public class NetImportResource : ProviderResource public class NetImportResource : ProviderResource
{ {
public bool Enabled { get; set; } public bool Enabled { get; set; }
public bool EnableSearch { get; set; } public bool EnableAuto { get; set; }
public int ProfileId { get; set; }
} }
} }

@ -16,7 +16,8 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("Implementation").AsString() .WithColumn("Implementation").AsString()
.WithColumn("ConfigContract").AsString().Nullable() .WithColumn("ConfigContract").AsString().Nullable()
.WithColumn("Settings").AsString().Nullable() .WithColumn("Settings").AsString().Nullable()
.WithColumn("EnableAuto").AsInt32(); .WithColumn("EnableAuto").AsInt32()
.WithColumn("ProfileId").AsInt32();
} }
} }
} }

@ -57,7 +57,9 @@ namespace NzbDrone.Core.Datastore
.Ignore(i => i.SupportsSearch); .Ignore(i => i.SupportsSearch);
Mapper.Entity<NetImportDefinition>().RegisterDefinition("NetImport") Mapper.Entity<NetImportDefinition>().RegisterDefinition("NetImport")
.Ignore(i => i.Enable); .Ignore(i => i.Enable)
.Relationship()
.HasOne(n => n.Profile, n => n.ProfileId);
Mapper.Entity<NotificationDefinition>().RegisterDefinition("Notifications") Mapper.Entity<NotificationDefinition>().RegisterDefinition("Notifications")
.Ignore(i => i.SupportsOnGrab) .Ignore(i => i.SupportsOnGrab)

@ -45,6 +45,8 @@ namespace NzbDrone.Core.NetImport
{ {
Name = this.Name, Name = this.Name,
Enabled = config.Validate().IsValid && Enabled, Enabled = config.Validate().IsValid && Enabled,
EnableAuto = true,
ProfileId = 1,
Implementation = GetType().Name, Implementation = GetType().Name,
Settings = config Settings = config
}; };

@ -21,15 +21,11 @@ namespace NzbDrone.Core.NetImport
public NetImportBaseSettings() public NetImportBaseSettings()
{ {
Link = "http://rss.imdb.com/list/"; Link = "http://rss.imdb.com/list/";
ProfileId = 1;
} }
[FieldDefinition(0, Label = "Link", HelpText = "Link to the list of movies.")] [FieldDefinition(0, Label = "Link", HelpText = "Link to the list of movies.")]
public string Link { get; set; } 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 bool IsValid => !string.IsNullOrWhiteSpace(Link);
public NzbDroneValidationResult Validate() public NzbDroneValidationResult Validate()

@ -1,10 +1,15 @@
using NzbDrone.Core.ThingiProvider; using Marr.Data;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.NetImport namespace NzbDrone.Core.NetImport
{ {
public class NetImportDefinition : ProviderDefinition public class NetImportDefinition : ProviderDefinition
{ {
public bool Enabled { get; set; } public bool Enabled { get; set; }
public bool EnableAuto { get; set; }
public int ProfileId { get; set; }
public LazyLoaded<Profile> Profile { get; set; }
public override bool Enable => Enabled; public override bool Enable => Enabled;
} }
} }

@ -33,6 +33,8 @@ namespace NzbDrone.Core.NetImport.RSSImport
{ {
Name = "IMDb Watchlist", Name = "IMDb Watchlist",
Enabled = config.Validate().IsValid && Enabled, Enabled = config.Validate().IsValid && Enabled,
EnableAuto = true,
ProfileId = 1,
Implementation = GetType().Name, Implementation = GetType().Name,
Settings = config Settings = config
}; };

@ -38,8 +38,7 @@ module.exports = Marionette.ItemView.extend({
_openEdit : function() { _openEdit : function() {
this.model.set({ this.model.set({
id : undefined, id : undefined,
enableRss : this.model.get('supportsRss'), enableAuto : this.model.get('enableAuto')
enableSearch : this.model.get('supportsSearch')
}); });
var editView = new EditView({ var editView = new EditView({

@ -3,6 +3,7 @@ var $ = require('jquery');
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var DeleteView = require('../Delete/IndexerDeleteView'); var DeleteView = require('../Delete/IndexerDeleteView');
var Profiles = require('../../../Profile/ProfileCollection');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsValidatedView = require('../../../Mixins/AsValidatedView');
var AsEditModalView = require('../../../Mixins/AsEditModalView'); var AsEditModalView = require('../../../Mixins/AsEditModalView');
@ -22,6 +23,8 @@ var view = Marionette.ItemView.extend({
initialize : function(options) { initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
this.templateHelpers = {};
this.templateHelpers.profiles = Profiles.toJSON();
}, },
_onAfterSave : function() { _onAfterSave : function() {

@ -23,7 +23,7 @@
<div class="col-sm-5"> <div class="col-sm-5">
<div class="input-group"> <div class="input-group">
<label class="checkbox toggle well"> <label class="checkbox toggle well">
<input type="checkbox" name="enableAutomatic" /> <input type="checkbox" name="enableAutomatic" {{#if enableAuto}} checked="checked" {{/if}} />
<p> <p>
<span>Yes</span> <span>Yes</span>
<span>No</span> <span>No</span>
@ -39,6 +39,15 @@
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-sm-3 control-label">Quality Profile</label>
<div class="col-sm-5">
{{> ProfileSelectionPartial profiles}}
</div>
</div>
{{formBuilder}} {{formBuilder}}
</div> </div>
</div> </div>

Loading…
Cancel
Save