1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00

Metadata settings added to UI

This commit is contained in:
Mark McDowall 2014-02-12 22:44:07 -08:00
parent c0ae876385
commit b339f8daf6
19 changed files with 302 additions and 4 deletions

View File

@ -0,0 +1,18 @@
using NzbDrone.Core.Metadata;
namespace NzbDrone.Api.Metadata
{
public class MetadataModule : ProviderModuleBase<MetadataResource, IMetadata, MetadataDefinition>
{
public MetadataModule(IMetadataFactory metadataFactory)
: base(metadataFactory, "metadata")
{
}
protected override void Validate(MetadataDefinition definition)
{
if (!definition.Enable) return;
base.Validate(definition);
}
}
}

View File

@ -0,0 +1,9 @@
using System;
namespace NzbDrone.Api.Metadata
{
public class MetadataResource : ProviderResource
{
public Boolean Enable { get; set; }
}
}

View File

@ -120,6 +120,8 @@
<Compile Include="Frontend\StaticResourceModule.cs" />
<Compile Include="History\HistoryResource.cs" />
<Compile Include="History\HistoryModule.cs" />
<Compile Include="Metadata\MetadataResource.cs" />
<Compile Include="Metadata\MetadataModule.cs" />
<Compile Include="ProviderResource.cs" />
<Compile Include="ProviderModuleBase.cs" />
<Compile Include="Indexers\IndexerSchemaModule.cs" />

View File

@ -34,7 +34,7 @@ protected override void InitializeProviders()
definitions.Add(new MetadataDefinition
{
Enable = false,
Name = provider.GetType().Name,
Name = provider.GetType().Name.Replace("Metadata", ""),
Implementation = provider.GetType().Name,
Settings = (IProviderConfig)Activator.CreateInstance(provider.ConfigContract)
});

View File

@ -8,16 +8,16 @@
<option es3="false" />
<option forin="true" />
<option immed="true" />
<option latedef="true" />
<option newcap="true" />
<option noarg="true" />
<option noempty="false" />
<option nonew="true" />
<option plusplus="false" />
<option undef="true" />
<option unused="true" />
<option strict="true" />
<option trailing="false" />
<option latedef="true" />
<option unused="true" />
<option quotmark="single" />
<option maxdepth="3" />
<option asi="false" />

View File

@ -0,0 +1,12 @@
'use strict';
define(
[
'backbone',
'Settings/Metadata/MetadataModel'
], function (Backbone, MetadataModel) {
return Backbone.Collection.extend({
model: MetadataModel,
url : window.NzbDrone.ApiRoot + '/metadata'
});
});

View File

@ -0,0 +1,13 @@
'use strict';
define(
[
'AppLayout',
'marionette',
'Settings/Metadata/MetadataItemView'
], function (AppLayout, Marionette, MetadataItemView) {
return Marionette.CompositeView.extend({
itemView : MetadataItemView,
itemViewContainer: '#x-metadata',
template : 'Settings/Metadata/MetadataCollectionViewTemplate'
});
});

View File

@ -0,0 +1,8 @@
<fieldset>
<legend>Metadata</legend>
<div class="row">
<div class="span12">
<ul id="x-metadata" class="metadata-list"></ul>
</div>
</div>
</fieldset>

View File

