mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
Finished #337
This commit is contained in:
parent
a9237db313
commit
6aae347297
2 changed files with 172 additions and 122 deletions
|
@ -46,6 +46,8 @@ using NLog;
|
||||||
|
|
||||||
using MarkdownSharp;
|
using MarkdownSharp;
|
||||||
|
|
||||||
|
using Nancy.Responses;
|
||||||
|
|
||||||
using PlexRequests.Api;
|
using PlexRequests.Api;
|
||||||
using PlexRequests.Api.Interfaces;
|
using PlexRequests.Api.Interfaces;
|
||||||
using PlexRequests.Core;
|
using PlexRequests.Core;
|
||||||
|
@ -204,6 +206,8 @@ namespace PlexRequests.UI.Modules
|
||||||
|
|
||||||
Get["/scheduledjobs", true] = async (x, ct) => await GetScheduledJobs();
|
Get["/scheduledjobs", true] = async (x, ct) => await GetScheduledJobs();
|
||||||
Post["/scheduledjobs", true] = async (x, ct) => await SaveScheduledJobs();
|
Post["/scheduledjobs", true] = async (x, ct) => await SaveScheduledJobs();
|
||||||
|
|
||||||
|
Post["/clearlogs", true] = async (x, ct) => await ClearLogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Negotiator> Authentication()
|
private async Task<Negotiator> Authentication()
|
||||||
|
@ -888,5 +892,23 @@ namespace PlexRequests.UI.Modules
|
||||||
? new JsonResponseModel { Result = true }
|
? new JsonResponseModel { Result = true }
|
||||||
: new JsonResponseModel { Result = false, Message = "Could not save to Db Please check the logs" });
|
: new JsonResponseModel { Result = false, Message = "Could not save to Db Please check the logs" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<Response> 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 });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,9 +5,11 @@
|
||||||
@{
|
@{
|
||||||
var baseUrl = Html.GetBaseUrl();
|
var baseUrl = Html.GetBaseUrl();
|
||||||
var formAction = "/admin/loglevel";
|
var formAction = "/admin/loglevel";
|
||||||
|
var clearAction = "/admin/clearlogs";
|
||||||
if (!string.IsNullOrEmpty(baseUrl.ToHtmlString()))
|
if (!string.IsNullOrEmpty(baseUrl.ToHtmlString()))
|
||||||
{
|
{
|
||||||
formAction = "/" + baseUrl.ToHtmlString() + formAction;
|
formAction = "/" + baseUrl.ToHtmlString() + formAction;
|
||||||
|
clearAction = "/" + baseUrl.ToHtmlString() + clearAction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +37,10 @@
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<form method="post" id="clearForm" action="@clearAction">
|
||||||
|
<button id="clearLogs" type="submit" class="btn btn-danger-outline ">Clear Logs</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
<table id="example" class="table table-striped table-hover table-responsive">
|
<table id="example" class="table table-striped table-hover table-responsive">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -118,6 +124,28 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#clearLogs').click(function() {
|
||||||
|
e.preventDefault();
|
||||||
|
var $form = $("#clearForm");
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: $form.prop("method"),
|
||||||
|
url: $form.prop("action"),
|
||||||
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
|
if (response.result === true) {
|
||||||
|
generateNotify(response.message, "success");
|
||||||
|
} else {
|
||||||
|
generateNotify(response.message, "warning");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue