From c8621b8100b8506fd34e888928ca2076a33ffb18 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 1 Jan 2013 18:06:55 -0800 Subject: [PATCH] Quality type sizes moved to backbone + SS (API) --- NzbDrone.Api/AppHost.cs | 6 +- NzbDrone.Api/Bootstrapper.cs | 18 ++-- NzbDrone.Api/NzbDrone.Api.csproj | 3 +- .../QualityProfiles/QualityProfileModel.cs | 1 - .../QualityProfiles/QualityProfileRequest.cs | 10 -- NzbDrone.Api/QualityType/QualityTypeModel.cs | 13 +++ .../QualityType/QualityTypeService.cs | 59 +++++++++++ .../Resolvers/AllowedToQualitiesResolver.cs | 2 +- .../Resolvers/QualityTypesToIntResolver.cs | 2 +- NzbDrone.Web/Content/QualitySettings.css | 12 +++ NzbDrone.Web/NzbDrone.Web.csproj | 8 +- NzbDrone.Web/Scripts/NzbDrone/AutoBind.js | 3 +- .../Scripts/NzbDrone/qualitySettings.js | 97 +++--------------- .../Scripts/backbone/apps/qualityTypeApp.js | 19 ++++ NzbDrone.Web/Scripts/backbone/bootstrapper.js | 7 -- NzbDrone.Web/Scripts/backbone/constants.js | 7 ++ NzbDrone.Web/Scripts/backbone/controller.js | 57 ----------- .../Scripts/backbone/models/qualityType.js | 38 +++++++ .../backbone/models/qualityTypeCollection.js | 4 + NzbDrone.Web/Scripts/backbone/utils.js | 53 ---------- .../Scripts/backbone/views/qualityProfiles.js | 10 +- .../Scripts/backbone/views/qualityTypes.js | 29 ++++++ NzbDrone.Web/Views/Settings/Quality.cshtml | 98 +++++-------------- .../Views/Settings/QualityProfileItem.cshtml | 44 --------- 24 files changed, 244 insertions(+), 356 deletions(-) delete mode 100644 NzbDrone.Api/QualityProfiles/QualityProfileRequest.cs create mode 100644 NzbDrone.Api/QualityType/QualityTypeModel.cs create mode 100644 NzbDrone.Api/QualityType/QualityTypeService.cs create mode 100644 NzbDrone.Web/Scripts/backbone/apps/qualityTypeApp.js delete mode 100644 NzbDrone.Web/Scripts/backbone/bootstrapper.js delete mode 100644 NzbDrone.Web/Scripts/backbone/controller.js create mode 100644 NzbDrone.Web/Scripts/backbone/models/qualityType.js create mode 100644 NzbDrone.Web/Scripts/backbone/models/qualityTypeCollection.js delete mode 100644 NzbDrone.Web/Scripts/backbone/utils.js create mode 100644 NzbDrone.Web/Scripts/backbone/views/qualityTypes.js delete mode 100644 NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml diff --git a/NzbDrone.Api/AppHost.cs b/NzbDrone.Api/AppHost.cs index e01030a7b..247bc784e 100644 --- a/NzbDrone.Api/AppHost.cs +++ b/NzbDrone.Api/AppHost.cs @@ -6,8 +6,10 @@ using System.Web; using Funq; using Ninject; using NzbDrone.Api.QualityProfiles; +using NzbDrone.Api.QualityType; using ServiceStack.ContainerAdapter.Ninject; using ServiceStack.WebHost.Endpoints; +using QualityProfileService = NzbDrone.Api.QualityProfiles.QualityProfileService; namespace NzbDrone.Api { @@ -28,7 +30,9 @@ namespace NzbDrone.Api Routes .Add("/qualityprofiles") - .Add("/qualityprofiles/{Id}"); + .Add("/qualityprofiles/{Id}") + .Add("/qualitytypes") + .Add("/qualitytypes/{Id}"); Bootstrapper.Initialize(); } diff --git a/NzbDrone.Api/Bootstrapper.cs b/NzbDrone.Api/Bootstrapper.cs index 1b2bc6328..81d509be7 100644 --- a/NzbDrone.Api/Bootstrapper.cs +++ b/NzbDrone.Api/Bootstrapper.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using AutoMapper; using NzbDrone.Api.QualityProfiles; +using NzbDrone.Api.QualityType; using NzbDrone.Api.Resolvers; using NzbDrone.Core.Repository.Quality; @@ -13,15 +14,7 @@ namespace NzbDrone.Api { public static void Initialize() { - //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.QualityProfileId)); - + //QualityProfiles Mapper.CreateMap() .ForMember(dest => dest.QualityProfileId, opt => opt.MapFrom(src => src.Id)) .ForMember(dest => dest.Allowed, opt => opt.ResolveUsing().FromMember(src => src.Qualities)); @@ -32,6 +25,13 @@ namespace NzbDrone.Api Mapper.CreateMap() .ForMember(dest => dest.Allowed, opt => opt.Ignore()); + + //QualityTypes + Mapper.CreateMap() + .ForMember(dest => dest.QualityTypeId, opt => opt.MapFrom(src => src.Id)); + + Mapper.CreateMap() + .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.QualityTypeId)); } } } diff --git a/NzbDrone.Api/NzbDrone.Api.csproj b/NzbDrone.Api/NzbDrone.Api.csproj index 2d5ae5007..93638f9c5 100644 --- a/NzbDrone.Api/NzbDrone.Api.csproj +++ b/NzbDrone.Api/NzbDrone.Api.csproj @@ -99,11 +99,12 @@ - + + diff --git a/NzbDrone.Api/QualityProfiles/QualityProfileModel.cs b/NzbDrone.Api/QualityProfiles/QualityProfileModel.cs index 7692f30e1..350c2f201 100644 --- a/NzbDrone.Api/QualityProfiles/QualityProfileModel.cs +++ b/NzbDrone.Api/QualityProfiles/QualityProfileModel.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using NzbDrone.Core.Repository.Quality; namespace NzbDrone.Api.QualityProfiles { diff --git a/NzbDrone.Api/QualityProfiles/QualityProfileRequest.cs b/NzbDrone.Api/QualityProfiles/QualityProfileRequest.cs deleted file mode 100644 index 361d80e57..000000000 --- a/NzbDrone.Api/QualityProfiles/QualityProfileRequest.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Linq; - -namespace NzbDrone.Api.QualityProfiles -{ - public class QualityProfileRequest : IApiRequest - { - public string ApiKey { get; set; } - public int Id { get; set; } - } -} \ No newline at end of file diff --git a/NzbDrone.Api/QualityType/QualityTypeModel.cs b/NzbDrone.Api/QualityType/QualityTypeModel.cs new file mode 100644 index 000000000..a503cf28a --- /dev/null +++ b/NzbDrone.Api/QualityType/QualityTypeModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Linq; + +namespace NzbDrone.Api.QualityType +{ + public class QualityTypeModel + { + public Int32 Id { get; set; } + public String Name { get; set; } + public Int32 MinSize { get; set; } + public Int32 MaxSize { get; set; } + } +} \ No newline at end of file diff --git a/NzbDrone.Api/QualityType/QualityTypeService.cs b/NzbDrone.Api/QualityType/QualityTypeService.cs new file mode 100644 index 000000000..def3b9cfb --- /dev/null +++ b/NzbDrone.Api/QualityType/QualityTypeService.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using AutoMapper; +using Ninject; +using NzbDrone.Api.Filters; +using NzbDrone.Core.Providers; +using ServiceStack.ServiceInterface; + +namespace NzbDrone.Api.QualityType +{ + [ValidApiRequest] + public class QualityTypeService : RestServiceBase + { + private readonly QualityTypeProvider _qualityTypeProvider; + + [Inject] + public QualityTypeService(QualityTypeProvider qualityTypeProvider) + { + _qualityTypeProvider = qualityTypeProvider; + } + + public QualityTypeService() + { + } + + public override object OnGet(QualityTypeModel request) + { + if (request.Id == 0) + { + var profiles = _qualityTypeProvider.All().Where(qualityProfile => qualityProfile.QualityTypeId > 0).ToList(); + return Mapper.Map, List>(profiles); + } + + var type = _qualityTypeProvider.Get(request.Id); + return Mapper.Map(type); + } + + //Create + public override object OnPost(QualityTypeModel request) + { + throw new NotImplementedException(); + } + + //Update + public override object OnPut(QualityTypeModel request) + { + var type = Mapper.Map(request); + _qualityTypeProvider.Update(type); + + return request; + } + + public override object OnDelete(QualityTypeModel request) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/NzbDrone.Api/Resolvers/AllowedToQualitiesResolver.cs b/NzbDrone.Api/Resolvers/AllowedToQualitiesResolver.cs index 2205c0759..84b098f02 100644 --- a/NzbDrone.Api/Resolvers/AllowedToQualitiesResolver.cs +++ b/NzbDrone.Api/Resolvers/AllowedToQualitiesResolver.cs @@ -12,7 +12,7 @@ namespace NzbDrone.Api.Resolvers { protected override List ResolveCore(List source) { - var qualities = Mapper.Map, List>(QualityTypes.All()); + var qualities = Mapper.Map, List>(QualityTypes.All().Where(q => q.Id > 0).ToList()); qualities.ForEach(quality => { diff --git a/NzbDrone.Api/Resolvers/QualityTypesToIntResolver.cs b/NzbDrone.Api/Resolvers/QualityTypesToIntResolver.cs index 66c339f0b..673485565 100644 --- a/NzbDrone.Api/Resolvers/QualityTypesToIntResolver.cs +++ b/NzbDrone.Api/Resolvers/QualityTypesToIntResolver.cs @@ -14,4 +14,4 @@ namespace NzbDrone.Api.Resolvers return source.Id; } } -} +} \ No newline at end of file diff --git a/NzbDrone.Web/Content/QualitySettings.css b/NzbDrone.Web/Content/QualitySettings.css index 2117fffd3..200b92b2c 100644 --- a/NzbDrone.Web/Content/QualitySettings.css +++ b/NzbDrone.Web/Content/QualitySettings.css @@ -123,6 +123,18 @@ width: 600px; } +.quality-type { + margin-top: 5px; + margin-bottom: 5px; + padding: 4px 10px 4px 10px; + border: 1px solid lightgray; +} + +.quality-type .slider { + margin-top: 3px; + margin-bottom: 3px; +} + #QualityForm .ui-accordion .ui-accordion-content { padding: 1em 2em; } \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index bc9ede946..aca852cdb 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -398,13 +398,14 @@ + - - + + - + @@ -531,7 +532,6 @@ - diff --git a/NzbDrone.Web/Scripts/NzbDrone/AutoBind.js b/NzbDrone.Web/Scripts/NzbDrone/AutoBind.js index 544e032bd..a45f9f81a 100644 --- a/NzbDrone.Web/Scripts/NzbDrone/AutoBind.js +++ b/NzbDrone.Web/Scripts/NzbDrone/AutoBind.js @@ -1,7 +1,7 @@ $(document).ready(function () { //All forms are ajax forms - $("form").livequery(function () { + $("form").livequery(function () { var options = { type: 'post', @@ -16,7 +16,6 @@ $(this).removeAttr('disabled'); }); - //All buttons are jQueryUI buttons $('button, input[type="button"], input[type="submit"], input[type="reset"]').livequery(function () { $(this).button(); diff --git a/NzbDrone.Web/Scripts/NzbDrone/qualitySettings.js b/NzbDrone.Web/Scripts/NzbDrone/qualitySettings.js index ac3de1858..b0617c724 100644 --- a/NzbDrone.Web/Scripts/NzbDrone/qualitySettings.js +++ b/NzbDrone.Web/Scripts/NzbDrone/qualitySettings.js @@ -1,80 +1,4 @@ -var deleteQualityProfileUrl = '../../Settings/DeleteQualityProfile'; - -$(document).on('click', '.delete-profile', function (e) { - var container = $(this).closest('.profileSection'); - var id = $(container).attr('data-profile-id'); - - $.ajax({ - type: "POST", - url: deleteQualityProfileUrl, - data: jQuery.param({ profileId: id }), - success: function (data, textStatus, jqXHR) { - $(container).remove(); - removeOption(id); - } - }); - - e.preventDefault(); -}); - -function renameOption(text, value) { - $("#DefaultQualityProfileId option[value='" + value + "']").html(text); -} - -function addOption(text, value) { - var myCombo = $('#DefaultQualityProfileId'); - - var exists = $("#DefaultQualityProfileId option[value='" + value + "']"); - - if (exists.length == 0) - myCombo.append($('\ \').val(value).html(text)); -} - -function removeOption(value) { - $("#DefaultQualityProfileId option[value='" + value + "']").remove(); -} - -function getProfileId(obj) { - var parentProfileSection = $(obj).closest('.profileSection'); - return parentProfileSection.attr('data-profile-id'); -} - -function getCleanId(obj) { - var parentProfileSection = $(obj).parents('.profileSection'); - return parentProfileSection.children('.cleanId').val(); -} - -$(document).on('keyup', '.profileName_textbox', function () { - var value = $(this).val(); - - $(this).closest('.profileSection').find('.titleText').text(value); - var profileId = getProfileId(this); - - renameOption(value, profileId); -}).keyup(); - -$(document).on('click', '.quality-selectee', function () { - var id = $(this).attr('id'); - var cleanId = getCleanId(this); - var cutoff = '#' + cleanId + '_Cutoff'; - var name = jQuery('[for="' + id + '"]').children('.ui-button-text').text(); - var qualityId = $(this).attr('data-quality-id'); - - //Remove 'Unknown' - $(cutoff + ' option').each(function () { if ($(this).text().indexOf('Unknown') > -1) $(cutoff + ' option').remove(':contains("' + $(this).text() + '")'); }); - - //Add option to cutoff SelectList - if ($(this).attr('checked')) { - $('').val(qualityId).appendTo(cutoff); - } - - //Remove option from cutoff SelectList - else { - $(cutoff).find('option[value="' + qualityId + '"]').remove(); - } -}); - -var sliderOptions = { +var sliderOptions = { min: 0, max: 200, value: 0, @@ -88,14 +12,19 @@ var sliderOptions = { $(this).siblings('.slider-value').val(ui.value); $(this).siblings('.30-minute').text(ui.value * 30); $(this).siblings('.60-minute').text(ui.value * 60); + }, + change: function (event, ui) { + $(this).siblings('.slider-value').val(ui.value).trigger('change'); } }; -function setupSliders() { - $(".slider").each(function () { - var localOptions = sliderOptions; - localOptions["value"] = $(this).siblings('.slider-value').val(); +$('.quality-selectee').livequery(function () { + $(this).button(); +}); - $(this).empty().slider(localOptions); - }); -} \ No newline at end of file +$('.slider').livequery(function () { + var localOptions = sliderOptions; + localOptions["value"] = $(this).siblings('.slider-value').val(); + + $(this).empty().slider(localOptions); +}); diff --git a/NzbDrone.Web/Scripts/backbone/apps/qualityTypeApp.js b/NzbDrone.Web/Scripts/backbone/apps/qualityTypeApp.js new file mode 100644 index 000000000..438152535 --- /dev/null +++ b/NzbDrone.Web/Scripts/backbone/apps/qualityTypeApp.js @@ -0,0 +1,19 @@ +QualityTypeApp = {}; + +QualityTypeApp.Views = {}; +QualityTypeApp.Models = {}; +QualityTypeApp.Collections = {}; + +QualityTypeApp.App = new Backbone.Marionette.Application(); + +// Setup default application views +QualityTypeApp.App.addInitializer(function () { + + QualityTypeApp.App.addRegions({ + mainRegion: '#sliders' + }); + + var qualityTypes = new QualityTypeCollectionView(); + + QualityTypeApp.App.mainRegion.show(qualityTypes); +}); \ No newline at end of file diff --git a/NzbDrone.Web/Scripts/backbone/bootstrapper.js b/NzbDrone.Web/Scripts/backbone/bootstrapper.js deleted file mode 100644 index 0ce23dccd..000000000 --- a/NzbDrone.Web/Scripts/backbone/bootstrapper.js +++ /dev/null @@ -1,7 +0,0 @@ -$(function () { - // Legacy support for templating - utils.loadTemplate(['QualityProfilesView', 'QualityProfileView'], - function () { - NzbDrone.App.start(); - }); -}); \ No newline at end of file diff --git a/NzbDrone.Web/Scripts/backbone/constants.js b/NzbDrone.Web/Scripts/backbone/constants.js index 1f38c99c6..5d71e1c33 100644 --- a/NzbDrone.Web/Scripts/backbone/constants.js +++ b/NzbDrone.Web/Scripts/backbone/constants.js @@ -3,4 +3,11 @@ QualityProfileCollection: '#QualityProfileCollectionTemplate', QualityProfile: '#QualityProfileTemplate' }, +}; + +QualityTypeApp.Constants = { + Templates: { + QualityTypeCollection: '#QualityTypeCollectionTemplate', + QualityType: '#QualityTypeTemplate' + }, }; \ No newline at end of file diff --git a/NzbDrone.Web/Scripts/backbone/controller.js b/NzbDrone.Web/Scripts/backbone/controller.js deleted file mode 100644 index c7d727f47..000000000 --- a/NzbDrone.Web/Scripts/backbone/controller.js +++ /dev/null @@ -1,57 +0,0 @@ -(function (nzbDrone) { - - var appController = function () { - return { - home: function (id) { - - // if (!this.homeView) { - // this.homeView = new HomeView(); - // } - // $('#content').html(this.homeView.el); - - nzbDrone.App.Layout.content.show(new nzbDrone.Views.HomeView()); - - this.menuItemSelected('home-menu'); - }, - - list: function (page) { - - var p = page ? parseInt(page, 10) : 1; - var profileList = new ProfileCollection(); - profileList.fetch({ - success: function () { - $('#content').html(new QualityProfilesView({ model: profileList, page: p }).el); - } - }); - this.menuItemSelected('home-menu'); - }, - - wineDetails: function (id) { - var profile = new Profile({ id: id }); - profile.fetch({ - success: function () { - $('#content').html(new QualityProfileView({ model: profile }).el); - } - }); - this.menuItemSelected(); - }, - - addWine: function () { - var wine = new Profile(); - $('#content').html(new QualityProfileView({ model: wine }).el); - this.menuItemSelected('add-menu'); - }, - - menuItemSelected: function (item) { - - // Using the application vent object as our global event aggregator - nzbDrone.App.vent.trigger( - nzbDrone.Constants.Events.MenuItemSelected, // Event name - item); // Options - } - }; - }; - - nzbDrone.AppController = appController; - -})(window.NodeCellar); \ No newline at end of file diff --git a/NzbDrone.Web/Scripts/backbone/models/qualityType.js b/NzbDrone.Web/Scripts/backbone/models/qualityType.js new file mode 100644 index 000000000..c289d1e6e --- /dev/null +++ b/NzbDrone.Web/Scripts/backbone/models/qualityType.js @@ -0,0 +1,38 @@ +window.QualityType = Backbone.Model.extend({ + + urlRoot: '/api/qualitytypes', + + idAttribute: 'Id', + + 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 + } +}); \ No newline at end of file diff --git a/NzbDrone.Web/Scripts/backbone/models/qualityTypeCollection.js b/NzbDrone.Web/Scripts/backbone/models/qualityTypeCollection.js new file mode 100644 index 000000000..79eafbda9 --- /dev/null +++ b/NzbDrone.Web/Scripts/backbone/models/qualityTypeCollection.js @@ -0,0 +1,4 @@ +window.QualityTypeCollection = Backbone.Collection.extend({ + model: QualityType, + url: '/api/qualitytypes' +}); \ No newline at end of file diff --git a/NzbDrone.Web/Scripts/backbone/utils.js b/NzbDrone.Web/Scripts/backbone/utils.js deleted file mode 100644 index 11b396260..000000000 --- a/NzbDrone.Web/Scripts/backbone/utils.js +++ /dev/null @@ -1,53 +0,0 @@ -window.utils = { - - // Asynchronously load templates located in separate .html files - loadTemplate: function (views, callback) { - - var deferreds = []; - - $.each(views, function (index, view) { - if (window[view]) { - deferreds.push($.get('tpl/' + view + '.html', function (data) { - window[view].prototype.template = _.template(data); - })); - } else { - alert(view + ' not found'); - } - }); - - $.when.apply(null, deferreds).done(callback); - }, - - displayValidationErrors: function (messages) { - for (var key in messages) { - if (messages.hasOwnProperty(key)) { - this.addValidationError(key, messages[key]); - } - } - this.showAlert('Warning!', 'Fix validation errors and try again', 'alert-warning'); - }, - - addValidationError: function (field, message) { - var controlGroup = $('#' + field).parent().parent(); - controlGroup.addClass('error'); - $('.help-inline', controlGroup).html(message); - }, - - removeValidationError: function (field) { - var controlGroup = $('#' + field).parent().parent(); - controlGroup.removeClass('error'); - $('.help-inline', controlGroup).html(''); - }, - - showAlert: function (title, text, klass) { - $('.alert').removeClass('alert-error alert-warning alert-success alert-info'); - $('.alert').addClass(klass); - $('.alert').html('' + title + ' ' + text); - $('.alert').show(); - }, - - hideAlert: function () { - $('.alert').hide(); - } - -}; \ 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 dc332b665..ea07a7b4f 100644 --- a/NzbDrone.Web/Scripts/backbone/views/qualityProfiles.js +++ b/NzbDrone.Web/Scripts/backbone/views/qualityProfiles.js @@ -107,15 +107,15 @@ QualityProfileCollectionView = Backbone.Marionette.CompositeView.extend({ //Todo: Need to get the default profile from the server, instead of creating it manually... var newProfile = new QualityProfile({ Name: '', Cutoff: 0, Qualities: [ - { "Id": 0, "Weight": 0, "Name": "Unknown", "Allowed": false }, { "Id": 1, "Weight": 1, "Name": "SDTV", "Allowed": false }, { "Id": 8, "Weight": 2, "Name": "WEBDL-480p", "Allowed": false }, { "Id": 2, "Weight": 3, "Name": "DVD", "Allowed": false }, - { "Id": 4, "Weight": 4, "Name": "HDTV", "Allowed": false }, - { "Id": 5, "Weight": 5, "Name": "WEBDL-720p", "Allowed": false }, + { "Id": 4, "Weight": 4, "Name": "HDTV-720p", "Allowed": false }, + { "Id": 9, "Weight": 5, "Name": "HDTV-1080p", "Allowed": false }, + { "Id": 5, "Weight": 6, "Name": "WEBDL-720p", "Allowed": false }, { "Id": 3, "Weight": 6, "Name": "WEBDL-1080p", "Allowed": false }, - { "Id": 6, "Weight": 7, "Name": "Bluray720p", "Allowed": false }, - { "Id": 7, "Weight": 8, "Name": "Bluray1080p", "Allowed": false } + { "Id": 6, "Weight": 8, "Name": "Bluray720p", "Allowed": false }, + { "Id": 7, "Weight": 9, "Name": "Bluray1080p", "Allowed": false } ] }); //Todo: It would be nice to not have to save this on add (via create) diff --git a/NzbDrone.Web/Scripts/backbone/views/qualityTypes.js b/NzbDrone.Web/Scripts/backbone/views/qualityTypes.js new file mode 100644 index 000000000..dc7004dc6 --- /dev/null +++ b/NzbDrone.Web/Scripts/backbone/views/qualityTypes.js @@ -0,0 +1,29 @@ +QualityTypeView = Backbone.Marionette.ItemView.extend({ + tagName: "div", + className: "quality-type", + template: QualityTypeApp.Constants.Templates.QualityType, + events: { + 'change .slider-value': 'changeSize' + }, + changeSize: function (e) { + var target = $(e.target); + var maxSize = parseInt($(target).val()); + + this.model.set({ "MaxSize": maxSize }); + this.model.save(); + } +}); + +QualityTypeCollectionView = Backbone.Marionette.CompositeView.extend({ + tagName: "div", + id: "quality-type-collection", + itemView: QualityTypeView, + template: QualityTypeApp.Constants.Templates.QualityTypeCollection, + + initialize: function () { + _.bindAll(this, 'render'); + this.collection = new QualityTypeCollection(); + this.collection.fetch(); + this.collection.bind('reset', this.render); + } +}); \ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/Quality.cshtml b/NzbDrone.Web/Views/Settings/Quality.cshtml index 3ffa2752d..c007dbb0e 100644 --- a/NzbDrone.Web/Views/Settings/Quality.cshtml +++ b/NzbDrone.Web/Views/Settings/Quality.cshtml @@ -14,104 +14,41 @@ @Html.DescriptionFor(m => m.DefaultQualityProfileId) @Html.DropDownListFor(m => m.DefaultQualityProfileId, Model.QualityProfileSelectList, new { @class = "inputClass" }) + +
+
-

- Profiles

+

Profiles

-

- Size Limits

+ +

Size Limits

Size Limits specify the maximum download size NzbDrone will send to your download client.
-
- SDTV -
-
- @Html.HiddenFor(m => m.SdtvMaxSize, new { @class = "slider-value" }) - 30 minute size: MB | 60 minute size: - MB -
-
- DVD -
-
- @Html.HiddenFor(m => m.DvdMaxSize, new { @class = "slider-value" }) - 30 minute size: MB | 60 minute size: - MB -
-
- HDTV -
-
- @Html.HiddenFor(m => m.HdtvMaxSize, new { @class = "slider-value" }) - 30 minute size: MB | 60 minute size: - MB -
-
- WEBDL-720p -
-
- @Html.HiddenFor(m => m.Webdl720pMaxSize, new { @class = "slider-value" }) - 30 minute size: MB | 60 minute size: - MB -
-
- Bluray 720p -
-
- @Html.HiddenFor(m => m.Bluray720pMaxSize, new { @class = "slider-value" }) - 30 minute size: MB | 60 minute size: - MB -
-
- WEBDL-1080p -
-
- @Html.HiddenFor(m => m.Webdl1080pMaxSize, new { @class = "slider-value" }) - 30 minute size: MB | 60 minute size: - MB -
-
- Bluray 1080p -
-
- @Html.HiddenFor(m => m.Bluray1080pMaxSize, new { @class = "slider-value" }) - 30 minute size: MB | 60 minute size: - MB -
+
-
- } @section Scripts { @Html.IncludeScript("NzbDrone/qualitySettings.js") - - @Html.IncludeScript("backbone/apps/qualityProfileApp.js") + @Html.IncludeScript("backbone/apps/qualityTypeApp.js") @Html.IncludeScript("backbone/constants.js") @Html.IncludeScript("backbone/models/qualityProfile.js") @Html.IncludeScript("backbone/models/qualityProfileCollection.js") @Html.IncludeScript("backbone/views/qualityProfiles.js") - @*@Html.IncludeScript("backbone/bootstrapper.js")*@ + @Html.IncludeScript("backbone/models/qualityType.js") + @Html.IncludeScript("backbone/models/qualityTypeCollection.js") + @Html.IncludeScript("backbone/views/qualityTypes.js") + + + + } \ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml b/NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml deleted file mode 100644 index 1c8e4edbb..000000000 --- a/NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml +++ /dev/null @@ -1,44 +0,0 @@ -@model NzbDrone.Web.Models.QualityProfileModel -@using NzbDrone.Web.Helpers -@{ - Layout = null; -} -@using (Html.BeginCollectionItem("Profiles")) -{ - var idClean = ViewData.TemplateInfo.HtmlFieldPrefix.Replace('[', '_').Replace(']', '_'); - -
-
- - @Model.Name - - - - -
-
- @Html.LabelFor(x => x.Name) - @Html.TextBoxFor(x => x.Name, new { @class = "profileName_textbox" }) - @Html.LabelFor(x => x.Cutoff) - @Html.DropDownListFor(m => m.Cutoff, new SelectList(Model.Allowed, "Id", "Name", Model.Cutoff)) -
-
- @Html.CheckBoxFor(m => m.Sdtv, new { @class = "quality-selectee", data_quality_id = Model.SdtvId }) - @Html.LabelFor(m => m.Sdtv) - @Html.CheckBoxFor(m => m.Dvd, new { @class = "quality-selectee", data_quality_id = Model.DvdId }) - @Html.LabelFor(m => m.Dvd) - @Html.CheckBoxFor(m => m.Hdtv, new { @class = "quality-selectee", data_quality_id = Model.HdtvId }) - @Html.LabelFor(m => m.Hdtv) - @Html.CheckBoxFor(m => m.Webdl720p, new { @class = "quality-selectee", data_quality_id = Model.Webdl720pId }) - @Html.LabelFor(m => m.Webdl720p) - @Html.CheckBoxFor(m => m.Bluray720p, new { @class = "quality-selectee", data_quality_id = Model.Bluray720pId }) - @Html.LabelFor(m => m.Bluray720p) - @Html.CheckBoxFor(m => m.Webdl1080p, new { @class = "quality-selectee", data_quality_id = Model.Webdl1080pId }) - @Html.LabelFor(m => m.Webdl1080p) - @Html.CheckBoxFor(m => m.Bluray1080p, new { @class = "quality-selectee", data_quality_id = Model.Bluray1080pId }) - @Html.LabelFor(m => m.Bluray1080p) -
- @Html.HiddenFor(x => x.QualityProfileId, new { @class = "qualityProfileId" }) - @Html.Hidden("cleanId", idClean, new { @class = "cleanId" }) -
-}