Settings wired up

pull/3113/head
Mark McDowall 12 years ago
parent 9a738e3a65
commit 50f6ec4fc6

@ -1,4 +1,6 @@
using System.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using Nancy;
using NzbDrone.Api.Extensions;
using NzbDrone.Core.Configuration;
@ -18,8 +20,12 @@ namespace NzbDrone.Api.Settings
private Response GetAllSettings()
{
var settings = _configService.All();
return settings.AsResponse();
var collection = Request.Query.Collection;
if(collection.HasValue && Boolean.Parse(collection.Value))
return _configService.All().AsResponse();
return _configService.All().ToDictionary(c => c.Key, c => c.Value).AsResponse();
}
}
}

@ -3,6 +3,7 @@
'Calendar/CalendarCollectionView', 'Shared/NotificationView',
'Shared/NotFoundView', 'MainMenuView', 'HeaderView',
'Series/Details/SeriesDetailsView', 'Series/EpisodeCollection'],
'Settings/SettingsLayout'],
function (app, modalRegion) {
var controller = Backbone.Marionette.Controller.extend({
@ -42,6 +43,17 @@
});
},
settings: function(action, query) {
this.setTitle('Settings');
var settingsModel = new NzbDrone.Settings.SettingsModel();
settingsModel.fetch({
success: function(settings){
NzbDrone.mainRegion.show(new NzbDrone.Settings.SettingsLayout(this, action, query, settings));
}
});
},
notFound: function () {
this.setTitle('Not Found');
NzbDrone.mainRegion.show(new NzbDrone.Shared.NotFoundView(this));

@ -147,7 +147,7 @@
<Content Include="Shared\ModalRegion.js" />
<Content Include="Shared\NotificationCollection.js" />
<Content Include="Shared\NotificationModel.js" />
<Content Include="Shared\NotificationView.js" />
<Content Include="Shared\NotificationsView.js" />
<Content Include="Shared\SpinnerTemplate.html" />
<Content Include="Shared\SpinnerView.js" />
<Content Include="Upcoming\UpcomingCollection.js" />

@ -13,6 +13,8 @@
'upcoming': 'upcoming',
'upcoming/index': 'upcoming',
'calendar': 'calendar',
'settings': 'settings',
'settings/:action(/:query)': 'settings',
':whatever': 'notFound'
}
});

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

