about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--MatrixRoomUtils.Core/Room.cs2
-rw-r--r--MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs16
-rw-r--r--MatrixRoomUtils.Web/Pages/DevOptions.razor32
-rw-r--r--MatrixRoomUtils.Web/Pages/MediaLocator.razor36
-rw-r--r--MatrixRoomUtils.Web/Shared/NavMenu.razor31
5 files changed, 109 insertions, 8 deletions
diff --git a/MatrixRoomUtils.Core/Room.cs b/MatrixRoomUtils.Core/Room.cs
index 3ef6ffa..64db03d 100644
--- a/MatrixRoomUtils.Core/Room.cs
+++ b/MatrixRoomUtils.Core/Room.cs
@@ -37,7 +37,7 @@ public class Room
         {
             if(RuntimeCache.GenericResponseCache[cache_key][url].ExpiryTime > DateTime.Now)
             {
-                Console.WriteLine($"[:3] Found cached state: {RuntimeCache.GenericResponseCache[cache_key][url].Result}");
+                // Console.WriteLine($"[:3] Found cached state: {RuntimeCache.GenericResponseCache[cache_key][url].Result}");
                 return (JsonElement?)RuntimeCache.GenericResponseCache[cache_key][url].Result;
             }
             else
diff --git a/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs b/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs
index 287d1e5..a439ea1 100644
--- a/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs
+++ b/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs
@@ -6,6 +6,8 @@ namespace MatrixRoomUtils.Web.Classes;
 
 public partial class LocalStorageWrapper
 {
+    public static Settings Settings { get; set; } = new();
+    
     //some basic logic
     public static async Task ReloadLocalStorage(ILocalStorageService localStorage)
     {
@@ -14,6 +16,7 @@ public partial class LocalStorageWrapper
     }
     public static async Task LoadFromLocalStorage(ILocalStorageService localStorage)
     {
+        Settings = await localStorage.GetItemAsync<Settings>("rory.matrixroomutils.settings") ?? new();
         // RuntimeCache.AccessToken = await localStorage.GetItemAsync<string>("rory.matrixroomutils.token");
         RuntimeCache.LastUsedToken = await localStorage.GetItemAsync<string>("rory.matrixroomutils.last_used_token");
         // RuntimeCache.CurrentHomeserver = await localStorage.GetItemAsync<string>("rory.matrixroomutils.current_homeserver");
@@ -34,6 +37,7 @@ public partial class LocalStorageWrapper
 
     public static async Task SaveToLocalStorage(ILocalStorageService localStorage)
     {
+        await localStorage.SetItemAsync("rory.matrixroomutils.settings", Settings);
         // if(RuntimeCache.AccessToken != null) await localStorage.SetItemAsStringAsync("rory.matrixroomutils.token", RuntimeCache.AccessToken);
         // if(RuntimeCache.CurrentHomeserver != null) await localStorage.SetItemAsync("rory.matrixroomutils.current_homeserver", RuntimeCache.CurrentHomeserver);
         if(RuntimeCache.LoginSessions != null) await localStorage.SetItemAsync("rory.matrixroomutils.user_cache", RuntimeCache.LoginSessions);
@@ -43,4 +47,16 @@ public partial class LocalStorageWrapper
                 .ToDictionary(x => x.Key, x => x.Value));
         await localStorage.SetItemAsync("rory.matrixroomutils.generic_cache", RuntimeCache.GenericResponseCache);
     }
+}
+
+
+public class Settings
+{
+    public DeveloperSettings DeveloperSettings { get; set; } = new();
+}
+
+
+public class DeveloperSettings
+{
+    public bool EnableLogViewers { get; set; } = false;
 }
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Pages/DevOptions.razor b/MatrixRoomUtils.Web/Pages/DevOptions.razor
new file mode 100644
index 0000000..0cc38d8
--- /dev/null
+++ b/MatrixRoomUtils.Web/Pages/DevOptions.razor
@@ -0,0 +1,32 @@
+@page "/DevOptions"
+@using MatrixRoomUtils.Web.Shared.IndexComponents
+@using System.Net
+@using MatrixRoomUtils.Core.Extensions
+@inject NavigationManager NavigationManager
+@inject ILocalStorageService LocalStorage
+
+<PageTitle>Developer options</PageTitle>
+
+<h3>Rory&::MatrixUtils - Developer options</h3>
+<hr/>
+
+<InputCheckbox @bind-Value="@LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers" @oninput="@LogStuff"></InputCheckbox><label> Enable log views</label>
+
+
+@code {
+    protected override async Task OnInitializedAsync()
+    {
+        await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
+        await base.OnInitializedAsync();
+        await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
+    }
+
+    protected async Task LogStuff()
+    {
+        await Task.Delay(100);
+        Console.WriteLine($"Settings: {LocalStorageWrapper.Settings.ToJson()}");
+        
+        await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
+    }
+
+}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Pages/MediaLocator.razor b/MatrixRoomUtils.Web/Pages/MediaLocator.razor
new file mode 100644
index 0000000..cd244ef
--- /dev/null
+++ b/MatrixRoomUtils.Web/Pages/MediaLocator.razor
@@ -0,0 +1,36 @@
+@page "/MediaLocator"
+<h3>MediaLocator</h3>
+<hr/>
+
+<span>MXC URL: </span>
+<input type="text" @bind="mxcUrl" />
+<button @onclick="executeSearch">Search</button>
+
+
+@code {
+    string mxcUrl { get; set; }
+    List<string> successResults = new List<string>();
+    List<string> errorResults = new List<string>();
+    List<string> homeservers = new List<string>();
+
+    protected override async Task OnInitializedAsync()
+    {
+        base.OnInitializedAsync();
+        
+    }
+
+    async Task executeSearch()
+    {
+        var client = new HttpClient();
+        var response = await client.GetAsync($"https://matrix.org/_matrix/media/r0/identicon/{mxcUrl}");
+        if (response.IsSuccessStatusCode)
+        {
+            successResults.Add(mxcUrl);
+        }
+        else
+        {
+            errorResults.Add(mxcUrl);
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/NavMenu.razor b/MatrixRoomUtils.Web/Shared/NavMenu.razor
index a033925..b77935d 100644
--- a/MatrixRoomUtils.Web/Shared/NavMenu.razor
+++ b/MatrixRoomUtils.Web/Shared/NavMenu.razor
@@ -15,15 +15,15 @@
             </NavLink>
         </div>
         <div class="nav-item px-3">
-            <h5 style="margin-left: 1em;">Main tools</h5>
-            <hr style="margin-bottom: 0em;"/>
-        </div>
-        <div class="nav-item px-3">
             <NavLink class="nav-link" href="About">
-                <span class="oi oi-plus" aria-hidden="true"></span> About MRU
+                <span class="oi oi-info" aria-hidden="true"></span> About MRU
             </NavLink>
         </div>
         <div class="nav-item px-3">
+            <h5 style="margin-left: 1em;">Main tools</h5>
+            <hr style="margin-bottom: 0em;"/>
+        </div>
+        <div class="nav-item px-3">
             <NavLink class="nav-link" href="Export">
                 <span class="oi oi-plus" aria-hidden="true"></span> Export data
             </NavLink>
@@ -43,11 +43,28 @@
                 <span class="oi oi-plus" aria-hidden="true"></span> Room state viewer
             </NavLink>
         </div>
+        @* <div class="nav-item px-3"> *@
+        @*     <h5 style="margin-left: 1em;">Plural tools</h5> *@
+        @*     <hr style="margin-bottom: 0em;"/> *@
+        @* </div> *@
         <div class="nav-item px-3">
-            <h5 style="margin-left: 1em;">Plural tools</h5>
+            <h5 style="margin-left: 1em;">Extra tools</h5>
             <hr style="margin-bottom: 0em;"/>
         </div>
-
+        <div class="nav-item px-3">
+            <NavLink class="nav-link" href="MediaLocator">
+                <span class="oi oi-plus" aria-hidden="true"></span> Media locator
+            </NavLink>
+        </div>
+        <div class="nav-item px-3">
+            <h5 style="margin-left: 1em;">MRU</h5>
+            <hr style="margin-bottom: 0em;"/>
+        </div>
+        <div class="nav-item px-3">
+            <NavLink class="nav-link" href="DevOptions">
+                <span class="oi oi-plus" aria-hidden="true"></span> Developer options
+            </NavLink>
+        </div>
     </nav>
 </div>