Skip to content

Commit

Permalink
Code(WEB::AssistantsDrawer): Fetch and display list of assistants on …
Browse files Browse the repository at this point in the history
…the UI
  • Loading branch information
ktutak1337 committed May 20, 2024
1 parent 8833094 commit fc7e295
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<MudDrawerContainer Class="mud-height-full">
@inject IAssistantService _assistantService

<MudDrawerContainer Class="mud-height-full">
<MudDrawer @bind-Open="IsOpen" Anchor="Anchor.Left" DisableOverlay="true" Elevation="8">
<MudDrawerHeader Class="pr-2 pt-1">
<MudText Typo="Typo.h6" Class="mt-2">Select or Manage Assistants</MudText>
<MudSpacer />
<MudIconButton OnClick="CloseDrawer" Icon="@Icons.Material.Filled.Close" Color="Color.Primary" />
</MudDrawerHeader>
<MudList Clickable="true">
<MudDivider />
@foreach (var assistant in Assistants)
{
<AssistantItem Assistant="@assistant" />
}
</MudList>
</MudDrawer>
</MudDrawerContainer>

Expand All @@ -16,6 +25,19 @@
[Parameter]
public EventCallback<bool> IsOpenChanged { get; set; }

public List<AssistantResponse> Assistants { get; set; } = new();

protected override async Task OnInitializedAsync()
{
await LoadAssistants();
}

private async Task LoadAssistants()
{
var response = await _assistantService.BrowseAssistants();
Assistants = response.Items.ToList();
}

private void CloseDrawer()
{
IsOpen = false;
Expand Down
2 changes: 2 additions & 0 deletions src/Client/StellarChat.Client.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using MudBlazor.Services;
using StellarChat.Client.Web;
using StellarChat.Client.Web.Services.Assistants;
using StellarChat.Client.Web.Services.Chat;
using StellarChat.Client.Web.State;

Expand All @@ -17,5 +18,6 @@
builder.Services.AddScoped<ChatState>();
builder.Services.AddMudServices();
builder.Services.AddScoped<IChatService, ChatService>();
builder.Services.AddScoped<IAssistantService, AssistantService>();

await builder.Build().RunAsync();
2 changes: 2 additions & 0 deletions src/Client/StellarChat.Client.Web/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
@using StellarChat.Client.Web.Layout
@using MudBlazor
@using StellarChat.Client.Web.Components
@using StellarChat.Shared.Contracts.Assistants
@using StellarChat.Shared.Contracts.Chat
@using StellarChat.Client.Web.Services.Assistants
@using StellarChat.Client.Web.Services.Chat
@using StellarChat.Client.Web.Models
@using StellarChat.Client.Web.State

0 comments on commit fc7e295

Please sign in to comment.