diff --git a/PlexRequests.Core/Queue/TransientFaultQueue.cs b/PlexRequests.Core/Queue/TransientFaultQueue.cs index 57fd2eb34..5c2f1de71 100644 --- a/PlexRequests.Core/Queue/TransientFaultQueue.cs +++ b/PlexRequests.Core/Queue/TransientFaultQueue.cs @@ -80,7 +80,7 @@ namespace PlexRequests.Core.Queue var existingItem = await RequestQueue.CustomAsync(async connection => { connection.Open(); - var result = await connection.QueryAsync("select * from RequestQueue where PrimaryIdentifier = @ProviderId", new { ProviderId = id }); + var result = await connection.QueryAsync("select * from RequestFaultQueue where PrimaryIdentifier = @ProviderId", new { ProviderId = id }); return result; }); diff --git a/PlexRequests.Store/Models/RequestQueue.cs b/PlexRequests.Store/Models/RequestQueue.cs index f98517ab3..cbbfb62b6 100644 --- a/PlexRequests.Store/Models/RequestQueue.cs +++ b/PlexRequests.Store/Models/RequestQueue.cs @@ -30,7 +30,7 @@ using Dapper.Contrib.Extensions; namespace PlexRequests.Store.Models { - [Table("RequestQueue")] + [Table("RequestFaultQueue")] public class RequestQueue : Entity { public string PrimaryIdentifier { get; set; } diff --git a/PlexRequests.Store/SqlTables.sql b/PlexRequests.Store/SqlTables.sql index f0e852717..84a31306f 100644 --- a/PlexRequests.Store/SqlTables.sql +++ b/PlexRequests.Store/SqlTables.sql @@ -133,7 +133,7 @@ CREATE UNIQUE INDEX IF NOT EXISTS PlexEpisodes_Id ON PlexEpisodes (Id); CREATE INDEX IF NOT EXISTS PlexEpisodes_ProviderId ON PlexEpisodes (ProviderId); -CREATE TABLE IF NOT EXISTS RequestQueue +CREATE TABLE IF NOT EXISTS RequestFaultQueue ( Id INTEGER PRIMARY KEY AUTOINCREMENT, PrimaryIdentifier VARCHAR(100) NOT NULL, diff --git a/PlexRequests.UI/Models/FaultedRequestsViewModel.cs b/PlexRequests.UI/Models/FaultedRequestsViewModel.cs new file mode 100644 index 000000000..d0f5de428 --- /dev/null +++ b/PlexRequests.UI/Models/FaultedRequestsViewModel.cs @@ -0,0 +1,56 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: FaultedRequestsViewModel.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion + +using System; +using PlexRequests.Store; +using PlexRequests.Store.Models; + +namespace PlexRequests.UI.Models +{ + public class FaultedRequestsViewModel + { + public int Id { get; set; } + public string PrimaryIdentifier { get; set; } + public RequestTypeViewModel Type { get; set; } + public string Title { get; set; } + public FaultTypeViewModel FaultType { get; set; } + public DateTime? LastRetry { get; set; } + } + + public enum RequestTypeViewModel + { + Movie, + TvShow, + Album + } + + public enum FaultTypeViewModel + { + RequestFault, + MissingInformation + } +} \ No newline at end of file diff --git a/PlexRequests.UI/Modules/Admin/FaultQueueModule.cs b/PlexRequests.UI/Modules/Admin/FaultQueueModule.cs new file mode 100644 index 000000000..355e823e2 --- /dev/null +++ b/PlexRequests.UI/Modules/Admin/FaultQueueModule.cs @@ -0,0 +1,74 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SystemStatusModule.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion + +using System.Collections.Generic; +using System.Linq; +using Nancy.Responses.Negotiation; +using PlexRequests.Core; +using PlexRequests.Core.SettingModels; +using PlexRequests.Helpers; +using PlexRequests.Helpers.Permissions; +using PlexRequests.Store; +using PlexRequests.Store.Models; +using PlexRequests.Store.Repository; +using PlexRequests.UI.Models; + +namespace PlexRequests.UI.Modules.Admin +{ + public class FaultQueueModule : BaseModule + { + public FaultQueueModule(ISettingsService settingsService, ICacheProvider cache, IRepository requestQueue) : base("admin", settingsService) + { + Cache = cache; + RequestQueue = requestQueue; + + Security.HasPermissionsResponse(Permissions.Administrator); + + Get["Index", "/faultqueue"] = x => Index(); + } + + private ICacheProvider Cache { get; } + private IRepository RequestQueue { get; } + + private Negotiator Index() + { + var requests = RequestQueue.GetAll(); + + var model = requests.Select(r => new FaultedRequestsViewModel + { + FaultType = (FaultTypeViewModel)(int)r.FaultType, + Type = (RequestTypeViewModel)(int)r.Type, + Title = ByteConverterHelper.ReturnObject(r.Content).Title, + Id = r.Id, + PrimaryIdentifier = r.PrimaryIdentifier, + LastRetry = r.LastRetry + }).ToList(); + + return View["RequestFaultQueue", model]; + } + } +} \ No newline at end of file diff --git a/PlexRequests.UI/Modules/DonationLinkModule.cs b/PlexRequests.UI/Modules/DonationLinkModule.cs index 9ede62e41..5b3aec76a 100644 --- a/PlexRequests.UI/Modules/DonationLinkModule.cs +++ b/PlexRequests.UI/Modules/DonationLinkModule.cs @@ -2,14 +2,11 @@ using System.Threading.Tasks; using Nancy; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using NLog; using PlexRequests.Core; using PlexRequests.Core.SettingModels; using PlexRequests.Helpers; -using PlexRequests.UI.Models; namespace PlexRequests.UI.Modules { diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs index 1e0e4c490..0e72cf9c9 100644 --- a/PlexRequests.UI/Modules/SearchModule.cs +++ b/PlexRequests.UI/Modules/SearchModule.cs @@ -616,7 +616,7 @@ namespace PlexRequests.UI.Modules /// private async Task RequestTvShow(int showId, string seasons) { - if (Security.DoesNotHavePermissions(Permissions.ReadOnlyUser, User)) + if (Security.HasPermissions(User, Permissions.ReadOnlyUser)) { return Response.AsJson(new JsonResponseModel() diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj index 75ecd4701..82f401655 100644 --- a/PlexRequests.UI/PlexRequests.UI.csproj +++ b/PlexRequests.UI/PlexRequests.UI.csproj @@ -229,6 +229,7 @@ + @@ -241,6 +242,7 @@ + @@ -724,6 +726,9 @@ PreserveNewest + + Always + web.config diff --git a/PlexRequests.UI/Views/Admin/RequestFaultQueue.cshtml b/PlexRequests.UI/Views/Admin/RequestFaultQueue.cshtml new file mode 100644 index 000000000..0e1329c4d --- /dev/null +++ b/PlexRequests.UI/Views/Admin/RequestFaultQueue.cshtml @@ -0,0 +1,103 @@ +@using PlexRequests.UI.Helpers +@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase> +@Html.Partial("_Sidebar") +
+
+ Release Fault Queue + + + + + + + + + + + + + @foreach (var m in Model) + { + + + + + + + } + +
+ Request Title + + Type + + Fault Type + + LastRetry +
+ @m.Title + + @m.Type + + @m.FaultType + + @m.LastRetry +
+ +
+
+ +@**@ \ No newline at end of file diff --git a/PlexRequests.UI/Views/Admin/_Sidebar.cshtml b/PlexRequests.UI/Views/Admin/_Sidebar.cshtml index d65cd9848..836fc856f 100644 --- a/PlexRequests.UI/Views/Admin/_Sidebar.cshtml +++ b/PlexRequests.UI/Views/Admin/_Sidebar.cshtml @@ -18,5 +18,6 @@ @Html.GetSidebarUrl(Context, "/admin/logs", "Logs") @Html.GetSidebarUrl(Context, "/admin/status", "Status") @Html.GetSidebarUrl(Context, "/admin/scheduledjobs", "Scheduled Jobs") + @Html.GetSidebarUrl(Context, "/admin/faultqueue", "Request Fault Queue") \ No newline at end of file