From 63f2ba7f7794fd83b37c14956fcf0b8bf2795500 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 20 May 2013 23:16:19 -0700 Subject: [PATCH] More notificationUI changes, start notification updates --- .../Notifications/NotificationModule.cs | 40 +++++++++-- .../Notifications/NotificationResource.cs | 1 + NzbDrone.Core/Notifications/Notification.cs | 1 + .../Notifications/NotificationService.cs | 8 +++ UI/Content/Images/Notifications/Growl.png | Bin 0 -> 769 bytes UI/Content/Images/Notifications/Plex.png | Bin 0 -> 606 bytes UI/Content/Images/Notifications/Prowl.png | Bin 0 -> 1195 bytes UI/Content/Images/Notifications/Smtp.png | Bin 0 -> 494 bytes UI/Content/Images/Notifications/Xbmc.png | Bin 0 -> 718 bytes .../Notifications/CollectionTemplate.html | 17 +++-- UI/Settings/Notifications/CollectionView.js | 2 +- UI/Settings/Notifications/EditTemplate.html | 67 ++++++++++++++++++ UI/Settings/Notifications/EditView.js | 36 ++++++++++ UI/Settings/Notifications/ItemTemplate.html | 56 +++------------ UI/Settings/Notifications/ItemView.js | 30 ++++---- .../Quality/Profile/QualityProfileView.js | 8 +-- 16 files changed, 188 insertions(+), 78 deletions(-) create mode 100644 UI/Content/Images/Notifications/Growl.png create mode 100644 UI/Content/Images/Notifications/Plex.png create mode 100644 UI/Content/Images/Notifications/Prowl.png create mode 100644 UI/Content/Images/Notifications/Smtp.png create mode 100644 UI/Content/Images/Notifications/Xbmc.png create mode 100644 UI/Settings/Notifications/EditTemplate.html create mode 100644 UI/Settings/Notifications/EditView.js diff --git a/NzbDrone.Api/Notifications/NotificationModule.cs b/NzbDrone.Api/Notifications/NotificationModule.cs index 34b51865d..c7e5a74e3 100644 --- a/NzbDrone.Api/Notifications/NotificationModule.cs +++ b/NzbDrone.Api/Notifications/NotificationModule.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; using NzbDrone.Api.ClientSchema; +using NzbDrone.Common.Reflection; +using NzbDrone.Core.Annotations; using NzbDrone.Core.Notifications; using Omu.ValueInjecter; @@ -12,7 +14,9 @@ namespace NzbDrone.Api.Notifications public NotificationModule(INotificationService notificationService) { _notificationService = notificationService; + GetResourceAll = GetAll; + UpdateResource = Update; } private List GetAll() @@ -23,14 +27,42 @@ namespace NzbDrone.Api.Notifications foreach (var notification in notifications) { - var indexerResource = new NotificationResource(); - indexerResource.InjectFrom(notification); - indexerResource.Fields = SchemaBuilder.GenerateSchema(notification.Settings); + var notificationResource = new NotificationResource(); + notificationResource.InjectFrom(notification); + notificationResource.Fields = SchemaBuilder.GenerateSchema(notification.Settings); - result.Add(indexerResource); + result.Add(notificationResource); } return result; } + + private NotificationResource Update(NotificationResource notificationResource) + { + //Todo: Convert Resource back to Settings + + var notification = _notificationService.Get(notificationResource.Id); + + notification.OnGrab = notificationResource.OnGrab; + notification.OnDownload = notificationResource.OnDownload; + + var properties = notification.Settings.GetType().GetSimpleProperties(); + + foreach (var propertyInfo in properties) + { + var fieldAttribute = propertyInfo.GetAttribute(false); + + if (fieldAttribute != null) + { + //Find coresponding field + + var field = notificationResource.Fields.Find(f => f.Name == propertyInfo.Name); + + propertyInfo.SetValue(notification.Settings, field.Value, null); + } + } + + return notificationResource; + } } } \ No newline at end of file diff --git a/NzbDrone.Api/Notifications/NotificationResource.cs b/NzbDrone.Api/Notifications/NotificationResource.cs index 24cddeff5..4b743dd5d 100644 --- a/NzbDrone.Api/Notifications/NotificationResource.cs +++ b/NzbDrone.Api/Notifications/NotificationResource.cs @@ -11,5 +11,6 @@ namespace NzbDrone.Api.Notifications public Boolean OnGrab { get; set; } public Boolean OnDownload { get; set; } public List Fields { get; set; } + public String Implementation { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Core/Notifications/Notification.cs b/NzbDrone.Core/Notifications/Notification.cs index a5bd2be43..3f2aa09bb 100644 --- a/NzbDrone.Core/Notifications/Notification.cs +++ b/NzbDrone.Core/Notifications/Notification.cs @@ -13,5 +13,6 @@ namespace NzbDrone.Core.Notifications public bool OnDownload { get; set; } public INotifcationSettings Settings { get; set; } public INotification Instance { get; set; } + public string Implementation { get; set; } } } diff --git a/NzbDrone.Core/Notifications/NotificationService.cs b/NzbDrone.Core/Notifications/NotificationService.cs index 874ff40d5..ccc0672b4 100644 --- a/NzbDrone.Core/Notifications/NotificationService.cs +++ b/NzbDrone.Core/Notifications/NotificationService.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using NLog; +using Newtonsoft.Json; using NzbDrone.Common; using NzbDrone.Common.Composition; using NzbDrone.Common.Messaging; @@ -13,6 +14,7 @@ namespace NzbDrone.Core.Notifications public interface INotificationService { List All(); + Notification Get(int id); } public class NotificationService @@ -42,6 +44,11 @@ namespace NzbDrone.Core.Notifications return _notificationRepository.All().Select(ToNotification).ToList(); } + public Notification Get(int id) + { + return ToNotification(_notificationRepository.Get(id)); + } + private Notification ToNotification(NotificationDefinition definition) { var notification = new Notification(); @@ -50,6 +57,7 @@ namespace NzbDrone.Core.Notifications notification.OnDownload = definition.OnDownload; notification.Instance = GetInstance(definition); notification.Name = definition.Name; + notification.Implementation = definition.Implementation; notification.Settings = ((dynamic)notification.Instance).ImportSettingsFromJson(definition.Settings); return notification; diff --git a/UI/Content/Images/Notifications/Growl.png b/UI/Content/Images/Notifications/Growl.png new file mode 100644 index 0000000000000000000000000000000000000000..ae07720788628cffe1be7477da92c80f191a25bf GIT binary patch literal 769 zcmV+c1OEJpP)~$T}wj1 zHiKt#o@~|FcT3>v>S`;d9McmerDful0-cvw{e}XLRCK&+KU?>_R^+E@iZ|CYJ_~lo zY?^mfsp)RGE+)C3^vEiy;EZ&bu&|Z3=Mm?Egsa)TOD5hU?!Mw#x5D}!AG$g%@d*hr zJ>xtM=b3W-b!_hV=YvGHC(|KyieNU8{3 z)InHw#6&Nz2yo0UBRnb&TB8LrCGuZ)aKG|_dNkSIR+R0)nes(EYgXWI4g|vzRJC|f z-{!>XvS*$bl<9|$DoJmj&A4u1^eG?2F>Fb=7?8}f0=$bZl-=n-PPmGg5H~X8-7u@& zaLrL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--git a/UI/Content/Images/Notifications/Xbmc.png b/UI/Content/Images/Notifications/Xbmc.png new file mode 100644 index 0000000000000000000000000000000000000000..9c9092c0df57d044e3256fd8291be1ff012f5717 GIT binary patch literal 718 zcmV;<0x|uGP){xg^wLXzL_|*o6%?2u zR76GCbek?yR2EuZP($bLj5FuVIi4QOqh``qo-|tu1VVL#|Tp$Y&|ka!8{!^ zC(!%BgMV{`v9N-k5%E=|Nsg)*SrNr$kYAW1aAPTv0cASD6!x6$L6R+A++0Gqf3oER z7rxVW$q#@i!Ir~=Xc>vuw@VRciUk1-P2yL#+ZF>Dx@6xcOc;weP@K8Rgtl0OiVX>z zMLGpu4JmKBF)42XUwOvni&iG-4|%4CxV>cnN4|+DTZA4iWYxA&>RNlrrX`+UEn~RL z&8DV7($PGe9)rFQMfR|ThSNtZ)otL;FX2-_v#XR>XYeg7W~2}LzGazTK8{*oB5Dix z`E`8m7EYdOW@*`C1VLbEaF`c?AoaU;P~dg}@G21G$>Zl7Y}|*xas?I^!B_7QYInC< zr_UTE7K_u~_5f8?IClIn?m{;m?GJhP_9IoRD``B`Kr|8~kw|j;);&_GG&#dSG)O z)$7;N`Rt|5P18hC75)WrXWcfwcXeY~(`$=GKV94gOEFp;^ciZlxs1B-DSF(A_28z8NgqEfz%O#sQWdql&^KaYV zkUz&gbBrPuUPZ&J=oCA2yo!$3G0A7znmcRx4UW?c$xPJeT>t<807*qoM6N<$f~7G^ A8~^|S literal 0 HcmV?d00001 diff --git a/UI/Settings/Notifications/CollectionTemplate.html b/UI/Settings/Notifications/CollectionTemplate.html index 3b9abe950..eb08fe772 100644 --- a/UI/Settings/Notifications/CollectionTemplate.html +++ b/UI/Settings/Notifications/CollectionTemplate.html @@ -1,5 +1,12 @@ -
-
-
-
-
\ No newline at end of file + + + + + + + + + + + +
TypeNameOn GrabOn DownloadControls
\ No newline at end of file diff --git a/UI/Settings/Notifications/CollectionView.js b/UI/Settings/Notifications/CollectionView.js index 24fc4334a..6c8b53a19 100644 --- a/UI/Settings/Notifications/CollectionView.js +++ b/UI/Settings/Notifications/CollectionView.js @@ -2,7 +2,7 @@ define(['app', 'Settings/Notifications/ItemView'], function () { NzbDrone.Settings.Notifications.CollectionView = Backbone.Marionette.CompositeView.extend({ itemView : NzbDrone.Settings.Notifications.ItemView, - itemViewContainer : '#x-notifications', + itemViewContainer : 'tbody', template : 'Settings/Notifications/CollectionTemplate' }); }); diff --git a/UI/Settings/Notifications/EditTemplate.html b/UI/Settings/Notifications/EditTemplate.html new file mode 100644 index 000000000..11b51d5e2 --- /dev/null +++ b/UI/Settings/Notifications/EditTemplate.html @@ -0,0 +1,67 @@ + + + \ No newline at end of file diff --git a/UI/Settings/Notifications/EditView.js b/UI/Settings/Notifications/EditView.js new file mode 100644 index 000000000..e8a2108c4 --- /dev/null +++ b/UI/Settings/Notifications/EditView.js @@ -0,0 +1,36 @@ +"use strict"; + +define([ + 'app', + 'Settings/Notifications/Model' + +], function () { + + NzbDrone.Settings.Notifications.EditView = Backbone.Marionette.ItemView.extend({ + template : 'Settings/Notifications/EditTemplate', + + events: { + 'click .x-save': 'save' + }, + + save: function () { + this.model.save(); + +// window.alert('saving'); +// this.model.save(undefined, this.syncNotification("Notification Settings Saved", "Couldn't Save Notification Settings")); + }, + + + syncNotification: function (success, error) { + return { + success: function () { + window.alert(success); + }, + + error: function () { + window.alert(error); + } + }; + } + }); +}); diff --git a/UI/Settings/Notifications/ItemTemplate.html b/UI/Settings/Notifications/ItemTemplate.html index bc8782adb..2129380aa 100644 --- a/UI/Settings/Notifications/ItemTemplate.html +++ b/UI/Settings/Notifications/ItemTemplate.html @@ -1,47 +1,9 @@ -
- {{name}} - -
- - -
- - - - - -
-
- -
- - -
- - - - - -
-
- - {{#each fields}} - {{formField}} - {{/each}} -
+{{implementation}} + + + + + + + | Delete + \ No newline at end of file diff --git a/UI/Settings/Notifications/ItemView.js b/UI/Settings/Notifications/ItemView.js index 7183c8ff7..a7b0d014c 100644 --- a/UI/Settings/Notifications/ItemView.js +++ b/UI/Settings/Notifications/ItemView.js @@ -2,32 +2,28 @@ define([ 'app', - 'Settings/Notifications/Collection' + 'Settings/Notifications/Collection', + 'Settings/Notifications/EditView' ], function () { NzbDrone.Settings.Notifications.ItemView = Backbone.Marionette.ItemView.extend({ template : 'Settings/Notifications/ItemTemplate', - initialize: function () { - NzbDrone.vent.on(NzbDrone.Commands.SaveSettings, this.saveSettings, this); - }, - - saveSettings: function () { + tagName: 'tr', - //this.model.save(undefined, this.syncNotification("Naming Settings Saved", "Couldn't Save Naming Settings")); + events: { + 'click .x-edit' : 'edit', + 'click .x-remove': 'remove' }, + edit: function () { + var view = new NzbDrone.Settings.Notifications.EditView({ model: this.model}); + NzbDrone.modalRegion.show(view); + }, - syncNotification: function (success, error) { - return { - success: function () { - window.alert(success); - }, - - error: function () { - window.alert(error); - } - }; + remove: function () { + var view = new NzbDrone.Settings.Notifications.DeleteView({ model: this.model}); + NzbDrone.modalRegion.show(view); } }); }); diff --git a/UI/Settings/Quality/Profile/QualityProfileView.js b/UI/Settings/Quality/Profile/QualityProfileView.js index 4bab5441f..fcb5faee2 100644 --- a/UI/Settings/Quality/Profile/QualityProfileView.js +++ b/UI/Settings/Quality/Profile/QualityProfileView.js @@ -16,16 +16,16 @@ define([ }, events: { - 'click .x-edit' : 'editSeries', - 'click .x-remove': 'removeSeries' + 'click .x-edit' : 'edit', + 'click .x-remove': 'remove' }, - editSeries: function () { + edit: function () { var view = new NzbDrone.Settings.Quality.Profile.EditQualityProfileView({ model: this.model}); NzbDrone.modalRegion.show(view); }, - removeSeries: function () { + remove: function () { var view = new NzbDrone.Series.Delete.DeleteSeriesView({ model: this.model }); NzbDrone.modalRegion.show(view); }