Implement Appsettings
This commit is contained in:
23
FoodsharingSiegen.Contracts/Model/AppSettings.cs
Normal file
23
FoodsharingSiegen.Contracts/Model/AppSettings.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
namespace FoodsharingSiegen.Contracts.Model
|
||||||
|
{
|
||||||
|
public class AppSettings
|
||||||
|
{
|
||||||
|
#region Public Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the title displayed in the sidebar.
|
||||||
|
/// This property represents the text that appears in the application's sidebar,
|
||||||
|
/// typically used for informational or navigational purposes.
|
||||||
|
/// </summary>
|
||||||
|
public string? SidebarTitle { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the title of the application.
|
||||||
|
/// This property holds the display name or title of the application,
|
||||||
|
/// which may be used for branding purposes in various parts of the UI.
|
||||||
|
/// </summary>
|
||||||
|
public string? Title { get; set; } = "Foodsharing Musterhausen";
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +1,73 @@
|
|||||||
using Blazorise;
|
using Blazorise;
|
||||||
using FoodsharingSiegen.Contracts.Entity;
|
using FoodsharingSiegen.Contracts.Entity;
|
||||||
|
using FoodsharingSiegen.Contracts.Model;
|
||||||
using FoodsharingSiegen.Server.Auth;
|
using FoodsharingSiegen.Server.Auth;
|
||||||
using FoodsharingSiegen.Server.Data.Service;
|
using FoodsharingSiegen.Server.Data.Service;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace FoodsharingSiegen.Server.BaseClasses
|
namespace FoodsharingSiegen.Server.BaseClasses
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The fs base class (a. beging, 08.04.2022)
|
/// The fs base class (a. beging, 08.04.2022)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="ComponentBase"/>
|
/// <seealso cref="ComponentBase" />
|
||||||
public class FsBase : ComponentBase
|
public class FsBase : ComponentBase
|
||||||
{
|
{
|
||||||
|
#region Dependencies
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
private IOptions<AppSettings> AppSettingsContainer { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value of the audit service (ab)
|
||||||
|
/// </summary>
|
||||||
|
[Inject]
|
||||||
|
private AuditService AuditService { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value of the auth service (ab)
|
||||||
|
/// </summary>
|
||||||
|
[Inject]
|
||||||
|
protected AuthService AuthService { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value of the message (ab)
|
||||||
|
/// </summary>
|
||||||
|
[Inject]
|
||||||
|
protected IMessageService Message { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value of the navigation manager (ab)
|
||||||
|
/// </summary>
|
||||||
|
[Inject]
|
||||||
|
protected NavigationManager NavigationManager { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value of the notification (ab)
|
||||||
|
/// </summary>
|
||||||
|
[Inject]
|
||||||
|
protected INotificationService Notification { get; set; } = null!;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Protected Properties
|
||||||
|
|
||||||
|
/// Provides application-specific settings used to configure the behavior and display of the application.
|
||||||
|
/// The AppSettings class encapsulates information such as the application title and other configurable parameters.
|
||||||
|
protected AppSettings AppSettings => AppSettingsContainer.Value;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the value of the current user (ab)
|
||||||
|
/// </summary>
|
||||||
|
protected User CurrentUser => AuthService?.User ?? new User();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Override OnInitializedAsync
|
#region Override OnInitializedAsync
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ons the initialized (a. beging, 11.04.2022)
|
/// Ons the initialized (a. beging, 11.04.2022)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
@@ -25,46 +77,16 @@ namespace FoodsharingSiegen.Server.BaseClasses
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Dependencies (Injected)
|
#region Protected Method RefreshState
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the value of the auth service (ab)
|
/// Refreshes the state (a. beging, 21.05.2022)
|
||||||
/// </summary>
|
|
||||||
[Inject] protected AuthService AuthService { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the value of the audit service (ab)
|
|
||||||
/// </summary>
|
|
||||||
[Inject] private AuditService AuditService { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the value of the notification (ab)
|
|
||||||
/// </summary>
|
|
||||||
[Inject] protected INotificationService Notification { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the value of the message (ab)
|
|
||||||
/// </summary>
|
|
||||||
[Inject] protected IMessageService Message { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the value of the navigation manager (ab)
|
|
||||||
/// </summary>
|
|
||||||
[Inject] protected NavigationManager NavigationManager { get; set; } = null!;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Refreshes the state (a. beging, 21.05.2022)
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected async Task RefreshState()
|
protected async Task RefreshState()
|
||||||
{
|
{
|
||||||
await AuthService?.RefreshState()!;
|
await AuthService?.RefreshState()!;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
#endregion
|
||||||
/// Gets the value of the current user (ab)
|
|
||||||
/// </summary>
|
|
||||||
protected User CurrentUser => AuthService?.User ?? new User();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using FoodsharingSiegen.Server.Data;
|
using FoodsharingSiegen.Contracts.Model;
|
||||||
|
using FoodsharingSiegen.Server.Data;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration.Json;
|
using Microsoft.Extensions.Configuration.Json;
|
||||||
|
|
||||||
@@ -52,6 +53,8 @@ namespace FoodsharingSiegen.Server
|
|||||||
// Add each file to the configuration
|
// Add each file to the configuration
|
||||||
foreach (var file in configFiles) builder.Configuration.AddJsonFile(file, true, true);
|
foreach (var file in configFiles) builder.Configuration.AddJsonFile(file, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
builder.Services.Configure<AppSettings>(builder.Configuration.GetSection("Settings"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<div class="d-flex justify-content-center align-items-center" style="height: 100vh;">
|
<div class="d-flex justify-content-center align-items-center" style="height: 100vh;">
|
||||||
<div class="card" style="width: 100%; max-width: 380px;">
|
<div class="card" style="width: 100%; max-width: 380px;">
|
||||||
<div class="card-header">FS Siegen</div>
|
<div class="card-header">@AppSettings.Title</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<Validation Validator="ValidationHelper.ValidateMail" @bind-Status="@IsValidMail">
|
<Validation Validator="ValidationHelper.ValidateMail" @bind-Status="@IsValidMail">
|
||||||
<TextEdit @bind-Text="MailAddress" Role="TextRole.Email" Placeholder="E-Mail" Class="mt-0" KeyUp="TextEdit_KeyUp"></TextEdit>
|
<TextEdit @bind-Text="MailAddress" Role="TextRole.Email" Placeholder="E-Mail" Class="mt-0" KeyUp="TextEdit_KeyUp"></TextEdit>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"applicationUrl": "http://localhost:8700",
|
"applicationUrl": "http://localhost:56000",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<nav class="flex-column">
|
<nav class="flex-column">
|
||||||
<div class="nav-logo"></div>
|
<div class="nav-logo"></div>
|
||||||
|
<div class="d-flex px-3 justify-content-center text-center font-weight-bold">
|
||||||
|
Einarbeitungen<br />
|
||||||
|
@(AppSettings.SidebarTitle ?? AppSettings.Title)
|
||||||
|
</div>
|
||||||
<div class="row px-3">
|
<div class="row px-3">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="nav-item">
|
<div class="nav-item">
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using FoodsharingSiegen.Contracts.Entity;
|
using FoodsharingSiegen.Contracts.Entity;
|
||||||
|
using FoodsharingSiegen.Contracts.Model;
|
||||||
using FoodsharingSiegen.Server.Auth;
|
using FoodsharingSiegen.Server.Auth;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace FoodsharingSiegen.Server.Shared
|
namespace FoodsharingSiegen.Server.Shared
|
||||||
{
|
{
|
||||||
@@ -11,10 +13,11 @@ namespace FoodsharingSiegen.Server.Shared
|
|||||||
{
|
{
|
||||||
#region Dependencies
|
#region Dependencies
|
||||||
|
|
||||||
/// <summary>
|
[Inject]
|
||||||
/// Gets or sets the value of the auth service (ab)
|
private IOptions<AppSettings> AppSettingsContainer { get; set; } = null!;
|
||||||
/// </summary>
|
|
||||||
[Inject] protected AuthService AuthService { get; set; } = null!;
|
[Inject]
|
||||||
|
protected AuthService AuthService { get; set; } = null!;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -27,6 +30,14 @@ namespace FoodsharingSiegen.Server.Shared
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Protected Properties
|
||||||
|
|
||||||
|
/// Provides application-specific settings used to configure the behavior and display of the application.
|
||||||
|
/// The AppSettings class encapsulates information such as the application title and other configurable parameters.
|
||||||
|
protected AppSettings AppSettings => AppSettingsContainer.Value;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Override OnInitializedAsync
|
#region Override OnInitializedAsync
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"DetailedErrors": true,
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*"
|
|
||||||
}
|
|
||||||
@@ -5,5 +5,8 @@
|
|||||||
"Url": "http://+:56000"
|
"Url": "http://+:56000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Settings": {
|
||||||
|
"Title": "Foodsharing Olpe-Wenden"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user