From dbeedad88fc42351b7ec0e2fbdf6b462b1be9de5 Mon Sep 17 00:00:00 2001 From: Milad Raeisi Date: Wed, 19 Jun 2024 11:35:56 +0330 Subject: [PATCH 01/20] Change size of Refresh Balance icon --- src/Angor/Client/Pages/Wallet.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Angor/Client/Pages/Wallet.razor b/src/Angor/Client/Pages/Wallet.razor index 2e9d2d79..083a460c 100644 --- a/src/Angor/Client/Pages/Wallet.razor +++ b/src/Angor/Client/Pages/Wallet.razor @@ -239,7 +239,7 @@ else From 8aab634cbd85ddfd10be38fabd5310ff4f7a2353 Mon Sep 17 00:00:00 2001 From: Milad Raeisi Date: Wed, 19 Jun 2024 17:13:48 +0330 Subject: [PATCH 02/20] Add form-control to tables --- src/Angor/Client/Pages/Investor.razor | 2 +- src/Angor/Client/Pages/Penalties.razor | 2 +- src/Angor/Client/Pages/Signatures.razor | 2 +- src/Angor/Client/Pages/View.razor | 2 +- src/Angor/Client/Pages/Wallet.razor | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Angor/Client/Pages/Investor.razor b/src/Angor/Client/Pages/Investor.razor index 5a80aa95..934f2787 100644 --- a/src/Angor/Client/Pages/Investor.razor +++ b/src/Angor/Client/Pages/Investor.razor @@ -74,7 +74,7 @@
-
+
diff --git a/src/Angor/Client/Pages/Penalties.razor b/src/Angor/Client/Pages/Penalties.razor index a5192894..7680ae58 100644 --- a/src/Angor/Client/Pages/Penalties.razor +++ b/src/Angor/Client/Pages/Penalties.razor @@ -65,7 +65,7 @@
-
+
diff --git a/src/Angor/Client/Pages/Signatures.razor b/src/Angor/Client/Pages/Signatures.razor index fd407c77..713f6e5c 100644 --- a/src/Angor/Client/Pages/Signatures.razor +++ b/src/Angor/Client/Pages/Signatures.razor @@ -59,7 +59,7 @@
-
+
diff --git a/src/Angor/Client/Pages/View.razor b/src/Angor/Client/Pages/View.razor index a8b6a758..27a37ca7 100644 --- a/src/Angor/Client/Pages/View.razor +++ b/src/Angor/Client/Pages/View.razor @@ -141,7 +141,7 @@

Stages

