From 625acef6359f8699bceef0fdff798133cedd0ef2 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 27 Jul 2013 13:57:41 -0700 Subject: [PATCH] Added links and api key links to notifications --- NzbDrone.Api/ClientSchema/Field.cs | 1 + NzbDrone.Api/ClientSchema/SchemaBuilder.cs | 1 + NzbDrone.Api/Notifications/NotificationResource.cs | 1 + .../Annotations/FieldDefinitionAttribute.cs | 1 + NzbDrone.Core/Notifications/Email/Email.cs | 5 +++++ NzbDrone.Core/Notifications/Growl/Growl.cs | 5 +++++ NzbDrone.Core/Notifications/INotification.cs | 1 + NzbDrone.Core/Notifications/Notification.cs | 1 + NzbDrone.Core/Notifications/NotificationBase.cs | 1 + NzbDrone.Core/Notifications/NotificationService.cs | 1 + NzbDrone.Core/Notifications/Plex/PlexClient.cs | 5 +++++ NzbDrone.Core/Notifications/Plex/PlexServer.cs | 5 +++++ NzbDrone.Core/Notifications/Prowl/Prowl.cs | 5 +++++ NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs | 2 +- NzbDrone.Core/Notifications/Pushover/Pushover.cs | 5 +++++ .../Notifications/Pushover/PushoverSettings.cs | 2 +- NzbDrone.Core/Notifications/Xbmc/Xbmc.cs | 5 +++++ UI/Content/form.less | 12 +++++++++++- UI/Form/FormHelpPartial.html | 11 +++++++++++ UI/Form/TextboxTemplate.html | 6 +----- UI/Settings/Notifications/AddItemTemplate.html | 3 +++ UI/Settings/Notifications/AddItemView.js | 6 +++++- UI/Settings/Notifications/notifications.less | 14 ++++++++++++++ 23 files changed, 90 insertions(+), 9 deletions(-) create mode 100644 UI/Form/FormHelpPartial.html diff --git a/NzbDrone.Api/ClientSchema/Field.cs b/NzbDrone.Api/ClientSchema/Field.cs index 858c51de0..6d5539016 100644 --- a/NzbDrone.Api/ClientSchema/Field.cs +++ b/NzbDrone.Api/ClientSchema/Field.cs @@ -8,6 +8,7 @@ public class Field public string Name { get; set; } public string Label { get; set; } public string HelpText { get; set; } + public string HelpLink { get; set; } public object Value { get; set; } public string Type { get; set; } public List SelectOptions { get; set; } diff --git a/NzbDrone.Api/ClientSchema/SchemaBuilder.cs b/NzbDrone.Api/ClientSchema/SchemaBuilder.cs index 13f61885b..99b2c6d15 100644 --- a/NzbDrone.Api/ClientSchema/SchemaBuilder.cs +++ b/NzbDrone.Api/ClientSchema/SchemaBuilder.cs @@ -26,6 +26,7 @@ public static List GenerateSchema(object model) Name = propertyInfo.Name, Label = fieldAttribute.Label, HelpText = fieldAttribute.HelpText, + HelpLink = fieldAttribute.HelpLink, Order = fieldAttribute.Order, Type = fieldAttribute.Type.ToString().ToLowerInvariant() }; diff --git a/NzbDrone.Api/Notifications/NotificationResource.cs b/NzbDrone.Api/Notifications/NotificationResource.cs index 1406571e5..d96539de8 100644 --- a/NzbDrone.Api/Notifications/NotificationResource.cs +++ b/NzbDrone.Api/Notifications/NotificationResource.cs @@ -9,6 +9,7 @@ public class NotificationResource : RestResource { public String Name { get; set; } public String ImplementationName { get; set; } + public String Link { get; set; } public Boolean OnGrab { get; set; } public Boolean OnDownload { get; set; } public List Fields { get; set; } diff --git a/NzbDrone.Core/Annotations/FieldDefinitionAttribute.cs b/NzbDrone.Core/Annotations/FieldDefinitionAttribute.cs index 9a795c728..794a00c43 100644 --- a/NzbDrone.Core/Annotations/FieldDefinitionAttribute.cs +++ b/NzbDrone.Core/Annotations/FieldDefinitionAttribute.cs @@ -13,6 +13,7 @@ public FieldDefinitionAttribute(int order) public int Order { get; private set; } public string Label { get; set; } public string HelpText { get; set; } + public string HelpLink { get; set; } public FieldType Type { get; set; } public Type SelectOptions { get; set; } } diff --git a/NzbDrone.Core/Notifications/Email/Email.cs b/NzbDrone.Core/Notifications/Email/Email.cs index 923712d06..87ddabc59 100644 --- a/NzbDrone.Core/Notifications/Email/Email.cs +++ b/NzbDrone.Core/Notifications/Email/Email.cs @@ -22,6 +22,11 @@ public override string ImplementationName get { return "Email"; } } + public override string Link + { + get { return null; } + } + public override void OnGrab(string message) { const string subject = "NzbDrone [TV] - Grabbed"; diff --git a/NzbDrone.Core/Notifications/Growl/Growl.cs b/NzbDrone.Core/Notifications/Growl/Growl.cs index fe4a49e6d..23c9620d8 100644 --- a/NzbDrone.Core/Notifications/Growl/Growl.cs +++ b/NzbDrone.Core/Notifications/Growl/Growl.cs @@ -21,6 +21,11 @@ public override string ImplementationName get { return "Growl"; } } + public override string Link + { + get { return "http://growl.info/"; } + } + public override void OnGrab(string message) { const string title = "Episode Grabbed"; diff --git a/NzbDrone.Core/Notifications/INotification.cs b/NzbDrone.Core/Notifications/INotification.cs index cdfa29c49..86f1bcc03 100644 --- a/NzbDrone.Core/Notifications/INotification.cs +++ b/NzbDrone.Core/Notifications/INotification.cs @@ -6,6 +6,7 @@ public interface INotification { string Name { get; } string ImplementationName { get; } + string Link { get; } NotificationDefinition InstanceDefinition { get; set; } diff --git a/NzbDrone.Core/Notifications/Notification.cs b/NzbDrone.Core/Notifications/Notification.cs index 01c168e73..09919c958 100644 --- a/NzbDrone.Core/Notifications/Notification.cs +++ b/NzbDrone.Core/Notifications/Notification.cs @@ -5,6 +5,7 @@ public class Notification public int Id { get; set; } public string Name { get; set; } public string ImplementationName { get; set; } + public string Link { get; set; } public bool OnGrab { get; set; } public bool OnDownload { get; set; } public INotifcationSettings Settings { get; set; } diff --git a/NzbDrone.Core/Notifications/NotificationBase.cs b/NzbDrone.Core/Notifications/NotificationBase.cs index e00f486eb..e8577c978 100644 --- a/NzbDrone.Core/Notifications/NotificationBase.cs +++ b/NzbDrone.Core/Notifications/NotificationBase.cs @@ -7,6 +7,7 @@ namespace NzbDrone.Core.Notifications { public abstract string Name { get; } public abstract string ImplementationName { get; } + public abstract string Link { get; } public NotificationDefinition InstanceDefinition { get; set; } diff --git a/NzbDrone.Core/Notifications/NotificationService.cs b/NzbDrone.Core/Notifications/NotificationService.cs index 046797dcf..7e75a9d38 100644 --- a/NzbDrone.Core/Notifications/NotificationService.cs +++ b/NzbDrone.Core/Notifications/NotificationService.cs @@ -68,6 +68,7 @@ public List Schema() newNotification.Instance = (INotification)_container.Resolve(type); newNotification.Id = i; newNotification.ImplementationName = notification.ImplementationName; + newNotification.Link = notification.Link; var instanceType = newNotification.Instance.GetType(); var baseGenArgs = instanceType.BaseType.GetGenericArguments(); diff --git a/NzbDrone.Core/Notifications/Plex/PlexClient.cs b/NzbDrone.Core/Notifications/Plex/PlexClient.cs index 0ca86daa6..b5d2a8d17 100644 --- a/NzbDrone.Core/Notifications/Plex/PlexClient.cs +++ b/NzbDrone.Core/Notifications/Plex/PlexClient.cs @@ -21,6 +21,11 @@ public override string ImplementationName get { return "Plex Client"; } } + public override string Link + { + get { return "http://www.plexapp.com/"; } + } + public override void OnGrab(string message) { const string header = "NzbDrone [TV] - Grabbed"; diff --git a/NzbDrone.Core/Notifications/Plex/PlexServer.cs b/NzbDrone.Core/Notifications/Plex/PlexServer.cs index 6a4a2d893..04d5df084 100644 --- a/NzbDrone.Core/Notifications/Plex/PlexServer.cs +++ b/NzbDrone.Core/Notifications/Plex/PlexServer.cs @@ -21,6 +21,11 @@ public override string ImplementationName get { return "Plex Server"; } } + public override string Link + { + get { return "http://www.plexapp.com/"; } + } + public override void OnGrab(string message) { } diff --git a/NzbDrone.Core/Notifications/Prowl/Prowl.cs b/NzbDrone.Core/Notifications/Prowl/Prowl.cs index 207104b6e..0164b222a 100644 --- a/NzbDrone.Core/Notifications/Prowl/Prowl.cs +++ b/NzbDrone.Core/Notifications/Prowl/Prowl.cs @@ -22,6 +22,11 @@ public override string ImplementationName get { return "Prowl"; } } + public override string Link + { + get { return "http://www.prowlapp.com/"; } + } + public override void OnGrab(string message) { const string title = "Episode Grabbed"; diff --git a/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs b/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs index faa1f876a..f6b9a7603 100644 --- a/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs +++ b/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs @@ -5,7 +5,7 @@ namespace NzbDrone.Core.Notifications.Prowl { public class ProwlSettings : INotifcationSettings { - [FieldDefinition(0, Label = "API Key")] + [FieldDefinition(0, Label = "API Key", HelpLink = "https://www.prowlapp.com/api_settings.php")] public String ApiKey { get; set; } [FieldDefinition(1, Label = "Priority", Type = FieldType.Select, SelectOptions= typeof(ProwlPriority) )] diff --git a/NzbDrone.Core/Notifications/Pushover/Pushover.cs b/NzbDrone.Core/Notifications/Pushover/Pushover.cs index 1dac1ff2a..51abfed35 100644 --- a/NzbDrone.Core/Notifications/Pushover/Pushover.cs +++ b/NzbDrone.Core/Notifications/Pushover/Pushover.cs @@ -23,6 +23,11 @@ public override string ImplementationName get { return "Pushover"; } } + public override string Link + { + get { return "https://pushover.net/"; } + } + public override void OnGrab(string message) { const string title = "Episode Grabbed"; diff --git a/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs b/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs index 20ab99339..43c7937b6 100644 --- a/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs +++ b/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs @@ -5,7 +5,7 @@ namespace NzbDrone.Core.Notifications.Pushover { public class PushoverSettings : INotifcationSettings { - [FieldDefinition(0, Label = "User Key")] + [FieldDefinition(0, Label = "User Key", HelpLink = "https://pushover.net/")] public String UserKey { get; set; } [FieldDefinition(1, Label = "Priority", Type = FieldType.Select, SelectOptions = typeof(PushoverPriority) )] diff --git a/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs b/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs index 0ef599573..20cfc80fe 100644 --- a/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs +++ b/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs @@ -22,6 +22,11 @@ public override string ImplementationName get { return "XBMC"; } } + public override string Link + { + get { return "http://xbmc.org/"; } + } + public override void OnGrab(string message) { const string header = "NzbDrone [TV] - Grabbed"; diff --git a/UI/Content/form.less b/UI/Content/form.less index a13ef0d69..00a64b748 100644 --- a/UI/Content/form.less +++ b/UI/Content/form.less @@ -1,4 +1,6 @@ -.control-group { +@import "../Shared/Styles/clickable.less"; + +.control-group { .controls { i { font-size : 16px; @@ -31,3 +33,11 @@ textarea.release-restrictions { width : 260px; } + +.help-link { + text-decoration: none !important; + + i { + .clickable; + } +} \ No newline at end of file diff --git a/UI/Form/FormHelpPartial.html b/UI/Form/FormHelpPartial.html new file mode 100644 index 000000000..cdf295852 --- /dev/null +++ b/UI/Form/FormHelpPartial.html @@ -0,0 +1,11 @@ +{{#if helpText}} + + + +{{/if}} + +{{#if helpLink}} + + + +{{/if}} \ No newline at end of file diff --git a/UI/Form/TextboxTemplate.html b/UI/Form/TextboxTemplate.html index d39f08db8..f0e0e5734 100644 --- a/UI/Form/TextboxTemplate.html +++ b/UI/Form/TextboxTemplate.html @@ -3,10 +3,6 @@
- {{#if helpText}} - - - - {{/if}} + {{> FormHelpPartial}}
diff --git a/UI/Settings/Notifications/AddItemTemplate.html b/UI/Settings/Notifications/AddItemTemplate.html index 9c5eb644f..2d08f3370 100644 --- a/UI/Settings/Notifications/AddItemTemplate.html +++ b/UI/Settings/Notifications/AddItemTemplate.html @@ -2,6 +2,9 @@
{{implementationName}} + {{#if link}} + + {{/if}}
\ No newline at end of file diff --git a/UI/Settings/Notifications/AddItemView.js b/UI/Settings/Notifications/AddItemView.js index 62dd32f5c..f58ff758a 100644 --- a/UI/Settings/Notifications/AddItemView.js +++ b/UI/Settings/Notifications/AddItemView.js @@ -18,7 +18,11 @@ define([ this.notificationCollection = options.notificationCollection; }, - addNotification: function () { + addNotification: function (e) { + if ($(e.target).hasClass('icon-info-sign')) { + return; + } + this.model.set('id', undefined); var editView = new EditView({ model: this.model, notificationCollection: this.notificationCollection }); App.modalRegion.show(editView); diff --git a/UI/Settings/Notifications/notifications.less b/UI/Settings/Notifications/notifications.less index 93bb3655f..24e54738f 100644 --- a/UI/Settings/Notifications/notifications.less +++ b/UI/Settings/Notifications/notifications.less @@ -1,4 +1,5 @@ @import "../../Shared/Styles/card.less"; +@import "../../Shared/Styles/clickable.less"; .add-notification-item { .card; @@ -6,6 +7,19 @@ font-size: 24px; font-weight: lighter; text-align: center; + + a { + font-size: 16px; + color: #595959; + + i { + .clickable; + } + } + + a:hover { + text-decoration: none; + } } .add-notifications {