From f5501f77fedbb1366d2b2cbd20327f0e1bbd852a Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Mon, 6 Nov 2023 17:41:24 +0100 Subject: [PATCH] Implemented file upload and improved ui. Fixed file upload bug in ticket service --- .../Services/Ticketing/TicketChatService.cs | 8 +-- .../Components/Forms/ChatFileSelect.razor | 56 +++++++++++++++++++ .../Components/Forms/SmartFileSelect.razor | 4 +- .../Partials/LiveChat/LiveChatOverview.razor | 25 +-------- .../Partials/LiveChat/LiveChatView.razor | 50 ++++++++++++++--- 5 files changed, 106 insertions(+), 37 deletions(-) create mode 100644 Moonlight/Shared/Components/Forms/ChatFileSelect.razor diff --git a/Moonlight/App/Services/Ticketing/TicketChatService.cs b/Moonlight/App/Services/Ticketing/TicketChatService.cs index f73cbcbc..7e8318f8 100644 --- a/Moonlight/App/Services/Ticketing/TicketChatService.cs +++ b/Moonlight/App/Services/Ticketing/TicketChatService.cs @@ -60,17 +60,17 @@ public class TicketChatService return Task.CompletedTask; } - public async Task SendMessage(string content, Stream? attachmentStream = null, string? attachmentString = null) + public async Task SendMessage(string content, Stream? attachmentStream = null, string? attachmentName = null) { if(string.IsNullOrEmpty(content)) return; - string? attachmentName = null; + string? attachmentBucketName = null; // Check and download attachments if (attachmentStream != null && attachmentName != null) { - attachmentName = await BucketService.Store( + attachmentBucketName = await BucketService.Store( "ticketAttachments", attachmentStream, attachmentName @@ -81,7 +81,7 @@ public class TicketChatService var message = new TicketMessage() { Content = content, - Attachment = attachmentName, + Attachment = attachmentBucketName, CreatedAt = DateTime.UtcNow, Sender = IdentityService.CurrentUser, IsSupport = IsSupporter diff --git a/Moonlight/Shared/Components/Forms/ChatFileSelect.razor b/Moonlight/Shared/Components/Forms/ChatFileSelect.razor new file mode 100644 index 00000000..2256bc32 --- /dev/null +++ b/Moonlight/Shared/Components/Forms/ChatFileSelect.razor @@ -0,0 +1,56 @@ +@using Microsoft.AspNetCore.Components.Forms + +@inject ToastService ToastService + +@{ + var id = $"fileUpload{GetHashCode()}"; +} + +