diff --git a/PlexRequests.Store/RequestedModel.cs b/PlexRequests.Store/RequestedModel.cs
index acc76320d..247433329 100644
--- a/PlexRequests.Store/RequestedModel.cs
+++ b/PlexRequests.Store/RequestedModel.cs
@@ -24,6 +24,7 @@ namespace PlexRequests.Store
public IssueState Issues { get; set; }
public string OtherMessage { get; set; }
public bool LatestTv { get; set; }
+ public string AdminNote { get; set; }
}
public enum RequestType
diff --git a/PlexRequests.Store/SqlTables.sql b/PlexRequests.Store/SqlTables.sql
index 1ea81ddce..08401d5ef 100644
--- a/PlexRequests.Store/SqlTables.sql
+++ b/PlexRequests.Store/SqlTables.sql
@@ -27,6 +27,7 @@ CREATE TABLE IF NOT EXISTS Requested
PosterPath varchar(50) NOT NULL,
ReleaseDate varchar(50) NOT NULL,
Status varchar(50) NOT NULL,
+ AdminNote varchar(50),
Approved INTEGER NOT NULL,
LatestTv INTEGER NOT NULL,
RequestedBy varchar(50),
diff --git a/PlexRequests.UI/Content/requests.js b/PlexRequests.UI/Content/requests.js
index 371fe8c51..756283b3b 100644
--- a/PlexRequests.UI/Content/requests.js
+++ b/PlexRequests.UI/Content/requests.js
@@ -90,6 +90,34 @@ $(".theSaveButton").click(function (e) {
});
});
+// Note Modal click
+$(".theNoteSaveButton").click(function (e) {
+ var comment = $("#noteArea").val();
+ e.preventDefault();
+
+ var $form = $("#noteForm");
+ var data = $form.serialize();
+
+
+ $.ajax({
+ type: $form.prop("method"),
+ url: $form.prop("action"),
+ data: data,
+ dataType: "json",
+ success: function (response) {
+ if (checkJsonResponse(response)) {
+ generateNotify("Success! Added Note.", "success");
+ $("#myModal").modal("hide");
+ $('#adminNotesArea').html("
Note from Admin: " + comment + "
");
+ }
+ },
+ error: function (e) {
+ console.log(e);
+ generateNotify("Something went wrong!", "danger");
+ }
+ });
+});
+
// Update the modal
$('#myModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget); // Button that triggered the modal
@@ -101,6 +129,17 @@ $('#myModal').on('show.bs.modal', function (event) {
requestField.val(id); // Add ID to the hidden field
});
+// Update the note modal
+$('#noteModal').on('show.bs.modal', function (event) {
+ var button = $(event.relatedTarget); // Button that triggered the modal
+ var id = button.data('identifier'); // Extract info from data-* attributes
+
+ var modal = $(this);
+ modal.find('.theNoteSaveButton').val(id); // Add ID to the button
+ var requestField = modal.find('input');
+ requestField.val(id); // Add ID to the hidden field
+});
+
// Delete
$(document).on("click", ".delete", function (e) {
e.preventDefault();
@@ -268,7 +307,8 @@ function buildRequestContext(result, type) {
admin: result.admin,
issues: result.issues,
otherMessage: result.otherMessage,
- requestId: result.id
+ requestId: result.id,
+ adminNote: result.adminNotes
};
return context;
diff --git a/PlexRequests.UI/Models/RequestViewModel.cs b/PlexRequests.UI/Models/RequestViewModel.cs
index c6e91b9bb..6018b50b1 100644
--- a/PlexRequests.UI/Models/RequestViewModel.cs
+++ b/PlexRequests.UI/Models/RequestViewModel.cs
@@ -47,5 +47,6 @@ namespace PlexRequests.UI.Models
public bool Admin { get; set; }
public string Issues { get; set; }
public string OtherMessage { get; set; }
+ public string AdminNotes { get; set; }
}
}
diff --git a/PlexRequests.UI/Modules/RequestsModule.cs b/PlexRequests.UI/Modules/RequestsModule.cs
index 1b60f7aa3..239b98e4a 100644
--- a/PlexRequests.UI/Modules/RequestsModule.cs
+++ b/PlexRequests.UI/Modules/RequestsModule.cs
@@ -61,7 +61,9 @@ namespace PlexRequests.UI.Modules
Post["/clearissues"] = _ => ClearIssue((int)Request.Form.Id);
Post["/changeavailability"] = _ => ChangeRequestAvailability((int)Request.Form.Id, (bool)Request.Form.Available);
+ Post["/addnote"] = _ => AddNote((int)Request.Form.Id, (string)Request.Form.noteArea);
}
+
private IRepository Service { get; }
private ISettingsService PrSettings { get; }
private ISettingsService PlexSettings { get; }
@@ -94,7 +96,8 @@ namespace PlexRequests.UI.Modules
Available = movie.Available,
Admin = isAdmin,
Issues = movie.Issues.Humanize(LetterCasing.Title),
- OtherMessage = movie.OtherMessage
+ OtherMessage = movie.OtherMessage,
+ AdminNotes = movie.AdminNote
}).ToList();
return Response.AsJson(viewModel);
@@ -122,7 +125,8 @@ namespace PlexRequests.UI.Modules
Available = tv.Available,
Admin = isAdmin,
Issues = tv.Issues.Humanize(LetterCasing.Title),
- OtherMessage = tv.OtherMessage
+ OtherMessage = tv.OtherMessage,
+ AdminNotes = tv.AdminNote
}).ToList();
return Response.AsJson(viewModel);
@@ -156,14 +160,14 @@ namespace PlexRequests.UI.Modules
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not add issue, please try again or contact the administrator!" });
}
originalRequest.Issues = issue;
- originalRequest.OtherMessage = !string.IsNullOrEmpty(comment)
- ? $"{Session[SessionKeys.UsernameKey]} - {comment}"
+ originalRequest.OtherMessage = !string.IsNullOrEmpty(comment)
+ ? $"{Session[SessionKeys.UsernameKey]} - {comment}"
: string.Empty;
var result = Service.Update(originalRequest);
return Response.AsJson(result
- ? new JsonResponseModel { Result = true }
+ ? new JsonResponseModel { Result = true }
: new JsonResponseModel { Result = false, Message = "Could not add issue, please try again or contact the administrator!" });
}
@@ -183,8 +187,8 @@ namespace PlexRequests.UI.Modules
originalRequest.OtherMessage = string.Empty;
var result = Service.Update(originalRequest);
- return Response.AsJson(result
- ? new JsonResponseModel { Result = true }
+ return Response.AsJson(result
+ ? new JsonResponseModel { Result = true }
: new JsonResponseModel { Result = false, Message = "Could not clear issue, please try again or check the logs" });
}
@@ -200,8 +204,24 @@ namespace PlexRequests.UI.Modules
var result = Service.Update(originalRequest);
return Response.AsJson(result
- ? new {Result = true, Available = available, Message = string.Empty}
- : new { Result = false, Available=false, Message = "Could not update the availability, please try again or check the logs" });
+ ? new { Result = true, Available = available, Message = string.Empty }
+ : new { Result = false, Available = false, Message = "Could not update the availability, please try again or check the logs" });
+ }
+
+ private Response AddNote(int requestId, string noteArea)
+ {
+ var originalRequest = Service.Get(requestId);
+ if (originalRequest == null)
+ {
+ return Response.AsJson(new JsonResponseModel { Result = false, Message = "Request does not exist to change the availability!" });
+ }
+
+ originalRequest.AdminNote = noteArea;
+
+ var result = Service.Update(originalRequest);
+ return Response.AsJson(result
+ ? new JsonResponseModel { Result = true }
+ : new JsonResponseModel { Result = false, Message = "Could not update the notes, please try again or check the logs" });
}
}
}
\ No newline at end of file
diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs
index 1a320cf7d..cf9c81531 100644
--- a/PlexRequests.UI/Modules/SearchModule.cs
+++ b/PlexRequests.UI/Modules/SearchModule.cs
@@ -189,10 +189,12 @@ namespace PlexRequests.UI.Modules
Log.Trace("Getting movie info from TheMovieDb");
Log.Trace(movieInfo.DumpJson);
+#if !DEBUG
if (CheckIfTitleExistsInPlex(movieInfo.Title))
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{movieInfo.Title} is already in Plex!" });
}
+#endif
var model = new RequestedModel
{
@@ -263,10 +265,12 @@ namespace PlexRequests.UI.Modules
var showInfo = tvApi.GetInformation(showId, token).data;
+#if !DEBUG
if (CheckIfTitleExistsInPlex(showInfo.seriesName))
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{showInfo.seriesName} is already in Plex!" });
}
+#endif
DateTime firstAir;
DateTime.TryParse(showInfo.firstAired, out firstAir);
diff --git a/PlexRequests.UI/Views/Requests/Index.cshtml b/PlexRequests.UI/Views/Requests/Index.cshtml
index e12d6cd80..6aeadfb7f 100644
--- a/PlexRequests.UI/Views/Requests/Index.cshtml
+++ b/PlexRequests.UI/Views/Requests/Index.cshtml
@@ -5,8 +5,8 @@
@if (Context.CurrentUser.IsAuthenticated())
{
-
-
+
+
}
@@ -102,10 +102,13 @@
Issue: {{issues}}
{{/if}}
+
+ {{#if adminNote}}
+
Note from Admin: {{adminNote}}
+ {{/if}}
+
-
-
{{#if_eq admin true}}
{{#if_eq approved false}}
-
+
+ {{#if_eq admin true}}
+
+
+
+ {{/if_eq}}
@* // TODO add Issues to the view *@
@@ -170,7 +178,7 @@
@@ -178,4 +186,25 @@
+
+