43 lines
1023 B
Plaintext
43 lines
1023 B
Plaintext
@page "/admin"
|
|
@using BLAIzor.Services
|
|
@attribute [Authorize]
|
|
@rendermode InteractiveServer
|
|
|
|
@inject AIService AIService
|
|
@inject NavigationManager NavManager;
|
|
|
|
<PageTitle>Admin</PageTitle>
|
|
<h1>Admin</h1>
|
|
|
|
<div class="form-check form-switch">
|
|
<input type="checkbox" class="form-check-input" id="apiToggle" @bind="UseWebSocket">
|
|
<label class="form-check-label" for="apiToggle">Use WebSocket Realtime</label>
|
|
<button class="btn btn-primary" @onclick="Leave">Save and exit</button>
|
|
</div>
|
|
|
|
@code {
|
|
private bool UseWebSocket;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
// Load the setting from appsettings.json
|
|
UseWebSocket = AIService.UseWebsocket;
|
|
}
|
|
|
|
private void ToggleMode()
|
|
{
|
|
var newMode = UseWebSocket;
|
|
SaveSettingToAppSettings(newMode);
|
|
}
|
|
|
|
private void SaveSettingToAppSettings(bool mode)
|
|
{
|
|
AIService.UseWebsocket = mode;
|
|
}
|
|
|
|
private void Leave()
|
|
{
|
|
NavManager.NavigateTo("/", forceLoad: false);
|
|
}
|
|
}
|