mirror of https://github.com/Radarr/Radarr
Instant progress notifications. Now use comet instead of pooling.
This commit is contained in:
parent
9a251394da
commit
a1caa789fe
|
@ -27,7 +27,7 @@ namespace NzbDrone.Core.Model.Notification
|
||||||
/// Gets or sets the title for this notification.
|
/// Gets or sets the title for this notification.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The title.</value>
|
/// <value>The title.</value>
|
||||||
public String Title { get; set; }
|
public String Title { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the current status of this task. this field could be use to show the currently processing item in a long running task.
|
/// Gets or sets the current status of this task. this field could be use to show the currently processing item in a long running task.
|
||||||
|
|
|
@ -51,6 +51,8 @@ namespace NzbDrone.Core.Providers.Jobs
|
||||||
Logger.Error("Unable to find an episode {0} in database", targetId);
|
Logger.Error("Unable to find an episode {0} in database", targetId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
notification.CurrentMessage = "Searching for " + episode;
|
||||||
|
|
||||||
|
|
||||||
var series = episode.Series;
|
var series = episode.Series;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace NzbDrone.Core.Providers
|
||||||
get { return new List<BasicNotification>(_basicNotifications.Values); }
|
get { return new List<BasicNotification>(_basicNotifications.Values); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual List<ProgressNotification> GetProgressNotifications
|
public virtual List<ProgressNotification> ProgressNotifications
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
using System.Web.Mvc;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Web.Mvc;
|
||||||
using MvcMiniProfiler;
|
using MvcMiniProfiler;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
|
|
||||||
|
@ -32,8 +35,8 @@ namespace NzbDrone.Web.Controllers
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_notifications.GetProgressNotifications.Count != 0)
|
if (_notifications.ProgressNotifications.Count != 0)
|
||||||
message = _notifications.GetProgressNotifications[0].CurrentMessage;
|
message = _notifications.ProgressNotifications[0].CurrentMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,5 +47,33 @@ namespace NzbDrone.Web.Controllers
|
||||||
|
|
||||||
return Json(message, JsonRequestBehavior.AllowGet);
|
return Json(message, JsonRequestBehavior.AllowGet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public JsonResult Comet(string message)
|
||||||
|
{
|
||||||
|
var requestTimer = Stopwatch.StartNew();
|
||||||
|
|
||||||
|
MiniProfiler.Stop(true);
|
||||||
|
|
||||||
|
var currentMessage = GetCurrentMessage();
|
||||||
|
|
||||||
|
while (message == currentMessage && requestTimer.Elapsed.TotalSeconds < 10)
|
||||||
|
{
|
||||||
|
Thread.Sleep(250);
|
||||||
|
currentMessage = GetCurrentMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Json(currentMessage, JsonRequestBehavior.AllowGet);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetCurrentMessage()
|
||||||
|
{
|
||||||
|
if (_notifications.ProgressNotifications.Count != 0)
|
||||||
|
return _notifications.ProgressNotifications[0].CurrentMessage;
|
||||||
|
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,30 +1,27 @@
|
||||||
/// <reference path="jquery-1.5.2-vsdoc.js" />
|
$(window).load(function () {
|
||||||
$(document).ready(function ()
|
var speed = 700;
|
||||||
{
|
|
||||||
var speed = 0;
|
|
||||||
var isShown = false;
|
var isShown = false;
|
||||||
refreshNotifications();
|
var currentMessage = "";
|
||||||
|
|
||||||
|
$.doTimeout(200, refreshNotifications);
|
||||||
|
|
||||||
|
|
||||||
var timer = window.setInterval(function () {
|
|
||||||
speed = 1000;
|
|
||||||
refreshNotifications();
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
function refreshNotifications() {
|
function refreshNotifications() {
|
||||||
$.ajax({
|
$.get('/notification/Comet', { message: currentMessage }, notificationCallback);
|
||||||
url: '/Notification',
|
|
||||||
success: notificationCallback
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function notificationCallback(data) {
|
function notificationCallback(data) {
|
||||||
|
currentMessage = data;
|
||||||
|
|
||||||
if (data === "") {
|
if (data === "") {
|
||||||
CloseMsg();
|
closeMsg();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DisplayMsg(data);
|
displayMsg(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
//SetupNotifications();
|
//SetupNotifications();
|
||||||
|
@ -32,32 +29,20 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function DisplayMsg(sMsg) {
|
function displayMsg(sMsg) {
|
||||||
//set the message text
|
//set the message text
|
||||||
|
$("#msgText").showHtml(sMsg, 150);
|
||||||
|
|
||||||
//$("#msgText").text(sMsg);
|
|
||||||
$("#msgText").showHtml(sMsg, 200);
|
|
||||||
|
|
||||||
|
|
||||||
if (!isShown) {
|
if (!isShown) {
|
||||||
isShown = true;
|
$('#msgBox').show("slide", { direction: "right" }, speed / 2);
|
||||||
if (speed === 0) {
|
|
||||||
$('#msgBox').show();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$('#msgBox').show("slide", { direction: "right" }, speed);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isShown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function CloseMsg() {
|
function closeMsg() {
|
||||||
//hide the message
|
//hide the message
|
||||||
if (isShown) {
|
$('#msgBox').hide("slide", { direction: "right" }, speed);
|
||||||
$('#msgBox').hide("slide", { direction: "right" }, speed);
|
|
||||||
}
|
|
||||||
|
|
||||||
isShown = false;
|
isShown = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue