From f7c340d7952ea26ce45b0c8110879f6996abd850 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 27 Jun 2013 18:55:45 -0700 Subject: [PATCH] Save and add, notif settings cleanup --- .../Notifications/Growl/GrowlSettings.cs | 6 +-- .../Notifications/Plex/PlexClientSettings.cs | 8 ++-- .../Notifications/Plex/PlexServerSettings.cs | 4 +- .../Notifications/Prowl/ProwlSettings.cs | 4 +- UI/AddSeries/RootFolders/ItemView.js | 2 +- UI/Settings/Indexers/EditTemplate.html | 13 ++++++- UI/Settings/Indexers/EditView.js | 39 +++++++++++++++++-- UI/Settings/Notifications/CollectionView.js | 13 ++----- UI/Settings/Notifications/EditTemplate.html | 19 +++++++-- UI/Settings/Notifications/EditView.js | 26 ++++++++++--- UI/Settings/Notifications/ItemTemplate.html | 2 +- UI/Settings/Notifications/SchemaModal.js | 19 +++++++++ UI/Settings/Notifications/notifications.less | 17 +++++--- .../Profile/EditQualityProfileTemplate.html | 2 +- UI/Settings/settings.less | 20 ++++++++++ 15 files changed, 151 insertions(+), 43 deletions(-) create mode 100644 UI/Settings/Notifications/SchemaModal.js diff --git a/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs b/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs index 87c6f2f55..7bce0fe36 100644 --- a/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs +++ b/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs @@ -8,13 +8,13 @@ namespace NzbDrone.Core.Notifications.Growl { public class GrowlSettings : INotifcationSettings { - [FieldDefinition(0, Label = "Host", HelpText = "Growl Host (IP or Hostname)")] + [FieldDefinition(0, Label = "Host")] public String Host { get; set; } - [FieldDefinition(1, Label = "Port", HelpText = "Growl Port")] + [FieldDefinition(1, Label = "Port")] public Int32 Port { get; set; } - [FieldDefinition(2, Label = "Password", HelpText = "Password for Growl")] + [FieldDefinition(2, Label = "Password")] public String Password { get; set; } public bool IsValid diff --git a/NzbDrone.Core/Notifications/Plex/PlexClientSettings.cs b/NzbDrone.Core/Notifications/Plex/PlexClientSettings.cs index 96c959c7d..5eec32e4f 100644 --- a/NzbDrone.Core/Notifications/Plex/PlexClientSettings.cs +++ b/NzbDrone.Core/Notifications/Plex/PlexClientSettings.cs @@ -8,16 +8,16 @@ namespace NzbDrone.Core.Notifications.Plex { public class PlexClientSettings : INotifcationSettings { - [FieldDefinition(0, Label = "Host", HelpText = "Plex Client Host (IP or Hostname)")] + [FieldDefinition(0, Label = "Host")] public String Host { get; set; } - [FieldDefinition(1, Label = "Port", HelpText = "Plex Client Port")] + [FieldDefinition(1, Label = "Port")] public Int32 Port { get; set; } - [FieldDefinition(2, Label = "Username", HelpText = "Username for Plex")] + [FieldDefinition(2, Label = "Username")] public String Username { get; set; } - [FieldDefinition(3, Label = "Password", HelpText = "Password for Plex")] + [FieldDefinition(3, Label = "Password")] public String Password { get; set; } public bool IsValid diff --git a/NzbDrone.Core/Notifications/Plex/PlexServerSettings.cs b/NzbDrone.Core/Notifications/Plex/PlexServerSettings.cs index de0e8bbfa..bd3b740d9 100644 --- a/NzbDrone.Core/Notifications/Plex/PlexServerSettings.cs +++ b/NzbDrone.Core/Notifications/Plex/PlexServerSettings.cs @@ -8,13 +8,13 @@ namespace NzbDrone.Core.Notifications.Plex { public class PlexServerSettings : INotifcationSettings { - [FieldDefinition(0, Label = "Host", HelpText = "Plex Server Host (IP or Hostname)")] + [FieldDefinition(0, Label = "Host")] public String Host { get; set; } [FieldDefinition(1, Label = "Port")] public Int32 Port { get; set; } - [FieldDefinition(2, Label = "Update Library")] + [FieldDefinition(2, Label = "Update Library", Type = FieldType.Checkbox)] public Boolean UpdateLibrary { get; set; } public bool IsValid diff --git a/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs b/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs index f224b4672..3ab4da458 100644 --- a/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs +++ b/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs @@ -8,10 +8,10 @@ namespace NzbDrone.Core.Notifications.Prowl { public class ProwlSettings : INotifcationSettings { - [FieldDefinition(0, Label = "API Key", HelpText = "API Key for Prowl")] + [FieldDefinition(0, Label = "API Key")] public String ApiKey { get; set; } - [FieldDefinition(1, Label = "Priority", HelpText = "Priority to send messages at", Type = FieldType.Select, SelectOptions= typeof(ProwlPriority) )] + [FieldDefinition(1, Label = "Priority", Type = FieldType.Select, SelectOptions= typeof(ProwlPriority) )] public Int32 Priority { get; set; } public bool IsValid diff --git a/UI/AddSeries/RootFolders/ItemView.js b/UI/AddSeries/RootFolders/ItemView.js index 991c9b253..33d870b33 100644 --- a/UI/AddSeries/RootFolders/ItemView.js +++ b/UI/AddSeries/RootFolders/ItemView.js @@ -11,7 +11,7 @@ define( tagName : 'tr', events: { - 'click .x-remove': 'removeFolder', + 'click .x-delete': 'removeFolder', 'click .x-folder': 'folderSelected' }, diff --git a/UI/Settings/Indexers/EditTemplate.html b/UI/Settings/Indexers/EditTemplate.html index e14d1b63d..2786e55c1 100644 --- a/UI/Settings/Indexers/EditTemplate.html +++ b/UI/Settings/Indexers/EditTemplate.html @@ -40,5 +40,16 @@ {{/if}} - + +
+ + + +
diff --git a/UI/Settings/Indexers/EditView.js b/UI/Settings/Indexers/EditView.js index d7b87a78d..e805df302 100644 --- a/UI/Settings/Indexers/EditView.js +++ b/UI/Settings/Indexers/EditView.js @@ -2,23 +2,54 @@ define( [ + 'app', 'marionette', 'Mixins/AsModelBoundView' - ], function (Marionette, AsModelBoundView) { + ], function (App, Marionette, AsModelBoundView) { var view = Marionette.ItemView.extend({ template: 'Settings/Indexers/EditTemplate', events: { - 'click .x-save': 'save' + 'click .x-save': '_save', + 'click .x-save-and-add': '_saveAndAdd' }, initialize: function (options) { this.indexerCollection = options.indexerCollection; }, - save: function () { - this.model.saveSettings(); + _save: function () { + var self = this; + var promise = this.model.saveSettings(); + + if (promise) { + promise.done(function () { + self.indexerCollection.add(self.model, { merge: true }); + App.modalRegion.closeModal(); + }); + } + }, + + _saveAndAdd: function () { + var self = this; + var promise = this.model.saveSettings(); + + if (promise) { + promise.done(function () { + self.indexerCollection.add(self.model, { merge: true }); + + self.model.set({ + id: undefined, + name: '', + enable: false + }); + + _.each(self.model.get('fields'), function (value, key, list) { + self.model.set('fields.' + key +'.value', ''); + }); + }); + } } }); diff --git a/UI/Settings/Notifications/CollectionView.js b/UI/Settings/Notifications/CollectionView.js index 2de13cc75..8c00dc559 100644 --- a/UI/Settings/Notifications/CollectionView.js +++ b/UI/Settings/Notifications/CollectionView.js @@ -2,10 +2,9 @@ define([ 'app', 'marionette', - 'Settings/Notifications/Collection', 'Settings/Notifications/ItemView', - 'Settings/Notifications/AddView' -], function (App, Marionette, NotificationCollection, NotificationItemView, AddSelectionNotificationView) { + 'Settings/Notifications/SchemaModal' +], function (App, Marionette, NotificationItemView, SchemaModal) { return Marionette.CompositeView.extend({ itemView : NotificationItemView, itemViewContainer: '.notifications', @@ -16,13 +15,7 @@ define([ }, _openSchemaModal: function () { - var schemaCollection = new NotificationCollection(); - schemaCollection.url = '/api/notification/schema'; - schemaCollection.fetch(); - schemaCollection.url = '/api/notification'; - - var view = new AddSelectionNotificationView({ collection: schemaCollection, notificationCollection: this.collection}); - App.modalRegion.show(view); + SchemaModal.open(this.collection); } }); }); diff --git a/UI/Settings/Notifications/EditTemplate.html b/UI/Settings/Notifications/EditTemplate.html index aba6fb573..90b8d0301 100644 --- a/UI/Settings/Notifications/EditTemplate.html +++ b/UI/Settings/Notifications/EditTemplate.html @@ -61,10 +61,23 @@ diff --git a/UI/Settings/Notifications/EditView.js b/UI/Settings/Notifications/EditView.js index 44c497290..27f4646f0 100644 --- a/UI/Settings/Notifications/EditView.js +++ b/UI/Settings/Notifications/EditView.js @@ -15,9 +15,11 @@ define([ template: 'Settings/Notifications/EditTemplate', events: { - 'click .x-save' : '_saveNotification', - 'click .x-remove': '_deleteNotification', - 'click .x-test' : '_test' + 'click .x-save' : '_saveNotification', + 'click .x-save-and-add' : '_saveAndAddNotification', + 'click .x-delete' : '_deleteNotification', + 'click .x-back' : '_back', + 'click .x-test' : '_test' }, ui: { @@ -41,14 +43,26 @@ define([ } }, + _saveAndAddNotification: function () { + var self = this; + var promise = this.model.saveSettings(); + + if (promise) { + promise.done(function () { + self.notificationCollection.add(self.model, { merge: true }); + + require('Settings/Notifications/SchemaModal').open(self.notificationCollection); + }); + } + }, + _deleteNotification: function () { var view = new DeleteView({ model: this.model }); App.modalRegion.show(view); }, - _saveSuccess: function () { - this.notificationCollection.add(this.model, { merge: true }); - App.modalRegion.closeModal(); + _back: function () { + require('Settings/Notifications/SchemaModal').open(this.notificationCollection); }, _test: function () { diff --git a/UI/Settings/Notifications/ItemTemplate.html b/UI/Settings/Notifications/ItemTemplate.html index 085f960a4..608060bd2 100644 --- a/UI/Settings/Notifications/ItemTemplate.html +++ b/UI/Settings/Notifications/ItemTemplate.html @@ -7,7 +7,7 @@ -
+
{{#if onGrab}} On Grab {{else}} diff --git a/UI/Settings/Notifications/SchemaModal.js b/UI/Settings/Notifications/SchemaModal.js new file mode 100644 index 000000000..254fff06f --- /dev/null +++ b/UI/Settings/Notifications/SchemaModal.js @@ -0,0 +1,19 @@ +'use strict'; +define([ + 'app', + 'Settings/Notifications/Collection', + 'Settings/Notifications/AddView' +], function (App, NotificationCollection, AddSelectionNotificationView) { + return ({ + + open: function (collection) { + var schemaCollection = new NotificationCollection(); + schemaCollection.url = '/api/notification/schema'; + schemaCollection.fetch(); + schemaCollection.url = '/api/notification'; + + var view = new AddSelectionNotificationView({ collection: schemaCollection, notificationCollection: collection}); + App.modalRegion.show(view); + } + }); +}); diff --git a/UI/Settings/Notifications/notifications.less b/UI/Settings/Notifications/notifications.less index 2903562eb..06ec6f3d3 100644 --- a/UI/Settings/Notifications/notifications.less +++ b/UI/Settings/Notifications/notifications.less @@ -23,24 +23,27 @@ } .notifications { + width: -webkit-fit-content; + width: -moz-fit-content; + width: fit-content; + li { display: inline-block; vertical-align: top; } } - .notification-item { .card; - width: 250px; - height: 80px; - padding: 10px 15px; + width: 290px; + height: 90px; + padding: 20px 20px; h3 { margin-top: 0px; display: inline-block; - width: 200px; + width: 230px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; @@ -49,4 +52,8 @@ .btn-group { margin-top: 8px; } + + .settings { + margin-top: 5px; + } } \ No newline at end of file diff --git a/UI/Settings/Quality/Profile/EditQualityProfileTemplate.html b/UI/Settings/Quality/Profile/EditQualityProfileTemplate.html index e4b5761b2..c66bf2abb 100644 --- a/UI/Settings/Quality/Profile/EditQualityProfileTemplate.html +++ b/UI/Settings/Quality/Profile/EditQualityProfileTemplate.html @@ -52,7 +52,7 @@