Added the functionality for the admin to clear the issues.

pull/13/head
tidusjar 9 years ago
parent 0556e4d32b
commit 9ef618af4b

@ -33,10 +33,11 @@ namespace PlexRequests.Store
public enum IssueState
{
WrongAudio,
NoSubtitles,
WrongContent,
PlaybackIssues,
Other
None = 99,
WrongAudio = 0,
NoSubtitles = 1,
WrongContent = 2,
PlaybackIssues = 3,
Other = 4 // Provide a message
}
}

@ -20,7 +20,7 @@ $('#approveAll').click(function () {
dataType: "json",
success: function (response) {
if (checkJsonResponse(response)) {
generateNotify("Success!", "success");
generateNotify("Success! All requests approved!", "success");
}
},
error: function (e) {
@ -52,7 +52,7 @@ $(document).on("click", ".dropdownIssue", function (e) {
dataType: "json",
success: function (response) {
if (checkJsonResponse(response)) {
generateNotify("Success!", "success");
generateNotify("Success! Added Issue.", "success");
}
},
error: function (e) {
@ -66,7 +66,7 @@ $(document).on("click", ".dropdownIssue", function (e) {
$(".theSaveButton").click(function (e) {
var comment = $("#commentArea").val();
e.preventDefault();
var id = e.target.value;
var $form = $("#commentForm");
var data = $form.serialize();
data = data + "&issue=" + 4 + "&comment=" + comment;
@ -78,7 +78,7 @@ $(".theSaveButton").click(function (e) {
dataType: "json",
success: function (response) {
if (checkJsonResponse(response)) {
generateNotify("Success!", "success");
generateNotify("Success! Added Issue.", "success");
$("#myModal").modal("hide");
}
},
@ -100,6 +100,7 @@ $('#myModal').on('show.bs.modal', function (event) {
requestField.val(id); // Add ID to the hidden field
});
// Delete
$(document).on("click", ".delete", function (e) {
e.preventDefault();
var buttonId = e.target.id;
@ -113,7 +114,7 @@ $(document).on("click", ".delete", function (e) {
success: function (response) {
if (checkJsonResponse(response)) {
generateNotify("Success!", "success");
generateNotify("Success! Request Deleted.", "success");
$("#" + buttonId + "Template").slideUp();
}
@ -126,6 +127,32 @@ $(document).on("click", ".delete", function (e) {
});
// Clear issues
$(document).on("click", ".clear", function (e) {
e.preventDefault();
var buttonId = e.target.id;
var $form = $('#clear' + buttonId);
$.ajax({
type: $form.prop('method'),
url: $form.prop('action'),
data: $form.serialize(),
dataType: "json",
success: function (response) {
if (checkJsonResponse(response)) {
generateNotify("Success! Issues Cleared.", "info");
$('#issueArea').html("<p>Issue: None</p>");
}
},
error: function (e) {
console.log(e);
generateNotify("Something went wrong!", "danger");
}
});
});
function movieLoad() {
$("#movieList").html("");

@ -59,6 +59,8 @@ namespace PlexRequests.UI.Modules
Post["/reportissue"] = _ => ReportIssue((int)Request.Form.requestId, (IssueState)(int)Request.Form.issue, null);
Post["/reportissuecomment"] = _ => ReportIssue((int)Request.Form.requestId, IssueState.Other, (string)Request.Form.commentArea);
Post["/clearissues"] = _ => ClearIssue((int)Request.Form.requestId);
}
private IRepository<RequestedModel> Service { get; }
private ISettingsService<PlexRequestSettings> PrSettings { get; }
@ -163,5 +165,26 @@ namespace PlexRequests.UI.Modules
}
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not add issue, please try again or contact the administrator!" });
}
private Response ClearIssue(int requestId)
{
if (!Context.CurrentUser.IsAuthenticated())
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = "You are not an Admin, so you cannot clear any issues." });
}
var originalRequest = Service.Get(requestId);
if (originalRequest == null)
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Request does not exist to clear it!" });
}
originalRequest.Issues = IssueState.None;
originalRequest.OtherMessage = string.Empty;
var result = Service.Update(originalRequest);
return Response.AsJson(result
? new JsonResponseModel { Result = true }
: new JsonResponseModel { Result = false, Message = "Could not clear issue, please try again or check the logs" });
}
}
}

@ -184,7 +184,8 @@ namespace PlexRequests.UI.Modules
Status = movieInfo.Status,
RequestedDate = DateTime.Now,
Approved = false,
RequestedBy = Session[SessionKeys.UsernameKey].ToString()
RequestedBy = Session[SessionKeys.UsernameKey].ToString(),
Issues = IssueState.None,
};
@ -255,7 +256,8 @@ namespace PlexRequests.UI.Modules
Status = showInfo.status,
RequestedDate = DateTime.Now,
Approved = false,
RequestedBy = Session[SessionKeys.UsernameKey].ToString()
RequestedBy = Session[SessionKeys.UsernameKey].ToString(),
Issues = IssueState.None
};
RequestService.AddRequest(showId, model);

@ -93,12 +93,13 @@
</p>
<p>Requested By: {{requestedBy}}</p>
<p>Requested Date: {{requestedDate}}</p>
<div id="issueArea">
{{#if otherMessage}}
<p>Message: {{otherMessage}}</p>
{{else}}
<p>Issue: {{issues}}</p>
{{/if}}
</div>
</div>
<div class="col-sm-2 col-sm-push-3">
<br />
@ -108,6 +109,11 @@
<input name="Id" type="text" value="{{requestId}}" hidden="hidden" />
<button id="{{requestId}}" style="text-align: right" class="btn btn-danger delete" type="submit"><i class="fa fa-plus"></i> Remove</button>
</form>
<form method="POST" action="/requests/clearissues" id="clear{{requestId}}">
<input name="Id" type="text" value="{{requestId}}" hidden="hidden" />
<button id="{{requestId}}" style="text-align: right" class="btn btn-info clear" type="submit"><i class="fa fa-check"></i> Clear Issues</button>
</form>
{{/if_eq}}
<form method="POST" action="/requests/reportissue/" id="report{{requestId}}">

Loading…
Cancel
Save