mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 20:42:37 +01:00
Merge branch 'master' of git://github.com/kayone/NzbDrone
This commit is contained in:
commit
66522b8109
@ -1,28 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace NzbDrone.Core.Model.Notification
|
||||
{
|
||||
public class BasicNotification
|
||||
{
|
||||
public BasicNotification()
|
||||
{
|
||||
Id = Guid.NewGuid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the unique id.
|
||||
/// </summary>
|
||||
/// <value>The Id.</value>
|
||||
public Guid Id { get; private set; }
|
||||
|
||||
public String Title { get; set; }
|
||||
|
||||
public BasicNotificationType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether or not this message should be automatically dismissed after a period of time.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [auto dismiss]; otherwise, <c>false</c>.</value>
|
||||
public bool AutoDismiss { get; set; }
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
namespace NzbDrone.Core.Model.Notification
|
||||
{
|
||||
public enum BasicNotificationType
|
||||
{
|
||||
Info = 0,
|
||||
Warrning = 1,
|
||||
Error = 2
|
||||
}
|
||||
}
|
@ -249,12 +249,9 @@
|
||||
<Compile Include="Providers\UpcomingEpisodesProvider.cs" />
|
||||
<Compile Include="Providers\XbmcProvider.cs" />
|
||||
<Compile Include="Repository\EpisodeFile.cs" />
|
||||
<Compile Include="Model\Notification\BasicNotification.cs" />
|
||||
<Compile Include="Model\Notification\ProgressNotificationStatus.cs" />
|
||||
<Compile Include="Model\Notification\BasicNotificationType.cs" />
|
||||
<Compile Include="Instrumentation\LogConfiguration.cs" />
|
||||
<Compile Include="Parser.cs" />
|
||||
<Compile Include="Providers\Fakes\FakeNotificationProvider.cs" />
|
||||
<Compile Include="Providers\MediaFileProvider.cs" />
|
||||
<Compile Include="Model\Notification\ProgressNotification.cs" />
|
||||
<Compile Include="Providers\NotificationProvider.cs" />
|
||||
|
@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
|
||||
namespace NzbDrone.Core.Providers.Fakes
|
||||
{
|
||||
internal class FakeNotificationProvider
|
||||
{
|
||||
private readonly Dictionary<Guid, BasicNotification> _basicNotifications =
|
||||
new Dictionary<Guid, BasicNotification>();
|
||||
|
||||
private readonly Object _lock = new object();
|
||||
|
||||
private readonly Dictionary<Guid, ProgressNotification> _progressNotification =
|
||||
new Dictionary<Guid, ProgressNotification>();
|
||||
|
||||
|
||||
private readonly ProgressNotification fakeNotification = new ProgressNotification("Updating Series");
|
||||
private readonly ProgressNotification fakeNotification2 = new ProgressNotification("Updating Series2");
|
||||
|
||||
public List<BasicNotification> BasicNotifications
|
||||
{
|
||||
get { return new List<BasicNotification>(_basicNotifications.Values); }
|
||||
}
|
||||
|
||||
public List<ProgressNotification> GetProgressNotifications
|
||||
{
|
||||
get
|
||||
{
|
||||
fakeNotification.Status = ProgressNotificationStatus.InProgress;
|
||||
fakeNotification.Status = ProgressNotificationStatus.InProgress;
|
||||
fakeNotification2.CurrentMessage = DateTime.UtcNow.ToString();
|
||||
fakeNotification.CurrentMessage = DateTime.Now.ToString();
|
||||
return new List<ProgressNotification> { fakeNotification };
|
||||
}
|
||||
}
|
||||
|
||||
public void Register(ProgressNotification notification)
|
||||
{
|
||||
_progressNotification.Add(notification.Id, notification);
|
||||
}
|
||||
|
||||
public void Register(BasicNotification notification)
|
||||
{
|
||||
_basicNotifications.Add(notification.Id, notification);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -7,19 +7,12 @@ namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class NotificationProvider
|
||||
{
|
||||
private static readonly Dictionary<Guid, BasicNotification> _basicNotifications =
|
||||
new Dictionary<Guid, BasicNotification>();
|
||||
|
||||
private static readonly Object _lock = new object();
|
||||
|
||||
private static readonly Dictionary<Guid, ProgressNotification> _progressNotification =
|
||||
new Dictionary<Guid, ProgressNotification>();
|
||||
|
||||
public virtual List<BasicNotification> BasicNotifications
|
||||
{
|
||||
get { return new List<BasicNotification>(_basicNotifications.Values); }
|
||||
}
|
||||
|
||||
public virtual List<ProgressNotification> ProgressNotifications
|
||||
{
|
||||
get
|
||||
@ -51,28 +44,5 @@ public virtual void Register(ProgressNotification notification)
|
||||
_progressNotification.Add(notification.Id, notification);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Register(BasicNotification notification)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_basicNotifications.Add(notification.Id, notification);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Dismiss(Guid notificationId)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_basicNotifications.ContainsKey(notificationId))
|
||||
{
|
||||
_basicNotifications.Remove(notificationId);
|
||||
}
|
||||
else if (_progressNotification.ContainsKey(notificationId))
|
||||
{
|
||||
_progressNotification.Remove(notificationId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -18,37 +18,6 @@ public NotificationController(NotificationProvider notificationProvider)
|
||||
_notifications = notificationProvider;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public JsonResult Index()
|
||||
{
|
||||
string message = string.Empty;
|
||||
|
||||
var basic = _notifications.BasicNotifications;
|
||||
|
||||
if (basic.Count != 0)
|
||||
{
|
||||
message = basic[0].Title;
|
||||
|
||||
if (basic[0].AutoDismiss)
|
||||
_notifications.Dismiss(basic[0].Id);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (_notifications.ProgressNotifications.Count != 0)
|
||||
message = _notifications.ProgressNotifications[0].CurrentMessage;
|
||||
}
|
||||
|
||||
|
||||
if (MiniProfiler.Current.DurationMilliseconds < 100)
|
||||
{
|
||||
MiniProfiler.Stop(true);
|
||||
}
|
||||
|
||||
return Json(message, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public JsonResult Comet(string message)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user