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);
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)

@ -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; }
}
}

@ -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();
}
}
}

@ -57,7 +57,9 @@ namespace NzbDrone.Core.Datastore
.Ignore(i => i.SupportsSearch);
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")
.Ignore(i => i.SupportsOnGrab)

@ -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
};

@ -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()

@ -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> Profile { get; set; }
public override bool Enable => Enabled;
}
}

@ -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
};

@ -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({

@ -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() {

@ -23,7 +23,7 @@
<div class="col-sm-5">
<div class="input-group">
<label class="checkbox toggle well">
<input type="checkbox" name="enableAutomatic" />
<input type="checkbox" name="enableAutomatic" {{#if enableAuto}} checked="checked" {{/if}} />
<p>
<span>Yes</span>
<span>No</span>
@ -39,6 +39,15 @@
</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}}
</div>
</div>

Loading…
Cancel
Save