Settings loading overhaul

Download client moved to a layout
Settings are only shown after all settings are loaded
This commit is contained in:
Mark McDowall 2013-07-01 23:46:38 -07:00
parent 29ed3293d1
commit b21e49f5fa
16 changed files with 443 additions and 372 deletions

View File

@ -167,15 +167,15 @@ namespace NzbDrone.Core.Configuration
public DownloadClientType DownloadClient
{
get { return GetValueEnum("DownloadClientType", DownloadClientType.Sabnzbd); }
get { return GetValueEnum("DownloadClient", DownloadClientType.Sabnzbd); }
set { SetValue("DownloadClient", value); }
}
public string BlackholeFolder
{
get { return GetValue("BlackholeDirectory", String.Empty); }
set { SetValue("BlackholeDirectory", value); }
get { return GetValue("BlackholeFolder", String.Empty); }
set { SetValue("BlackholeFolder", value); }
}
public string ServiceRootUrl
@ -192,8 +192,8 @@ namespace NzbDrone.Core.Configuration
public string PneumaticFolder
{
get { return GetValue("PneumaticDirectory", String.Empty); }
set { SetValue("PneumaticDirectory", value); }
get { return GetValue("PneumaticFolder", String.Empty); }
set { SetValue("PneumaticFolder", value); }
}
public string RecycleBin
@ -204,7 +204,7 @@ namespace NzbDrone.Core.Configuration
public int RssSyncInterval
{
get { return GetValueInt("RssSyncInterval", 25); }
get { return GetValueInt("RssSyncInterval", 15); }
set { SetValue("RssSyncInterval", value); }
}

View File

@ -78,6 +78,7 @@ namespace NzbDrone.Core.MediaFiles
string path = series.Path;
if (series.SeasonFolder)
{
//TODO: Allow series name
var seasonFolder = _configService.SortingSeasonFolderFormat
.Replace("%0s", seasonNumber.ToString("00"))
.Replace("%s", seasonNumber.ToString());

View File

@ -0,0 +1,15 @@
'use strict';
define(
[
'marionette',
'Mixins/AsModelBoundView',
'bootstrap'
], function (Marionette, AsModelBoundView) {
var view = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/BlackholeViewTemplate'
});
return AsModelBoundView.call(view);
});

View File

@ -0,0 +1,13 @@
<fieldset>
<legend>Blackhole</legend>
<div class="control-group">
<label class="control-label">Blackhole Folder</label>
<div class="controls">
<input type="text" name="blackholeFolder" class="x-path"/>
<span class="help-inline">
<i class="icon-question-sign" title="The folder where your download client will pickup .nzb files"/>
</span>
</div>
</div>
</fieldset>

View File

