Passwortdialog für Einstellungen eingebaut
This commit is contained in:
parent
7ee75d0de3
commit
5331a1c9d1
@ -9,5 +9,7 @@
|
||||
public string SerialPort { get; set; } = "COM5";
|
||||
|
||||
public int Baudrate { get; set; } = 115200;
|
||||
|
||||
public string? SettingsPassword { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
@using Microsoft.AspNetCore.Components.Sections
|
||||
@using Microsoft.Extensions.Options
|
||||
@inject IOptions<GeneralSettings> Config
|
||||
@inject NavigationManager navman
|
||||
|
||||
<div class="d-flex align-items-center fixed-top justify-content-between px-4 bg-dark border-primary-subtle" style="border-bottom: 1px solid #d6d5d5; height: 56px; align-items: center; top: 0; z-index: 1;">
|
||||
<div class="d-flex gap-3 align-items-center">
|
||||
@ -10,24 +13,107 @@
|
||||
<SectionOutlet SectionId="Title" />
|
||||
</div>
|
||||
|
||||
<div class="dropdown show">
|
||||
<a class="btn btn-secondary dropdown-toggle" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-gear-fill" viewBox="0 0 16 16">
|
||||
<path d="M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z" />
|
||||
</svg>
|
||||
Einstellungen
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="dropdownMenuLink">
|
||||
<a class="dropdown-item" href="/settings/maschine">Maschine</a>
|
||||
<a class="dropdown-item" href="/settings/flaschen">Zutaten</a>
|
||||
<a class="dropdown-item" href="/settings/cocktails">Cocktails</a>
|
||||
<a class="dropdown-item" href="/settings/glaeser">Gläser</a>
|
||||
<a class="dropdown-item" href="/serialtest">Serial Test</a>
|
||||
</div>
|
||||
<div>
|
||||
@Environment.MachineName:@navman.ToAbsoluteUri(navman.BaseUri).Port
|
||||
</div>
|
||||
|
||||
@* Einstellungen-Dropdown Menü*@
|
||||
@if (SettingsUnlocked || Config.Value.SettingsPassword == "" || Config.Value.SettingsPassword == null)
|
||||
{
|
||||
<div class="dropdown show z-2">
|
||||
<a class="btn btn-secondary dropdown-toggle z-2" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-gear-fill" viewBox="0 0 16 16">
|
||||
<path d="M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z" />
|
||||
</svg>
|
||||
Einstellungen
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-end z-2" aria-labelledby="dropdownMenuLink">
|
||||
<a class="dropdown-item z-3 position-relative" href="/settings/machine">Maschine</a>
|
||||
<a class="dropdown-item z-3 position-relative" href="/settings/ingredients">Zutaten</a>
|
||||
<a class="dropdown-item z-3 position-relative" href="/settings/cocktails">Cocktails</a>
|
||||
<a class="dropdown-item z-3 position-relative" href="/settings/glasses">Gläser</a>
|
||||
<a class="dropdown-item z-3 position-relative" href="/serialtest">Serial Test</a>
|
||||
@if (Config.Value.SettingsPassword != "" && Config.Value.SettingsPassword != null)
|
||||
{
|
||||
<a class="dropdown-item z-3 position-relative" @onclick=LockSettings>Einstellungen sperren</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="d-flex gap-3 align-items-center">
|
||||
<a class="btn btn-secondary" @onclick=OpenDialog>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-lock" viewBox="0 0 16 16">
|
||||
<path d="M8 1a2 2 0 0 1 2 2v4H6V3a2 2 0 0 1 2-2m3 6V3a3 3 0 0 0-6 0v4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2M5 8h6a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1" />
|
||||
</svg>
|
||||
Einstellungen
|
||||
</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<ModalComponent @ref="Pwd_Dialog">
|
||||
<Title>Passwort eingeben</Title>
|
||||
<Body>
|
||||
<label class="form-label" for="settingspassword">Passwort</label>
|
||||
<input class="form-control" id="settingspassword" name="settingspassword" type="text" @bind=@Pwd_inputPassword />
|
||||
<label class="text-danger">@Pwd_ErrorText</label>
|
||||
</Body>
|
||||
<Footer>
|
||||
<button type="button" class="btn btn-secondary" @onclick="PasswordDialog_Cancel">Abbrechen</button>
|
||||
<button type="button" class="btn btn-primary" @onclick="PasswordDialog_OK">OK</button>
|
||||
</Footer>
|
||||
</ModalComponent>
|
||||
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
"MaxAllowedUploadSizeInMB": 10,
|
||||
"ImageUploadDir": "images",
|
||||
"SerialPort": "COM5",
|
||||
"Baudrate": 115200
|
||||
"Baudrate": 115200,
|
||||
"SettingsPassword": ""
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user