diff options
author | Rory& <root@rory.gay> | 2024-05-14 17:49:09 +0200 |
---|---|---|
committer | Rory& <root@rory.gay> | 2024-05-14 17:49:09 +0200 |
commit | 41c5a84dacfd036b8d8f01f72226ac5a519995e3 (patch) | |
tree | a4bfc76541692cbbb0fc18f34463cf31a57440f5 /MatrixUtils.Web/Pages/Moderation | |
parent | Improve the heatmap layout (diff) | |
download | MatrixUtils-41c5a84dacfd036b8d8f01f72226ac5a519995e3.tar.xz |
Organise tools somewhat, set proper icons for nav menu
Diffstat (limited to 'MatrixUtils.Web/Pages/Moderation')
-rw-r--r-- | MatrixUtils.Web/Pages/Moderation/DraupnirProtectedRoomsEditor.razor | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/MatrixUtils.Web/Pages/Moderation/DraupnirProtectedRoomsEditor.razor b/MatrixUtils.Web/Pages/Moderation/DraupnirProtectedRoomsEditor.razor deleted file mode 100644 index f9cbfa2..0000000 --- a/MatrixUtils.Web/Pages/Moderation/DraupnirProtectedRoomsEditor.razor +++ /dev/null @@ -1,99 +0,0 @@ -@page "/Moderation/DraupnirProtectedRoomsEditor" -@using System.Text.Json.Serialization -@using LibMatrix.EventTypes.Spec.State -@using LibMatrix.RoomTypes -<h3>Edit Draupnir protected rooms</h3> -<hr/> - -@if (data is not null) { - <div class="row"> - <div class="col-12"> - <h4>Current rooms</h4> - <ul> - @foreach (var room in data.Rooms) { - <li>@room</li> - } - </ul> - <hr/> - <h4>Tickyboxes</h4> - <table class="table"> - <thead> - <tr> - <th></th> @* Checkbox column *@ - <th>Kick?</th> @* PL > kick *@ - <th>Ban?</th> @* PL > ban *@ - <th>ACL?</th> @* PL > m.room.server_acls event *@ - <th>Room ID</th> - <th>Room name</th> - </tr> - </thead> - <tbody> - @foreach (var room in Rooms.OrderBy(x => x.RoomName)) { - <tr> - <td> - <input type="checkbox" @bind="room.IsProtected"/> - </td> - <td>@(room.PowerLevels.Kick <= room.PowerLevels.GetUserPowerLevel(hs.UserId) ? "X" : "")</td> - <td>@(room.PowerLevels.Ban <= room.PowerLevels.GetUserPowerLevel(hs.UserId) ? "X" : "")</td> - <td>@(room.PowerLevels.UserHasStatePermission(hs.UserId, RoomServerACLEventContent.EventId) ? "X" : "")</td> - <td>@room.Room.RoomId</td> - <td>@room.RoomName</td> - </tr> - } - </tbody> - </table> - </div> - </div> -} -<br/> -<LinkButton OnClick="@Apply">Apply</LinkButton> - - -@code { - private DraupnirProtectedRoomsData data { get; set; } = new(); - private List<EditorRoomInfo> Rooms { get; set; } = new(); - private AuthenticatedHomeserverGeneric hs { get; set; } - - protected override async Task OnInitializedAsync() { - hs = await RMUStorage.GetCurrentSessionOrNavigate(); - if (hs is null) return; - data = await hs.GetAccountDataAsync<DraupnirProtectedRoomsData>("org.matrix.mjolnir.protected_rooms"); - StateHasChanged(); - var tasks = (await hs.GetJoinedRooms()).Select(async room => { - var plTask = room.GetPowerLevelsAsync(); - var roomNameTask = room.GetNameOrFallbackAsync(); - var EditorRoomInfo = new EditorRoomInfo { - Room = room, - IsProtected = data.Rooms.Contains(room.RoomId), - RoomName = await roomNameTask, - PowerLevels = await plTask - }; - - Rooms.Add(EditorRoomInfo); - StateHasChanged(); - return Task.CompletedTask; - }).ToList(); - await Task.WhenAll(tasks); - await Task.Delay(500); - StateHasChanged(); - } - - private class DraupnirProtectedRoomsData { - [JsonPropertyName("rooms")] - public List<string> Rooms { get; set; } = new(); - } - - private class EditorRoomInfo { - public GenericRoom Room { get; set; } - public bool IsProtected { get; set; } - public string RoomName { get; set; } - public RoomPowerLevelEventContent PowerLevels { get; set; } - } - - private async Task Apply() { - Console.WriteLine(string.Join('\n', Rooms.Where(x => x.IsProtected).Select(x => x.Room.RoomId))); - data.Rooms = Rooms.Where(x => x.IsProtected).Select(x => x.Room.RoomId).ToList(); - await hs.SetAccountDataAsync("org.matrix.mjolnir.protected_rooms", data); - } - -} \ No newline at end of file |