@ -1,258 +0,0 @@
<fieldset>
<legend>General</legend>
<div class="control-group">
<label class="control-label">Download Client</label>
<div class="controls">
<select class="inputClass x-download-client" name="downloadClient">
<option value="sabnzbd">SABnzbd</option>
<option value="blackhole">Blackhole</option>
<option value="pneumatic">Pneumatic</option>
<option value="nzbget">NZBGet</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label">Drone Factory</label>
<div class="controls">
<input type="text" name="downloadedEpisodesFolder" class="x-path"/>
<span class="help-inline">
<i class="icon-question-sign" title="The folder where your download client downloads TV shows to (aka TV Download Dir)"/>
<i class="icon-exclamation-sign danger" title="Do not use the folder that contains some or all of your sorted and named TV shows - doing so could cause data loss"></i>
</span>
</div>
</div>
</fieldset>
<fieldset class="x-sab-config">
<legend>SABnzbd</legend>
{{!<div class="control-group">
<label class="control-label">Auto-Configure</label>
<div class="controls">
<input type="button" value="Auto-Configure" class="btn btn-inverse"/>
<span class="help-inline">
<i class="icon-question-sign"
title="(Windows only) If access to SABnzbd doesn't require a username & password and it is on the same system as NzbDrone, you can auto-configure it"/>
</span>
</div>
</div>}}
<div class="control-group">
<label class="control-label">Host</label>
<div class="controls">
<input type="text" name="sabHost"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Port</label>
<div class="controls">
<input type="text" name="sabPort"/>
</div>
</div>
<div class="control-group">
<label class="control-label">API Key</label>
<div class="controls">
<input type="text" name="sabApiKey"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Username</label>
<div class="controls">
<input type="text" name="sabUsername"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Password</label>
<div class="controls">
<input type="password" name="sabPassword"/>
</div>
</div>
<div class="control-group">
<label class="control-label">TV Category</label>
<div class="controls">
<input type="text" name="sabTvCategory" placeholder="This is not the dropdownlist you're looking for"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Backlog Priority</label>
<div class="controls">
<select name="sabBacklogTvPriority">
<option value="default">Default</option>
<option value="paused">Paused</option>
<option value="low">Low</option>
<option value="normal">Normal</option>
<option value="high">High</option>
<option value="force">Force</option>
</select>
<span class="help-inline">
<i class="icon-question-sign" title="Priority to use when sending episodes older than 7 days to SABnzbd"/>
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Recent Priority</label>
<div class="controls">
<select name="sabRecentTvPriority">
<option value="default">Default</option>
<option value="paused">Paused</option>
<option value="low">Low</option>
<option value="normal">Normal</option>
<option value="high">High</option>
<option value="force">Force</option>
</select>
<span class="help-inline">
<i class="icon-question-sign" title="Priority to use when sending episodes that aired within the last 7 days to SABnzbd"/>
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Test</label>
<div class="controls">
<input type="button" value="Test" class="btn btn-inverse"/>
</div>
</div>
</fieldset>
<fieldset class="x-blackhole-config">
<legend>Blackhole</legend>
<div class="control-group">
<label class="control-label">Blackhole Folder</label>
<div class="controls">
<input type="text" name="blackholeFolder" class="x-path"/>
<span class="help-inline">
<i class="icon-question-sign" title="The folder where your download client will pickup .nzb files"/>
</span>
</div>
</div>
</fieldset>
<fieldset class="x-pneumatic-config">
<legend>Pneumatic</legend>
<div class="control-group">
<label class="control-label">Nzb Folder</label>
<div class="controls">
<input type="text" name="pneumaticFolder" class="x-path"/>
<span class="help-inline">
<i class="icon-question-sign" title="Folder to save NZBs for Pneumatic<br/>must be accessible from XBMC"></i>
</span>
</div>
</div>
</fieldset>
<fieldset class="x-nzbget-config">
<legend>NZBGet</legend>
<div class="control-group">
<label class="control-label">Host</label>
<div class="controls">
<input type="text" name="nzbgetHost"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Port</label>
<div class="controls">
<input type="text" name="nzbgetPort"/>
</div>
</div>
<div class="control-group">
<label class="control-label">API Key</label>
<div class="controls">
<input type="text" name="nzbgetApiKey"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Username</label>
<div class="controls">
<input type="text" name="nzbgetUsername"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Password</label>
<div class="controls">
<input type="password" name="nzbgetPassword"/>
</div>
</div>
<div class="control-group">
<label class="control-label">TV Category</label>
<div class="controls">
<input type="text" name="nzbgetTvCategory"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Backlog Priority</label>
<div class="controls">
<select name="nzbgetBacklogTvPriority">
<option value="default">Default</option>
<option value="pasued">Paused</option>
<option value="low">Low</option>
<option value="normal">Normal</option>
<option value="high">High</option>
<option value="force">Force</option>
</select>
<span class="help-inline">
<i class="icon-question-sign" title="Priority to use when sending episodes older than 7 days to NZBGet"/>
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Recent Priority</label>
<div class="controls">
<select name="nzbgetRecentTvPriority">
<option value="default">Default</option>
<option value="pasued">Paused</option>
<option value="low">Low</option>
<option value="normal">Normal</option>
<option value="high">High</option>
<option value="force">Force</option>
</select>
<span class="help-inline">
<i class="icon-question-sign" title="Priority to use when sending episodes that aired within the last 7 days to NZBGet"/>
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Test</label>
<div class="controls">
<input type="button" value="Test" class="btn btn-inverse"/>
</div>
</div>
</fieldset>

View File

