From b21e49f5fad147a295a6eb5e0254831ade6f8a8f Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 1 Jul 2013 23:46:38 -0700 Subject: [PATCH] Settings loading overhaul Download client moved to a layout Settings are only shown after all settings are loaded --- NzbDrone.Core/Configuration/ConfigService.cs | 12 +- NzbDrone.Core/MediaFiles/MediaFileService.cs | 1 + UI/Settings/DownloadClient/BlackholeView.js | 15 + .../DownloadClient/BlackholeViewTemplate.html | 13 + .../DownloadClientTemplate.html | 258 ------------------ .../DownloadClient/DownloadClientView.js | 81 ------ UI/Settings/DownloadClient/Layout.js | 74 +++++ .../DownloadClient/LayoutTemplate.html | 29 ++ UI/Settings/DownloadClient/NzbgetView.js | 15 + .../DownloadClient/NzbgetViewTemplate.html | 94 +++++++ UI/Settings/DownloadClient/PneumaticView.js | 15 + .../DownloadClient/PneumaticViewTemplate.html | 13 + UI/Settings/DownloadClient/SabView.js | 15 + .../DownloadClient/SabViewTemplate.html | 107 ++++++++ UI/Settings/SettingsLayout.js | 71 +++-- UI/Settings/SettingsLayoutTemplate.html | 2 + 16 files changed, 443 insertions(+), 372 deletions(-) create mode 100644 UI/Settings/DownloadClient/BlackholeView.js create mode 100644 UI/Settings/DownloadClient/BlackholeViewTemplate.html delete mode 100644 UI/Settings/DownloadClient/DownloadClientTemplate.html delete mode 100644 UI/Settings/DownloadClient/DownloadClientView.js create mode 100644 UI/Settings/DownloadClient/Layout.js create mode 100644 UI/Settings/DownloadClient/LayoutTemplate.html create mode 100644 UI/Settings/DownloadClient/NzbgetView.js create mode 100644 UI/Settings/DownloadClient/NzbgetViewTemplate.html create mode 100644 UI/Settings/DownloadClient/PneumaticView.js create mode 100644 UI/Settings/DownloadClient/PneumaticViewTemplate.html create mode 100644 UI/Settings/DownloadClient/SabView.js create mode 100644 UI/Settings/DownloadClient/SabViewTemplate.html diff --git a/NzbDrone.Core/Configuration/ConfigService.cs b/NzbDrone.Core/Configuration/ConfigService.cs index a6b6623d4..6da46ed50 100644 --- a/NzbDrone.Core/Configuration/ConfigService.cs +++ b/NzbDrone.Core/Configuration/ConfigService.cs @@ -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); } } diff --git a/NzbDrone.Core/MediaFiles/MediaFileService.cs b/NzbDrone.Core/MediaFiles/MediaFileService.cs index a5f3d6774..c332ffeb7 100644 --- a/NzbDrone.Core/MediaFiles/MediaFileService.cs +++ b/NzbDrone.Core/MediaFiles/MediaFileService.cs @@ -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()); diff --git a/UI/Settings/DownloadClient/BlackholeView.js b/UI/Settings/DownloadClient/BlackholeView.js new file mode 100644 index 000000000..50d4edc92 --- /dev/null +++ b/UI/Settings/DownloadClient/BlackholeView.js @@ -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); + }); diff --git a/UI/Settings/DownloadClient/BlackholeViewTemplate.html b/UI/Settings/DownloadClient/BlackholeViewTemplate.html new file mode 100644 index 000000000..4eb595199 --- /dev/null +++ b/UI/Settings/DownloadClient/BlackholeViewTemplate.html @@ -0,0 +1,13 @@ +
+ Blackhole +
+ + +
+ + + + +
+
+
diff --git a/UI/Settings/DownloadClient/DownloadClientTemplate.html b/UI/Settings/DownloadClient/DownloadClientTemplate.html deleted file mode 100644 index ad7f54f6c..000000000 --- a/UI/Settings/DownloadClient/DownloadClientTemplate.html +++ /dev/null @@ -1,258 +0,0 @@ -
- General - -
- - -
- -
-
-
- - -
- - - - - -
-
-
- -
- SABnzbd - - {{!
- - -
- - - - -
-
}} - -
- - -
- -
-
- -
- - -
- -
-
- -
- - -
- -
-
- -
- - -
- -
-
- -
- - -
- -
-
- -
- - -
- -
-
- -
- - -
- - - - -
-
- -
- - -
- - - - -
-
- -
- - -
- -
-
-
- -
- Blackhole -
- - -
- - - - -
-
-
- -
- Pneumatic -
- - -
- - - - -
-
-
- -
- NZBGet -
- - -
- -
-
- -
- - -
- -
-
- -
- - -
- -
-
- -
- - -
- -
-
- -
- - -
- -
-
- -
- - -
- -
-
- -
- - -
- - - - -
-
- -
- - -
- - - - -
-
- -
- - -
- -
-
-
diff --git a/UI/Settings/DownloadClient/DownloadClientView.js b/UI/Settings/DownloadClient/DownloadClientView.js deleted file mode 100644 index fa2f4ef31..000000000 --- a/UI/Settings/DownloadClient/DownloadClientView.js +++ /dev/null @@ -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); - }); diff --git a/UI/Settings/DownloadClient/Layout.js b/UI/Settings/DownloadClient/Layout.js new file mode 100644 index 000000000..31c59be8e --- /dev/null +++ b/UI/Settings/DownloadClient/Layout.js @@ -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); + }); \ No newline at end of file diff --git a/UI/Settings/DownloadClient/LayoutTemplate.html b/UI/Settings/DownloadClient/LayoutTemplate.html new file mode 100644 index 000000000..0980c0de5 --- /dev/null +++ b/UI/Settings/DownloadClient/LayoutTemplate.html @@ -0,0 +1,29 @@ +
+ General + +
+ + +
+ +
+
+
+ + +
+ + + + + +
+
+
+ +
\ No newline at end of file diff --git a/UI/Settings/DownloadClient/NzbgetView.js b/UI/Settings/DownloadClient/NzbgetView.js new file mode 100644 index 000000000..601df8457 --- /dev/null +++ b/UI/Settings/DownloadClient/NzbgetView.js @@ -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); + }); diff --git a/UI/Settings/DownloadClient/NzbgetViewTemplate.html b/UI/Settings/DownloadClient/NzbgetViewTemplate.html new file mode 100644 index 000000000..f8c7f7dde --- /dev/null +++ b/UI/Settings/DownloadClient/NzbgetViewTemplate.html @@ -0,0 +1,94 @@ +
+ NZBGet +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ + + + +
+
+ +
+ + +
+ + + + +
+
+ +
+ + +
+ +
+
+
diff --git a/UI/Settings/DownloadClient/PneumaticView.js b/UI/Settings/DownloadClient/PneumaticView.js new file mode 100644 index 000000000..aa5f29878 --- /dev/null +++ b/UI/Settings/DownloadClient/PneumaticView.js @@ -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); + }); diff --git a/UI/Settings/DownloadClient/PneumaticViewTemplate.html b/UI/Settings/DownloadClient/PneumaticViewTemplate.html new file mode 100644 index 000000000..4f0fbd415 --- /dev/null +++ b/UI/Settings/DownloadClient/PneumaticViewTemplate.html @@ -0,0 +1,13 @@ +
+ Pneumatic +
+ + +
+ + + + +
+
+
diff --git a/UI/Settings/DownloadClient/SabView.js b/UI/Settings/DownloadClient/SabView.js new file mode 100644 index 000000000..ce6da37e5 --- /dev/null +++ b/UI/Settings/DownloadClient/SabView.js @@ -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); + }); diff --git a/UI/Settings/DownloadClient/SabViewTemplate.html b/UI/Settings/DownloadClient/SabViewTemplate.html new file mode 100644 index 000000000..36cc53238 --- /dev/null +++ b/UI/Settings/DownloadClient/SabViewTemplate.html @@ -0,0 +1,107 @@ +
+ SABnzbd + + {{!
+ + +
+ + + + +
+
}} + +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ + + + +
+
+ +
+ + +
+ + + + +
+
+ +
+ + +
+ +
+
+
diff --git a/UI/Settings/SettingsLayout.js b/UI/Settings/SettingsLayout.js index ca4e544df..9126116a4 100644 --- a/UI/Settings/SettingsLayout.js +++ b/UI/Settings/SettingsLayout.js @@ -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 () { diff --git a/UI/Settings/SettingsLayoutTemplate.html b/UI/Settings/SettingsLayoutTemplate.html index 85712618f..940681c21 100644 --- a/UI/Settings/SettingsLayoutTemplate.html +++ b/UI/Settings/SettingsLayoutTemplate.html @@ -18,3 +18,5 @@
general Settings
Misc Settings
+ +
\ No newline at end of file