From 4e12e02bc805170e6b03d33e0ef894b2a3021fb3 Mon Sep 17 00:00:00 2001 From: Rory& Date: Sun, 1 Jun 2025 11:13:55 +0200 Subject: Add alarm endpoints, basic budget routes, spend history --- testFrontend/SafeNSound.Frontend/Pages/Alarm.razor | 36 +++++++++++++ testFrontend/SafeNSound.Frontend/Pages/Auth.razor | 4 +- .../SafeNSound.Frontend/Pages/Weather.razor | 60 ---------------------- 3 files changed, 39 insertions(+), 61 deletions(-) create mode 100644 testFrontend/SafeNSound.Frontend/Pages/Alarm.razor delete mode 100644 testFrontend/SafeNSound.Frontend/Pages/Weather.razor (limited to 'testFrontend/SafeNSound.Frontend/Pages') diff --git a/testFrontend/SafeNSound.Frontend/Pages/Alarm.razor b/testFrontend/SafeNSound.Frontend/Pages/Alarm.razor new file mode 100644 index 0000000..9b90ef4 --- /dev/null +++ b/testFrontend/SafeNSound.Frontend/Pages/Alarm.razor @@ -0,0 +1,36 @@ +@page "/Alarm" + +

Alarm

+ +

+ +@if (Exception != null) { +
+ Error:
+
+            @Exception
+        
+
+} + +@if (Result != null) { +
+ Result:
+
+            @Result.ToJson(indent: true)
+        
+
+} + +@code { + private Exception? Exception { get; set; } + private object? Result { get; set; } + + protected override async Task OnInitializedAsync() { + if (App.Client is null) { + NavigationManager.NavigateTo("/Auth"); + return; + } + } + +} \ No newline at end of file diff --git a/testFrontend/SafeNSound.Frontend/Pages/Auth.razor b/testFrontend/SafeNSound.Frontend/Pages/Auth.razor index 3db77a1..c58a996 100644 --- a/testFrontend/SafeNSound.Frontend/Pages/Auth.razor +++ b/testFrontend/SafeNSound.Frontend/Pages/Auth.razor @@ -73,11 +73,13 @@ Result = null; Exception = null; try { - Result = await Authentication.Login(new() { + SafeNSoundAuthResult result; + Result = result = await Authentication.Login(new() { Username = Username, Password = Password, Email = Email }); + App.Client = new SafeNSoundClient(Config, result.AccessToken); } catch (Exception ex) { Exception = ex; diff --git a/testFrontend/SafeNSound.Frontend/Pages/Weather.razor b/testFrontend/SafeNSound.Frontend/Pages/Weather.razor deleted file mode 100644 index a0ca515..0000000 --- a/testFrontend/SafeNSound.Frontend/Pages/Weather.razor +++ /dev/null @@ -1,60 +0,0 @@ -@page "/weather" -@inject HttpClient Http - -Weather - -

Weather

- -

This component demonstrates fetching data from the server.

- -@if (forecasts == null) -{ -

- Loading... -

-} -else -{ - - - - - - - - - - - @foreach (var forecast in forecasts) - { - - - - - - - } - -
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
-} - -@code { - private WeatherForecast[]? forecasts; - - protected override async Task OnInitializedAsync() - { - forecasts = await Http.GetFromJsonAsync("sample-data/weather.json"); - } - - public class WeatherForecast - { - public DateOnly Date { get; set; } - - public int TemperatureC { get; set; } - - public string? Summary { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - } - -} \ No newline at end of file -- cgit 1.5.1