@ -1,81 +0,0 @@
'use strict';
define(
[
'marionette',
'Mixins/AsModelBoundView',
'bootstrap'
], function (Marionette, AsModelBoundView) {
var view = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/DownloadClientTemplate',
className: 'form-horizontal',
ui: {
bsSwitch : '.switch',
tooltip : '.help-inline i',
pathInput : '.x-path',
sabConfig : '.x-sab-config',
blackholeConfig : '.x-blackhole-config',
pneumaticConfig : '.x-pneumatic-config',
nzbGetConfig : '.x-nzbget-config',
downloadClientSelect: '.x-download-client'
},
events: {
'change .x-download-client': 'downloadClientChanged'
},
onRender: function () {
this.ui.pathInput.autoComplete('/directories');
this.refreshUIVisibility(this.model.get('downloadClient'));
},
downloadClientChanged: function () {
var clientId = this.ui.downloadClientSelect.val();
this.refreshUIVisibility(clientId);
},
refreshUIVisibility: function (clientId) {
if (!clientId) {
clientId = 'sabnzbd';
}
switch (clientId.toString()) {
case 'sabnzbd':
this.ui.sabConfig.show();
this.ui.blackholeConfig.hide();
this.ui.pneumaticConfig.hide();
this.ui.nzbGetConfig.hide();
break;
case 'blackhole':
this.ui.sabConfig.hide();
this.ui.blackholeConfig.show();
this.ui.pneumaticConfig.hide();
this.ui.nzbGetConfig.hide();
break;
case 'pneumatic':
this.ui.sabConfig.hide();
this.ui.blackholeConfig.hide();
this.ui.pneumaticConfig.show();
this.ui.nzbGetConfig.hide();
break;
case 'nzbget':
this.ui.sabConfig.hide();
this.ui.blackholeConfig.hide();
this.ui.pneumaticConfig.hide();
this.ui.nzbGetConfig.show();
break;
default :
throw 'unknown download client id' + clientId;
}
}
});
return AsModelBoundView.call(view);
});

View File

@ -0,0 +1,74 @@
'use strict';
define(
[
'marionette',
'Settings/DownloadClient/SabView',
'Settings/DownloadClient/BlackholeView',
'Settings/DownloadClient/PneumaticView',
'Settings/DownloadClient/NzbgetView',
'Mixins/AsModelBoundView',
'bootstrap'
], function (Marionette, SabView, BlackholeView, PneumaticView, NzbgetView, AsModelBoundView) {
var view = Marionette.Layout.extend({
template : 'Settings/DownloadClient/LayoutTemplate',
regions: {
downloadClient: '#download-client-settings-region'
},
ui: {
downloadClientSelect: '.x-download-client'
},
events: {
'change .x-download-client': 'downloadClientChanged'
},
onShow: function () {
this.sabView = new SabView({ model: this.model});
this.blackholeView = new BlackholeView({ model: this.model});
this.pneumaticView = new PneumaticView({ model: this.model});
this.nzbgetView = new NzbgetView({ model: this.model});
var client = this.model.get('downloadClient');
this.refreshUIVisibility(client);
},
downloadClientChanged: function () {
var clientId = this.ui.downloadClientSelect.val();
this.refreshUIVisibility(clientId);
},
refreshUIVisibility: function (clientId) {
if (!clientId) {
clientId = 'sabnzbd';
}
switch (clientId.toString()) {
case 'sabnzbd':
this.downloadClient.show(this.sabView);
break;
case 'blackhole':
this.downloadClient.show(this.blackholeView);
break;
case 'pneumatic':
this.downloadClient.show(this.pneumaticView);
break;
case 'nzbget':
this.downloadClient.show(this.nzbgetView);
break;
default :
throw 'unknown download client id' + clientId;
}
}
});
return AsModelBoundView.call(view);
});

View File

@ -0,0 +1,29 @@
<fieldset class="form-horizontal">
<legend>General</legend>
<div class="control-group">
<label class="control-label">Download Client</label>
<div class="controls">
<select class="inputClass x-download-client" name="downloadClient">
<option value="sabnzbd">SABnzbd</option>
<option value="blackhole">Blackhole</option>
<option value="pneumatic">Pneumatic</option>
<option value="nzbget">NZBGet</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label">Drone Factory</label>
<div class="controls">
<input type="text" name="downloadedEpisodesFolder" class="x-path"/>
<span class="help-inline">
<i class="icon-question-sign" title="The folder where your download client downloads TV shows to (aka TV Download Dir)"/>
<i class="icon-exclamation-sign danger" title="Do not use the folder that contains some or all of your sorted and named TV shows - doing so could cause data loss"></i>
</span>
</div>
</div>
</fieldset>
<div id="download-client-settings-region" class="form-horizontal"></div>

View File

