From ce7be6bbdf0edf069cb50aee64df187609893b92 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Sat, 17 Jun 2023 20:58:51 +0200 Subject: Start refactor --- MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor | 115 +++++++++++++++++++-- .../Pages/HSAdmin/RoomQuery.razor.css | 0 MatrixRoomUtils.Web/Pages/ModalTest.razor | 102 ++++++++++++++++++ 3 files changed, 207 insertions(+), 10 deletions(-) create mode 100644 MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor.css create mode 100644 MatrixRoomUtils.Web/Pages/ModalTest.razor (limited to 'MatrixRoomUtils.Web/Pages') diff --git a/MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor b/MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor index a62362b..1fe13bd 100644 --- a/MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor +++ b/MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor @@ -1,12 +1,13 @@ @page "/HSAdmin/RoomQuery" @using MatrixRoomUtils.Core.Extensions +@using MatrixRoomUtils.Core.Filters @using MatrixRoomUtils.Core.Responses.Admin +@using MatrixRoomUtils.Web.Shared.SimpleComponents +

Homeserver Administration - Room Query


- -


+
+ + Local filtering (slow) + + +
+ String contains + Room ID: + Room name: + Canonical alias: + Creator: + Room version: + Encryption algorithm: + Join rules: + Guest access: + History visibility: + + Optional checks + + Is federated: + @if (Filter.CheckFederation) { + + } + + + Is public: + @if (Filter.CheckPublic) { + + } + + + Ranges + + state events + + + members + + + local members + +
+

@if (Results.Count > 0) {

Found @Results.Count rooms

+
+ TSV data (copy/paste) +
+            
+                @foreach (var res in Results) {
+                    
+                        
+                        
+                        
+                        
+                    
+                }
+            
@res.RoomId@("\t")@res.CanonicalAlias@("\t")@res.Creator@("\t")@res.Name
+
+
} @foreach (var res in Results) { @@ -27,20 +86,58 @@

@if (!string.IsNullOrWhiteSpace(res.CanonicalAlias)) { - @res.CanonicalAlias (@res.RoomId)
+ @res.CanonicalAlias (@res.RoomId) +
} else { - @res.RoomId
+ @res.RoomId +
} @if (!string.IsNullOrWhiteSpace(res.Creator)) { - Created by
+ Created by +
}

@res.StateEvents state events
@res.JoinedMembers members, of which @res.JoinedLocalMembers are on this server +
+ Full result data +
@res.ToJson(ignoreNull: true)
+
} + + @code { [Parameter] @@ -51,10 +148,6 @@ [SupplyParameterFromQuery(Name = "name_search")] public string SearchTerm { get; set; } - [Parameter] - [SupplyParameterFromQuery(Name = "content_search")] - public string ContentSearchTerm { get; set; } - [Parameter] [SupplyParameterFromQuery(Name = "ascending")] public bool Ascending { get; set; } @@ -63,6 +156,8 @@ private string Status { get; set; } + public LocalRoomQueryFilter Filter { get; set; } = new(); + protected override async Task OnParametersSetAsync() { if (Ascending == null) Ascending = true; @@ -71,7 +166,7 @@ private async Task Search() { Results.Clear(); - var searchRooms = RuntimeCache.CurrentHomeServer.Admin.SearchRoomsAsync(orderBy: OrderBy!, dir: Ascending ? "f" : "b", searchTerm: SearchTerm, contentSearch: ContentSearchTerm).GetAsyncEnumerator(); + var searchRooms = RuntimeCache.CurrentHomeServer.Admin.SearchRoomsAsync(orderBy: OrderBy!, dir: Ascending ? "f" : "b", searchTerm: SearchTerm, localFilter: Filter).GetAsyncEnumerator(); while (await searchRooms.MoveNextAsync()) { var room = searchRooms.Current; Console.WriteLine("Hit: " + room.ToJson(false)); diff --git a/MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor.css b/MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor.css new file mode 100644 index 0000000..e69de29 diff --git a/MatrixRoomUtils.Web/Pages/ModalTest.razor b/MatrixRoomUtils.Web/Pages/ModalTest.razor new file mode 100644 index 0000000..d031dc2 --- /dev/null +++ b/MatrixRoomUtils.Web/Pages/ModalTest.razor @@ -0,0 +1,102 @@ +@page "/ModalTest" +@inject IJSRuntime JsRuntime +

ModalTest

+ +@foreach (var (key, value) in _windowInfos) { + @* @value.Content *@ +} +@for (int i = 0; i < 5; i++) { + var i1 = i; + + @for (int j = 0; j < i1; j++) { +

@j

+ } +
+} + +@code { + + private Dictionary _windowInfos = new Dictionary(); + + private class WindowInfo { + public double X; + public double Y; + public string Title; + public RenderFragment Content; + } + + protected override async Task OnInitializedAsync() { + double _x = 2; + double _xv = 20; + double _y = 0; + double multiplier = 1; + + await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage); + //var rooms = await RuntimeCache.CurrentHomeServer.GetJoinedRooms(); + + //rooms.ForEach(async room => { + // var name = await room.GetNameAsync(); + // _windowInfos.Add(_windowInfos.Count, new WindowInfo() { X = _x, Y = _y, Title = name}); + // _x += 20; + // _y += 20; + // var dimension = await JsRuntime.InvokeAsync("getWindowDimensions"); + // if (_x > dimension.Width - 100) _x %= dimension.Width - 100; + // if (_y > dimension.Height - 50) _y %= dimension.Height - 50; + // StateHasChanged(); + //}); + + for (int i = 0; i < 200; i++) { + var i1 = i; + _windowInfos.Add(_windowInfos.Count, new WindowInfo() { + X = _x, + Y = _y, + Title = "Win" + i1, + Content = builder => { + builder.OpenComponent(0); + builder.AddAttribute(1, "X", _x); + builder.AddAttribute(2, "Y", _y); + builder.AddAttribute(3, "Title", "Win" + i1); + builder.AddAttribute(4, "ChildContent", (RenderFragment)(builder2 => { + builder2.OpenElement(0, "h1"); + builder2.AddContent(1, "Hello " + i1); + builder2.CloseElement(); + })); + builder.CloseComponent(); + } + }); + //_x += _xv /= 1000/System.Math.Sqrt((double)_windowInfos.Count)*_windowInfos.Count.ToString().Length*multiplier; + _y += 20; + _x += 20; + var dimension = await JsRuntime.InvokeAsync("getWindowDimensions"); + if (_x > dimension.Width - 100) _x %= dimension.Width - 100; + if (_y > dimension.Height - 50) { + _y %= dimension.Height - 50; + _xv = 20; + } + if ( + (_windowInfos.Count < 10 && _windowInfos.Count % 2 == 0) || + (_windowInfos.Count < 100 && _windowInfos.Count % 10 == 0) || + (_windowInfos.Count < 1000 && _windowInfos.Count % 50 == 0) || + (_windowInfos.Count < 10000 && _windowInfos.Count % 100 == 0) + ) { + StateHasChanged(); + await Task.Delay(25); + } + if(_windowInfos.Count > 750) multiplier = 2; + if(_windowInfos.Count > 1500) multiplier = 3; + + } + + await base.OnInitializedAsync(); + } + + private void OnCloseClicked(int i1) { + Console.WriteLine("Close clicked on " + i1); + } + + public class WindowDimension { + public int Width { get; set; } + public int Height { get; set; } + } + +} -- cgit 1.5.1