Model driven indexer settings

This commit is contained in:
Mark McDowall 2013-04-30 17:01:54 -07:00
commit 9d5cb6f3e0
14 changed files with 576 additions and 17 deletions

View file

@ -0,0 +1,6 @@
define(['app', 'Settings/Indexers/Model'], function () {
NzbDrone.Settings.Indexers.Collection = Backbone.Collection.extend({
url : NzbDrone.Constants.ApiRoot + '/indexer',
model: NzbDrone.Settings.Indexers.Model
});
});

View file

@ -0,0 +1,5 @@
<div class="row">
<div class="span12">
<div id="x-indexers" class="form-horizontal"></div>
</div>
</div>

View file

@ -0,0 +1,10 @@
'use strict';
define(['app', 'Settings/Indexers/ItemView'], function (app) {
NzbDrone.Settings.Indexers.CollectionView = Backbone.Marionette.CompositeView.extend({
itemView : NzbDrone.Settings.Indexers.ItemView,
itemViewContainer : '#x-indexers',
template : 'Settings/Indexers/CollectionTemplate'
});
});

View file

@ -1,3 +0,0 @@
<div>
Indexer settings will go here
</div>

View file

@ -1,11 +0,0 @@
'use strict';
define([
'app', 'Settings/SettingsModel'
], function () {
NzbDrone.Settings.Indexers.IndexersView = Backbone.Marionette.ItemView.extend({
template: 'Settings/Indexers/IndexersTemplate'
});
});

View file

@ -0,0 +1,38 @@
<fieldset>
<legend>{{name}}</legend>
<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>On</span>
<span>Off</span>
</p>
<div class="btn btn-primary slide-button"></div>
</label>
<span class="help-inline-checkbox">
<i class="icon-question-sign" title="Do you want to use {{name}} to download NZBs?"></i>
</span>
</div>
</div>
{{debug}}
{{#each fields}}
<div class="control-group">
<label class="control-label">{{title}}</label>
<div class="controls">
<input type="text" name="fields.{{@index}}.value"/>
<span class="help-inline">
<i class="icon-question-sign" title="{{helpText}}"></i>
</span>
</div>
</div>
{{/each}}
</fieldset>

View file

@ -0,0 +1,38 @@
"use strict";
define([
'app',
'Settings/Indexers/Collection'
], function () {
NzbDrone.Settings.Indexers.ItemView = Backbone.Marionette.ItemView.extend({
template: 'Settings/Indexers/ItemTemplate',
initialize: function () {
this.model.set('fields', [
{ key: 'username', title: 'Username', helpText: 'HALP!', value: 'mark' },
{ key: 'apiKey', title: 'API Key', helpText: 'HALP!', value: 'private' }
]);
NzbDrone.vent.on(NzbDrone.Commands.SaveSettings, this.saveSettings, this);
},
saveSettings: function () {
var test = 1;
//this.model.save(undefined, this.syncNotification("Naming Settings Saved", "Couldn't Save Naming Settings"));
},
syncNotification: function (success, error) {
return {
success: function () {
window.alert(success);
},
error: function () {
window.alert(error);
}
};
}
});
});

View file

@ -0,0 +1,13 @@
"use strict";
define(['app'], function (app) {
NzbDrone.Settings.Indexers.Model = Backbone.DeepModel.extend({
mutators: {
fields: function () {
return [
{ key: 'username', title: 'Username', helpText: 'HALP!', value: 'mark', index: 0 },
{ key: 'apiKey', title: 'API Key', helpText: 'HALP!', value: '', index: 1 }
];
}
}
});
});

View file

@ -3,7 +3,7 @@ define([
'app',
'Settings/Naming/NamingView',
'Settings/Quality/QualityLayout',
'Settings/Indexers/IndexersView',
'Settings/Indexers/CollectionView',
'Settings/DownloadClient/DownloadClientView',
'Settings/Notifications/NotificationsView',
'Settings/System/SystemView',
@ -112,6 +112,9 @@ define([
this.namingSettings = new NzbDrone.Settings.Naming.NamingModel();
this.namingSettings.fetch();
this.indexerSettings = new NzbDrone.Settings.Indexers.Collection();
this.indexerSettings.fetch();
if (options.action) {
this.action = options.action.toLowerCase();
}
@ -120,7 +123,7 @@ define([
onRender: function () {
this.naming.show(new NzbDrone.Settings.Naming.NamingView());
this.quality.show(new NzbDrone.Settings.Quality.QualityLayout({settings: this.settings}));
this.indexers.show(new NzbDrone.Settings.Indexers.IndexersView({model: this.settings}));
this.indexers.show(new NzbDrone.Settings.Indexers.CollectionView({collection: this.indexerSettings}));
this.downloadClient.show(new NzbDrone.Settings.DownloadClient.DownloadClientView({model: this.settings}));
this.notifications.show(new NzbDrone.Settings.Notifications.NotificationsView({model: this.settings}));
this.system.show(new NzbDrone.Settings.System.SystemView({model: this.settings}));