From fc749b3e57098740377e6eabd5d010d133256fa5 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Tue, 13 Jun 2023 01:49:10 +0200 Subject: Improved many features --- MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor | 86 +++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor (limited to 'MatrixRoomUtils.Web/Pages/HSAdmin') diff --git a/MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor b/MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor new file mode 100644 index 0000000..109ad7d --- /dev/null +++ b/MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor @@ -0,0 +1,86 @@ +@page "/RoomQuery" +@using MatrixRoomUtils.Core.Extensions +@using System.Runtime.InteropServices +@using System.ComponentModel +@using MatrixRoomUtils.Core.Responses.Admin +

Homeserver Administration - Room Query

+ + +
+ +
+ +
+ +
+ +
+ +@foreach (var res in Results) +{ +
+ +

@res.CanonicalAlias, created by

+

@res.StateEvents state events

+

@res.JoinedMembers members, of which @res.JoinedLocalMembers are on this server

+
+} + +@code { + + [Parameter, SupplyParameterFromQuery(Name = "order_by")] + public string? OrderBy { get; set; } + + [Parameter, SupplyParameterFromQuery(Name = "search_term")] + public string SearchTerm { get; set; } + + [Parameter, SupplyParameterFromQuery(Name = "content_search_term")] + public string ContentSearchTerm { get; set; } + + [Parameter, SupplyParameterFromQuery(Name = "ascending")] + public bool Ascending { get; set; } + + public List Results { get; set; } = new(); + + protected override async Task OnParametersSetAsync() + { + if(Ascending == null) + Ascending = true; + OrderBy ??= "name"; + } + + private async Task Search() + { + Results.Clear(); + var searchRooms = RuntimeCache.CurrentHomeServer.Admin.SearchRoomsAsync(orderBy: OrderBy!, dir: Ascending ? "f" : "b", searchTerm: SearchTerm, contentSearch: ContentSearchTerm).GetAsyncEnumerator(); + while (await searchRooms.MoveNextAsync()) + { + var room = searchRooms.Current; + Console.WriteLine("Hit: " + room.ToJson(indent: false)); + Results.Add(room); + } + } + + private Dictionary validOrderBy = new Dictionary() + { + { "name", "Room name" }, + { "canonical_alias", "Main alias address" }, + { "joined_members", "Number of members (reversed)" }, + { "joined_local_members", "Number of local members (reversed)" }, + { "version", "Room version" }, + { "creator", "Creator of the room" }, + { "encryption", "End-to-end encryption algorithm" }, + { "federatable", "Is room federated" }, + { "public", "Visibility in room list" }, + { "join_rules", "Join rules" }, + { "guest_access", "Guest access" }, + { "history_visibility", "Visibility of history" }, + { "state_events", "Number of state events" }, + }; + +} \ No newline at end of file -- cgit 1.4.1