pull/332/head
tidusjar 9 years ago
parent e7aba8a4c8
commit 9d4881032d

@ -42,6 +42,7 @@ namespace PlexRequests.Core.Models
public List<IssueModel> Issues { get; set; } public List<IssueModel> Issues { get; set; }
public bool Deleted { get; set; } public bool Deleted { get; set; }
public RequestType Type { get; set; } public RequestType Type { get; set; }
public IssueStatus IssueStatus { get; set; }
} }
public class IssueModel public class IssueModel
@ -50,7 +51,6 @@ namespace PlexRequests.Core.Models
public string UserReported { get; set; } public string UserReported { get; set; }
public IssueState Issue { get; set; } public IssueState Issue { get; set; }
public string AdminNote { get; set; } public string AdminNote { get; set; }
public IssueStatus IssueStatus { get; set; }
} }
public enum IssueStatus public enum IssueStatus

@ -57,13 +57,13 @@ namespace PlexRequests.Core
var version = CheckSchema(); var version = CheckSchema();
if (version > 0) if (version > 0)
{ {
if (version > 1700 && version <= 1799) if (version > 1700 && version <= 1759)
{ {
MigrateToVersion1700(); MigrateToVersion1700();
} }
if (version > 1800 && version <= 1899) if (version > 1759 && version <= 1799)
{ {
MigrateToVersion1800(); MigrateToVersion1760();
} }
} }
@ -183,7 +183,7 @@ namespace PlexRequests.Core
/// <para>This includes updating the admin account to have all roles.</para> /// <para>This includes updating the admin account to have all roles.</para>
/// <para>Set the log level to info</para> /// <para>Set the log level to info</para>
/// </summary> /// </summary>
private void MigrateToVersion1800() private void MigrateToVersion1760()
{ {
try try
{ {

@ -5,10 +5,14 @@ using System.Threading.Tasks;
using Nancy; using Nancy;
using Nancy.Responses.Negotiation; using Nancy.Responses.Negotiation;
using Nancy.Security;
using NLog;
using PlexRequests.Core; using PlexRequests.Core;
using PlexRequests.Core.Models; using PlexRequests.Core.Models;
using PlexRequests.Core.SettingModels; using PlexRequests.Core.SettingModels;
using PlexRequests.Helpers;
using PlexRequests.Store; using PlexRequests.Store;
using PlexRequests.UI.Models; using PlexRequests.UI.Models;
@ -23,22 +27,37 @@ namespace PlexRequests.UI.Modules
Get["/"] = x => Index(); Get["/"] = x => Index();
Get["/issuecount", true] = async (x, ct) => await IssueCount();
Get["/{id}", true] = async (x, ct) => await Details(x.id); Get["/{id}", true] = async (x, ct) => await Details(x.id);
Post["/issue", true] = async (x, ct) => await ReportIssue((int)Request.Form.requestId, (IssueState)(int)Request.Form.issue, null); Post["/issue", true] = async (x, ct) => await ReportIssue((int)Request.Form.requestId, (IssueState)(int)Request.Form.issue, null);
Get["/inprogress", true] = async (x, ct) => await GetInProgressIssues(IssueStatus.InProgressIssue);
Get["/pending", true] = async (x, ct) => await GetInProgressIssues(IssueStatus.PendingIssue);
Get["/resolved", true] = async (x, ct) => await GetInProgressIssues(IssueStatus.ResolvedIssue);
Post["/remove", true] = async (x, ct) => await RemoveIssue((int)Request.Form.issueId);
Get["/issuecount", true] = async (x, ct) => await IssueCount();
Post["/issuecomment", true] = async (x, ct) => await ReportIssue((int)Request.Form.requestId, IssueState.Other, (string)Request.Form.commentArea); Post["/issuecomment", true] = async (x, ct) => await ReportIssue((int)Request.Form.requestId, IssueState.Other, (string)Request.Form.commentArea);
} }
private IIssueService IssuesService { get; } private IIssueService IssuesService { get; }
private IRequestService RequestService { get; } private IRequestService RequestService { get; }
private static Logger Log = LogManager.GetCurrentClassLogger();
public Negotiator Index() public Negotiator Index()
{ {
return View["Index"]; return View["Index"];
} }
private async Task<Response> GetInProgressIssues(IssueStatus status)
{
var issues = await IssuesService.GetAllAsync();
return Response.AsJson(issues.Where(x => x.IssueStatus == status));
}
public async Task<Response> IssueCount() public async Task<Response> IssueCount()
{ {
var issues = await IssuesService.GetAllAsync(); var issues = await IssuesService.GetAllAsync();
@ -52,7 +71,6 @@ namespace PlexRequests.UI.Modules
public async Task<Negotiator> Details(int id) public async Task<Negotiator> Details(int id)
{ {
var issue = await IssuesService.GetAsync(id); var issue = await IssuesService.GetAsync(id);
return issue == null return issue == null
@ -66,7 +84,6 @@ namespace PlexRequests.UI.Modules
var model = new IssueModel var model = new IssueModel
{ {
Issue = issue, Issue = issue,
IssueStatus = IssueStatus.PendingIssue,
UserReported = Username, UserReported = Username,
UserNote = !string.IsNullOrEmpty(comment) UserNote = !string.IsNullOrEmpty(comment)
? $"{Username} - {comment}" ? $"{Username} - {comment}"
@ -95,7 +112,8 @@ namespace PlexRequests.UI.Modules
Title = request.Title, Title = request.Title,
PosterUrl = request.PosterPath, PosterUrl = request.PosterPath,
RequestId = requestId, RequestId = requestId,
Type = request.Type Type = request.Type,
IssueStatus = IssueStatus.PendingIssue
}; };
issues.Issues.Add(model); issues.Issues.Add(model);
@ -130,6 +148,24 @@ namespace PlexRequests.UI.Modules
return myIssues; return myIssues;
} }
private async Task<Response> RemoveIssue(int issueId)
{
try
{
this.RequiresClaims(UserClaims.PowerUser);
await IssuesService.DeleteIssueAsync(issueId);
return Response.AsJson(new JsonResponseModel {Result = true, Message = "Issue Removed"});
}
catch (Exception e)
{
Log.Error(e);
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Looks like we couldn't remove the issue. Check the logs!" });
}
}
} }
} }

Loading…
Cancel
Save