| | | 1 | | @using UIBlazor.Models |
| | | 2 | | @inject DialogService DialogService |
| | | 3 | | |
| | 0 | 4 | | @if (_sessions != null && _sessions.Any()) |
| | | 5 | | { |
| | | 6 | | <RadzenStack AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="1rem" Style="max-width: 600p |
| | 0 | 7 | | @if (ShowTitle) |
| | | 8 | | { |
| | 0 | 9 | | <RadzenText TextStyle="TextStyle.H6" class="rz-text-secondary-color">@SharedResource.SessionsTitle</RadzenTe |
| | | 10 | | } |
| | | 11 | | <RadzenDataList Data="@_sessions" TItem="SessionSummary" Count="@_sessions.Count" WrapItems="true"> |
| | | 12 | | <Template Context="session"> |
| | 0 | 13 | | <RadzenCard class="rz-p-2 rz-w-100" Style="cursor: pointer;" @onclick="() => LoadSession(session.Id)"> |
| | | 14 | | <RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="Jus |
| | | 15 | | <RadzenIcon Icon="chat_bubble_outline" class="rz-text-tertiary-color" /> |
| | | 16 | | <RadzenStack Orientation="Orientation.Vertical" Gap="0.2rem" Style="flex: 1; overflow: hidden;"> |
| | 0 | 17 | | <RadzenText TextStyle="TextStyle.Caption" class="rz-color-info-light" Style="text-align: end |
| | 0 | 18 | | <RadzenText TextStyle="TextStyle.Body2" Style="white-space: nowrap; overflow: hidden; text-o |
| | | 19 | | </RadzenStack> |
| | 0 | 20 | | <RadzenButton Icon="delete" ButtonStyle="ButtonStyle.Danger" Variant="Variant.Text" Size="Button |
| | | 21 | | </RadzenStack> |
| | | 22 | | </RadzenCard> |
| | | 23 | | </Template> |
| | | 24 | | </RadzenDataList> |
| | | 25 | | </RadzenStack> |
| | | 26 | | } |
| | | 27 | | else |
| | | 28 | | { |
| | | 29 | | <RadzenStack class="rz-chat-empty" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="1rem"> |
| | | 30 | | <RadzenIcon Icon="chat_bubble_outline" class="rz-text-secondary-color" /> |
| | 0 | 31 | | <RadzenText TextStyle="TextStyle.Body2" class="rz-mt-2 rz-text-tertiary-color">@SharedResource.EmptyMessage</Rad |
| | | 32 | | </RadzenStack> |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | @code { |
| | | 36 | | private List<SessionSummary>? _sessions; |
| | | 37 | | |
| | 0 | 38 | | [Inject] ChatService ChatService { get; set; } = null!; |
| | | 39 | | |
| | 0 | 40 | | [Parameter] public bool ShowTitle { get; set; } = false; |
| | | 41 | | |
| | | 42 | | protected override async Task OnInitializedAsync() |
| | | 43 | | { |
| | 0 | 44 | | _sessions = await ChatService.GetRecentSessionsAsync(5); |
| | 0 | 45 | | } |
| | | 46 | | |
| | | 47 | | private async Task LoadSession(string id) |
| | | 48 | | { |
| | 0 | 49 | | await ChatService.LoadSessionAsync(id); |
| | 0 | 50 | | DialogService.Close(); |
| | 0 | 51 | | } |
| | | 52 | | |
| | | 53 | | private async Task DeleteSessionAsync(string id, MouseEventArgs args) |
| | | 54 | | { |
| | 0 | 55 | | var result = await DialogService.Confirm(SharedResource.ConfirmQuestion, SharedResource.DeleteSession); |
| | 0 | 56 | | if (result == true) |
| | | 57 | | { |
| | 0 | 58 | | await ChatService.DeleteSessionAsync(id); |
| | 0 | 59 | | _sessions = await ChatService.GetRecentSessionsAsync(5); |
| | 0 | 60 | | await InvokeAsync(StateHasChanged); |
| | | 61 | | } |
| | 0 | 62 | | } |
| | | 63 | | } |