mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 21:13:28 -07:00
More notificationUI changes, start notification updates
This commit is contained in:
parent
c5376319fe
commit
63f2ba7f77
16 changed files with 188 additions and 78 deletions
|
@ -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<NotificationResource> 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<FieldDefinitionAttribute>(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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue