mirror of https://github.com/Radarr/Radarr
Bootstrap loading profiles via ajax
This commit is contained in:
parent
44c7a58595
commit
0ecbb30345
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using AutoMapper;
|
||||
using NzbDrone.Api.QualityProfiles;
|
||||
using NzbDrone.Api.Resolvers;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
|
||||
namespace NzbDrone.Api
|
||||
|
@ -12,6 +13,12 @@ namespace NzbDrone.Api
|
|||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
//Mapper.CreateMap<QualityTypes, Int32>()
|
||||
// .ForMember(dest => dest, opt => opt.ResolveUsing<QualityTypesToIntResolver>());
|
||||
|
||||
Mapper.CreateMap<Int32, QualityTypes>()
|
||||
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src));
|
||||
|
||||
Mapper.CreateMap<QualityProfile, QualityProfileModel>()
|
||||
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.QualityProfileId));
|
||||
|
||||
|
|
|
@ -103,6 +103,7 @@
|
|||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="QualityProfiles\QualityProfileModel.cs" />
|
||||
<Compile Include="QualityProfiles\QualityProfileService.cs" />
|
||||
<Compile Include="Resolvers\QualityTypesToIntResolver.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace NzbDrone.Api.QualityProfiles
|
|||
{
|
||||
public Int32 Id { get; set; }
|
||||
public String Name { get; set; }
|
||||
public QualityTypes Cutoff { get; set; }
|
||||
public List<QualityTypes> Allowed { get; set; }
|
||||
public Int32 Cutoff { get; set; }
|
||||
public List<Int32> Allowed { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using AutoMapper;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
|
||||
namespace NzbDrone.Api.Resolvers
|
||||
{
|
||||
public class QualityTypesToIntResolver : ValueResolver<QualityTypes, Int32>
|
||||
{
|
||||
protected override int ResolveCore(QualityTypes source)
|
||||
{
|
||||
return source.Id;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using NLog;
|
||||
using Newtonsoft.Json;
|
||||
using Ninject;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
@ -17,6 +18,7 @@ namespace NzbDrone.Core.Providers
|
|||
private readonly HttpProvider _httpProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
|
||||
[Inject]
|
||||
public SceneMappingProvider(IDatabase database, HttpProvider httpProvider, ConfigProvider configProvider)
|
||||
{
|
||||
_database = database;
|
||||
|
|
|
@ -330,7 +330,7 @@
|
|||
.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; }
|
||||
.ui-accordion .ui-accordion-li-fix { display: inline; }
|
||||
.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; }
|
||||
.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
|
||||
.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em 2.2em; }
|
||||
.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }
|
||||
.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
|
||||
.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; }
|
||||
|
|
Binary file not shown.
|
@ -388,13 +388,12 @@
|
|||
<Content Include="Scripts\backbone.js" />
|
||||
<Content Include="Scripts\backbone.marionette.min.js" />
|
||||
<Content Include="Scripts\backbone.min.js" />
|
||||
<Content Include="Scripts\backbone\app.js" />
|
||||
<Content Include="Scripts\backbone\apps\qualityProfileApp.js" />
|
||||
<Content Include="Scripts\backbone\bootstrapper.js" />
|
||||
<Content Include="Scripts\backbone\constants.js" />
|
||||
<Content Include="Scripts\backbone\controller.js" />
|
||||
<Content Include="Scripts\backbone\models\profileCollection.js" />
|
||||
<Content Include="Scripts\backbone\models\profileModel.js" />
|
||||
<Content Include="Scripts\backbone\router.js" />
|
||||
<Content Include="Scripts\backbone\models\qualityProfileCollection.js" />
|
||||
<Content Include="Scripts\backbone\models\qualityProfile.js" />
|
||||
<Content Include="Scripts\backbone\utils.js" />
|
||||
<Content Include="Scripts\backbone\views\qualityProfiles.js" />
|
||||
<Content Include="Scripts\conditional-validation.js" />
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
NzbDrone = {};
|
||||
|
||||
NzbDrone.Views = {};
|
||||
NzbDrone.Models = {};
|
||||
NzbDrone.Collections = {};
|
||||
|
||||
NzbDrone.App = new Backbone.Marionette.Application();
|
||||
|
||||
// Setup default application views
|
||||
NzbDrone.App.addInitializer(function () {
|
||||
|
||||
NzbDrone.App.addRegions({
|
||||
main: '#main-region'
|
||||
});
|
||||
|
||||
var layout = new NzbDrone.Views.AppLayout();
|
||||
|
||||
NzbDrone.App.Layout = layout;
|
||||
NzbDrone.App.main.show(layout);
|
||||
|
||||
layout.header.show(new NzbDrone.Views.HeaderView());
|
||||
});
|
||||
|
||||
NzbDrone.App.addInitializer(function () {
|
||||
new NzbDrone.AppRouter();
|
||||
Backbone.history.start();
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
QualityProfileApp = {};
|
||||
|
||||
QualityProfileApp.Views = {};
|
||||
QualityProfileApp.Models = {};
|
||||
QualityProfileApp.Collections = {};
|
||||
|
||||
QualityProfileApp.App = new Backbone.Marionette.Application();
|
||||
|
||||
// Setup default application views
|
||||
QualityProfileApp.App.addInitializer(function () {
|
||||
|
||||
QualityProfileApp.App.addRegions({
|
||||
mainRegion: '#profiles'
|
||||
});
|
||||
|
||||
var qualityProfiles = new QualityProfileCollectionView();
|
||||
|
||||
QualityProfileApp.App.mainRegion.show(qualityProfiles);
|
||||
});
|
|
@ -1,11 +1,6 @@
|
|||
NzbDrone.Constants = {
|
||||
QualityProfileApp.Constants = {
|
||||
Templates: {
|
||||
AppLayout: '#AppLayout',
|
||||
QualityProfilesView: '#QualityProfilesView',
|
||||
QualityProfileView: '#QualityProfileView'
|
||||
QualityProfileCollection: '#QualityProfileCollectionTemplate',
|
||||
QualityProfile: '#QualityProfileTemplate'
|
||||
},
|
||||
|
||||
Events: {
|
||||
MenuItemSelected: 'MenuItemSelected'
|
||||
}
|
||||
};
|
|
@ -1,18 +0,0 @@
|
|||
window.ProfileCollection = Backbone.Collection.extend({
|
||||
|
||||
model: Profile,
|
||||
|
||||
url: '/api/qualityprofiles',
|
||||
|
||||
search: function (searchTerm, options) {
|
||||
|
||||
var self = this;
|
||||
this.fetch({
|
||||
success: function () {
|
||||
if (options.success) {
|
||||
options.success();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
|
@ -1,4 +1,4 @@
|
|||
window.Profile = Backbone.Model.extend({
|
||||
window.QualityProfile = Backbone.Model.extend({
|
||||
|
||||
urlRoot: '/api/qualityprofiles',
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
window.QualityProfileCollection = Backbone.Collection.extend({
|
||||
model: QualityProfile,
|
||||
url: '/api/qualityprofiles'
|
||||
});
|
|
@ -1,16 +0,0 @@
|
|||
(function (nzbDrone, backbone) {
|
||||
nzbDrone.AppRouter = backbone.Marionette.AppRouter.extend({
|
||||
|
||||
controller: new nzbDrone.AppController(),
|
||||
|
||||
appRoutes: {
|
||||
'': 'home',
|
||||
'wines': 'list',
|
||||
'wines/page/:page': 'list',
|
||||
'wines/add': 'addWine',
|
||||
'wines/:id': 'wineDetails',
|
||||
'about': 'about',
|
||||
'search/:searchTerm': 'handleSearch'
|
||||
}
|
||||
});
|
||||
})(window.NzbDrone, window.Backbone);s
|
|
@ -1,37 +1,23 @@
|
|||
window.QualityProfilesView = Backbone.View.extend({
|
||||
|
||||
initialize: function () {
|
||||
this.render();
|
||||
},
|
||||
|
||||
render: function () {
|
||||
var profiles = this.model.models;
|
||||
var len = profiles.length;
|
||||
var startPos = (this.options.page - 1) * 8;
|
||||
var endPos = Math.min(startPos + 8, len);
|
||||
|
||||
$(this.el).html('<ul class="thumbnails"></ul>');
|
||||
|
||||
for (var i = startPos; i < endPos; i++) {
|
||||
$('.thumbnails', this.el).append(new QualityProfileView({ model: profiles[i] }).render().el);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
QualityProfileView = Backbone.Marionette.ItemView.extend({
|
||||
tagName: "div",
|
||||
className: "quality-profile",
|
||||
template: "#QualityProfileTemplate"
|
||||
});
|
||||
|
||||
window.QualityProfileView = Backbone.View.extend({
|
||||
|
||||
tagName: "li",
|
||||
|
||||
QualityProfileCollectionView = Backbone.Marionette.CompositeView.extend({
|
||||
tagName: "div",
|
||||
id: "quality-profile-collection",
|
||||
itemView: QualityProfileView,
|
||||
template: QualityProfileApp.Constants.Templates.QualityProfileCollection,
|
||||
|
||||
//appendHtml: function (collectionView, itemView) {
|
||||
// collectionView.$('#collection').append(itemView.el);
|
||||
//},
|
||||
|
||||
initialize: function () {
|
||||
this.model.bind("change", this.render, this);
|
||||
this.model.bind("destroy", this.close, this);
|
||||
},
|
||||
|
||||
render: function () {
|
||||
$(this.el).html(this.template(this.model.toJSON()));
|
||||
return this;
|
||||
_.bindAll(this, 'render');
|
||||
this.collection = new QualityProfileCollection();
|
||||
this.collection.fetch();
|
||||
this.collection.bind('reset', this.render);
|
||||
}
|
||||
|
||||
});
|
|
@ -106,8 +106,7 @@
|
|||
<p>
|
||||
</p>
|
||||
<a id="addNewznab" href="@Url.Action("AddNewznabProvider", "Settings")">
|
||||
<img src="../../Content/Images/Plus.png" alt="Add Newznab Provider" width="20px"
|
||||
height="20px" />
|
||||
<img src="../../Content/Images/Plus.png" alt="Add Newznab Provider" width="20px" height="20px" />
|
||||
Add Newznab Provider</a>
|
||||
<div id="newznabProviders">
|
||||
@foreach (var provider in Model.NewznabDefinitions)
|
||||
|
|
|
@ -27,10 +27,6 @@
|
|||
</a>
|
||||
</div>
|
||||
<div id="profiles">
|
||||
@*@foreach (var item in (List<QualityProfile>)ViewData["Profiles"])
|
||||
{
|
||||
Html.RenderAction("GetQualityProfileView", item);
|
||||
}*@
|
||||
</div>
|
||||
</div>
|
||||
<h3>
|
||||
|
@ -116,19 +112,25 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
@Html.IncludeScript("backbone/app.js")
|
||||
@Html.IncludeScript("backbone/controller.js")
|
||||
@Html.IncludeScript("backbone/router.js")
|
||||
@Html.IncludeScript("backbone/apps/qualityProfileApp.js")
|
||||
@Html.IncludeScript("backbone/constants.js")
|
||||
@Html.IncludeScript("backbone/utils.js")
|
||||
@Html.IncludeScript("backbone/models/profileCollection.js")
|
||||
@Html.IncludeScript("backbone/models/profileModel.js")
|
||||
@Html.IncludeScript("backbone/models/qualityProfile.js")
|
||||
@Html.IncludeScript("backbone/models/qualityProfileCollection.js")
|
||||
@Html.IncludeScript("backbone/views/qualityProfiles.js")
|
||||
@*@Html.IncludeScript("backbone/bootstrapper.js")*@
|
||||
|
||||
<script id="QualityProfileView" type="text/template">
|
||||
<script id="QualityProfileTemplate" type="text/template">
|
||||
<%= Name %>
|
||||
<%= Cutoff %>
|
||||
<%= Allowed %>
|
||||
</script>
|
||||
|
||||
<script id="QualityProfileCollectionTemplate" type="text/template">
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
QualityProfileApp.App.start();
|
||||
});
|
||||
</script>
|
||||
}
|
Loading…
Reference in New Issue