@ -0,0 +1,15 @@
'use strict';
define(
[
'marionette',
'Mixins/AsModelBoundView',
'bootstrap'
], function (Marionette, AsModelBoundView) {
var view = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/NzbgetViewTemplate'
});
return AsModelBoundView.call(view);
});

View File

@ -0,0 +1,94 @@
<fieldset>
<legend>NZBGet</legend>
<div class="control-group">
<label class="control-label">Host</label>
<div class="controls">
<input type="text" name="nzbgetHost"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Port</label>
<div class="controls">
<input type="text" name="nzbgetPort"/>
</div>
</div>
<div class="control-group">
<label class="control-label">API Key</label>
<div class="controls">
<input type="text" name="nzbgetApiKey"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Username</label>
<div class="controls">
<input type="text" name="nzbgetUsername"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Password</label>
<div class="controls">
<input type="password" name="nzbgetPassword"/>
</div>
</div>
<div class="control-group">
<label class="control-label">TV Category</label>
<div class="controls">
<input type="text" name="nzbgetTvCategory"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Backlog Priority</label>
<div class="controls">
<select name="nzbgetBacklogTvPriority">
<option value="default">Default</option>
<option value="pasued">Paused</option>
<option value="low">Low</option>
<option value="normal">Normal</option>
<option value="high">High</option>
<option value="force">Force</option>
</select>
<span class="help-inline">
<i class="icon-question-sign" title="Priority to use when sending episodes older than 7 days to NZBGet"/>
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Recent Priority</label>
<div class="controls">
<select name="nzbgetRecentTvPriority">
<option value="default">Default</option>
<option value="pasued">Paused</option>
<option value="low">Low</option>
<option value="normal">Normal</option>
<option value="high">High</option>
<option value="force">Force</option>
</select>
<span class="help-inline">
<i class="icon-question-sign" title="Priority to use when sending episodes that aired within the last 7 days to NZBGet"/>
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Test</label>
<div class="controls">
<input type="button" value="Test" class="btn btn-inverse"/>
</div>
</div>
</fieldset>

View File

@ -0,0 +1,15 @@
'use strict';
define(
[
'marionette',
'Mixins/AsModelBoundView',
'bootstrap'
], function (Marionette, AsModelBoundView) {
var view = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/PneumaticViewTemplate'
});
return AsModelBoundView.call(view);
});

View File

@ -0,0 +1,13 @@
<fieldset>
<legend>Pneumatic</legend>
<div class="control-group">
<label class="control-label">Nzb Folder</label>
<div class="controls">
<input type="text" name="pneumaticFolder" class="x-path"/>
<span class="help-inline">
<i class="icon-question-sign" title="Folder to save NZBs for Pneumatic<br/>must be accessible from XBMC"></i>
</span>
</div>
</div>
</fieldset>

View File

@ -0,0 +1,15 @@
'use strict';
define(
[
'marionette',
'Mixins/AsModelBoundView',
'bootstrap'
], function (Marionette, AsModelBoundView) {
var view = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/SabViewTemplate'
});
return AsModelBoundView.call(view);
});

View File

@ -0,0 +1,107 @@
<fieldset>
<legend>SABnzbd</legend>
{{!<div class="control-group">
<label class="control-label">Auto-Configure</label>
<div class="controls">
<input type="button" value="Auto-Configure" class="btn btn-inverse"/>
<span class="help-inline">
<i class="icon-question-sign"
title="(Windows only) If access to SABnzbd doesn't require a username & password and it is on the same system as NzbDrone, you can auto-configure it"/>
</span>
</div>
</div>}}
<div class="control-group">
<label class="control-label">Host</label>
<div class="controls">
<input type="text" name="sabHost"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Port</label>
<div class="controls">
<input type="text" name="sabPort"/>
</div>
</div>
<div class="control-group">
<label class="control-label">API Key</label>
<div class="controls">
<input type="text" name="sabApiKey"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Username</label>
<div class="controls">
<input type="text" name="sabUsername"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Password</label>
<div class="controls">
<input type="password" name="sabPassword"/>
</div>
</div>
<div class="control-group">
<label class="control-label">TV Category</label>
<div class="controls">
<input type="text" name="sabTvCategory" placeholder="This is not the dropdownlist you're looking for"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Backlog Priority</label>
<div class="controls">
<select name="sabBacklogTvPriority">
<option value="default">Default</option>
<option value="paused">Paused</option>
<option value="low">Low</option>
<option value="normal">Normal</option>
<option value="high">High</option>
<option value="force">Force</option>
</select>
<span class="help-inline">
<i class="icon-question-sign" title="Priority to use when sending episodes older than 7 days to SABnzbd"/>
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Recent Priority</label>
<div class="controls">
<select name="sabRecentTvPriority">
<option value="default">Default</option>
<option value="paused">Paused</option>
<option value="low">Low</option>
<option value="normal">Normal</option>
<option value="high">High</option>
<option value="force">Force</option>
</select>
<span class="help-inline">
<i class="icon-question-sign" title="Priority to use when sending episodes that aired within the last 7 days to SABnzbd"/>
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Test</label>
<div class="controls">
<input type="button" value="Test" class="btn btn-inverse"/>
</div>
</div>
</fieldset>

