|
|
@ -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!" });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|