Skip to content

Commit

Permalink
Add a delete ravenbot log
Browse files Browse the repository at this point in the history
  • Loading branch information
zerratar committed Jul 27, 2023
1 parent 61ae9b5 commit 65faa2a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/RavenNest.Blazor.Services/ServerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ public ServerService(
}

public GameData GameData => gameData;
public async Task<IReadOnlyList<RavenbotLogFile>> DeleteLogFileAsync(RavenbotLogFile file)
{

var currentDir = new DirectoryInfo(Directory.GetCurrentDirectory());
var logsFolder = new DirectoryInfo(Path.Combine(currentDir.Parent.FullName, "logs"));

var f = Path.Combine(logsFolder.FullName, file.FileName);
if (System.IO.File.Exists(f))
{
System.IO.File.Delete(f);
}

return await GetLogFilesAsync();
}


public async Task<IReadOnlyList<RavenbotLogFile>> GetLogFilesAsync()
{
Expand Down
6 changes: 6 additions & 0 deletions src/RavenNest.Blazor/Pages/Admin/RavenbotLogs.razor
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<td class='item'>@(FormatSize(item.FileSize))</td>
<td class='item'>
<a href="@(item.DownloadUrl)" target="_blank"><i class="fa-solid fa-download"></i></a>
<a @onclick="()=>DeleteLog(item)" target="_blank"><i class="fa-solid fa-trash"></i></a>
</td>
</tr>
}
Expand All @@ -61,6 +62,11 @@
{
return input.ToString("yyyy-MM-dd");
}

private async Task DeleteLog(RavenNest.Blazor.Services.RavenbotLogFile file)
{
logFiles = await ServerService.DeleteLogFileAsync(file);
}

private string FormatSize(long bytes)
{
Expand Down

0 comments on commit 65faa2a

Please sign in to comment.