Init
This commit is contained in:
20
Server/Components/App.razor
Normal file
20
Server/Components/App.razor
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<base href="/"/>
|
||||
<link rel="stylesheet" href="bootstrap/bootstrap.min.css"/>
|
||||
<link rel="stylesheet" href="app.css"/>
|
||||
<link rel="stylesheet" href="Server.styles.css"/>
|
||||
<link rel="icon" type="image/png" href="favicon.png"/>
|
||||
<HeadOutlet/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<Routes />
|
||||
<script src="_framework/blazor.web.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
23
Server/Components/Layout/MainLayout.razor
Normal file
23
Server/Components/Layout/MainLayout.razor
Normal file
@@ -0,0 +1,23 @@
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
<div class="page">
|
||||
<div class="sidebar">
|
||||
<NavMenu/>
|
||||
</div>
|
||||
|
||||
<main>
|
||||
<div class="top-row px-4">
|
||||
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
|
||||
</div>
|
||||
|
||||
<article class="content px-4">
|
||||
@Body
|
||||
</article>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<div id="blazor-error-ui">
|
||||
An unhandled error has occurred.
|
||||
<a href="" class="reload">Reload</a>
|
||||
<a class="dismiss">🗙</a>
|
||||
</div>
|
||||
96
Server/Components/Layout/MainLayout.razor.css
Normal file
96
Server/Components/Layout/MainLayout.razor.css
Normal file
@@ -0,0 +1,96 @@
|
||||
.page {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
main {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
|
||||
}
|
||||
|
||||
.top-row {
|
||||
background-color: #f7f7f7;
|
||||
border-bottom: 1px solid #d6d5d5;
|
||||
justify-content: flex-end;
|
||||
height: 3.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.top-row ::deep a, .top-row ::deep .btn-link {
|
||||
white-space: nowrap;
|
||||
margin-left: 1.5rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.top-row ::deep a:first-child {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
@media (max-width: 640.98px) {
|
||||
.top-row {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.top-row ::deep a, .top-row ::deep .btn-link {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 641px) {
|
||||
.page {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 250px;
|
||||
height: 100vh;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.top-row {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.top-row.auth ::deep a:first-child {
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.top-row, article {
|
||||
padding-left: 2rem !important;
|
||||
padding-right: 1.5rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
#blazor-error-ui {
|
||||
background: lightyellow;
|
||||
bottom: 0;
|
||||
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
|
||||
display: none;
|
||||
left: 0;
|
||||
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
#blazor-error-ui .dismiss {
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
right: 0.75rem;
|
||||
top: 0.5rem;
|
||||
}
|
||||
44
Server/Components/Layout/NavMenu.razor
Normal file
44
Server/Components/Layout/NavMenu.razor
Normal file
@@ -0,0 +1,44 @@
|
||||
<div class="top-row ps-3 navbar navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="">Server</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="checkbox" title="Navigation menu" class="navbar-toggler"/>
|
||||
|
||||
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
|
||||
<nav class="flex-column">
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="/create" Match="NavLinkMatch.All">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-square-fill" viewBox="0 0 16 16">
|
||||
<path d="M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0"/>
|
||||
</svg> Neue Rechnung
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="/" Match="NavLinkMatch.All">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-receipt" viewBox="0 0 16 16">
|
||||
<path d="M1.92.506a.5.5 0 0 1 .434.14L3 1.293l.646-.647a.5.5 0 0 1 .708 0L5 1.293l.646-.647a.5.5 0 0 1 .708 0L7 1.293l.646-.647a.5.5 0 0 1 .708 0L9 1.293l.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .801.13l.5 1A.5.5 0 0 1 15 2v12a.5.5 0 0 1-.053.224l-.5 1a.5.5 0 0 1-.8.13L13 14.707l-.646.647a.5.5 0 0 1-.708 0L11 14.707l-.646.647a.5.5 0 0 1-.708 0L9 14.707l-.646.647a.5.5 0 0 1-.708 0L7 14.707l-.646.647a.5.5 0 0 1-.708 0L5 14.707l-.646.647a.5.5 0 0 1-.708 0L3 14.707l-.646.647a.5.5 0 0 1-.801-.13l-.5-1A.5.5 0 0 1 1 14V2a.5.5 0 0 1 .053-.224l.5-1a.5.5 0 0 1 .367-.27m.217 1.338L2 2.118v11.764l.137.274.51-.51a.5.5 0 0 1 .707 0l.646.647.646-.646a.5.5 0 0 1 .708 0l.646.646.646-.646a.5.5 0 0 1 .708 0l.646.646.646-.646a.5.5 0 0 1 .708 0l.646.646.646-.646a.5.5 0 0 1 .708 0l.646.646.646-.646a.5.5 0 0 1 .708 0l.509.509.137-.274V2.118l-.137-.274-.51.51a.5.5 0 0 1-.707 0L12 1.707l-.646.647a.5.5 0 0 1-.708 0L10 1.707l-.646.647a.5.5 0 0 1-.708 0L8 1.707l-.646.647a.5.5 0 0 1-.708 0L6 1.707l-.646.647a.5.5 0 0 1-.708 0L4 1.707l-.646.647a.5.5 0 0 1-.708 0z"/>
|
||||
<path d="M3 4.5a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5m8-6a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5"/>
|
||||
</svg> Rechnungen
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="customers">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person-vcard-fill" viewBox="0 0 16 16">
|
||||
<path d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2zm9 1.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 0-1h-4a.5.5 0 0 0-.5.5M9 8a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 0-1h-4A.5.5 0 0 0 9 8m1 2.5a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 0-1h-3a.5.5 0 0 0-.5.5m-1 2C9 10.567 7.21 9 5 9c-2.086 0-3.8 1.398-3.984 3.181A1 1 0 0 0 2 13h6.96q.04-.245.04-.5M7 6a2 2 0 1 0-4 0 2 2 0 0 0 4 0"/>
|
||||
</svg> Kunden
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="settings">
|
||||
<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
|
||||
</NavLink>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
105
Server/Components/Layout/NavMenu.razor.css
Normal file
105
Server/Components/Layout/NavMenu.razor.css
Normal file
@@ -0,0 +1,105 @@
|
||||
.navbar-toggler {
|
||||
appearance: none;
|
||||
cursor: pointer;
|
||||
width: 3.5rem;
|
||||
height: 2.5rem;
|
||||
color: white;
|
||||
position: absolute;
|
||||
top: 0.5rem;
|
||||
right: 1rem;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.navbar-toggler:checked {
|
||||
background-color: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
|
||||
.top-row {
|
||||
height: 3.5rem;
|
||||
background-color: rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.bi {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
margin-right: 0.75rem;
|
||||
top: -1px;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.bi-house-door-fill-nav-menu {
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E");
|
||||
}
|
||||
|
||||
.bi-plus-square-fill-nav-menu {
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E");
|
||||
}
|
||||
|
||||
.bi-list-nested-nav-menu {
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
font-size: 0.9rem;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.nav-item:first-of-type {
|
||||
padding-top: 1rem;
|
||||
}
|
||||
|
||||
.nav-item:last-of-type {
|
||||
padding-bottom: 1rem;
|
||||
}
|
||||
|
||||
.nav-item ::deep .nav-link {
|
||||
color: #d7d7d7;
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
height: 3rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
line-height: 3rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-item ::deep a.active {
|
||||
background-color: rgba(255,255,255,0.37);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.nav-item ::deep .nav-link:hover {
|
||||
background-color: rgba(255,255,255,0.1);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.nav-scrollable {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.navbar-toggler:checked ~ .nav-scrollable {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@media (min-width: 641px) {
|
||||
.navbar-toggler {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-scrollable {
|
||||
/* Never collapse the sidebar for wide screens */
|
||||
display: block;
|
||||
|
||||
/* Allow sidebar to scroll for tall menus */
|
||||
height: calc(100vh - 3.5rem);
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
20
Server/Components/Pages/Counter.razor
Normal file
20
Server/Components/Pages/Counter.razor
Normal file
@@ -0,0 +1,20 @@
|
||||
@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++;
|
||||
}
|
||||
|
||||
}
|
||||
19
Server/Components/Pages/CreatePage.razor
Normal file
19
Server/Components/Pages/CreatePage.razor
Normal file
@@ -0,0 +1,19 @@
|
||||
@page "/create"
|
||||
@rendermode InteractiveServer
|
||||
<h3>Neue Rechnung</h3>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Rechnungsnummer</label>
|
||||
<InputText class="form-control" @bind-Value="@InvoiceId" style="width: 100%; max-width: 400px;"></InputText>
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(AlertMessage))
|
||||
{
|
||||
<div class="alert alert-danger mt-3">
|
||||
@AlertMessage
|
||||
</div>
|
||||
}
|
||||
|
||||
<button type="button" class="btn btn-primary" @onclick="CreateInvoiceAsync">Anlegen</button>
|
||||
71
Server/Components/Pages/CreatePage.razor.cs
Normal file
71
Server/Components/Pages/CreatePage.razor.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Server.Data;
|
||||
using Server.Model;
|
||||
|
||||
namespace Server.Components.Pages
|
||||
{
|
||||
public partial class CreatePage
|
||||
{
|
||||
#region Dependencies
|
||||
|
||||
[Inject]
|
||||
private NavigationManager NavigationManager { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private string? AlertMessage { get; set; }
|
||||
private string? InvoiceId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override SetParametersAsync
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task SetParametersAsync(ParameterView parameters)
|
||||
{
|
||||
parameters.SetParameterProperties(this);
|
||||
|
||||
await SettingsData.LoadAsync();
|
||||
|
||||
await base.SetParametersAsync(ParameterView.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method CreateInvoiceAsync
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously creates a new invoice if the provided InvoiceId is not null, empty,
|
||||
/// or whitespace, and does not already exist in the system. If the invoice is created
|
||||
/// successfully, navigates to the newly created invoice page.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A Task representing the asynchronous operation.
|
||||
/// </returns>
|
||||
private async Task CreateInvoiceAsync()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(InvoiceId)) return;
|
||||
if (await InvoiceData.ExistsAsync(InvoiceId))
|
||||
{
|
||||
AlertMessage = "Eine Rechnung mit der Rechnungsnummer existiert bereits";
|
||||
return;
|
||||
}
|
||||
|
||||
var invoice = new InvoiceModel
|
||||
{
|
||||
InvoiceId = InvoiceId,
|
||||
Comment = SettingsData.Instance.Comment,
|
||||
PaymentData = SettingsData.Instance.PaymentData,
|
||||
Seller = SettingsData.Instance.SellerAddress
|
||||
};
|
||||
|
||||
await InvoiceData.SaveAsync(invoice);
|
||||
|
||||
NavigationManager.NavigateTo($"/edit/{InvoiceId}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
68
Server/Components/Pages/CustomerPage.razor
Normal file
68
Server/Components/Pages/CustomerPage.razor
Normal file
@@ -0,0 +1,68 @@
|
||||
@page "/customers"
|
||||
@using Server.Data
|
||||
@using Server.Model
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<h3>Kunden</h3>
|
||||
|
||||
@if (EditFormShow && EditFormObject != null)
|
||||
{
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Name</label>
|
||||
<InputText DisplayName="Name" class="form-control" @bind-Value="@EditFormObject.Name"></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Name2</label>
|
||||
<InputText DisplayName="Name2" class="form-control" @bind-Value="@EditFormObject.Name2"></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Street</label>
|
||||
<InputText DisplayName="Street" class="form-control" @bind-Value="@EditFormObject.Street"></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Zip</label>
|
||||
<InputText DisplayName="Zip" class="form-control" @bind-Value="@EditFormObject.Zip"></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">City</label>
|
||||
<InputText DisplayName="City" class="form-control" @bind-Value="@EditFormObject.City"></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Phone</label>
|
||||
<InputText DisplayName="Phone" class="form-control" @bind-Value="@EditFormObject.Phone"></InputText>
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-sm btn-primary" @onclick="SaveCustomerAsync">Speichern</button>
|
||||
<button type="button" class="btn btn-sm btn-secondary" @onclick="HideEditFormAsync">Abbrechen</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button type="button" class="btn btn-primary" @onclick="ShowCreateAsync">Neuer Kunde</button>
|
||||
}
|
||||
|
||||
<hr />
|
||||
<div class="row">
|
||||
@foreach (var customer in CustomerData.Instance.Customers.Where(x => x.State != RecordState.Deleted))
|
||||
{
|
||||
<div class="col-md-auto pt-3">
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">@customer.Name</h5>
|
||||
<p class="card-text">
|
||||
@customer.Name2<br>
|
||||
@customer.Street<br>
|
||||
@customer.Zip - @customer.City<br>
|
||||
@customer.Phone<br>
|
||||
</p>
|
||||
<button type="button" class="btn btn-sm btn-primary" @onclick="() => EditCustomerAsync(customer)">Bearbeiten</button>
|
||||
<button type="button" class="btn btn-sm btn-danger" @onclick="() => DeleteCustomerAsync(customer)">Löschen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
116
Server/Components/Pages/CustomerPage.razor.cs
Normal file
116
Server/Components/Pages/CustomerPage.razor.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Server.Data;
|
||||
using Server.Model;
|
||||
|
||||
namespace Server.Components.Pages
|
||||
{
|
||||
public partial class CustomerPage : ComponentBase
|
||||
{
|
||||
#region Private Properties
|
||||
|
||||
private bool EditFormIsNew { get; set; }
|
||||
|
||||
private Address? EditFormObject { get; set; }
|
||||
|
||||
private bool EditFormShow { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override SetParametersAsync
|
||||
|
||||
//// <inheritdoc />
|
||||
public override async Task SetParametersAsync(ParameterView parameters)
|
||||
{
|
||||
parameters.SetParameterProperties(this);
|
||||
|
||||
await CustomerData.LoadAsync();
|
||||
|
||||
await base.SetParametersAsync(ParameterView.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method DeleteCustomerAsync
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the specified customer asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="customer">The customer to be deleted.</param>
|
||||
/// <return>A Task representing the asynchronous operation.</return>
|
||||
private async Task DeleteCustomerAsync(Address customer)
|
||||
{
|
||||
customer.State = RecordState.Deleted;
|
||||
await CustomerData.SaveAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method EditCustomerAsync
|
||||
|
||||
/// <summary>
|
||||
/// Initiates the edit process for a given customer asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="customer">The customer to be edited.</param>
|
||||
/// <returns>A Task representing the asynchronous operation.</returns>
|
||||
private Task EditCustomerAsync(Address customer)
|
||||
{
|
||||
EditFormIsNew = false;
|
||||
EditFormObject = customer;
|
||||
EditFormShow = true;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method HideEditFormAsync
|
||||
|
||||
/// <summary>
|
||||
/// Hides the edit form asynchronously.
|
||||
/// </summary>
|
||||
/// <return>A Task representing the asynchronous operation.</return>
|
||||
private Task HideEditFormAsync()
|
||||
{
|
||||
EditFormObject = new();
|
||||
EditFormShow = false;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method SaveCustomerAsync
|
||||
|
||||
/// <summary>
|
||||
/// Saves the current customer data asynchronously.
|
||||
/// </summary>
|
||||
/// <returns>A Task representing the asynchronous operation.</returns>
|
||||
private async Task SaveCustomerAsync()
|
||||
{
|
||||
if (EditFormObject == null) return;
|
||||
|
||||
EditFormShow = false;
|
||||
if (EditFormIsNew) CustomerData.Instance.Customers.Add(EditFormObject);
|
||||
await CustomerData.SaveAsync();
|
||||
EditFormObject = new();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method ShowCreateAsync
|
||||
|
||||
/// <summary>
|
||||
/// Displays the form for creating a new customer.
|
||||
/// </summary>
|
||||
/// <returns>A Task representing the asynchronous operation.</returns>
|
||||
private Task ShowCreateAsync()
|
||||
{
|
||||
EditFormIsNew = true;
|
||||
EditFormObject = new();
|
||||
EditFormShow = true;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
38
Server/Components/Pages/Error.razor
Normal file
38
Server/Components/Pages/Error.razor
Normal file
@@ -0,0 +1,38 @@
|
||||
@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;
|
||||
|
||||
}
|
||||
30
Server/Components/Pages/InvoiceListPage.razor
Normal file
30
Server/Components/Pages/InvoiceListPage.razor
Normal file
@@ -0,0 +1,30 @@
|
||||
@page "/"
|
||||
@page "/invoices"
|
||||
@using Server.Model
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<h3>Rechnungen (@((Invoices ?? []).Count))</h3>
|
||||
|
||||
@foreach (var invoice in Invoices ?? [])
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-md-auto pt-3">
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">#@invoice.InvoiceId</h5>
|
||||
<h6 class="card-subtitle mb-2 text-muted">@invoice.IssueDate.ToShortDateString()</h6>
|
||||
<p class="card-text">
|
||||
@invoice.Customer?.Name<br />
|
||||
@invoice.Items.Count Artikel<br />
|
||||
@($"{invoice.TotalNetto:N2} €") Netto<br />
|
||||
</p>
|
||||
<a href="@($"edit/{invoice.InvoiceId}")" class="btn btn-sm btn-primary">Bearbeiten</a>
|
||||
@if (invoice.DeletionAllowed)
|
||||
{
|
||||
<button class="btn btn-sm btn-danger" style="margin-left: .5rem;" @onclick="() => DeleteInvoiceAsync(invoice.InvoiceId)">Löschen</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
45
Server/Components/Pages/InvoiceListPage.razor.cs
Normal file
45
Server/Components/Pages/InvoiceListPage.razor.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Server.Data;
|
||||
using Server.Model;
|
||||
|
||||
namespace Server.Components.Pages
|
||||
{
|
||||
public partial class InvoiceListPage : ComponentBase
|
||||
{
|
||||
#region Private Properties
|
||||
|
||||
private List<InvoiceModel>? Invoices { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override SetParametersAsync
|
||||
|
||||
//// <inheritdoc />
|
||||
public override async Task SetParametersAsync(ParameterView parameters)
|
||||
{
|
||||
parameters.SetParameterProperties(this);
|
||||
|
||||
Invoices = await InvoiceData.LoadAllAsync();
|
||||
|
||||
await base.SetParametersAsync(ParameterView.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method DeleteInvoiceAsync
|
||||
|
||||
/// <summary>
|
||||
/// Deletes an invoice asynchronously by its ID.
|
||||
/// </summary>
|
||||
/// <param name="invoiceInvoiceId">The ID of the invoice to be deleted.</param>
|
||||
/// <returns>A task representing the asynchronous delete operation.</returns>
|
||||
private async Task DeleteInvoiceAsync(string? invoiceInvoiceId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(invoiceInvoiceId)) return;
|
||||
await InvoiceData.DeleteAsync(invoiceInvoiceId);
|
||||
Invoices = await InvoiceData.LoadAllAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
86
Server/Components/Pages/InvoicePage.razor
Normal file
86
Server/Components/Pages/InvoicePage.razor
Normal file
@@ -0,0 +1,86 @@
|
||||
@page "/edit/{InvoiceId}"
|
||||
@using Server.Model
|
||||
@rendermode InteractiveServer
|
||||
|
||||
|
||||
<PageTitle>Home</PageTitle>
|
||||
|
||||
|
||||
|
||||
<h1>@Invoice.InvoiceId</h1>
|
||||
|
||||
<button type="button" class="btn btn-primary" @onclick="SaveInvoiceAsync">Speichern</button>
|
||||
<button type="button" class="btn btn-info" @onclick="GenerateInvoiceAsync">Generieren</button>
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(AlertMessage))
|
||||
{
|
||||
<div class="alert alert-danger mt-3">
|
||||
@AlertMessage
|
||||
</div>
|
||||
}
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-check form-switch">
|
||||
<InputCheckbox @bind-Value="@Invoice.DeletionAllowed" class="form-check-input" id="deletionallowedcheck"></InputCheckbox>
|
||||
<label class="form-check-label" for="deletionallowedcheck">Löschen erlaubt</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Datum</label>
|
||||
<InputDate class="form-control" @bind-Value="@Invoice.IssueDate"></InputDate>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" >Rechnungsnummer</label>
|
||||
<InputText class="form-control" @bind-Value="@Invoice.InvoiceId" disabled></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Kommentar</label>
|
||||
<InputTextArea class="form-control" @bind-Value="@Invoice.Comment"></InputTextArea>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<button type="button" class="btn btn-sm btn-primary" @onclick="CreateItemAsync">Neuer Artikel</button>
|
||||
|
||||
@foreach (var item in Invoice.Items)
|
||||
{
|
||||
<hr />
|
||||
|
||||
<div class="card" style="width: 100%; max-width: 1000px;">
|
||||
<div class="card-body">
|
||||
<div class="row pt-1">
|
||||
<div class="col-xl">
|
||||
<label class="form-label mb-0">Name</label>
|
||||
<InputText class="form-control" @bind-Value="@item.Name"></InputText>
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<label class="form-label mb-0">Menge</label>
|
||||
<InputNumber TValue="double" class="form-control" @bind-Value="@item.Quantity"></InputNumber>
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<label class="form-label mb-0">Price (Netto)</label>
|
||||
<InputNumber TValue="double" class="form-control" @bind-Value="@item.PriceNetto"></InputNumber>
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<label class="form-label mb-0">Tax Type</label>
|
||||
<InputSelect @bind-Value="@item.TaxType" class="form-select">
|
||||
@foreach (var taxType in Enum.GetValues(typeof(TaxType)))
|
||||
{
|
||||
<option value="@taxType">@taxType</option>
|
||||
}
|
||||
</InputSelect>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-1 mt-2">
|
||||
<label class="form-label mb-0">Description</label>
|
||||
<InputText class="form-control" @bind-Value="@item.Description"></InputText>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
153
Server/Components/Pages/InvoicePage.razor.cs
Normal file
153
Server/Components/Pages/InvoicePage.razor.cs
Normal file
@@ -0,0 +1,153 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using QuestPDF;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Infrastructure;
|
||||
using Server.Data;
|
||||
using Server.Model;
|
||||
|
||||
namespace Server.Components.Pages
|
||||
{
|
||||
public partial class InvoicePage
|
||||
{
|
||||
#region Dependencies
|
||||
|
||||
[Inject]
|
||||
private NavigationManager NavigationManager { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Parameters
|
||||
|
||||
[Parameter]
|
||||
public string? InvoiceId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private InvoiceModel Invoice { get; set; } = new();
|
||||
|
||||
private string? AlertMessage { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override SetParametersAsync
|
||||
|
||||
//// <inheritdoc />
|
||||
public override async Task SetParametersAsync(ParameterView parameters)
|
||||
{
|
||||
parameters.SetParameterProperties(this);
|
||||
|
||||
// No invoice id
|
||||
if (string.IsNullOrWhiteSpace(InvoiceId))
|
||||
{
|
||||
NavigationManager.NavigateTo("/");
|
||||
return;
|
||||
}
|
||||
|
||||
// Existing
|
||||
var invoice = await InvoiceData.LoadAsync(InvoiceId);
|
||||
if (invoice == null)
|
||||
{
|
||||
NavigationManager.NavigateTo("/");
|
||||
return;
|
||||
}
|
||||
|
||||
// Found
|
||||
Invoice = invoice;
|
||||
|
||||
Settings.License = LicenseType.Community;
|
||||
|
||||
await CustomerData.LoadAsync();
|
||||
|
||||
await base.SetParametersAsync(ParameterView.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method CreateItemAsync
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously creates a new item and adds it to the current invoice.
|
||||
/// </summary>
|
||||
/// <returns>A Task representing the asynchronous operation.</returns>
|
||||
private Task CreateItemAsync()
|
||||
{
|
||||
Invoice.Items.Add(new());
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method Generate
|
||||
|
||||
private async Task Generate()
|
||||
{
|
||||
var doc = new InvoiceDocument(new()
|
||||
{
|
||||
InvoiceId = "3129",
|
||||
Seller = SettingsData.Instance.SellerAddress,
|
||||
PaymentData = SettingsData.Instance.PaymentData,
|
||||
Comment = SettingsData.Instance.Comment,
|
||||
Customer = new()
|
||||
{
|
||||
Name = "DRK-Ortsverein Dreis-Tiefenbach e.V.",
|
||||
Name2 = "Jutta Weber",
|
||||
Street = "Feldwasserstraße 9",
|
||||
Zip = "57250",
|
||||
City = "Netphen"
|
||||
},
|
||||
Items =
|
||||
[
|
||||
new OrderItem
|
||||
{
|
||||
Name = "Schulung DRK-Cloud in Std.",
|
||||
Description = "09.12.2022 - Schulungsgruppe 1",
|
||||
Quantity = 5,
|
||||
TaxType = TaxType.Tax19,
|
||||
PriceNetto = 29
|
||||
},
|
||||
new OrderItem
|
||||
{
|
||||
Name = "Schulung DRK-Cloud in Std.",
|
||||
Description = "10.12.2022 - Schulungsgruppe 2",
|
||||
Quantity = 5,
|
||||
TaxType = TaxType.Tax19,
|
||||
PriceNetto = 29
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
doc.GeneratePdfAndShow();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method GenerateInvoiceAsync
|
||||
|
||||
private Task GenerateInvoiceAsync()
|
||||
{
|
||||
var doc = new InvoiceDocument(Invoice);
|
||||
doc.GeneratePdfAndShow();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method SaveInvoiceAsync
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously saves the current invoice.
|
||||
/// </summary>
|
||||
/// <returns>A Task representing the asynchronous save operation.</returns>
|
||||
private async Task SaveInvoiceAsync()
|
||||
{
|
||||
AlertMessage = null;
|
||||
|
||||
await InvoiceData.SaveAsync(Invoice);
|
||||
NavigationManager.NavigateTo("/invoices");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
74
Server/Components/Pages/SettingsPage.razor
Normal file
74
Server/Components/Pages/SettingsPage.razor
Normal file
@@ -0,0 +1,74 @@
|
||||
@page "/settings"
|
||||
@using Server.Data
|
||||
@using Server.Model
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<h3>Einstellungen</h3>
|
||||
|
||||
<button type="button" class="btn btn-primary" @onclick="Save">Save</button>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" >Name</label>
|
||||
<InputText DisplayName="Name" class="form-control" @bind-Value="@SettingsData.Instance.SellerAddress.Name"></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" >Name 2</label>
|
||||
<InputText DisplayName="Name 2" class="form-control" @bind-Value="@SettingsData.Instance.SellerAddress.Name2"></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" >Street</label>
|
||||
<InputText DisplayName="Street" class="form-control" @bind-Value="@SettingsData.Instance.SellerAddress.Street"></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" >Zip</label>
|
||||
<InputText DisplayName="Zip" class="form-control" @bind-Value="@SettingsData.Instance.SellerAddress.Zip"></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" >City</label>
|
||||
<InputText DisplayName="City" class="form-control" @bind-Value="@SettingsData.Instance.SellerAddress.City"></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" >Phone</label>
|
||||
<InputText DisplayName="Phone" class="form-control" @bind-Value="@SettingsData.Instance.SellerAddress.Phone"></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" >Web</label>
|
||||
<InputText DisplayName="Web" class="form-control" @bind-Value="@SettingsData.Instance.SellerAddress.Web"></InputText>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" >Comment</label>
|
||||
<InputTextArea DisplayName="Comment" class="form-control" @bind-Value="@SettingsData.Instance.Comment"></InputTextArea>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" >TaxId</label>
|
||||
<InputText DisplayName="TaxId" class="form-control" @bind-Value="@SettingsData.Instance.SellerAddress.TaxId"></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" >Bank</label>
|
||||
<InputText DisplayName="Bank" class="form-control" @bind-Value="@SettingsData.Instance.PaymentData.BankName"></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" >IBAN</label>
|
||||
<InputText DisplayName="IBAN" class="form-control" @bind-Value="@SettingsData.Instance.PaymentData.Iban"></InputText>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" >BIC</label>
|
||||
<InputText DisplayName="BIC" class="form-control" @bind-Value="@SettingsData.Instance.PaymentData.Bic"></InputText>
|
||||
</div>
|
||||
33
Server/Components/Pages/SettingsPage.razor.cs
Normal file
33
Server/Components/Pages/SettingsPage.razor.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Server.Data;
|
||||
using Server.Model;
|
||||
|
||||
namespace Server.Components.Pages
|
||||
{
|
||||
public partial class SettingsPage : ComponentBase
|
||||
{
|
||||
#region Override SetParametersAsync
|
||||
|
||||
//// <inheritdoc />
|
||||
public override async Task SetParametersAsync(ParameterView parameters)
|
||||
{
|
||||
parameters.SetParameterProperties(this);
|
||||
|
||||
await SettingsData.LoadAsync();
|
||||
|
||||
await base.SetParametersAsync(ParameterView.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method Save
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously saves the current settings to a JSON file.
|
||||
/// </summary>
|
||||
/// <returns>A task that represents the asynchronous save operation.</returns>
|
||||
private async Task Save() => await SettingsData.SaveAsync();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
65
Server/Components/Pages/Weather.razor
Normal file
65
Server/Components/Pages/Weather.razor
Normal file
@@ -0,0 +1,65 @@
|
||||
@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>Temp. (C)</th>
|
||||
<th>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);
|
||||
}
|
||||
|
||||
}
|
||||
6
Server/Components/Routes.razor
Normal file
6
Server/Components/Routes.razor
Normal file
@@ -0,0 +1,6 @@
|
||||
<Router AppAssembly="typeof(Program).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)"/>
|
||||
<FocusOnNavigate RouteData="routeData" Selector="h1"/>
|
||||
</Found>
|
||||
</Router>
|
||||
10
Server/Components/_Imports.razor
Normal file
10
Server/Components/_Imports.razor
Normal file
@@ -0,0 +1,10 @@
|
||||
@using System.Net.Http
|
||||
@using System.Net.Http.Json
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using static Microsoft.AspNetCore.Components.Web.RenderMode
|
||||
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||
@using Microsoft.JSInterop
|
||||
@using Server
|
||||
@using Server.Components
|
||||
Reference in New Issue
Block a user