From 635366261c106ae2a0304008c78a1393329446d4 Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Fri, 10 Mar 2017 09:20:40 +0000 Subject: [PATCH] Done #1012 --- Ombi.UI/Modules/Admin/FaultQueueModule.cs | 34 +++++++++ Ombi.UI/Views/Admin/SchedulerSettings.cshtml | 6 ++ .../Views/FaultQueue/RequestFaultQueue.cshtml | 69 ++++++++----------- 3 files changed, 69 insertions(+), 40 deletions(-) diff --git a/Ombi.UI/Modules/Admin/FaultQueueModule.cs b/Ombi.UI/Modules/Admin/FaultQueueModule.cs index aacd5b992..096ce69b1 100644 --- a/Ombi.UI/Modules/Admin/FaultQueueModule.cs +++ b/Ombi.UI/Modules/Admin/FaultQueueModule.cs @@ -25,7 +25,10 @@ // ************************************************************************/ #endregion +using System; using System.Linq; +using System.Threading.Tasks; +using Nancy; using Nancy.Responses.Negotiation; using Ombi.Core; using Ombi.Core.SettingModels; @@ -48,6 +51,7 @@ namespace Ombi.UI.Modules.Admin Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx); Get["Index", "/faultqueue"] = x => Index(); + Get["DeleteFault", "/deleteFault", true] = async (x,ct) => await DeleteFault(Convert.ToInt32(Request.Form.id)); } private IRepository RequestQueue { get; } @@ -69,5 +73,35 @@ namespace Ombi.UI.Modules.Admin return View["RequestFaultQueue", model]; } + + public async Task DeleteFault(int faultId) + { + + if (faultId == 0) + { + return Response.AsJson(new JsonResponseModel + { + Result = true, + Message = "Fault does not exist" + }); + } + + var fault = await RequestQueue.GetAsync(faultId); + if (fault == null) + { + return Response.AsJson(new JsonResponseModel + { + Result = true, + Message = "Fault does not exist" + }); + } + + await RequestQueue.DeleteAsync(fault); + + return Response.AsJson(new JsonResponseModel + { + Result = true + }); + } } } \ No newline at end of file diff --git a/Ombi.UI/Views/Admin/SchedulerSettings.cshtml b/Ombi.UI/Views/Admin/SchedulerSettings.cshtml index 57e619ad6..e1083ba10 100644 --- a/Ombi.UI/Views/Admin/SchedulerSettings.cshtml +++ b/Ombi.UI/Views/Admin/SchedulerSettings.cshtml @@ -175,13 +175,19 @@ success: function (response) { if (response.result === true) { generateNotify("Success!", "success"); + ev.removeClass("fa-spin"); + ev.addClass("fa-check"); } else { generateNotify(response.message, "warning"); + ev.removeClass("fa-spin"); + ev.addClass("fa-times"); } }, error: function (e) { console.log(e); generateNotify("Something went wrong!", "danger"); + ev.removeClass("fa-spin"); + ev.addClass("fa-times"); } }); diff --git a/Ombi.UI/Views/FaultQueue/RequestFaultQueue.cshtml b/Ombi.UI/Views/FaultQueue/RequestFaultQueue.cshtml index f5df31e65..451734902 100644 --- a/Ombi.UI/Views/FaultQueue/RequestFaultQueue.cshtml +++ b/Ombi.UI/Views/FaultQueue/RequestFaultQueue.cshtml @@ -22,6 +22,9 @@ Error Description + + Delete + @@ -44,6 +47,7 @@ @m.Message + } @@ -52,57 +56,42 @@ -@**@ \ No newline at end of file + + }); + \ No newline at end of file