-
+
diff --git a/src/Angor/Client/Pages/Wallet.razor b/src/Angor/Client/Pages/Wallet.razor index 083a460c..04b24294 100644 --- a/src/Angor/Client/Pages/Wallet.razor +++ b/src/Angor/Client/Pages/Wallet.razor @@ -573,7 +573,7 @@ else
-
+
@@ -604,7 +604,7 @@ else
-
+
From 0cd40196cf8b4873ad63caa4fdbfa220a3874add Mon Sep 17 00:00:00 2001 From: Milad Raeisi Date: Wed, 19 Jun 2024 17:14:59 +0330 Subject: [PATCH 03/20] Change Settings Icons --- src/Angor/Client/Pages/Settings.razor | 73 +++++++++++-------- .../Client/wwwroot/assets/icons/change.svg | 5 ++ .../Client/wwwroot/assets/icons/explorer.svg | 8 ++ .../Client/wwwroot/assets/icons/indexer.svg | 8 ++ .../Client/wwwroot/assets/icons/link.svg | 4 + .../Client/wwwroot/assets/icons/network.svg | 6 ++ .../Client/wwwroot/assets/icons/plus.svg | 4 + .../Client/wwwroot/assets/icons/relay.svg | 3 + .../Client/wwwroot/assets/icons/remove.svg | 5 ++ 9 files changed, 87 insertions(+), 29 deletions(-) create mode 100644 src/Angor/Client/wwwroot/assets/icons/change.svg create mode 100644 src/Angor/Client/wwwroot/assets/icons/explorer.svg create mode 100644 src/Angor/Client/wwwroot/assets/icons/indexer.svg create mode 100644 src/Angor/Client/wwwroot/assets/icons/link.svg create mode 100644 src/Angor/Client/wwwroot/assets/icons/network.svg create mode 100644 src/Angor/Client/wwwroot/assets/icons/plus.svg create mode 100644 src/Angor/Client/wwwroot/assets/icons/relay.svg create mode 100644 src/Angor/Client/wwwroot/assets/icons/remove.svg diff --git a/src/Angor/Client/Pages/Settings.razor b/src/Angor/Client/Pages/Settings.razor index 97eb14f9..55251a2c 100644 --- a/src/Angor/Client/Pages/Settings.razor +++ b/src/Angor/Client/Pages/Settings.razor @@ -33,17 +33,7 @@ - + @@ -53,7 +43,9 @@
- currency_bitcoin + + +
Change Network @@ -65,7 +57,9 @@
- + @if (showChangeNetworkModal) { @@ -85,9 +79,6 @@
- - warning - Warning
@@ -141,7 +132,9 @@
- search + + +
Explorer @@ -152,7 +145,9 @@
@@ -165,21 +160,31 @@
- fact_check + + +
Indexer
+
+
- +
-
+
@@ -222,21 +227,30 @@
- wifi + + +
Nostr Relays
+
- +
-
+
@@ -281,7 +295,9 @@
- delete_forever + + +
Wipe Storage @@ -292,7 +308,9 @@
- + @if (showWipeallModal) {
- } @@ -267,19 +273,27 @@ - + - } From 6624b647699f6dc088c6afd7eb800c3a8301257b Mon Sep 17 00:00:00 2001 From: Milad Raeisi Date: Tue, 25 Jun 2024 00:47:09 +0330 Subject: [PATCH 08/20] Fix typo --- src/Angor/Client/Pages/Settings.razor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Angor/Client/Pages/Settings.razor b/src/Angor/Client/Pages/Settings.razor index b2a0361f..fe0cf012 100644 --- a/src/Angor/Client/Pages/Settings.razor +++ b/src/Angor/Client/Pages/Settings.razor @@ -362,7 +362,7 @@ @@ -579,7 +579,7 @@ } } - private void WipteAllData() + private void WipeAllData() { if (!confirmWipe) { From 9c448459c841db76475e357878ede06c4f245858 Mon Sep 17 00:00:00 2001 From: Milad Raeisi Date: Tue, 25 Jun 2024 00:47:20 +0330 Subject: [PATCH 09/20] Create NetworkMonitoringService.cs --- .../Services/NetworkMonitoringService.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/Angor/Shared/Services/NetworkMonitoringService.cs diff --git a/src/Angor/Shared/Services/NetworkMonitoringService.cs b/src/Angor/Shared/Services/NetworkMonitoringService.cs new file mode 100644 index 00000000..0784f50a --- /dev/null +++ b/src/Angor/Shared/Services/NetworkMonitoringService.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Hosting; +using System.Threading; +using System.Threading.Tasks; +using Angor.Shared.Services; + +public class NetworkMonitoringService : BackgroundService +{ + private readonly INetworkService _networkService; + private readonly TimeSpan _checkInterval = TimeSpan.FromMinutes(1); + + public NetworkMonitoringService(INetworkService networkService) + { + _networkService = networkService; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + while (!stoppingToken.IsCancellationRequested) + { + await _networkService.CheckServices(true); + + await Task.Delay(_checkInterval, stoppingToken); + } + } +} From ee5251b6c560db3e95d85b6b203b291b6c97bf4b Mon Sep 17 00:00:00 2001 From: Milad Raeisi Date: Tue, 25 Jun 2024 00:48:31 +0330 Subject: [PATCH 10/20] Use NetworkMonitoringService --- src/Angor/Client/Program.cs | 1 + src/Angor/Server/FaucetController.cs | 2 ++ src/Angor/Shared/Angor.Shared.csproj | 1 + src/Angor/Shared/Services/INetworkService.cs | 2 ++ src/Angor/Shared/Services/NetworkService.cs | 3 +++ 5 files changed, 9 insertions(+) diff --git a/src/Angor/Client/Program.cs b/src/Angor/Client/Program.cs index 4a9162d0..1c52a993 100644 --- a/src/Angor/Client/Program.cs +++ b/src/Angor/Client/Program.cs @@ -35,6 +35,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddHostedService(); builder.Services.AddTransient(); builder.Services.AddTransient(); diff --git a/src/Angor/Server/FaucetController.cs b/src/Angor/Server/FaucetController.cs index 7553ace9..e8ef1473 100644 --- a/src/Angor/Server/FaucetController.cs +++ b/src/Angor/Server/FaucetController.cs @@ -112,6 +112,8 @@ private AddressInfo GenerateAddressFromPubKey(int scanIndex, Network network, bo public class NetworkServiceMock : INetworkService { + public event Action OnStatusChanged; + public Task CheckServices(bool force = false) { throw new NotImplementedException(); diff --git a/src/Angor/Shared/Angor.Shared.csproj b/src/Angor/Shared/Angor.Shared.csproj index 150db58c..60a476ca 100644 --- a/src/Angor/Shared/Angor.Shared.csproj +++ b/src/Angor/Shared/Angor.Shared.csproj @@ -12,6 +12,7 @@ + diff --git a/src/Angor/Shared/Services/INetworkService.cs b/src/Angor/Shared/Services/INetworkService.cs index 9c29571b..5bfabd25 100644 --- a/src/Angor/Shared/Services/INetworkService.cs +++ b/src/Angor/Shared/Services/INetworkService.cs @@ -12,4 +12,6 @@ public interface INetworkService void CheckAndHandleError(HttpResponseMessage httpResponseMessage); void HandleException(Exception exception); void CheckAndSetNetwork(string url, string? setNetwork = null); + event Action OnStatusChanged; + } \ No newline at end of file diff --git a/src/Angor/Shared/Services/NetworkService.cs b/src/Angor/Shared/Services/NetworkService.cs index 422d02a7..59ccd32e 100644 --- a/src/Angor/Shared/Services/NetworkService.cs +++ b/src/Angor/Shared/Services/NetworkService.cs @@ -14,6 +14,8 @@ public class NetworkService : INetworkService private readonly HttpClient _httpClient; private readonly ILogger _logger; private readonly INetworkConfiguration _networkConfiguration; + public event Action OnStatusChanged; + public NetworkService(INetworkStorage networkStorage, HttpClient httpClient, ILogger logger, INetworkConfiguration networkConfiguration) { @@ -104,6 +106,7 @@ public async Task CheckServices(bool force = false) { _logger.LogError($"Failed to check indexer status url = {indexerUrl.Url}, StatusCode = {response.StatusCode}"); } + OnStatusChanged?.Invoke(); } catch (Exception ex) { From 4429036251434f27e34e5311289c76ca063243e5 Mon Sep 17 00:00:00 2001 From: Milad Raeisi Date: Tue, 25 Jun 2024 01:58:22 +0330 Subject: [PATCH 11/20] Update NetworkMonitoringService type --- src/Angor/Client/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Angor/Client/Program.cs b/src/Angor/Client/Program.cs index 1c52a993..57bb3955 100644 --- a/src/Angor/Client/Program.cs +++ b/src/Angor/Client/Program.cs @@ -35,7 +35,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); -builder.Services.AddHostedService(); +builder.Services.AddScoped(); builder.Services.AddTransient(); builder.Services.AddTransient(); From 8a63c9c6489924099b4c6e66df7c7bf8b50300e3 Mon Sep 17 00:00:00 2001 From: Milad Raeisi Date: Tue, 25 Jun 2024 01:59:21 +0330 Subject: [PATCH 12/20] Run NetworkMonitoringService in background --- src/Angor/Client/Pages/Settings.razor | 28 +++++++++++++++---- src/Angor/Client/Shared/MainLayout.razor | 8 ++++++ .../Services/NetworkMonitoringService.cs | 26 +++++++++++------ 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/src/Angor/Client/Pages/Settings.razor b/src/Angor/Client/Pages/Settings.razor index fe0cf012..7316d484 100644 --- a/src/Angor/Client/Pages/Settings.razor +++ b/src/Angor/Client/Pages/Settings.razor @@ -203,9 +203,9 @@ @@ -402,12 +402,28 @@ networkType = _networkConfiguration.GetNetwork().Name; + _networkService.OnStatusChanged += UpdateUI; + if (!networkType.ToLower().Contains("test")) selectedNetwork = "mainnet"; return base.OnInitializedAsync(); } + private void UpdateUI() + { + InvokeAsync(async () => + { + settingsInfo = _clientStorage.GetSettingsInfo(); + StateHasChanged(); + }); + } + + public void Dispose() + { + _networkService.OnStatusChanged -= UpdateUI; + } + protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) @@ -565,17 +581,17 @@ try { await _networkService.CheckServices(force); - settingsInfo = _clientStorage.GetSettingsInfo(); } catch (Exception e) { - Logger.LogError(e, e.Message); - notificationComponent.ShowErrorMessage(e.Message); + Logger.LogError(e, $"Error during Refresh: {e.Message}"); + notificationComponent.ShowErrorMessage("Failed to refresh settings: " + e.Message); } finally { refreshSpinner = false; + StateHasChanged(); } } diff --git a/src/Angor/Client/Shared/MainLayout.razor b/src/Angor/Client/Shared/MainLayout.razor index 4e15e6cd..ece269b8 100644 --- a/src/Angor/Client/Shared/MainLayout.razor +++ b/src/Angor/Client/Shared/MainLayout.razor @@ -11,6 +11,7 @@ @inject INetworkService _networkService @inject NavigationManager _navManager @inject NavMenuState NavMenuState; +@inject NetworkMonitoringService NetworkMonitoringService
@if (indexer.IsPrimary) { - + + + } else { - + + + } - + +
@relay.Url @relay.Name@relay.Status.ToString() + @relay.Status.ToString() + @if (relay.IsPrimary) { - + + + } else { - + + + } - + +
@if (indexer.IsPrimary) { - + - + } else { @@ -286,7 +286,7 @@ else { - + }