mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 11:59:48 +00:00
Refactor Settings component to inherit from MSGComponentBase
This commit is contained in:
parent
06fcaf7f8f
commit
6e0deb4e64
@ -1,6 +1,7 @@
|
|||||||
@attribute [Route(Routes.SETTINGS)]
|
|
||||||
@using AIStudio.Components.Settings
|
@using AIStudio.Components.Settings
|
||||||
@using AIStudio.Settings.DataModel
|
@using AIStudio.Settings.DataModel
|
||||||
|
@attribute [Route(Routes.SETTINGS)]
|
||||||
|
@inherits MSGComponentBase
|
||||||
|
|
||||||
<div class="inner-scrolling-context">
|
<div class="inner-scrolling-context">
|
||||||
<MudText Typo="Typo.h3" Class="mb-12">Settings</MudText>
|
<MudText Typo="Typo.h3" Class="mb-12">Settings</MudText>
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
|
using AIStudio.Components;
|
||||||
using AIStudio.Settings;
|
using AIStudio.Settings;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
namespace AIStudio.Pages;
|
namespace AIStudio.Pages;
|
||||||
|
|
||||||
public partial class Settings : ComponentBase, IMessageBusReceiver, IDisposable
|
public partial class Settings : MSGComponentBase
|
||||||
{
|
{
|
||||||
[Inject]
|
|
||||||
private SettingsManager SettingsManager { get; init; } = null!;
|
|
||||||
|
|
||||||
[Inject]
|
|
||||||
private MessageBus MessageBus { get; init; } = null!;
|
|
||||||
|
|
||||||
private List<ConfigurationSelectData<string>> availableLLMProviders = new();
|
private List<ConfigurationSelectData<string>> availableLLMProviders = new();
|
||||||
private List<ConfigurationSelectData<string>> availableEmbeddingProviders = new();
|
private List<ConfigurationSelectData<string>> availableEmbeddingProviders = new();
|
||||||
|
|
||||||
@ -19,20 +14,18 @@ public partial class Settings : ComponentBase, IMessageBusReceiver, IDisposable
|
|||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
// Register this component with the message bus:
|
this.ApplyFilters([], [ Event.CONFIGURATION_CHANGED ]);
|
||||||
this.MessageBus.RegisterComponent(this);
|
|
||||||
this.MessageBus.ApplyFilters(this, [], [ Event.CONFIGURATION_CHANGED ]);
|
|
||||||
|
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Implementation of IMessageBusReceiver
|
#region Overrides of MSGComponentBase
|
||||||
|
|
||||||
public string ComponentName => nameof(Settings);
|
public override string ComponentName => nameof(Settings);
|
||||||
|
|
||||||
public Task ProcessMessage<TMsg>(ComponentBase? sendingComponent, Event triggeredEvent, TMsg? data)
|
protected override Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
|
||||||
{
|
{
|
||||||
switch (triggeredEvent)
|
switch (triggeredEvent)
|
||||||
{
|
{
|
||||||
@ -44,19 +37,5 @@ public partial class Settings : ComponentBase, IMessageBusReceiver, IDisposable
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<TResult?> ProcessMessageWithResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data)
|
|
||||||
{
|
|
||||||
return Task.FromResult<TResult?>(default);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Implementation of IDisposable
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
this.MessageBus.Unregister(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user