From 5331a1c9d17ff8f3850affa8f64aca873a780613 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 28 Feb 2024 19:50:42 +0100 Subject: [PATCH] =?UTF-8?q?Passwortdialog=20f=C3=BCr=20Einstellungen=20ein?= =?UTF-8?q?gebaut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CocktailWeb/GeneralSettings.cs | 2 + CocktailWeb/Shared/TopRow.razor | 114 ++++++++++++++++++++++++++++---- CocktailWeb/appsettings.json | 3 +- 3 files changed, 104 insertions(+), 15 deletions(-) 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": "" } }