Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanMillett committed Nov 9, 2024
1 parent c2f2aa7 commit 363478b
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions Pages/AdminPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
textarea
{
font-family: monospace;
resize: none;
min-width: 100%;
height: 500px;
Expand Down Expand Up @@ -138,21 +139,22 @@

if (HttpResponse.IsSuccessStatusCode)
{
LogText = JsonSerializer.Serialize(
JsonSerializer.Deserialize<JsonElement>(
await HttpResponse.Content.ReadAsStringAsync()),
new JsonSerializerOptions
{
WriteIndented = true
});

LogText = string.Join(Environment.NewLine, LogText
.Split(Environment.NewLine)
.Where(line => !line.Trim().StartsWith("{") &&
!line.Trim().StartsWith("}") &&
!line.Trim().StartsWith("[") &&
!line.Trim().StartsWith("]"))
.Select(line => line.Trim()));
List<DataNotificationLog>? DownloadedLogs = await HttpResponse.Content.ReadFromJsonAsync<List<DataNotificationLog>>();

LogText = "";

if (DownloadedLogs != null)
{
foreach (DataNotificationLog Log in DownloadedLogs)
{
string localTimeFormatted = Log.Timestamp.ToLocalTime().ToString("HH:mm:ss:fff");
LogText += $"[{localTimeFormatted}]\t#{Log.Id}\t{Log.Message}\n";
}
}
else
{
LogText = "No logs to download";
}
}
else if (HttpResponse.StatusCode == System.Net.HttpStatusCode.Unauthorized)
{
Expand Down Expand Up @@ -550,4 +552,11 @@
public required string Title { get; set; }
public required string Body { get; set; }
}

public class DataNotificationLog
{
public required int Id { get; set; }
public required string Message { get; set; }
public required DateTime Timestamp { get; set; }
}
}

0 comments on commit 363478b

Please sign in to comment.