@ -0,0 +1,44 @@
'use strict';
define(
[
'vent',
'marionette',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
], function (vent, Marionette, AsModelBoundView, AsValidatedView) {
var view = Marionette.ItemView.extend({
template: 'Settings/Metadata/MetadataEditViewTemplate',
ui: {
activity: '.x-activity'
},
events: {
'click .x-save' : '_save'
},
_save: function () {
this.ui.activity.html('<i class="icon-nd-spinner"></i>');
var self = this;
var promise = this.model.save();
if (promise) {
promise.done(function () {
vent.trigger(vent.Commands.CloseModalCommand);
});
promise.fail(function () {
self.ui.activity.empty();
});
}
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
});

View File

@ -0,0 +1,39 @@
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>Edit</h3>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="control-group">
<label class="control-label">Name</label>
<div class="controls">
<input type="text" name="name"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Enable</label>
<div class="controls">
<label class="checkbox toggle well">
<input type="checkbox" name="enable"/>
<p>
<span>Yes</span>
<span>No</span>
</p>
<div class="btn btn-primary slide-button"/>
</label>
</div>
</div>
{{formBuilder}}
</div>
</div>
<div class="modal-footer">
<span class="x-activity"></span>
<button class="btn" data-dismiss="modal">cancel</button>
<button class="btn btn-primary x-save">save</button>
</div>

View File

@ -0,0 +1,30 @@
'use strict';
define(
[
'AppLayout',
'marionette',
'Settings/Metadata/MetadataEditView',
'Mixins/AsModelBoundView'
], function (AppLayout, Marionette, EditView, AsModelBoundView) {
var view = Marionette.ItemView.extend({
template: 'Settings/Metadata/MetadataItemViewTemplate',
tagName : 'li',
events: {
'click .x-edit' : '_edit'
},
initialize: function () {
this.listenTo(this.model, 'sync', this.render);
},
_edit: function () {
var view = new EditView({ model: this.model});
AppLayout.modalRegion.show(view);
}
});
return AsModelBoundView.call(view);
});

View File

@ -0,0 +1,26 @@
<div class="metadata-item">
<div>
<h3>{{name}}</h3>
<span class="btn-group pull-right">
<button class="btn btn-mini btn-icon-only x-edit"><i class="icon-nd-edit"/></button>
</span>
</div>
<div class="settings">
{{#if enable}}
<span class="label label-success">Enabled</span>
{{else}}
<span class="label">Not Enabled</span>
{{/if}}
<hr>
{{#each fields}}
{{#if_eq type compare="checkbox"}}
{{#if value}}
<span class="label label-success">{{label}}</span>
{{else}}
<span class="label">{{label}}</span>
{{/if}}
{{/if_eq}}
{{/each}}
</div>
</div>

View File

@ -0,0 +1,27 @@
'use strict';
define(
[
'marionette',
'Settings/Metadata/MetadataCollection',
'Settings/Metadata/MetadataCollectionView'
], function (Marionette, MetadataCollection, MetadataCollectionView) {
return Marionette.Layout.extend({
template: 'Settings/Metadata/MetadataLayoutTemplate',
regions: {
metadata : '#x-metadata-providers'
},
initialize: function (options) {
this.settings = options.settings;
this.metadataCollection = new MetadataCollection();
this.metadataCollection.fetch();
},
onShow: function () {
this.metadata.show(new MetadataCollectionView({collection: this.metadataCollection}));
}
});
});

View File

@ -0,0 +1,3 @@
<div class="row">
<div class="span12" id="x-metadata-providers"/>
</div>

View File

@ -0,0 +1,10 @@
'use strict';
define(
[
'backbone.deepmodel'
], function (DeepModel) {
return DeepModel.DeepModel.extend({
});
});

View File

@ -0,0 +1,36 @@
@import "../../Shared/Styles/card";
.metadata-list {
li {
display: inline-block;
vertical-align: top;
}
}
.metadata-item {
.card;
width: 200px;
height: 230px;
padding: 10px 15px;
h3 {
margin-top: 0px;
display: inline-block;
width: 150px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.btn-group {
margin-top: 8px;
}
.label {
margin-top : 3px;
display : block;
text-align : center;
}
}

View File

@ -15,6 +15,7 @@ define(
'Settings/DownloadClient/Layout',
'Settings/Notifications/CollectionView',
'Settings/Notifications/Collection',
'Settings/Metadata/MetadataLayout',
'Settings/General/GeneralView',
'Shared/LoadingView',
'Config'
@ -32,6 +33,7 @@ define(
DownloadClientLayout,
NotificationCollectionView,
NotificationCollection,
MetadataLayout,
GeneralView,
LoadingView,
Config) {
@ -44,6 +46,7 @@ define(
indexers : '#indexers',
downloadClient : '#download-client',
notifications : '#notifications',
metadata : '#metadata',
general : '#general',
loading : '#loading-region'
},
@ -54,8 +57,9 @@ define(
indexersTab : '.x-indexers-tab',
downloadClientTab : '.x-download-client-tab',
notificationsTab : '.x-notifications-tab',
metadataTab : '.x-metadata-tab',
generalTab : '.x-general-tab',
advancedSettings : '.x-advanced-settings'
advancedSettings : '.x-advanced-settings'
},
events: {
@ -64,6 +68,7 @@ define(
'click .x-indexers-tab' : '_showIndexers',
'click .x-download-client-tab' : '_showDownloadClient',
'click .x-notifications-tab' : '_showNotifications',
'click .x-metadata-tab' : '_showMetadata',
'click .x-general-tab' : '_showGeneral',
'click .x-save-settings' : '_save',
'change .x-advanced-settings' : '_toggleAdvancedSettings'
@ -99,6 +104,7 @@ define(
self.indexers.show(new IndexerLayout({ settings: self.settings, indexersCollection: self.indexerSettings }));
self.downloadClient.show(new DownloadClientLayout({ model: self.settings }));
self.notifications.show(new NotificationCollectionView({ collection: self.notificationSettings }));
self.metadata.show(new MetadataLayout());
self.general.show(new GeneralView({ model: self.generalSettings }));
}
});
@ -123,6 +129,9 @@ define(
case 'notifications':
this._showNotifications();
break;
case 'metadata':
this._showMetadata();
break;
case 'general':
this._showGeneral();
break;
@ -176,6 +185,15 @@ define(
this._navigate('settings/connect');
},
_showMetadata: function (e) {
if (e) {
e.preventDefault();
}
this.ui.metadataTab.tab('show');
this._navigate('settings/metadata');
},
_showGeneral: function (e) {
if (e) {
e.preventDefault();

View File

@ -4,6 +4,7 @@
<li><a href="#indexers" class="x-indexers-tab no-router">Indexers</a></li>
<li><a href="#download-client" class="x-download-client-tab no-router">Download Client</a></li>
<li><a href="#notifications" class="x-notifications-tab no-router">Connect</a></li>
<li><a href="#metadata" class="x-metadata-tab no-router">Metadata</a></li>
<li><a href="#general" class="x-general-tab no-router">General</a></li>
<li class="pull-right"><button class="btn btn-primary x-save-settings">Save</button></li>
<li class="pull-right advanced-settings-toggle">
@ -27,6 +28,7 @@
<div class="tab-pane" id="indexers"></div>
<div class="tab-pane" id="download-client"></div>
<div class="tab-pane" id="notifications"></div>
<div class="tab-pane" id="metadata"></div>
<div class="tab-pane" id="general"></div>
</div>

View File

@ -3,6 +3,7 @@
@import "Indexers/indexers";
@import "Quality/quality";
@import "Notifications/notifications";
@import "Metadata/metadata";
li.save-and-add {
.clickable;