diff --git a/NzbDrone.Api/Bootstrapper.cs b/NzbDrone.Api/Bootstrapper.cs index f8db1f13a..d065673fb 100644 --- a/NzbDrone.Api/Bootstrapper.cs +++ b/NzbDrone.Api/Bootstrapper.cs @@ -16,14 +16,17 @@ namespace NzbDrone.Api //Mapper.CreateMap() // .ForMember(dest => dest, opt => opt.ResolveUsing()); - Mapper.CreateMap() - .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src)); + //Mapper.CreateMap() + // .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src)); - Mapper.CreateMap() - .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.QualityProfileId)); + //Mapper.CreateMap() + // .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.QualityProfileId)); - Mapper.CreateMap() - .ForMember(dest => dest.QualityProfileId, opt => opt.MapFrom(src => src.Id)); + //Mapper.CreateMap() + // .ForMember(dest => dest.QualityProfileId, opt => opt.MapFrom(src => src.Id)); + + Mapper.CreateMap() + .ForMember(dest => dest.Allowed, opt => opt.Ignore()); } } } diff --git a/NzbDrone.Api/NzbDrone.Api.csproj b/NzbDrone.Api/NzbDrone.Api.csproj index 0f159eca9..27e849c94 100644 --- a/NzbDrone.Api/NzbDrone.Api.csproj +++ b/NzbDrone.Api/NzbDrone.Api.csproj @@ -103,6 +103,7 @@ + diff --git a/NzbDrone.Api/QualityProfiles/QualityProfileModel.cs b/NzbDrone.Api/QualityProfiles/QualityProfileModel.cs index 5a9048f3e..7692f30e1 100644 --- a/NzbDrone.Api/QualityProfiles/QualityProfileModel.cs +++ b/NzbDrone.Api/QualityProfiles/QualityProfileModel.cs @@ -11,6 +11,6 @@ namespace NzbDrone.Api.QualityProfiles public Int32 Id { get; set; } public String Name { get; set; } public Int32 Cutoff { get; set; } - public List Allowed { get; set; } + public List Qualities { get; set; } } -} +} \ No newline at end of file diff --git a/NzbDrone.Api/QualityProfiles/QualityProfileService.cs b/NzbDrone.Api/QualityProfiles/QualityProfileService.cs index a80c1ace0..61cc52244 100644 --- a/NzbDrone.Api/QualityProfiles/QualityProfileService.cs +++ b/NzbDrone.Api/QualityProfiles/QualityProfileService.cs @@ -29,11 +29,14 @@ namespace NzbDrone.Api.QualityProfiles if (request.Id == 0) { var profiles = _qualityProvider.All(); - return Mapper.Map, IEnumerable>(profiles); + var models = new List(); + + profiles.ForEach(p => models.Add(ToModel(p))); + return models; } var profile = _qualityProvider.Get(request.Id); - return Mapper.Map(profile); + return ToModel(profile); } public override object OnPost(QualityProfileModel data) @@ -58,5 +61,21 @@ namespace NzbDrone.Api.QualityProfiles return "ok"; } + + public QualityProfileModel ToModel(QualityProfile profile) + { + var model = new QualityProfileModel(); + model.Id = profile.QualityProfileId; + model.Name = profile.Name; + model.Cutoff = (int)profile.Cutoff; + model.Qualities = Mapper.Map, List>(QualityTypes.All()); + + model.Qualities.ForEach(quality => + { + quality.Allowed = profile.Allowed.SingleOrDefault(q => q.Id == quality.Id) != null; + }); + + return model; + } } } \ No newline at end of file diff --git a/NzbDrone.Api/QualityProfiles/QualityProfileType.cs b/NzbDrone.Api/QualityProfiles/QualityProfileType.cs new file mode 100644 index 000000000..b2b7f1b0b --- /dev/null +++ b/NzbDrone.Api/QualityProfiles/QualityProfileType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NzbDrone.Api.QualityProfiles +{ + public class QualityProfileType + { + public Int32 Id { get; set; } + public Int32 Weight { get; set; } + public String Name { get; set; } + public Boolean Allowed { get; set; } + } +} diff --git a/NzbDrone.Web/FakesAssemblies/Ninject.Web.Mvc.Fakes.dll b/NzbDrone.Web/FakesAssemblies/Ninject.Web.Mvc.Fakes.dll index 4ab4a5094..3f0b67053 100644 Binary files a/NzbDrone.Web/FakesAssemblies/Ninject.Web.Mvc.Fakes.dll and b/NzbDrone.Web/FakesAssemblies/Ninject.Web.Mvc.Fakes.dll differ diff --git a/NzbDrone.Web/Scripts/backbone/models/qualityProfile.js b/NzbDrone.Web/Scripts/backbone/models/qualityProfile.js index 742410d24..cf11bf398 100644 --- a/NzbDrone.Web/Scripts/backbone/models/qualityProfile.js +++ b/NzbDrone.Web/Scripts/backbone/models/qualityProfile.js @@ -2,7 +2,7 @@ urlRoot: '/api/qualityprofiles', - idAttribute: 'id', + idAttribute: 'Id', initialize: function () { this.validators = {}; @@ -11,9 +11,9 @@ 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' }; - }; + //this.validators.allowed = function (value) { + // return value.length > 0 ? { isValid: true } : { isValid: false, message: 'You must have allowed qualities' }; + //}; this.validators.cutoff = function (value) { return value != null ? { isValid: true } : { isValid: false, message: 'You must have a valid cutoff' }; @@ -42,9 +42,9 @@ }, defaults: { - id: null, - name: '', - allowed: {}, - cutoff: null + Id: null, + Name: '', + //allowed: {}, + Cutoff: null } }); \ No newline at end of file diff --git a/NzbDrone.Web/Scripts/backbone/views/qualityProfiles.js b/NzbDrone.Web/Scripts/backbone/views/qualityProfiles.js index a71e81e28..e4d8a9f69 100644 --- a/NzbDrone.Web/Scripts/backbone/views/qualityProfiles.js +++ b/NzbDrone.Web/Scripts/backbone/views/qualityProfiles.js @@ -1,7 +1,17 @@ QualityProfileView = Backbone.Marionette.ItemView.extend({ tagName: "div", className: "quality-profile", - template: "#QualityProfileTemplate" + template: "#QualityProfileTemplate", + events: { + 'click .quality-selectee': 'toggleAllowed' + }, + toggleAllowed: function (e) { + //Add to cutoff + //Update model + + var checked = $(e.target).attr('checked') != undefined; + this.model.set({ }); + } }); QualityProfileCollectionView = Backbone.Marionette.CompositeView.extend({ diff --git a/NzbDrone.Web/Views/Settings/Quality.cshtml b/NzbDrone.Web/Views/Settings/Quality.cshtml index 485c710eb..7a3070992 100644 --- a/NzbDrone.Web/Views/Settings/Quality.cshtml +++ b/NzbDrone.Web/Views/Settings/Quality.cshtml @@ -122,7 +122,16 @@