-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor(WEB): Code refractor and cleanup
- Loading branch information
1 parent
d01f28d
commit 5d7cb86
Showing
10 changed files
with
271 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...eb/Components/AssistantPickerButton.razor → ...ts/Assistants/AssistantPickerButton.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...onents/ChangeChatSessionTitleDialog.razor → ...s/Chat/ChangeChatSessionTitleDialog.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 59 additions & 59 deletions
118
...ient.Web/Components/ChatHistoryItem.razor → ...Web/Components/Chat/ChatHistoryItem.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,59 @@ | ||
@inject NavigationManager NavigationManager | ||
@inject IChatService _chatService | ||
@inject IDialogService _dialogService | ||
@inject ChatState _chatState | ||
|
||
<MudListItem OnClick="@NavigateToChat"> | ||
<ChildContent> | ||
<div class="d-flex flex-row flex-grow-1 gap-4"> | ||
<MudAvatar Size="@Size.Medium" Class="my-auto"> | ||
<MudImage Src="https://avatars.githubusercontent.com/u/49451143?v=4"></MudImage> | ||
</MudAvatar> | ||
<MudText Typo="Typo.body1" Class="my-auto">@ChatSessionItem?.Title</MudText> | ||
<MudSpacer /> | ||
<MudMenu Icon="@Icons.Material.Filled.MoreVert"> | ||
<MudMenuItem OnClick="OpenChangeTitleDialog">Rename</MudMenuItem> | ||
<MudMenuItem OnClick="DeleteChat">Delete</MudMenuItem> | ||
</MudMenu> | ||
</div> | ||
</ChildContent> | ||
</MudListItem> | ||
<MudDivider /> | ||
|
||
@code | ||
{ | ||
[Parameter] public ChatSessionResponse? ChatSessionItem { get; set; } | ||
[Parameter] public EventCallback<ChatSessionResponse> OnDeleteChat { get; set; } | ||
[Parameter] public EventCallback<ChangeTitleInfo> OnChangeTitle { get; set; } | ||
|
||
private void NavigateToChat() | ||
{ | ||
_chatState.SetChatId(ChatSessionItem!.Id); | ||
NavigationManager.NavigateTo($"/c/{ChatSessionItem.Id}"); | ||
} | ||
|
||
private async Task DeleteChat() | ||
=> await OnDeleteChat.InvokeAsync(ChatSessionItem); | ||
|
||
private async Task OpenChangeTitleDialog() | ||
{ | ||
var parameters = new DialogParameters(); | ||
parameters.Add(nameof(ChatSessionItem), ChatSessionItem); | ||
|
||
var options = new DialogOptions { CloseOnEscapeKey = true }; | ||
var dialog = _dialogService.Show<ChangeChatSessionTitleDialog>("Change title", parameters, options); | ||
|
||
var result = await dialog.Result; | ||
|
||
if (!result.Canceled) | ||
{ | ||
var updatedTitle = result.Data as string; | ||
|
||
if (!string.IsNullOrEmpty(updatedTitle)) | ||
{ | ||
var changeTitleInfo = new ChangeTitleInfo(ChatSessionItem!.Id, updatedTitle); | ||
await OnChangeTitle.InvokeAsync(changeTitleInfo); | ||
} | ||
} | ||
} | ||
} | ||
@inject NavigationManager NavigationManager | ||
@inject IChatService _chatService | ||
@inject IDialogService _dialogService | ||
@inject ChatState _chatState | ||
|
||
<MudListItem OnClick="@NavigateToChat"> | ||
<ChildContent> | ||
<div class="d-flex flex-row flex-grow-1 gap-4"> | ||
<MudAvatar Size="@Size.Medium" Class="my-auto"> | ||
<MudImage Src="https://avatars.githubusercontent.com/u/49451143?v=4"/> | ||
</MudAvatar> | ||
<MudText Typo="Typo.body1" Class="my-auto">@ChatSessionItem?.Title</MudText> | ||
<MudSpacer /> | ||
<MudMenu Icon="@Icons.Material.Filled.MoreVert"> | ||
<MudMenuItem OnClick="OpenChangeTitleDialog">Rename</MudMenuItem> | ||
<MudMenuItem OnClick="DeleteChat">Delete</MudMenuItem> | ||
</MudMenu> | ||
</div> | ||
</ChildContent> | ||
</MudListItem> | ||
<MudDivider /> | ||
|
||
@code | ||
{ | ||
[Parameter] public ChatSessionResponse? ChatSessionItem { get; set; } | ||
[Parameter] public EventCallback<ChatSessionResponse> OnDeleteChat { get; set; } | ||
[Parameter] public EventCallback<ChangeTitleInfo> OnChangeTitle { get; set; } | ||
|
||
private void NavigateToChat() | ||
{ | ||
_chatState.SetChatId(ChatSessionItem!.Id); | ||
NavigationManager.NavigateTo($"/c/{ChatSessionItem.Id}"); | ||
} | ||
|
||
private async Task DeleteChat() | ||
=> await OnDeleteChat.InvokeAsync(ChatSessionItem); | ||
|
||
private async Task OpenChangeTitleDialog() | ||
{ | ||
var parameters = new DialogParameters(); | ||
parameters.Add(nameof(ChatSessionItem), ChatSessionItem); | ||
|
||
var options = new DialogOptions { CloseOnEscapeKey = true }; | ||
var dialog = _dialogService.Show<ChangeChatSessionTitleDialog>("Change title", parameters, options); | ||
|
||
var result = await dialog.Result; | ||
|
||
if (!result.Canceled) | ||
{ | ||
var updatedTitle = result.Data as string; | ||
|
||
if (!string.IsNullOrEmpty(updatedTitle)) | ||
{ | ||
var changeTitleInfo = new ChangeTitleInfo(ChatSessionItem!.Id, updatedTitle); | ||
await OnChangeTitle.InvokeAsync(changeTitleInfo); | ||
} | ||
} | ||
} | ||
} |
56 changes: 28 additions & 28 deletions
56
...t.Client.Web/Components/ChatMessage.razor → ...ent.Web/Components/Chat/ChatMessage.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
<div class="d-flex mb-6"> | ||
<div id="chat-message-avatar" class="avatar mr-2"> | ||
|
||
@* TODO: Implement logic to display the correct avatar based on whether the author is a user or a bot. | ||
Use the avatar image URL from the application state. *@ | ||
|
||
<MudAvatar Rounded="true" Color="Color.Secondary"> | ||
<MudImage Src="https://avatars.githubusercontent.com/u/49451143?v=4" Alt="An image of the best dog ever!"></MudImage> | ||
</MudAvatar> | ||
</div> | ||
<div id="chat-message-text" class="flex-grow-1"> | ||
@Message?.Content | ||
<div id="chat-message-icons" class="d-flex flex-row mt-4"> | ||
<MudIconButton id="chat-read-aloud-button" Class="mt-1" Size="Size.Small" Color="Color.Inherit" Disabled="true"> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 19" width="20" height="20"> | ||
<path fill="currentColor" d="M13 2.25c0-1.079-1.274-1.65-2.08-.934L6.427 5.309a.75.75 0 0 1-.498.19H2.25A2.25 2.25 0 0 0 0 7.749v4.497a2.25 2.25 0 0 0 2.25 2.25h3.68a.75.75 0 0 1 .498.19l4.491 3.994c.806.716 2.081.144 2.081-.934V2.25ZM7.425 6.43 11.5 2.807v14.382l-4.075-3.624a2.25 2.25 0 0 0-1.495-.569H2.25a.75.75 0 0 1-.75-.75V7.75a.75.75 0 0 1 .75-.75h3.68a2.25 2.25 0 0 0 1.495-.569Zm9.567-2.533a.75.75 0 0 1 1.049.157A9.959 9.959 0 0 1 20 10a9.96 9.96 0 0 1-1.96 5.946.75.75 0 0 1-1.205-.892A8.459 8.459 0 0 0 18.5 10a8.459 8.459 0 0 0-1.665-5.054.75.75 0 0 1 .157-1.049ZM15.143 6.37a.75.75 0 0 1 1.017.303c.536.99.84 2.125.84 3.328a6.973 6.973 0 0 1-.84 3.328.75.75 0 0 1-1.32-.714c.42-.777.66-1.666.66-2.614s-.24-1.837-.66-2.614a.75.75 0 0 1 .303-1.017Z"></path> | ||
</svg> | ||
</MudIconButton> | ||
<MudIconButton id="chat-copy-message-button" Size="Size.Small" Class="ml-2" Icon="@Icons.Material.Filled.ContentCopy" Color="Color.Inherit" Disabled="true" /> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
@code | ||
{ | ||
[Parameter] | ||
public ChatMessageResponse? Message { get; set; } | ||
} | ||
<div class="d-flex mb-6"> | ||
<div id="chat-message-avatar" class="avatar mr-2"> | ||
|
||
@* TODO: Implement logic to display the correct avatar based on whether the author is a user or a bot. | ||
Use the avatar image URL from the application state. *@ | ||
|
||
<MudAvatar Rounded="true" Color="Color.Secondary"> | ||
<MudImage Src="https://avatars.githubusercontent.com/u/49451143?v=4" /> | ||
</MudAvatar> | ||
</div> | ||
<div id="chat-message-text" class="flex-grow-1"> | ||
@Message?.Content | ||
<div id="chat-message-icons" class="d-flex flex-row mt-4"> | ||
<MudIconButton id="chat-read-aloud-button" Class="mt-1" Size="Size.Small" Color="Color.Inherit" Disabled="true"> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 19" width="20" height="20"> | ||
<path fill="currentColor" d="M13 2.25c0-1.079-1.274-1.65-2.08-.934L6.427 5.309a.75.75 0 0 1-.498.19H2.25A2.25 2.25 0 0 0 0 7.749v4.497a2.25 2.25 0 0 0 2.25 2.25h3.68a.75.75 0 0 1 .498.19l4.491 3.994c.806.716 2.081.144 2.081-.934V2.25ZM7.425 6.43 11.5 2.807v14.382l-4.075-3.624a2.25 2.25 0 0 0-1.495-.569H2.25a.75.75 0 0 1-.75-.75V7.75a.75.75 0 0 1 .75-.75h3.68a2.25 2.25 0 0 0 1.495-.569Zm9.567-2.533a.75.75 0 0 1 1.049.157A9.959 9.959 0 0 1 20 10a9.96 9.96 0 0 1-1.96 5.946.75.75 0 0 1-1.205-.892A8.459 8.459 0 0 0 18.5 10a8.459 8.459 0 0 0-1.665-5.054.75.75 0 0 1 .157-1.049ZM15.143 6.37a.75.75 0 0 1 1.017.303c.536.99.84 2.125.84 3.328a6.973 6.973 0 0 1-.84 3.328.75.75 0 0 1-1.32-.714c.42-.777.66-1.666.66-2.614s-.24-1.837-.66-2.614a.75.75 0 0 1 .303-1.017Z"></path> | ||
</svg> | ||
</MudIconButton> | ||
<MudIconButton id="chat-copy-message-button" Size="Size.Small" Class="ml-2" Icon="@Icons.Material.Filled.ContentCopy" Color="Color.Inherit" Disabled="true" /> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
@code | ||
{ | ||
[Parameter] | ||
public ChatMessageResponse? Message { get; set; } | ||
} |
Oops, something went wrong.