Skip to content

Commit

Permalink
Merge pull request #334 from neozhu/navigation
Browse files Browse the repository at this point in the history
add  GlobalVariable
  • Loading branch information
neozhu authored Mar 26, 2023
2 parents ea2e09d + eb600de commit a1930b6
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 14 deletions.
5 changes: 5 additions & 0 deletions src/Application/Constants/GlobalVariable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace CleanArchitecture.Blazor.Application.Constants;
public static class GlobalVariable
{
public static long maxAllowedSize => 512000 * 100;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override Task SetParametersAsync(ParameterView parameters)
return base.SetParametersAsync(parameters);

}
private async Task<IEnumerable<string>> searchKeyValues(string value, CancellationToken cancellation)
private Task<IEnumerable<string>> searchKeyValues(string value, CancellationToken cancellation)
{
// if text is null or empty, show complete list
_userList = _dataProvider.DataSource.Where(x => x.TenantId == TenantId).ToList();
Expand All @@ -39,7 +39,7 @@ private async Task<IEnumerable<string>> searchKeyValues(string value, Cancellati
{
result = _userList.Where(x => x.UserName.Contains(value, StringComparison.OrdinalIgnoreCase) || x.Email.Contains(value, StringComparison.OrdinalIgnoreCase)).Select(x => x.UserName).ToList();
}
return result;
return Task.FromResult(result.AsEnumerable());
}

private string toString(string str)
Expand Down
2 changes: 1 addition & 1 deletion src/Blazor.Server.UI/Pages/Customers/Customers.razor
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
{
_uploading = true;
var stream = new MemoryStream();
await file.OpenReadStream().CopyToAsync(stream);
await file.OpenReadStream(GlobalVariable.maxAllowedSize).CopyToAsync(stream);
var command = new ImportCustomersCommand(file.Name, stream.ToArray());
var result = await _mediator.Send(command);
if (result.Succeeded)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
private ISender _mediator { get; set; } = default!;
[Inject] private IUploadService _uploadService { get; set; } = default!;
List<FileUploadProgress> uploadedFiles = new();
const long MAXALLOWEDSIZE = 5242880;
private async ValueTask LoadFiles(InputFileChangeEventArgs e)
{
try
Expand All @@ -90,7 +89,7 @@
{
foreach (var file in files)
{
using var stream = file.OpenReadStream(maxAllowedSize: 10 * 1024 * 1024);
using var stream = file.OpenReadStream(GlobalVariable.maxAllowedSize);
while (await stream.ReadAsync(buffer) is int read && read > 0)
{
uploadedFiles[startIndex].UploadedBytes += read;
Expand Down Expand Up @@ -141,7 +140,7 @@
{
try
{
var filestream = uploaded.File.OpenReadStream(MAXALLOWEDSIZE);
var filestream = uploaded.File.OpenReadStream(GlobalVariable.maxAllowedSize);
var imgstream = new MemoryStream();
await filestream.CopyToAsync(imgstream);
imgstream.Position = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Blazor.Server.UI/Pages/Identity/Users/Profile.razor
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
}
private async Task UploadPhoto(InputFileChangeEventArgs e)
{
var filestream = e.File.OpenReadStream();
var filestream = e.File.OpenReadStream(GlobalVariable.maxAllowedSize);
var imgstream = new MemoryStream();
await filestream.CopyToAsync(imgstream);
imgstream.Position = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Blazor.Server.UI/Pages/Identity/Users/Users.razor
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@
{
_uploading = true;
var stream = new MemoryStream();
await file.OpenReadStream().CopyToAsync(stream);
await file.OpenReadStream(GlobalVariable.maxAllowedSize).CopyToAsync(stream);
var result = await _excelService.ImportAsync(stream.ToArray(), mappers: new Dictionary<string, Func<DataRow, ApplicationUser, object?>>
{
{ L["User Name"], (row, item) => item.UserName = row[L["User Name"]]?.ToString() },
Expand Down
2 changes: 1 addition & 1 deletion src/Blazor.Server.UI/Pages/Identity/Users/_UserForm.razor
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@

private async Task UploadPhoto(InputFileChangeEventArgs e)
{
var filestream = e.File.OpenReadStream();
var filestream = e.File.OpenReadStream(GlobalVariable.maxAllowedSize);
var imgstream = new MemoryStream();
await filestream.CopyToAsync(imgstream);
imgstream.Position = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Blazor.Server.UI/Pages/Products/Products.razor
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@
{
_uploading = true;
var stream = new MemoryStream();
await file.OpenReadStream().CopyToAsync(stream);
await file.OpenReadStream(GlobalVariable.maxAllowedSize).CopyToAsync(stream);
var command = new ImportProductsCommand(file.Name, stream.ToArray());

var result = await _mediator.Send(command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
{
try
{
var filestream = file.OpenReadStream(MAXALLOWEDSIZE);
var filestream = file.OpenReadStream(GlobalVariable.maxAllowedSize);
var imgstream = new MemoryStream();
await filestream.CopyToAsync(imgstream);
imgstream.Position = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
{
_uploading = true;
var stream = new MemoryStream();
await e.File.OpenReadStream().CopyToAsync(stream);
await e.File.OpenReadStream(GlobalVariable.maxAllowedSize).CopyToAsync(stream);
var command = new ImportKeyValuesCommand(e.File.Name, stream.ToArray());
var result = await _mediator.Send(command);
if(result.Succeeded){
Expand Down
3 changes: 1 addition & 2 deletions src/Blazor.Server.UI/Shared/MainLayout.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
}
private async Task ApplyUserPreferences()
{

_defaultDarkMode =await _mudThemeProvider.GetSystemPreference();
UserPreferences = await _layoutService.ApplyUserPreferences(_defaultDarkMode);
}
protected override async Task OnInitializedAsync()
{
_layoutService.MajorUpdateOccured += LayoutServiceOnMajorUpdateOccured;
_layoutService.SetBaseTheme(Theme.ApplicationTheme());
_layoutService.SetDarkMode(_defaultDarkMode);
_hotKeysContext = _hotKeys.CreateContext().Add(ModKey.Ctrl, Key.K, async () => await OpenCommandPalette(), "Open command palette.");
await base.OnInitializedAsync();

Expand Down

0 comments on commit a1930b6

Please sign in to comment.