about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Pages/DebugTools.razor
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-19 07:21:41 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-19 07:21:41 +0200
commit063fb6f12aea3a5b71c05beea22e7f6482c2f1cf (patch)
tree064aa9edd5a27017f95ed0a6b19ac69499005778 /MatrixRoomUtils.Web/Pages/DebugTools.razor
parentAdd user management page (diff)
downloadMatrixUtils-063fb6f12aea3a5b71c05beea22e7f6482c2f1cf.tar.xz
Refactor, fix stuff
Diffstat (limited to 'MatrixRoomUtils.Web/Pages/DebugTools.razor')
-rw-r--r--MatrixRoomUtils.Web/Pages/DebugTools.razor80
1 files changed, 0 insertions, 80 deletions
diff --git a/MatrixRoomUtils.Web/Pages/DebugTools.razor b/MatrixRoomUtils.Web/Pages/DebugTools.razor
deleted file mode 100644

index 5d47277..0000000 --- a/MatrixRoomUtils.Web/Pages/DebugTools.razor +++ /dev/null
@@ -1,80 +0,0 @@ -@page "/Debug" -@using System.Reflection -@using ArcaneLibs.Extensions -@using LibMatrix -@using LibMatrix.Extensions -@using LibMatrix.Homeservers -@inject ILocalStorageService LocalStorage -@inject NavigationManager NavigationManager -<h3>Debug Tools</h3> -<hr/> -@if (Rooms.Count == 0) { - <p>You are not in any rooms!</p> - @* <p>Loading progress: @checkedRoomCount/@totalRoomCount</p> *@ -} -else { - <details> - <summary>Room List</summary> - @foreach (var room in Rooms) { - <a style="color: unset; text-decoration: unset;" href="/RoomStateViewer/@room.Replace('.', '~')"> - <RoomListItem RoomId="@room"></RoomListItem> - </a> - } - </details> -} - -<details open> - <summary>Send GET request to URL</summary> - <div class="input-group"> - <input type="text" class="form-control" @bind-value="get_request_url" placeholder="URL"> - <button class="btn btn-outline-secondary" type="button" @onclick="SendGetRequest">Send</button> - </div> - <br/> - <pre>@get_request_result</pre> -</details> - -<div style="margin-bottom: 4em;"></div> -<LogView></LogView> - -@code { - public List<string> Rooms { get; set; } = new(); - - protected override async Task OnInitializedAsync() { - await base.OnInitializedAsync(); - var hs = await MRUStorage.GetCurrentSessionOrNavigate(); - if (hs == null) return; - Rooms = (await hs.GetJoinedRooms()).Select(x => x.RoomId).ToList(); - Console.WriteLine("Fetched joined rooms!"); - } - - //send req - string get_request_url { get; set; } = ""; - string get_request_result { get; set; } = ""; - - private async Task SendGetRequest() { - var field = typeof(RemoteHomeServer).GetRuntimeFields().First(x => x.ToString().Contains("<_httpClient>k__BackingField")); - var hs = await MRUStorage.GetCurrentSessionOrNavigate(); - if (hs == null) return; - var httpClient = field.GetValue(hs) as MatrixHttpClient; - try { - var res = await httpClient.GetAsync(get_request_url); - if (res.IsSuccessStatusCode) { - if (res.Content.Headers.ContentType.MediaType == "application/json") - get_request_result = (await res.Content.ReadFromJsonAsync<object>()).ToJson(); - else - get_request_result = await res.Content.ReadAsStringAsync(); - StateHasChanged(); - return; - } - if (res.Content.Headers.ContentType.MediaType == "application/json") - get_request_result = $"Error: {res.StatusCode}\n" + (await res.Content.ReadFromJsonAsync<object>()).ToJson(); - else - get_request_result = $"Error: {res.StatusCode}\n" + await res.Content.ReadAsStringAsync(); - } - catch (Exception e) { - get_request_result = $"Error: {e}"; - } - StateHasChanged(); - } - -}