Erste lauffähige Version

This commit is contained in:
2026-05-27 10:58:37 +02:00
parent 3181ecaff9
commit 3b46311b09
76 changed files with 61064 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
@page "/counter"
@rendermode InteractiveServer
<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++;
}
}
+36
View File
@@ -0,0 +1,36 @@
@page "/Error"
@using System.Diagnostics
<PageTitle>Error</PageTitle>
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
@code{
[CascadingParameter]
private HttpContext? HttpContext { get; set; }
private string? RequestId { get; set; }
private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
protected override void OnInitialized() =>
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
}
+77
View File
@@ -0,0 +1,77 @@
@page "/"
@rendermode InteractiveServer
@using TodoTicketApp.Models
@using TodoTicketApp.Services
@inject ITicketService TicketService
@inject NavigationManager Nav
<PageTitle>Ticket Dashboard</PageTitle>
<div class="dashboard-container">
<div class="quick-entry">
<input class="form-control form-control-lg"
placeholder="Ticket-Titel eingeben..."
@bind="newTicketTitle"
@onkeyup="HandleKeyUp" />
</div>
<div class="ticket-list">
@foreach (var ticket in TicketService.GetPendingTickets())
{
<div class="ticket-card priority-@ticket.Priority.ToString().ToLower()">
<div class="ticket-header" @onclick="() => GoToDetails(ticket.Id)">
<span class="prio-tag">@ticket.Priority</span>
<h5>@ticket.Title</h5>
<small>@ticket.CreatedAt.ToLocalTime().ToString("g")</small>
</div>
<div class="ticket-body" @onclick="() => GoToDetails(ticket.Id)">
<p>@(ticket.Description.Length > 200 ? ticket.Description.Substring(0, 200) + "..." : ticket.Description)</p>
</div>
<div class="ticket-footer">
<span class="comments-info">
<i class="bi bi-chat-left-text"></i> @ticket.Comments.Count Kommentare
</span>
<button class="btn btn-sm btn-outline-success" @onclick="() => Complete(ticket.Id)">
Erledigen
</button>
</div>
</div>
}
</div>
</div>
@code {
private string newTicketTitle = "";
private async Task HandleKeyUp(KeyboardEventArgs e)
{
if (e.Key == "Enter" && !string.IsNullOrWhiteSpace(newTicketTitle))
{
var newTicket = new Ticket { Title = newTicketTitle };
TicketService.AddTicket(newTicket);
newTicketTitle = "";
// Hier könnten wir direkt auf die Detailseite navigieren:
// Nav.NavigateTo($"/ticket/edit/{newTicket.Id}");
}
}
private void Complete(Guid id) => TicketService.CompleteTicket(id);
private void GoToDetails(Guid id) => Nav.NavigateTo($"/ticket/edit/{id}");
}
<style>
.dashboard-container { max-width: 800px; margin: 2rem auto; }
.quick-entry { margin-bottom: 2rem; }
.ticket-card {
background: #f8f9fa; border-radius: 8px; padding: 1rem; margin-bottom: 1rem;
border-left: 5px solid #ccc; cursor: pointer; transition: transform 0.1s;
}
.ticket-card:hover { transform: scale(1.01); }
.priority-critical { border-left-color: #dc3545; }
.priority-high { border-left-color: #fd7e14; }
.ticket-header { display: flex; justify-content: space-between; align-items: center; }
.prio-tag { font-size: 0.7rem; font-weight: bold; text-transform: uppercase; }
.ticket-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }
</style>
+5
View File
@@ -0,0 +1,5 @@
@page "/not-found"
@layout MainLayout
<h3>Not Found</h3>
<p>Sorry, the content you are looking for does not exist.</p>
+127
View File
@@ -0,0 +1,127 @@
@page "/ticket/edit/{Id:guid}"
@rendermode InteractiveServer
@using TodoTicketApp.Models
@using TodoTicketApp.Services
@inject ITicketService TicketService
@inject NavigationManager Nav
<div class="detail-container">
@if (ticket == null)
{
<p>Lade Ticket...</p>
}
else
{
<div class="header-actions">
<button class="btn btn-link" @onclick="GoBack">&larr; Zurück zum Dashboard</button>
<span class="badge @(ticket.IsCompleted ? "bg-success" : "bg-warning")">
@(ticket.IsCompleted ? "Erledigt" : "Offen")
</span>
</div>
<div class="card shadow-sm p-4">
<div class="mb-3">
<label class="form-label fw-bold">Titel</label>
<input class="form-control form-control-lg" @bind="ticket.Title" />
</div>
<div class="row mb-3">
<div class="col-md-6">
<label class="form-label fw-bold">Priorität</label>
<select class="form-select" @bind="ticket.Priority">
@foreach (var prio in Enum.GetValues<TicketPriority>())
{
<option value="@prio">@prio</option>
}
</select>
</div>
<div class="col-md-6 d-flex align-items-end">
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" id="isDone" @bind="ticket.IsCompleted">
<label class="form-check-label" for="isDone">Als erledigt markieren</label>
</div>
</div>
</div>
<div class="mb-3">
<label class="form-label fw-bold">Beschreibung</label>
<textarea class="form-control" rows="5" @bind="ticket.Description" placeholder="Beschreibe das Ticket näher..."></textarea>
</div>
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
<button class="btn btn-primary px-5" @onclick="Save">Speichern</button>
</div>
</div>
<div class="row mt-4">
<div class="col-md-7">
<h5 class="mb-3">Kommentare (@ticket.Comments.Count)</h5>
<div class="comment-list mb-3">
@foreach (var c in ticket.Comments.OrderByDescending(x => x.CreatedAt))
{
<div class="card mb-2 p-2 bg-light border-0">
<small class="text-muted">@c.CreatedAt.ToLocalTime().ToString("g")</small>
<p class="mb-0">@c.Text</p>
</div>
}
</div>
<div class="input-group">
<input class="form-control" placeholder="Kommentar schreiben..." @bind="newCommentText" />
<button class="btn btn-outline-secondary" @onclick="AddComment">Senden</button>
</div>
</div>
<div class="col-md-5">
<h5 class="mb-3">Anhänge</h5>
<div class="list-group mb-2">
@foreach (var file in ticket.AttachmentNames)
{
<div class="list-group-item d-flex justify-content-between align-items-center">
<span><i class="bi bi-file-earmark"></i> @file</span>
</div>
}
</div>
<button class="btn btn-sm btn-outline-primary" @onclick="MockAddFile">+ Datei simulieren</button>
</div>
</div>
}
</div>
@code {
[Parameter] public Guid Id { get; set; }
private Ticket? ticket;
private string newCommentText = "";
protected override void OnInitialized()
{
ticket = TicketService.GetTicketById(Id);
}
private void Save()
{
if (ticket != null) TicketService.UpdateTicket(ticket);
Nav.NavigateTo("/");
}
private void AddComment()
{
if (!string.IsNullOrWhiteSpace(newCommentText) && ticket != null)
{
TicketService.AddComment(ticket.Id, new TicketComment { Text = newCommentText });
newCommentText = "";
StateHasChanged();
}
}
private void MockAddFile()
{
ticket?.AttachmentNames.Add($"dokument_{DateTime.Now.Ticks % 1000}.pdf");
}
private void GoBack() => Nav.NavigateTo("/");
}
<style>
.detail-container { max-width: 1000px; margin: 2rem auto; }
.header-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
</style>
+64
View File
@@ -0,0 +1,64 @@
@page "/weather"
@attribute [StreamRendering]
<PageTitle>Weather</PageTitle>
<h1>Weather</h1>
<p>This component demonstrates showing data.</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 Fahrenheit">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()
{
// Simulate asynchronous loading to demonstrate streaming rendering
await Task.Delay(500);
var startDate = DateOnly.FromDateTime(DateTime.Now);
var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" };
forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = startDate.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = summaries[Random.Shared.Next(summaries.Length)]
}).ToArray();
}
private 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);
}
}