mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-23 06:45:19 -07:00
WIP UI Update for adding lists.
This commit is contained in:
parent
451f2d30e4
commit
dd553b9439
19 changed files with 1221 additions and 1212 deletions
|
@ -1,11 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Reflection;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Profiles;
|
||||
|
||||
namespace NzbDrone.Api.ClientSchema
|
||||
{
|
||||
|
@ -147,6 +150,18 @@ namespace NzbDrone.Api.ClientSchema
|
|||
|
||||
private static List<SelectOption> GetSelectOptions(Type selectOptions)
|
||||
{
|
||||
if (selectOptions == typeof(Profile))
|
||||
{
|
||||
return new List<SelectOption>();
|
||||
}
|
||||
|
||||
if (selectOptions == typeof(Quality))
|
||||
{
|
||||
var qOptions = from Quality q in selectOptions.GetProperties(BindingFlags.Static | BindingFlags.Public)
|
||||
select new SelectOption {Name = q.Name, Value = q.Id};
|
||||
return qOptions.OrderBy(o => o.Value).ToList();
|
||||
}
|
||||
|
||||
var options = from Enum e in Enum.GetValues(selectOptions)
|
||||
select new SelectOption { Value = Convert.ToInt32(e), Name = e.ToString() };
|
||||
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
using NzbDrone.Core.NetImport;
|
||||
using NzbDrone.Api.ClientSchema;
|
||||
using NzbDrone.Core.NetImport;
|
||||
using NzbDrone.Core.Profiles;
|
||||
|
||||
namespace NzbDrone.Api.NetImport
|
||||
{
|
||||
public class NetImportModule : ProviderModuleBase<NetImportResource, INetImport, NetImportDefinition>
|
||||
{
|
||||
public NetImportModule(NetImportFactory indexerFactory)
|
||||
private readonly IProfileService _profileService;
|
||||
public NetImportModule(NetImportFactory indexerFactory, IProfileService profileService)
|
||||
: base(indexerFactory, "netimport")
|
||||
{
|
||||
_profileService = profileService;
|
||||
}
|
||||
|
||||
protected override void MapToResource(NetImportResource resource, NetImportDefinition definition)
|
||||
|
@ -14,6 +18,20 @@ 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")
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override void MapToModel(NetImportDefinition definition, NetImportResource resource)
|
||||
|
|
|
@ -3,7 +3,7 @@ using NzbDrone.Core.Datastore.Migration.Framework;
|
|||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(119)]
|
||||
[Migration(125)]
|
||||
public class create_netimport_table : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,39 +1,39 @@
|
|||
var _ = require('underscore');
|
||||
var AppLayout = require('../../../AppLayout');
|
||||
var Backbone = require('backbone');
|
||||
var SchemaCollection = require('../IndexerCollection');
|
||||
var SchemaCollection = require('../NetImportCollection');
|
||||
var AddCollectionView = require('./IndexerAddCollectionView');
|
||||
|
||||
module.exports = {
|
||||
open : function(collection) {
|
||||
var schemaCollection = new SchemaCollection();
|
||||
var originalUrl = schemaCollection.url;
|
||||
schemaCollection.url = schemaCollection.url + '/schema';
|
||||
schemaCollection.fetch();
|
||||
schemaCollection.url = originalUrl;
|
||||
open : function(collection) {
|
||||
var schemaCollection = new SchemaCollection();
|
||||
var originalUrl = schemaCollection.url;
|
||||
schemaCollection.url = schemaCollection.url + '/schema';
|
||||
schemaCollection.fetch();
|
||||
schemaCollection.url = originalUrl;
|
||||
|
||||
var groupedSchemaCollection = new Backbone.Collection();
|
||||
var groupedSchemaCollection = new Backbone.Collection();
|
||||
|
||||
schemaCollection.on('sync', function() {
|
||||
schemaCollection.on('sync', function() {
|
||||
|
||||
var groups = schemaCollection.groupBy(function(model, iterator) {
|
||||
return model.get('protocol');
|
||||
});
|
||||
var modelCollection = _.map(groups, function(values, key, list) {
|
||||
return {
|
||||
"header" : key,
|
||||
collection : values
|
||||
};
|
||||
});
|
||||
var groups = schemaCollection.groupBy(function(model, iterator) {
|
||||
return model.get('protocol');
|
||||
});
|
||||
var modelCollection = _.map(groups, function(values, key, list) {
|
||||
return {
|
||||
"header" : key,
|
||||
collection : values
|
||||
};
|
||||
});
|
||||
|
||||
groupedSchemaCollection.reset(modelCollection);
|
||||
});
|
||||
groupedSchemaCollection.reset(modelCollection);
|
||||
});
|
||||
|
||||
var view = new AddCollectionView({
|
||||
collection : groupedSchemaCollection,
|
||||
targetCollection : collection
|
||||
});
|
||||
var view = new AddCollectionView({
|
||||
collection : groupedSchemaCollection,
|
||||
targetCollection : collection
|
||||
});
|
||||
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
};
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
var Marionette = require('marionette');
|
||||
var ItemView = require('./IndexerItemView');
|
||||
var SchemaModal = require('./Add/IndexerSchemaModal');
|
||||
|
||||
module.exports = Marionette.CompositeView.extend({
|
||||
itemView : ItemView,
|
||||
itemViewContainer : '.indexer-list',
|
||||
template : 'Settings/Indexers/IndexerCollectionViewTemplate',
|
||||
|
||||
ui : {
|
||||
'addCard' : '.x-add-card'
|
||||
},
|
||||
|
||||
events : {
|
||||
'click .x-add-card' : '_openSchemaModal'
|
||||
},
|
||||
|
||||
appendHtml : function(collectionView, itemView, index) {
|
||||
collectionView.ui.addCard.parent('li').before(itemView.el);
|
||||
},
|
||||
|
||||
_openSchemaModal : function() {
|
||||
SchemaModal.open(this.collection);
|
||||
}
|
||||
});
|
|
@ -1,16 +0,0 @@
|
|||
<fieldset>
|
||||
<legend>Indexers</legend>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<ul class="indexer-list thingies">
|
||||
<li>
|
||||
<div class="indexer-item thingy add-card x-add-card">
|
||||
<span class="center well">
|
||||
<i class="icon-sonarr-add"/>
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
|
@ -1,24 +0,0 @@
|
|||
var AppLayout = require('../../AppLayout');
|
||||
var Marionette = require('marionette');
|
||||
var EditView = require('./Edit/IndexerEditView');
|
||||
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'Settings/Indexers/IndexerItemViewTemplate',
|
||||
tagName : 'li',
|
||||
|
||||
events : {
|
||||
'click' : '_edit'
|
||||
},
|
||||
|
||||
initialize : function() {
|
||||
this.listenTo(this.model, 'sync', this.render);
|
||||
},
|
||||
|
||||
_edit : function() {
|
||||
var view = new EditView({
|
||||
model : this.model,
|
||||
targetCollection : this.model.collection
|
||||
});
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
});
|
|
@ -1,27 +0,0 @@
|
|||
<div class="indexer-item thingy">
|
||||
<div>
|
||||
<h3>{{name}}</h3>
|
||||
</div>
|
||||
|
||||
<div class="settings">
|
||||
{{#if supportsRss}}
|
||||
{{#if enableRss}}
|
||||
<span class="label label-success">RSS</span>
|
||||
{{else}}
|
||||
<span class="label label-default">RSS</span>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
<span class="label label-default label-disabled">RSS</span>
|
||||
{{/if}}
|
||||
|
||||
{{#if supportsSearch}}
|
||||
{{#if enableSearch}}
|
||||
<span class="label label-success">Search</span>
|
||||
{{else}}
|
||||
<span class="label label-default">Search</span>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
<span class="label label-default label-disabled">Search</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
|
@ -1,30 +0,0 @@
|
|||
var Marionette = require('marionette');
|
||||
var IndexerCollection = require('./IndexerCollection');
|
||||
var CollectionView = require('./IndexerCollectionView');
|
||||
var OptionsView = require('./Options/IndexerOptionsView');
|
||||
var RestrictionCollection = require('./Restriction/RestrictionCollection');
|
||||
var RestrictionCollectionView = require('./Restriction/RestrictionCollectionView');
|
||||
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'Settings/Indexers/IndexerLayoutTemplate',
|
||||
|
||||
regions : {
|
||||
indexers : '#x-indexers-region',
|
||||
indexerOptions : '#x-indexer-options-region',
|
||||
restriction : '#x-restriction-region'
|
||||
},
|
||||
|
||||
initialize : function() {
|
||||
this.indexersCollection = new IndexerCollection();
|
||||
this.indexersCollection.fetch();
|
||||
|
||||
this.restrictionCollection = new RestrictionCollection();
|
||||
this.restrictionCollection.fetch();
|
||||
},
|
||||
|
||||
onShow : function() {
|
||||
this.indexers.show(new CollectionView({ collection : this.indexersCollection }));
|
||||
this.indexerOptions.show(new OptionsView({ model : this.model }));
|
||||
this.restriction.show(new RestrictionCollectionView({ collection : this.restrictionCollection }));
|
||||
}
|
||||
});
|
|
@ -1,5 +0,0 @@
|
|||
<div id="x-indexers-region"></div>
|
||||
<div class="form-horizontal">
|
||||
<div id="x-indexer-options-region"></div>
|
||||
<div id="x-restriction-region"></div>
|
||||
</div>
|
16
src/UI/Settings/NetImport/NetImportCollectionView.hbs
Normal file
16
src/UI/Settings/NetImport/NetImportCollectionView.hbs
Normal file
|
@ -0,0 +1,16 @@
|
|||
<fieldset>
|
||||
<legend>Lists</legend>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<ul class="list-list thingies">
|
||||
<li>
|
||||
<div class="list-item thingy add-card x-add-card">
|
||||
<span class="center well">
|
||||
<i class="icon-sonarr-add"/>
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
25
src/UI/Settings/NetImport/NetImportCollectionView.js
Normal file
25
src/UI/Settings/NetImport/NetImportCollectionView.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
var Marionette = require('marionette');
|
||||
var ItemView = require('./NetImportItemView');
|
||||
var SchemaModal = require('./Add/IndexerSchemaModal');
|
||||
|
||||
module.exports = Marionette.CompositeView.extend({
|
||||
itemView : ItemView,
|
||||
itemViewContainer : '.list-list',
|
||||
template : 'Settings/NetImport/NetImportCollectionViewTemplate',
|
||||
|
||||
ui : {
|
||||
'addCard' : '.x-add-card'
|
||||
},
|
||||
|
||||
events : {
|
||||
'click .x-add-card' : '_openSchemaModal'
|
||||
},
|
||||
|
||||
appendHtml : function(collectionView, itemView, index) {
|
||||
collectionView.ui.addCard.parent('li').before(itemView.el);
|
||||
},
|
||||
|
||||
_openSchemaModal : function() {
|
||||
SchemaModal.open(this.collection);
|
||||
}
|
||||
});
|
24
src/UI/Settings/NetImport/NetImportItemView.js
Normal file
24
src/UI/Settings/NetImport/NetImportItemView.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
var AppLayout = require('../../AppLayout');
|
||||
var Marionette = require('marionette');
|
||||
var EditView = require('./Edit/IndexerEditView');
|
||||
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'Settings/NetImport/NetImportItemViewTemplate',
|
||||
tagName : 'li',
|
||||
|
||||
events : {
|
||||
'click' : '_edit'
|
||||
},
|
||||
|
||||
initialize : function() {
|
||||
this.listenTo(this.model, 'sync', this.render);
|
||||
},
|
||||
|
||||
_edit : function() {
|
||||
var view = new EditView({
|
||||
model : this.model,
|
||||
targetCollection : this.model.collection
|
||||
});
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
});
|
8
src/UI/Settings/NetImport/NetImportItemViewTemplate.hbs
Normal file
8
src/UI/Settings/NetImport/NetImportItemViewTemplate.hbs
Normal file
|
@ -0,0 +1,8 @@
|
|||
<div class="list-item thingy">
|
||||
<div>
|
||||
<h3>{{name}}</h3>
|
||||
</div>
|
||||
|
||||
<div class="settings">
|
||||
</div>
|
||||
</div>
|
23
src/UI/Settings/NetImport/NetImportLayout.js
Normal file
23
src/UI/Settings/NetImport/NetImportLayout.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
var Marionette = require('marionette');
|
||||
var NetImportCollection = require('./NetImportCollection');
|
||||
var CollectionView = require('./NetImportCollectionView');
|
||||
var OptionsView = require('./Options/IndexerOptionsView');
|
||||
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'Settings/NetImport/NetImportLayoutTemplate',
|
||||
|
||||
regions : {
|
||||
lists : '#x-lists-region',
|
||||
listOption : '#x-list-options-region',
|
||||
},
|
||||
|
||||
initialize : function() {
|
||||
this.indexersCollection = new NetImportCollection();
|
||||
this.indexersCollection.fetch();
|
||||
},
|
||||
|
||||
onShow : function() {
|
||||
this.lists.show(new CollectionView({ collection : this.indexersCollection }));
|
||||
this.listOption.show(new OptionsView({ model : this.model }));
|
||||
}
|
||||
});
|
4
src/UI/Settings/NetImport/NetImportLayoutTemplate.hbs
Normal file
4
src/UI/Settings/NetImport/NetImportLayoutTemplate.hbs
Normal file
|
@ -0,0 +1,4 @@
|
|||
<div id="x-lists-region"></div>
|
||||
<div class="form-horizontal">
|
||||
<div id="x-list-options-region"></div>
|
||||
</div>
|
|
@ -13,6 +13,8 @@ var IndexerLayout = require('./Indexers/IndexerLayout');
|
|||
var IndexerCollection = require('./Indexers/IndexerCollection');
|
||||
var IndexerSettingsModel = require('./Indexers/IndexerSettingsModel');
|
||||
var NetImportSettingsModel = require("./NetImport/NetImportSettingsModel");
|
||||
var NetImportCollection = require('./NetImport/NetImportCollection');
|
||||
var NetImportLayout = require('./NetImport/NetImportLayout');
|
||||
var DownloadClientLayout = require('./DownloadClient/DownloadClientLayout');
|
||||
var DownloadClientSettingsModel = require('./DownloadClient/DownloadClientSettingsModel');
|
||||
var NotificationCollectionView = require('./Notifications/NotificationCollectionView');
|
||||
|
@ -102,6 +104,7 @@ module.exports = Marionette.Layout.extend({
|
|||
self.quality.show(new QualityLayout());
|
||||
self.indexers.show(new IndexerLayout({ model : self.indexerSettings }));
|
||||
self.downloadClient.show(new DownloadClientLayout({ model : self.downloadClientSettings }));
|
||||
self.netImport.show(new NetImportLayout({model : self.netImportSettings}));
|
||||
self.notifications.show(new NotificationCollectionView({ collection : self.notificationCollection }));
|
||||
self.metadata.show(new MetadataLayout());
|
||||
self.general.show(new GeneralView({ model : self.generalSettings }));
|
||||
|
@ -190,7 +193,7 @@ module.exports = Marionette.Layout.extend({
|
|||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.ui.downloadClientTab.tab('show');
|
||||
this.ui.netImportTab.tab('show');
|
||||
this._navigate('settings/netimport');
|
||||
},
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<div class="tab-pane" id="quality"></div>
|
||||
<div class="tab-pane" id="indexers"></div>
|
||||
<div class="tab-pane" id="download-client"></div>
|
||||
<div class="tab-pane" id="net-import"></div>
|
||||
<div class="tab-pane" id="net-import"></div>
|
||||
<div class="tab-pane" id="notifications"></div>
|
||||
<div class="tab-pane" id="metadata"></div>
|
||||
<div class="tab-pane" id="general"></div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue