diff --git a/PlexRequests.UI/Modules/AdminModule.cs b/PlexRequests.UI/Modules/AdminModule.cs index a6ebd486e..dcd11dff1 100644 --- a/PlexRequests.UI/Modules/AdminModule.cs +++ b/PlexRequests.UI/Modules/AdminModule.cs @@ -46,6 +46,8 @@ using NLog; using MarkdownSharp; +using Nancy.Responses; + using PlexRequests.Api; using PlexRequests.Api.Interfaces; using PlexRequests.Core; @@ -204,6 +206,8 @@ namespace PlexRequests.UI.Modules Get["/scheduledjobs", true] = async (x, ct) => await GetScheduledJobs(); Post["/scheduledjobs", true] = async (x, ct) => await SaveScheduledJobs(); + + Post["/clearlogs", true] = async (x, ct) => await ClearLogs(); } private async Task Authentication() @@ -888,5 +892,23 @@ namespace PlexRequests.UI.Modules ? new JsonResponseModel { Result = true } : new JsonResponseModel { Result = false, Message = "Could not save to Db Please check the logs" }); } + + private async Task ClearLogs() + { + try + { + var allLogs = await LogsRepo.GetAllAsync(); + foreach (var logEntity in allLogs) + { + await LogsRepo.DeleteAsync(logEntity); + } + return Response.AsJson(new JsonResponseModel { Result = true }); + } + catch (Exception e) + { + Log.Error(e); + return Response.AsJson(new JsonResponseModel { Result = false, Message = e.Message }); + } + } } } \ No newline at end of file diff --git a/PlexRequests.UI/Views/Admin/Logs.cshtml b/PlexRequests.UI/Views/Admin/Logs.cshtml index 9fc58d202..8e7b2a096 100644 --- a/PlexRequests.UI/Views/Admin/Logs.cshtml +++ b/PlexRequests.UI/Views/Admin/Logs.cshtml @@ -1,123 +1,151 @@ -@using PlexRequests.UI.Helpers -@Html.Partial("_Sidebar") -@Html.LoadTableAssets() - -@{ - var baseUrl = Html.GetBaseUrl(); - var formAction = "/admin/loglevel"; - if (!string.IsNullOrEmpty(baseUrl.ToHtmlString())) - { - formAction = "/" + baseUrl.ToHtmlString() + formAction; - } -} - -
-
- Logs -
-
- -
- -
-
-
-
- -
-
-
- - - - - - - - - - - -
MessageAreaLog LevelDate
-
-
- - - - \ No newline at end of file