@ -0,0 +1,29 @@
'use strict';
define([
'app', 'Settings/SettingsModel'
], function () {
NzbDrone.Settings.DownloadClient.DownloadClientView = Backbone.Marionette.ItemView.extend({
template: 'Settings/DownloadClient/DownloadClientTemplate',
events: {
'click .x-save': 'save'
},
initialize: function (options) {
this.model = options.model;
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
save: function () {
//Todo: Actually save the model
alert('Save pressed!');
}
});
});

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

@ -0,0 +1,29 @@
'use strict';
define([
'app', 'Settings/SettingsModel'
], function () {
NzbDrone.Settings.Indexers.IndexersView = Backbone.Marionette.ItemView.extend({
template: 'Settings/Indexers/IndexersTemplate',
events: {
'click .x-save': 'save'
},
initialize: function (options) {
this.model = options.model;
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
save: function () {
//Todo: Actually save the model
alert('Save pressed!');
}
});
});

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

@ -0,0 +1,29 @@
'use strict';
define([
'app', 'Settings/SettingsModel'
], function () {
NzbDrone.Settings.Misc.MiscView = Backbone.Marionette.ItemView.extend({
template: 'Settings/Misc/MiscTemplate',
events: {
'click .x-save': 'save'
},
initialize: function (options) {
this.model = options.model;
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
save: function () {
//Todo: Actually save the model
alert('Save pressed!');
}
});
});

@ -0,0 +1,4 @@
<div>
Naming settings will go here
{{uGuid}}
</div>

@ -0,0 +1,30 @@
'use strict';
define([
'app', 'Settings/SettingsModel'
], function () {
NzbDrone.Settings.Naming.NamingView = Backbone.Marionette.ItemView.extend({
template: 'Settings/Naming/NamingTemplate',
events: {
'click .x-save': 'save'
},
initialize: function (options) {
this.model = options.model;
var test = 1;
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
save: function () {
//Todo: Actually save the model
alert('Save pressed!');
}
});
});

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

@ -0,0 +1,29 @@
'use strict';
define([
'app', 'Settings/SettingsModel'
], function () {
NzbDrone.Settings.Notifications.NotificationsView = Backbone.Marionette.ItemView.extend({
template: 'Settings/Notifications/NotificationsTemplate',
events: {
'click .x-save': 'save'
},
initialize: function (options) {
this.model = options.model;
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
save: function () {
//Todo: Actually save the model
alert('Save pressed!');
}
});
});

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

@ -0,0 +1,29 @@
'use strict';
define([
'app', 'Settings/SettingsModel'
], function () {
NzbDrone.Settings.Quality.QualityView = Backbone.Marionette.ItemView.extend({
template: 'Settings/Quality/QualityTemplate',
events: {
'click .x-save': 'save'
},
initialize: function (options) {
this.model = options.model;
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
save: function () {
//Todo: Actually save the model
alert('Save pressed!');
}
});
});

@ -0,0 +1,159 @@
define([
'app',
'Quality/QualityProfileCollection',
'Settings/Naming/NamingView',
'Settings/Quality/QualityView',
'Settings/Indexers/IndexersView',
'Settings/DownloadClient/DownloadClientView',
'Settings/Notifications/NotificationsView',
'Settings/System/SystemView',
'Settings/Misc/MiscView'
],
function (app, qualityProfileCollection) {
NzbDrone.Settings.SettingsLayout = Backbone.Marionette.Layout.extend({
template: 'Settings/SettingsLayoutTemplate',
regions: {
naming: '#naming',
quality: '#quality',
indexers: '#indexers',
downloadClient: '#download-client',
notifications: '#notifications',
system: '#system',
misc: '#misc'
},
ui: {
namingTab: '.x-naming-tab',
qualityTab: '.x-quality-tab',
indexersTab: '.x-indexers-tab',
downloadClientTab: '.x-download-client-tab',
notificationsTab: '.x-notifications-tab',
systemTab: '.x-system-tab',
miscTab: '.x-misc-tab'
},
events: {
'click .x-naming-tab': 'showNaming',
'click .x-quality-tab': 'showQuality',
'click .x-indexers-tab': 'showIndexers',
'click .x-download-client-tab': 'showDownloadClient',
'click .x-notifications-tab': 'showNotifications',
'click .x-system-tab': 'showSystem',
'click .x-misc-tab': 'showMisc'
},
showNaming: function (e) {
if (e) {
e.preventDefault();
}
this.ui.namingTab.tab('show');
NzbDrone.Router.navigate('settings/naming');
},
showQuality: function (e) {
if (e) {
e.preventDefault();
}
this.ui.qualityTab.tab('show');
NzbDrone.Router.navigate('settings/quality');
},
showIndexers: function (e) {
if (e) {
e.preventDefault();
}
this.ui.indexersTab.tab('show');
NzbDrone.Router.navigate('settings/indexers');
},
showDownloadClient: function (e) {
if (e) {
e.preventDefault();
}
this.ui.downloadClientTab.tab('show');
NzbDrone.Router.navigate('settings/downloadclient');
},
showNotifications: function (e) {
if (e) {
e.preventDefault();
}
this.ui.notificationsTab.tab('show');
NzbDrone.Router.navigate('settings/notifications');
},
showSystem: function (e) {
if (e) {
e.preventDefault();
}
this.ui.systemTab.tab('show');
NzbDrone.Router.navigate('settings/system');
},
showMisc: function (e) {
if (e) {
e.preventDefault();
}
this.ui.miscTab.tab('show');
NzbDrone.Router.navigate('settings/misc');
},
initialize: function (context, action, query, settings) {
this.settings = settings;
if (action) {
this.action = action.toLowerCase();
}
if (query) {
this.query = query.toLowerCase();
}
},
onRender: function () {
qualityProfileCollection.fetch();
this.naming.show(new NzbDrone.Settings.Naming.NamingView({model: this.settings}));
this.quality.show(new NzbDrone.Settings.Quality.QualityView({model: this.settings}));
this.indexers.show(new NzbDrone.Settings.Indexers.IndexersView({model: this.settings}));
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}));
this.misc.show(new NzbDrone.Settings.Misc.MiscView({model: this.settings}));
},
onShow: function () {
switch (this.action) {
case 'quality':
this.showQuality();
break;
case 'indexers':
this.showIndexers();
break;
case 'downloadclient':
this.showDownloadClient();
break;
case 'notifications':
this.showNotifications();
break;
case 'system':
this.showSystem();
break;
case 'misc':
this.showMisc();
break;
default:
this.showNaming();
}
}
});
});

@ -0,0 +1,19 @@
<ul class="nav nav-tabs" id="myTab">
<li><a href="#naming" class="x-naming-tab">Naming</a></li>
<li><a href="#quality" class="x-quality-tab">Quality</a></li>
<li><a href="#indexers" class ="x-indexers-tab">Indexers</a></li>
<li><a href="#download-client" class ="x-download-client-tab">Download Client</a></li>
<li><a href="#notifications" class ="x-notifications-tab">Notifications</a></li>
<li><a href="#system" class ="x-system-tab">System</a></li>
<li><a href="#misc" class ="x-misc-tab">Misc</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane" id="naming">Naming Settings</div>
<div class="tab-pane" id="quality">Quality Settings</div>
<div class="tab-pane" id="indexers">Indexer Settings</div>
<div class="tab-pane" id="download-client">Download Client Settings</div>
<div class="tab-pane" id="notifications">Notification Settings</div>
<div class="tab-pane" id="system">System Settings</div>
<div class="tab-pane" id="misc">Misc Settings</div>
</div>

@ -0,0 +1,5 @@
define(['app'], function (app) {
NzbDrone.Settings.SettingsModel = Backbone.Model.extend({
url: NzbDrone.Constants.ApiRoot + '/settings'
});
});

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

@ -0,0 +1,29 @@
'use strict';
define([
'app', 'Settings/SettingsModel'
], function () {
NzbDrone.Settings.System.SystemView = Backbone.Marionette.ItemView.extend({
template: 'Settings/System/SystemTemplate',
events: {
'click .x-save': 'save'
},
initialize: function (options) {
this.model = options.model;
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
save: function () {
//Todo: Actually save the model
alert('Save pressed!');
}
});
});

@ -28,55 +28,63 @@
define('app', function () {
window.NzbDrone = new Backbone.Marionette.Application();
window.NzbDrone.Series = {};
window.NzbDrone = new Backbone.Marionette.Application();
window.NzbDrone.Series = {};
window.NzbDrone.Series.Index = {};
window.NzbDrone.Series.Edit = {};
window.NzbDrone.Series.Delete = {};
window.NzbDrone.Series.Details = {};
window.NzbDrone.AddSeries = {};
window.NzbDrone.AddSeries.New = {};
window.NzbDrone.AddSeries.Existing = {};
window.NzbDrone.AddSeries.RootFolders = {};
window.NzbDrone.Quality = {};
window.NzbDrone.Shared = {};
window.NzbDrone.Upcoming = {};
window.NzbDrone.Calendar = {};
window.NzbDrone.Events = {
OpenModalDialog :'openModal',
CloseModalDialog : 'closeModal'
},
window.NzbDrone.Series.Edit = {};
window.NzbDrone.Series.Delete = {};
window.NzbDrone.Series.Details = {};
window.NzbDrone.AddSeries = {};
window.NzbDrone.AddSeries.New = {};
window.NzbDrone.AddSeries.Existing = {};
window.NzbDrone.AddSeries.RootFolders = {};
window.NzbDrone.Quality = {};
window.NzbDrone.Shared = {};
window.NzbDrone.Upcoming = {};
window.NzbDrone.Calendar = {};
window.NzbDrone.Settings = {};
window.NzbDrone.Settings.Naming = {};
window.NzbDrone.Settings.Quality = {};
window.NzbDrone.Settings.Indexers = {};
window.NzbDrone.Settings.DownloadClient = {};
window.NzbDrone.Settings.Notifications = {};
window.NzbDrone.Settings.System = {};
window.NzbDrone.Settings.Misc = {};
window.NzbDrone.Events = {
OpenModalDialog :'openModal',
CloseModalDialog : 'closeModal'
},
window.NzbDrone.Constants = {
ApiRoot: '/api'
};
window.NzbDrone.Constants = {
ApiRoot: '/api'
};
window.NzbDrone.addInitializer(function () {
window.NzbDrone.addInitializer(function () {
console.log('starting application');
console.log('starting application');
NzbDrone.ModelBinder = new Backbone.ModelBinder();
NzbDrone.ModelBinder = new Backbone.ModelBinder();
//TODO: move this out of here
Handlebars.registerHelper("formatStatus", function (status, monitored) {
if (!monitored) return '<i class="icon-pause grid-icon" title="Not Monitored"></i>';
if (status === 'Continuing') return '<i class="icon-play grid-icon" title="Continuing"></i>';
//TODO: move this out of here
Handlebars.registerHelper("formatStatus", function (status, monitored) {
if (!monitored) return '<i class="icon-pause grid-icon" title="Not Monitored"></i>';
if (status === 'Continuing') return '<i class="icon-play grid-icon" title="Continuing"></i>';
return '<i class="icon-stop grid-icon" title="Ended"></i>';
});
return '<i class="icon-stop grid-icon" title="Ended"></i>';
});
NzbDrone.addRegions({
titleRegion: '#title-region',
mainRegion: '#main-region',
notificationRegion: '#notification-region',
});
NzbDrone.addRegions({
titleRegion: '#title-region',
mainRegion: '#main-region',
notificationRegion: '#notification-region',
});
});
window.NzbDrone.start();
window.NzbDrone.start();
return NzbDrone;
});
return NzbDrone;
});

@ -76,6 +76,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("S02E10 6-50 to SLC [SDTV]", "", 2, 10)]
[TestCase("Franklin & Bash S02E10 6-50 to SLC [SDTV]", "Franklin & Bash", 2, 10)]
[TestCase("The_Big_Bang_Theory_-_6x12_-_The_Egg_Salad_Equivalency_[HDTV-720p]", "The Big Bang Theory", 6, 12)]
[TestCase("Top_Gear.19x06.720p_HDTV_x264-FoV", "Top Gear", 19, 6)]
public void ParseTitle_single(string postTitle, string title, int seasonNumber, int episodeNumber)
{
var result = Parser.ParseTitle(postTitle);

Loading…
Cancel
Save