2024-02-28 19:50:42 +01:00

120 lines
5.3 KiB
Plaintext

@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">
<a class="btn btn-primary" href="/">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-house" viewBox="0 0 16 16">
<path d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5z" />
</svg>
</a>
<SectionOutlet SectionId="Title" />
</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();
}
}