Display names for Notifications

pull/6/head
Mark McDowall 10 years ago
parent ecd941a6e5
commit 9a629c2fc6

@ -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; }
}
}

@ -55,9 +55,9 @@ namespace NzbDrone.Api
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 @@ namespace NzbDrone.Api
private Response GetTemplates()
{
var defaultDefinitions = _providerFactory.GetDefaultDefinitions().ToList();
var defaultDefinitions = _providerFactory.GetDefaultDefinitions().OrderBy(p => p.ImplementationName).ToList();
var result = new List<TProviderResource>(defaultDefinitions.Count());

@ -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; }
}

@ -3,6 +3,7 @@ using System.Reflection;
using Marr.Data;
using Marr.Data.Mapping;
using NzbDrone.Common.Reflection;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Datastore.Extensions
{
@ -16,7 +17,11 @@ namespace NzbDrone.Core.Datastore.Extensions
.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()
{
return mapBuilder.Table.MapTable(tableName)
@ -55,7 +60,5 @@ namespace NzbDrone.Core.Datastore.Extensions
return false;
}
}
}

@ -45,18 +45,18 @@ namespace NzbDrone.Core.Datastore
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");

@ -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 @@ namespace NzbDrone.Core.Download
protected readonly IRemotePathMappingService _remotePathMappingService;
protected readonly Logger _logger;
public string Name
{
get
{
return GetType().Name;
}
}
public Type ConfigContract
{
get

@ -19,6 +19,14 @@ namespace NzbDrone.Core.Indexers
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; }

@ -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

@ -40,6 +40,14 @@ namespace NzbDrone.Core.Notifications.Email
{
}
public override string Name
{
get
{
return "Email";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

@ -37,6 +37,14 @@ namespace NzbDrone.Core.Notifications.Growl
{
}
public override string Name
{
get
{
return "Growl";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

@ -53,6 +53,14 @@ namespace NzbDrone.Core.Notifications.MediaBrowser
}
}
public override string Name
{
get
{
return "Emby (Media Browser)";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

@ -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

@ -38,6 +38,14 @@ namespace NzbDrone.Core.Notifications.NotifyMyAndroid
{
}
public override string Name
{
get
{
return "Notify My Android";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

@ -35,6 +35,14 @@ namespace NzbDrone.Core.Notifications.Plex
{
}
public override string Name
{
get
{
return "Plex Media Center";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

@ -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);
}
}
}
}

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

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

@ -38,6 +38,14 @@ namespace NzbDrone.Core.Notifications.Prowl
{
}
public override string Name
{
get
{
return "Prowl";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

@ -37,6 +37,14 @@ namespace NzbDrone.Core.Notifications.PushBullet
{
}
public override string Name
{
get
{
return "Pushbullet";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

@ -38,6 +38,14 @@ namespace NzbDrone.Core.Notifications.Pushalot
{
}
public override string Name
{
get
{
return "Pushalot";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

@ -37,6 +37,14 @@ namespace NzbDrone.Core.Notifications.Pushover
{
}
public override string Name
{
get
{
return "Pushover";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

@ -53,6 +53,14 @@ namespace NzbDrone.Core.Notifications.Synology
}
}
public override string Name
{
get
{
return "Synology Indexer";
}
}
public override ValidationResult Test()
{
var failures = new List<ValidationFailure>();

@ -45,11 +45,19 @@ namespace NzbDrone.Core.Notifications.Xbmc
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);
}

@ -16,7 +16,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
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 @@ namespace NzbDrone.Core.Notifications.Xbmc
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 @@ namespace NzbDrone.Core.Notifications.Xbmc
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)
{

@ -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" />

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

@ -1,5 +1,4 @@
using System;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.ThingiProvider
{
@ -7,10 +6,11 @@ namespace NzbDrone.Core.ThingiProvider
{
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
{

@ -140,6 +140,8 @@ namespace NzbDrone.Core.ThingiProvider
public virtual TProviderDefinition GetProviderCharacteristics(TProvider provider, TProviderDefinition definition)
{
definition.ImplementationName = provider.Name;
return definition;
}

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

Loading…
Cancel
Save