-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Send messages from uploaded files (#52)
- Loading branch information
Showing
13 changed files
with
178 additions
and
10 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
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
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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace CrossBusExplorer.ServiceBus.Contracts.Types; | ||
|
||
public enum UploadFileType | ||
{ | ||
Body = 0, | ||
BodyWithApplicationProperties = 1 | ||
} |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using System.Collections.Generic; | ||
using CrossBusExplorer.ServiceBus.Contracts.Types; | ||
namespace CrossBusExplorer.Website.Models; | ||
|
||
public record MessagesUploadDialogResult(UploadFileType Type, IList<string> FilesContent); |
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
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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
@using CrossBusExplorer.ServiceBus.Contracts.Types | ||
@using System.IO | ||
@using CrossBusExplorer.Website.Models | ||
<MudDialog> | ||
<TitleContent> | ||
<MudText Typo="Typo.h6"> | ||
Upload messages from file | ||
</MudText> | ||
<MudText>Max 1000 at once</MudText> | ||
</TitleContent> | ||
<DialogContent> | ||
<MudPaper Elevation="3"> | ||
<MudField Variant="Variant.Outlined" Label="File type"> | ||
<MudRadioGroup @bind-SelectedOption="_uploadFileType" | ||
For="@(() => _uploadFileType)"> | ||
<MudRadio Dense="true" | ||
Size="Size.Small" | ||
Option="UploadFileType.Body"> | ||
Body only | ||
</MudRadio> | ||
<MudRadio Dense="true" | ||
Size="Size.Small" | ||
Disabled="true" | ||
Option="UploadFileType.BodyWithApplicationProperties"> | ||
Body with ApplicationProperties (not yet supported) | ||
</MudRadio> | ||
</MudRadioGroup> | ||
</MudField> | ||
</MudPaper> | ||
<MudPaper Elevation="3"> | ||
<MudField Variant="Variant.Outlined" Label="Select files"> | ||
<MudFileUpload T="IReadOnlyList<IBrowserFile>" FilesChanged="UploadFilesAsync" MaximumFileCount="1000"> | ||
<ButtonTemplate> | ||
<MudButton HtmlTag="label" | ||
Variant="Variant.Filled" | ||
Color="Color.Primary" | ||
StartIcon="@Icons.Material.Filled.CloudUpload" | ||
for="@context.Id"> | ||
Select multiple files | ||
</MudButton> | ||
</ButtonTemplate> | ||
</MudFileUpload> | ||
</MudField> | ||
</MudPaper> | ||
</DialogContent> | ||
<DialogActions> | ||
<MudButton ButtonType="ButtonType.Reset" | ||
Color="Color.Default" | ||
OnClick="@(CloseDialog)" | ||
Class="px-10"> | ||
Close | ||
</MudButton> | ||
<MudButton ButtonType="ButtonType.Button" | ||
Color="Color.Success" | ||
OnClick="@(Submit)" | ||
Disabled="@(!_fileContents.Any())" | ||
Class="px-10"> | ||
Upload @_fileContents.Count files | ||
</MudButton> | ||
</DialogActions> | ||
</MudDialog> | ||
|
||
@code { | ||
[CascadingParameter] | ||
MudDialogInstance MudDialog { get; set; } | ||
|
||
IList<string> _fileContents = new List<string>(); | ||
|
||
private UploadFileType _uploadFileType; | ||
|
||
private void CloseDialog() | ||
{ | ||
MudDialog.Close(DialogResult.Cancel()); | ||
} | ||
|
||
private void Submit() | ||
{ | ||
MudDialog.Close(DialogResult.Ok(new MessagesUploadDialogResult(_uploadFileType, _fileContents))); | ||
} | ||
|
||
private async Task UploadFilesAsync(IReadOnlyList<IBrowserFile> files) | ||
{ | ||
_fileContents.Clear(); | ||
|
||
foreach (IBrowserFile file in files) | ||
{ | ||
using var reader = new StreamReader(file.OpenReadStream()); | ||
var fileContent = await reader.ReadToEndAsync(default); | ||
|
||
_fileContents.Add(fileContent); | ||
} | ||
} | ||
} |
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
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
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