diff --git a/CocktailWeb/GeneralSettings.cs b/CocktailWeb/GeneralSettings.cs index 90296d6..dd1bfe2 100644 --- a/CocktailWeb/GeneralSettings.cs +++ b/CocktailWeb/GeneralSettings.cs @@ -9,5 +9,7 @@ public string SerialPort { get; set; } = "COM5"; public int Baudrate { get; set; } = 115200; + + public string? SettingsPassword { get; set; } } } diff --git a/CocktailWeb/Shared/TopRow.razor b/CocktailWeb/Shared/TopRow.razor index 72a356a..0b66921 100644 --- a/CocktailWeb/Shared/TopRow.razor +++ b/CocktailWeb/Shared/TopRow.razor @@ -1,4 +1,7 @@ @using Microsoft.AspNetCore.Components.Sections +@using Microsoft.Extensions.Options +@inject IOptions Config +@inject NavigationManager navman
@@ -10,24 +13,107 @@
- + + Passwort eingeben + + + + + + + + @code { public static SectionOutlet Title = new(); + + public bool SettingsUnlocked; + + ModalComponent Pwd_Dialog = null!; + + public string? Pwd_inputPassword; + + public string? Pwd_ErrorText; + + private async Task PasswordDialog_OK(MouseEventArgs e) + { + if (Pwd_inputPassword == Config.Value.SettingsPassword) + { + SettingsUnlocked = true; + await CloseDialog(); + } + else + { + Pwd_inputPassword = null; + Pwd_ErrorText = "Falsches Passwort"; + } + } + + private void LockSettings() + { + SettingsUnlocked = false; + } + + private async Task PasswordDialog_Cancel(MouseEventArgs e) + { + await CloseDialog(); + } + + private async Task OpenDialog() + { + await Pwd_Dialog.OpenModal(); + } + + private async Task CloseDialog() + { + Pwd_ErrorText = null; + Pwd_inputPassword = null; + await Pwd_Dialog.Close(); + } + + + } diff --git a/CocktailWeb/appsettings.json b/CocktailWeb/appsettings.json index 7c8f6b3..1dd72b8 100644 --- a/CocktailWeb/appsettings.json +++ b/CocktailWeb/appsettings.json @@ -13,6 +13,7 @@ "MaxAllowedUploadSizeInMB": 10, "ImageUploadDir": "images", "SerialPort": "COM5", - "Baudrate": 115200 + "Baudrate": 115200, + "SettingsPassword": "" } }