View File

@ -10,13 +10,27 @@ define(
'Settings/Quality/QualityLayout',
'Settings/Indexers/CollectionView',
'Settings/Indexers/Collection',
'Settings/DownloadClient/DownloadClientView',
'Settings/DownloadClient/Layout',
'Settings/Notifications/CollectionView',
'Settings/Notifications/Collection',
'Settings/General/GeneralView',
'Settings/Misc/MiscView'
], function (App, Marionette, SettingsModel, GeneralSettingsModel,NamingModel, NamingView, QualityLayout, IndexerCollectionView, IndexerCollection, DownloadClientView,
NotificationCollectionView, NotificationCollection, GeneralView, MiscView) {
'Settings/Misc/MiscView',
'Shared/LoadingView'
], function (App,
Marionette,
SettingsModel,
GeneralSettingsModel,
NamingModel,
NamingView,
QualityLayout,
IndexerCollectionView,
IndexerCollection,
DownloadClientLayout,
NotificationCollectionView,
NotificationCollection,
GeneralView,
MiscView,
LoadingView) {
return Marionette.Layout.extend({
template: 'Settings/SettingsLayoutTemplate',
@ -27,7 +41,8 @@ define(
downloadClient: '#download-client',
notifications : '#notifications',
general : '#general',
misc : '#misc'
misc : '#misc',
loading : '#loading-region'
},
ui: {
@ -121,34 +136,36 @@ define(
},
initialize: function (options) {
this.settings = new SettingsModel();
this.settings.fetch();
this.generalSettings = new GeneralSettingsModel();
this.generalSettings.fetch();
this.namingSettings = new NamingModel();
this.namingSettings.fetch();
this.indexerSettings = new IndexerCollection();
this.indexerSettings.fetch();
this.notificationSettings = new NotificationCollection();
this.notificationSettings.fetch();
if (options.action) {
this.action = options.action.toLowerCase();
}
},
onRender: function () {
this.naming.show(new NamingView());
this.quality.show(new QualityLayout({settings: this.settings}));
this.indexers.show(new IndexerCollectionView({collection: this.indexerSettings}));
this.downloadClient.show(new DownloadClientView({model: this.settings}));
this.notifications.show(new NotificationCollectionView({collection: this.notificationSettings}));
this.general.show(new GeneralView({model: this.generalSettings}));
this.misc.show(new MiscView({model: this.settings}));
this.loading.show(new LoadingView());
var self = this;
this.settings = new SettingsModel();
this.generalSettings = new GeneralSettingsModel();
this.namingSettings = new NamingModel();
this.indexerSettings = new IndexerCollection();
this.notificationSettings = new NotificationCollection();
$.when(this.settings.fetch(),
this.generalSettings.fetch(),
this.namingSettings.fetch(),
this.indexerSettings.fetch(),
this.notificationSettings.fetch()
).done(function () {
self.loading.$el.hide();
self.naming.show(new NamingView());
self.quality.show(new QualityLayout({settings: self.settings}));
self.indexers.show(new IndexerCollectionView({collection: self.indexerSettings}));
self.downloadClient.show(new DownloadClientLayout({model: self.settings}));
self.notifications.show(new NotificationCollectionView({collection: self.notificationSettings}));
self.general.show(new GeneralView({model: self.generalSettings}));
self.misc.show(new MiscView({model: self.settings}));
});
},
onShow: function () {

View File

@ -18,3 +18,5 @@
<div class="tab-pane" id="general">general Settings</div>
<div class="tab-pane" id="misc">Misc Settings</div>
</div>
<div id="loading-region"></div>