Erstes Formular + QR Integration
This commit is contained in:
parent
b039e23f91
commit
195e0a7b45
@ -39,7 +39,7 @@
|
||||
<Authorized Context="auth">
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<span class="text-white small">
|
||||
👋 @auth.User.Identity?.Name
|
||||
@auth.User.Identity?.Name
|
||||
</span>
|
||||
<NavLink href="authentication/logout" class="btn btn-outline-light btn-sm">
|
||||
<i class="bi bi-box-arrow-right me-1"></i> Abmelden
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
@page "/counter"
|
||||
|
||||
<PageTitle>Counter</PageTitle>
|
||||
|
||||
<h1>Counter</h1>
|
||||
|
||||
<p role="status">Current count: @currentCount</p>
|
||||
|
||||
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
|
||||
|
||||
@code {
|
||||
private int currentCount = 0;
|
||||
|
||||
private void IncrementCount()
|
||||
{
|
||||
currentCount++;
|
||||
}
|
||||
}
|
||||
@ -1,91 +1,147 @@
|
||||
@page "/filterform"
|
||||
@inject IJSRuntime JS
|
||||
|
||||
@using FilterCair.Shared.Models
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
|
||||
<PageTitle>Filterdaten erfassen</PageTitle>
|
||||
|
||||
<div class="container py-4">
|
||||
<h4 class="mb-4 text-center">Filterdaten erfassen</h4>
|
||||
<div class="container py-4 fade-in">
|
||||
<div class="card shadow-sm border-0 rounded-4">
|
||||
<div class="card-body p-4">
|
||||
|
||||
<EditForm Model="@filter" OnValidSubmit="SaveForm">
|
||||
<DataAnnotationsValidator />
|
||||
<ValidationSummary />
|
||||
<h4 class="mb-4 text-center text-primary">
|
||||
<i class="bi bi-funnel me-2"></i> Filterdaten erfassen
|
||||
</h4>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Filter-ID</label>
|
||||
<InputText class="form-control" @bind-Value="filter.FilterId" placeholder="z. B. FC-A-234" />
|
||||
<EditForm Model="@filter" OnValidSubmit="SaveForm">
|
||||
<DataAnnotationsValidator />
|
||||
<ValidationSummary />
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Filter-ID</label>
|
||||
<InputText class="form-control form-control-lg" @bind-Value="filter.FilterId" placeholder="z. B. FC-A-234" />
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Halle</label>
|
||||
<InputSelect class="form-select form-select-lg" @bind-Value="filter.Halle">
|
||||
<option value="">– bitte wählen –</option>
|
||||
@foreach (var h in halls)
|
||||
{
|
||||
<option value="@h">@h</option>
|
||||
}
|
||||
</InputSelect>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Zustand</label>
|
||||
<InputSelect class="form-select form-select-lg" @bind-Value="filter.Zustand">
|
||||
<option value="">– bitte wählen –</option>
|
||||
<option>In Ordnung</option>
|
||||
<option>Verschmutzt</option>
|
||||
<option>Defekt</option>
|
||||
</InputSelect>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Luftdruck (Pa)</label>
|
||||
<InputNumber class="form-control form-control-lg" @bind-Value="filter.Luftdruck" />
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<label class="form-label fw-semibold">Bemerkung</label>
|
||||
<InputTextArea class="form-control form-control-lg" rows="3" @bind-Value="filter.Bemerkung" />
|
||||
</div>
|
||||
|
||||
<!-- 📸 Fotos hinzufügen -->
|
||||
<div class="col-12">
|
||||
<label class="form-label fw-semibold">Fotos anhängen</label>
|
||||
<InputFile OnChange="OnFilesSelected" multiple class="form-control" />
|
||||
</div>
|
||||
|
||||
@if (imagePreviews.Count > 0)
|
||||
{
|
||||
<div class="col-12 mt-3">
|
||||
<div class="d-flex flex-wrap gap-3 justify-content-center">
|
||||
@foreach (var img in imagePreviews)
|
||||
{
|
||||
<div class="image-preview border rounded shadow-sm">
|
||||
<img src="@img" alt="Foto" class="img-thumbnail" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="d-grid mt-4">
|
||||
<button type="submit" class="btn btn-primary btn-lg rounded-pill shadow-sm">
|
||||
<i class="bi bi-save me-2"></i> Speichern
|
||||
</button>
|
||||
</div>
|
||||
</EditForm>
|
||||
|
||||
@if (showToast)
|
||||
{
|
||||
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
||||
<div class="toast align-items-center text-bg-success border-0 show fade-in-toast">
|
||||
<div class="d-flex">
|
||||
<div class="toast-body">
|
||||
✅ Filterdaten erfolgreich gespeichert!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Halle</label>
|
||||
<InputSelect class="form-select" @bind-Value="filter.Halle">
|
||||
<option value="">– bitte wählen –</option>
|
||||
@foreach (var h in halls)
|
||||
{
|
||||
<option value="@h">@h</option>
|
||||
}
|
||||
</InputSelect>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Zustand</label>
|
||||
<InputSelect class="form-select" @bind-Value="filter.Zustand">
|
||||
<option value="">– bitte wählen –</option>
|
||||
<option>In Ordnung</option>
|
||||
<option>Verschmutzt</option>
|
||||
<option>Defekt</option>
|
||||
</InputSelect>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Luftdruck (Pa)</label>
|
||||
<InputNumber class="form-control" @bind-Value="filter.Luftdruck" />
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bemerkung</label>
|
||||
<InputTextArea class="form-control" rows="3" @bind-Value="filter.Bemerkung" />
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-success w-100">
|
||||
Speichern
|
||||
</button>
|
||||
</EditForm>
|
||||
|
||||
@if (saved)
|
||||
{
|
||||
<div class="alert alert-success mt-4 text-center">
|
||||
Daten gespeichert!
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private FilterModel filter = new();
|
||||
private bool saved = false;
|
||||
private List<string> halls = new() { "Halle A", "Halle B", "Halle C" };
|
||||
private bool showToast;
|
||||
private List<string> imagePreviews = new();
|
||||
|
||||
private async Task OnFilesSelected(InputFileChangeEventArgs e)
|
||||
{
|
||||
imagePreviews.Clear();
|
||||
|
||||
foreach (var file in e.GetMultipleFiles(3)) // max. 3 Bilder
|
||||
{
|
||||
using var stream = file.OpenReadStream(maxAllowedSize: 5_000_000); // 5 MB max
|
||||
using var ms = new MemoryStream();
|
||||
await stream.CopyToAsync(ms);
|
||||
var base64 = Convert.ToBase64String(ms.ToArray());
|
||||
imagePreviews.Add($"data:{file.ContentType};base64,{base64}");
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task SaveForm()
|
||||
{
|
||||
saved = true;
|
||||
Console.WriteLine($"Gespeichert: {System.Text.Json.JsonSerializer.Serialize(filter)}");
|
||||
|
||||
// später → JS.InvokeVoidAsync("IndexedDB.saveFilter", filter);
|
||||
await JS.InvokeVoidAsync("console.log", "Filter gespeichert:", filter);
|
||||
|
||||
showToast = true;
|
||||
StateHasChanged();
|
||||
|
||||
await Task.Delay(3000);
|
||||
showToast = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
// optional: QR-Ergebnis vorbelegen
|
||||
[Inject] NavigationManager? NavManager { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
var qrParam = NavManager?.ToAbsoluteUri(NavManager.Uri).Query;
|
||||
if (!string.IsNullOrEmpty(qrParam))
|
||||
{
|
||||
// z. B. ?id=FC-123
|
||||
var parts = System.Web.HttpUtility.ParseQueryString(qrParam);
|
||||
filter.FilterId = parts.Get("id");
|
||||
}
|
||||
}
|
||||
|
||||
[Inject] NavigationManager? NavManager { get; set; }
|
||||
}
|
||||
|
||||
@ -1,57 +0,0 @@
|
||||
@page "/weather"
|
||||
@inject HttpClient Http
|
||||
|
||||
<PageTitle>Weather</PageTitle>
|
||||
|
||||
<h1>Weather</h1>
|
||||
|
||||
<p>This component demonstrates fetching data from the server.</p>
|
||||
|
||||
@if (forecasts == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th aria-label="Temperature in Celsius">Temp. (C)</th>
|
||||
<th aria-label="Temperature in Farenheit">Temp. (F)</th>
|
||||
<th>Summary</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var forecast in forecasts)
|
||||
{
|
||||
<tr>
|
||||
<td>@forecast.Date.ToShortDateString()</td>
|
||||
<td>@forecast.TemperatureC</td>
|
||||
<td>@forecast.TemperatureF</td>
|
||||
<td>@forecast.Summary</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
@code {
|
||||
private WeatherForecast[]? forecasts;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("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);
|
||||
}
|
||||
}
|
||||
@ -210,3 +210,16 @@ code {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.image-preview img {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
object-fit: cover;
|
||||
border-radius: 0.5rem;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.image-preview img:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user