1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00

Display names for Notifications

This commit is contained in:
Mark McDowall 2015-04-25 09:02:17 -07:00
parent ecd941a6e5
commit 9a629c2fc6
29 changed files with 258 additions and 36 deletions

View File

@ -5,11 +5,11 @@ namespace NzbDrone.Api.Notifications
{
public class NotificationResource : ProviderResource
{
public String Link { get; set; }
public Boolean OnGrab { get; set; }
public Boolean OnDownload { get; set; }
public Boolean OnUpgrade { get; set; }
public String TestCommand { get; set; }
public HashSet<Int32> Tags { get; set; }
public string Link { get; set; }
public bool OnGrab { get; set; }
public bool OnDownload { get; set; }
public bool OnUpgrade { get; set; }
public string TestCommand { get; set; }
public HashSet<int> Tags { get; set; }
}
}

View File

@ -55,9 +55,9 @@ private TProviderResource GetProviderById(int id)
private List<TProviderResource> GetAll()
{
var providerDefinitions = _providerFactory.All();
var providerDefinitions = _providerFactory.All().OrderBy(p => p.ImplementationName);
var result = new List<TProviderResource>(providerDefinitions.Count);
var result = new List<TProviderResource>(providerDefinitions.Count());
foreach (var definition in providerDefinitions)
{
@ -124,7 +124,7 @@ private void DeleteProvider(int id)
private Response GetTemplates()
{
var defaultDefinitions = _providerFactory.GetDefaultDefinitions().ToList();
var defaultDefinitions = _providerFactory.GetDefaultDefinitions().OrderBy(p => p.ImplementationName).ToList();
var result = new List<TProviderResource>(defaultDefinitions.Count());

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using NzbDrone.Api.ClientSchema;
using NzbDrone.Api.REST;
@ -7,11 +6,12 @@ namespace NzbDrone.Api
{
public class ProviderResource : RestResource
{
public String Name { get; set; }
public string Name { get; set; }
public List<Field> Fields { get; set; }
public String Implementation { get; set; }
public String ConfigContract { get; set; }
public String InfoLink { get; set; }
public string ImplementationName { get; set; }
public string Implementation { get; set; }
public string ConfigContract { get; set; }
public string InfoLink { get; set; }
public List<ProviderResource> Presets { get; set; }
}

View File

@ -3,6 +3,7 @@
using Marr.Data;
using Marr.Data.Mapping;
using NzbDrone.Common.Reflection;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Datastore.Extensions
{
@ -16,6 +17,10 @@ public static class MappingExtensions
.AutoMapPropertiesWhere(IsMappableProperty);
}
public static ColumnMapBuilder<T> RegisterDefinition<T>(this FluentMappings.MappingsFluentEntity<T> mapBuilder, string tableName = null) where T : ProviderDefinition, new()
{
return RegisterModel(mapBuilder, tableName).Ignore(c => c.ImplementationName);
}
public static ColumnMapBuilder<T> RegisterModel<T>(this FluentMappings.MappingsFluentEntity<T> mapBuilder, string tableName = null) where T : ModelBase, new()
{
@ -55,7 +60,5 @@ public static bool IsMappableProperty(MemberInfo memberInfo)
return false;
}
}
}

View File

@ -45,18 +45,18 @@ public static void Map()
Mapper.Entity<Config>().RegisterModel("Config");
Mapper.Entity<RootFolder>().RegisterModel("RootFolders").Ignore(r => r.FreeSpace);
Mapper.Entity<ScheduledTask>().RegisterModel("ScheduledTasks");
Mapper.Entity<IndexerDefinition>().RegisterModel("Indexers")
Mapper.Entity<IndexerDefinition>().RegisterDefinition("Indexers")
.Ignore(i => i.Enable)
.Ignore(i => i.Protocol)
.Ignore(i => i.SupportsRss)
.Ignore(i => i.SupportsSearch);
Mapper.Entity<ScheduledTask>().RegisterModel("ScheduledTasks");
Mapper.Entity<NotificationDefinition>().RegisterModel("Notifications");
Mapper.Entity<MetadataDefinition>().RegisterModel("Metadata");
Mapper.Entity<NotificationDefinition>().RegisterDefinition("Notifications");
Mapper.Entity<MetadataDefinition>().RegisterDefinition("Metadata");
Mapper.Entity<DownloadClientDefinition>().RegisterModel("DownloadClients")
Mapper.Entity<DownloadClientDefinition>().RegisterDefinition("DownloadClients")
.Ignore(d => d.Protocol);
Mapper.Entity<SceneMapping>().RegisterModel("SceneMappings");

View File

@ -1,5 +1,4 @@
using System;
using System.IO;
using System.Collections.Generic;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Indexers;
@ -21,6 +20,14 @@ public abstract class DownloadClientBase<TSettings> : IDownloadClient
protected readonly IRemotePathMappingService _remotePathMappingService;
protected readonly Logger _logger;
public string Name
{
get
{
return GetType().Name;
}
}
public Type ConfigContract
{
get

View File

@ -19,6 +19,14 @@ public abstract class IndexerBase<TSettings> : IIndexer
protected readonly IParsingService _parsingService;
protected readonly Logger _logger;
public string Name
{
get
{
return GetType().Name;
}
}
public abstract DownloadProtocol Protocol { get; }
public abstract Boolean SupportsRss { get; }

View File

@ -10,6 +10,14 @@ namespace NzbDrone.Core.Metadata
{
public abstract class MetadataBase<TSettings> : IMetadata where TSettings : IProviderConfig, new()
{
public string Name
{
get
{
return GetType().Name;
}
}
public Type ConfigContract
{
get

View File

@ -40,6 +40,14 @@ public override void AfterRename(Series series)
{
}
public override string Name
{
get
{
return "Email";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

View File

@ -37,6 +37,14 @@ public override void AfterRename(Series series)
{
}
public override string Name
{
get
{
return "Growl";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

View File

@ -53,6 +53,14 @@ public override void AfterRename(Series series)
}
}
public override string Name
{
get
{
return "Emby (Media Browser)";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

View File

@ -8,6 +8,8 @@ namespace NzbDrone.Core.Notifications
{
public abstract class NotificationBase<TSettings> : INotification where TSettings : IProviderConfig, new()
{
public abstract string Name { get; }
public Type ConfigContract
{
get

View File

@ -38,6 +38,14 @@ public override void AfterRename(Series series)
{
}
public override string Name
{
get
{
return "Notify My Android";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

View File

@ -35,6 +35,14 @@ public override void AfterRename(Series series)
{
}
public override string Name
{
get
{
return "Plex Media Center";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

View File

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Net.Sockets;
using FluentValidation.Results;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Notifications.Xbmc;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Notifications.Plex
{
public class PlexHomeTheater : NotificationBase<PlexHomeTheaterSettings>
{
private readonly IXbmcService _xbmcService;
private readonly Logger _logger;
public PlexHomeTheater(IXbmcService xbmcService, Logger logger)
{
_xbmcService = xbmcService;
_logger = logger;
}
public override string Link
{
get { return "https://plex.tv/"; }
}
public override void OnGrab(string message)
{
const string header = "Sonarr - Grabbed";
Notify(Settings, header, message);
}
public override void OnDownload(DownloadMessage message)
{
const string header = "Sonarr - Downloaded";
Notify(Settings, header, message.Message);
}
public override void AfterRename(Series series)
{
}
public override string Name
{
get
{
return "Plex Home Theater";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();
failures.AddIfNotNull(_xbmcService.Test(Settings, "Success! PHT has been successfully configured!"));
return new ValidationResult(failures);
}
private void Notify(XbmcSettings settings, string header, string message)
{
try
{
if (Settings.Notify)
{
_xbmcService.Notify(Settings, header, message);
}
}
catch (SocketException ex)
{
var logMessage = String.Format("Unable to connect to PHT Host: {0}:{1}", Settings.Host, Settings.Port);
_logger.DebugException(logMessage, ex);
}
}
}
}

View File

@ -0,0 +1,13 @@
using NzbDrone.Core.Notifications.Xbmc;
namespace NzbDrone.Core.Notifications.Plex
{
public class PlexHomeTheaterSettings : XbmcSettings
{
public PlexHomeTheaterSettings()
{
DisplayTime = 5;
Port = 3005;
}
}
}

View File

@ -41,6 +41,14 @@ private void UpdateIfEnabled()
}
}
public override string Name
{
get
{
return "Plex Media Server";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

View File

@ -38,6 +38,14 @@ public override void AfterRename(Series series)
{
}
public override string Name
{
get
{
return "Prowl";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

View File

@ -37,6 +37,14 @@ public override void AfterRename(Series series)
{
}
public override string Name
{
get
{
return "Pushbullet";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

View File

@ -38,6 +38,14 @@ public override void AfterRename(Series series)
{
}
public override string Name
{
get
{
return "Pushalot";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

View File

@ -37,6 +37,14 @@ public override void AfterRename(Series series)
{
}
public override string Name
{
get
{
return "Pushover";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

View File

@ -53,6 +53,14 @@ public override void AfterRename(Series series)
}
}
public override string Name
{
get
{
return "Synology Indexer";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

View File

@ -45,11 +45,19 @@ public override void AfterRename(Series series)
UpdateAndClean(series);
}
public override string Name
{
get
{
return "Kodi (XBMC)";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();
failures.AddIfNotNull(_xbmcService.Test(Settings));
failures.AddIfNotNull(_xbmcService.Test(Settings, "Success! XBMC has been successfully configured!"));
return new ValidationResult(failures);
}

View File

@ -16,7 +16,7 @@ public interface IXbmcService
void Notify(XbmcSettings settings, string title, string message);
void Update(XbmcSettings settings, Series series);
void Clean(XbmcSettings settings);
ValidationFailure Test(XbmcSettings settings);
ValidationFailure Test(XbmcSettings settings, string message);
}
public class XbmcService : IXbmcService
@ -101,13 +101,13 @@ private IApiProvider GetApiProvider(XbmcSettings settings)
return apiProvider;
}
public ValidationFailure Test(XbmcSettings settings)
public ValidationFailure Test(XbmcSettings settings, string message)
{
_xbmcVersionCache.Clear();
try
{
_logger.Debug("Determining version of XBMC Host: {0}", settings.Address);
_logger.Debug("Determining version of Host: {0}", settings.Address);
var version = GetJsonVersion(settings);
_logger.Debug("Version is: {0}", version);
@ -116,7 +116,7 @@ public ValidationFailure Test(XbmcSettings settings)
throw new InvalidXbmcVersionException("Version received from XBMC is invalid, please correct your settings.");
}
Notify(settings, "Test Notification", "Success! XBMC has been successfully configured!");
Notify(settings, "Test Notification", message);
}
catch (Exception ex)
{

View File

@ -665,6 +665,8 @@
<Compile Include="Metadata\MetadataType.cs" />
<Compile Include="MetadataSource\IProvideSeriesInfo.cs" />
<Compile Include="MetadataSource\ISearchForNewSeries.cs" />
<Compile Include="Notifications\Plex\PlexHomeTheater.cs" />
<Compile Include="Notifications\Plex\PlexHomeTheaterSettings.cs" />
<Compile Include="Notifications\Synology\SynologyException.cs" />
<Compile Include="Notifications\Synology\SynologyIndexer.cs" />
<Compile Include="Notifications\Synology\SynologyIndexerProxy.cs" />

View File

@ -6,6 +6,7 @@ namespace NzbDrone.Core.ThingiProvider
{
public interface IProvider
{
string Name { get; }
Type ConfigContract { get; }
IEnumerable<ProviderDefinition> DefaultDefinitions { get; }

View File

@ -1,5 +1,4 @@
using System;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.ThingiProvider
{
@ -7,10 +6,11 @@ public abstract class ProviderDefinition : ModelBase
{
private IProviderConfig _settings;
public String Name { get; set; }
public String Implementation { get; set; }
public String ConfigContract { get; set; }
public virtual Boolean Enable { get; set; }
public string Name { get; set; }
public string ImplementationName { get; set; }
public string Implementation { get; set; }
public string ConfigContract { get; set; }
public virtual bool Enable { get; set; }
public IProviderConfig Settings
{

View File

@ -140,6 +140,8 @@ protected virtual List<TProviderDefinition> Active()
public virtual TProviderDefinition GetProviderCharacteristics(TProvider provider, TProviderDefinition definition)
{
definition.ImplementationName = provider.Name;
return definition;
}

View File

@ -1,6 +1,6 @@
<div class="add-thingy">
<div>
{{implementation}}
{{implementationName}}
</div>
<div class="pull-right">
{{#if_gt presets.length compare=0}}