blob: 87416a2c2ba051ce86e764a9806db762070c370f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
@page "/Dev/Utilities"
@using ArcaneLibs.Extensions
@using MatrixUtils.Abstractions
@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 roomId in Rooms) {
<a style="color: unset; text-decoration: unset;" href="/RoomStateViewer/@roomId.Replace('.', '~')">
<RoomListItem RoomInfo="@(new RoomInfo(hs.GetRoom(roomId)))" LoadData="true"></RoomListItem>
</a>
}
</details>
}
<details open>
<summary>Send GET request to URL</summary>
<div class="input-group">
<input type="text" class="form-control" @bind-value="GetRequestUrl" placeholder="URL">
<button class="btn btn-outline-secondary" type="button" @onclick="SendGetRequest">Send</button>
</div>
<br/>
<pre>@GetRequestResult</pre>
</details>
<div style="margin-bottom: 4em;"></div>
<LogView></LogView>
@code {
public List<string> Rooms { get; set; } = new();
public AuthenticatedHomeserverGeneric? hs { get; set; }
protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
hs = await RMUStorage.GetCurrentSessionOrNavigate();
if (hs == null) return;
Rooms = (await hs.GetJoinedRooms()).Select(x => x.RoomId).ToList();
Console.WriteLine("Fetched joined rooms!");
}
//send req
string GetRequestUrl { get; set; } = "";
string GetRequestResult { get; set; } = "";
private async Task SendGetRequest() {
var httpClient = hs?.ClientHttpClient;
try {
var res = await httpClient.GetAsync(GetRequestUrl);
if (res.IsSuccessStatusCode) {
if (res.Content.Headers.ContentType.MediaType == "application/json")
GetRequestResult = (await res.Content.ReadFromJsonAsync<object>()).ToJson();
else
GetRequestResult = await res.Content.ReadAsStringAsync();
StateHasChanged();
return;
}
if (res.Content.Headers.ContentType.MediaType == "application/json")
GetRequestResult = $"Error: {res.StatusCode}\n" + (await res.Content.ReadFromJsonAsync<object>()).ToJson();
else
GetRequestResult = $"Error: {res.StatusCode}\n" + await res.Content.ReadAsStringAsync();
}
catch (Exception e) {
GetRequestResult = $"Error: {e}";
}
StateHasChanged();
}
}
|