Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed Jan 22, 2024
2 parents 0c3fe16 + fe00e2f commit 74e21f7
Show file tree
Hide file tree
Showing 20 changed files with 179 additions and 178 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ csharp_style_prefer_pattern_matching = true:silent
csharp_style_prefer_not_pattern = true:suggestion
csharp_style_prefer_extended_property_pattern = true:suggestion
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_prefer_primary_constructors = false:suggestion
dotnet_diagnostic.SA1101.severity = none
dotnet_diagnostic.SA1633.severity = none
dotnet_diagnostic.SA1128.severity = none
Expand All @@ -188,6 +188,7 @@ dotnet_diagnostic.SA1306.severity = none
dotnet_diagnostic.SA1600.severity = none
dotnet_diagnostic.SA1124.severity = none
dotnet_diagnostic.SA1602.severity = none
dotnet_diagnostic.SA1202.severity = none

[**/Migrations/**/*.cs]
dotnet_analyzer_diagnostic.severity = none
4 changes: 2 additions & 2 deletions NetEvent/Client.Tests/NetEvent.Client.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5">
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
14 changes: 7 additions & 7 deletions NetEvent/Client/Components/ImageValueTypeUpload.razor
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
@inject Microsoft.Extensions.Localization.IStringLocalizer<App> Localize

<MudField Label="@Localize[SystemSetting.LabelKey]" Margin="Margin.Dense" HelperText="@(string.IsNullOrEmpty(SystemSetting.DescriptionKey) ? string.Empty : Localize[SystemSetting.DescriptionKey])" Variant="Variant.Outlined" Class="@DragClass" @ondragenter="@SetDragClass" @ondragleave="@ClearDragClass" @ondragend="@ClearDragClass">
@if (!Clearing)
<MudField Label="@Localize[SystemSetting.LabelKey]" Margin="Margin.Dense" HelperText="@(string.IsNullOrEmpty(SystemSetting.DescriptionKey) ? string.Empty : Localize[SystemSetting.DescriptionKey])" Variant="Variant.Outlined" Class="@_DragClass" @ondragenter="@SetDragClass" @ondragleave="@ClearDragClass" @ondragend="@ClearDragClass">
@if (!_Clearing)
{
<InputFile OnChange="OnInputFileChanged" class="absolute mud-width-full mud-height-full overflow-hidden z-2" style="opacity:0;" accept=".jpg, .jpeg, .png" />
}

@if (string.IsNullOrEmpty(imageFileName))
@if (string.IsNullOrEmpty(_ImageFileName))
{
<MudText Typo="Typo.body2">@Localize["ImageValueTypeUpload.DragAndDropHint"]</MudText>
}

@if (uploading)
@if (_Uploading)
{
<MudProgressCircular Color="Color.Primary" Size="Size.Large" Indeterminate="true" />
<MudChip Color="Color.Dark" Text="@fileName?.Name" />
<MudChip Color="Color.Dark" Text="@_FileName?.Name" />
}

@if (!string.IsNullOrEmpty(imageFileName))
@if (!string.IsNullOrEmpty(_ImageFileName))
{
<div class="container">
<MudImage Src="@imageSrc" Fluid="true"></MudImage>
<MudImage Src="@_ImageSrc" Fluid="true"></MudImage>
<MudButton OnClick="Clear" Class="show-on-hover center-in-container" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete" Variant="Variant.Text">@Localize["ImageValueTypeUpload.Clear"]</MudButton>
</div>
}
Expand Down
52 changes: 26 additions & 26 deletions NetEvent/Client/Components/ImageValueTypeUpload.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ namespace NetEvent.Client.Components
{
public partial class ImageValueTypeUpload
{
private const string ImageUrl = "/api/system/image/";
private bool _Clearing;
private string _DragClass = string.Empty;
private IBrowserFile? _FileName;
private string? _ImageFileName;
private string? _ImageSrc;
private bool _Uploading;

[Parameter]
public ImageValueType ImageValueType { get; set; } = default!;

Expand All @@ -18,65 +26,57 @@ public partial class ImageValueTypeUpload
[Inject]
private ISystemSettingsDataService SystemSettingsDataService { get; set; } = default!;

private const string ImageUrl = "/api/system/image/";
private bool Clearing;
private string DragClass = string.Empty;
private IBrowserFile? fileName;
private string? imageFileName;
private string? imageSrc;
private bool uploading;

protected override async Task OnInitializedAsync()
{
using var cancellationTokenSource = new CancellationTokenSource();
imageFileName = (await SystemSettingsDataService.GetSystemSettingAsync(SystemSettingGroup.OrganizationData, SystemSetting.Key, cancellationTokenSource.Token).ConfigureAwait(false))?.Value;
if (!string.IsNullOrEmpty(imageFileName))
_ImageFileName = (await SystemSettingsDataService.GetSystemSettingAsync(SystemSettingGroup.OrganizationData, SystemSetting.Key, cancellationTokenSource.Token).ConfigureAwait(false))?.Value;
if (!string.IsNullOrEmpty(_ImageFileName))
{
imageSrc = $"{ImageUrl}{imageFileName}";
_ImageSrc = $"{ImageUrl}{_ImageFileName}";
}
}

private async Task OnInputFileChanged(InputFileChangeEventArgs e)
{
uploading = true;
fileName = e.File;
_Uploading = true;
_FileName = e.File;

using var cancellationTokenSource = new CancellationTokenSource();
var uploadResult = await SystemSettingsDataService.UploadSystemImage(e.File, cancellationTokenSource.Token);
if (uploadResult.Successful)
{
imageFileName = uploadResult.ResultData;
if (!string.IsNullOrEmpty(imageFileName))
_ImageFileName = uploadResult.ResultData;
if (!string.IsNullOrEmpty(_ImageFileName))
{
await SystemSettingsDataService.UpdateSystemSetting(SystemSettingGroup.OrganizationData, new NetEvent.Shared.Dto.SystemSettingValueDto { Key = SystemSetting.Key, Value = imageFileName }, cancellationTokenSource.Token).ConfigureAwait(false);
imageSrc = $"{ImageUrl}{imageFileName}";
await SystemSettingsDataService.UpdateSystemSetting(SystemSettingGroup.OrganizationData, new NetEvent.Shared.Dto.SystemSettingValueDto { Key = SystemSetting.Key, Value = _ImageFileName }, cancellationTokenSource.Token).ConfigureAwait(false);
_ImageSrc = $"{ImageUrl}{_ImageFileName}";
}
}

ClearDragClass();
uploading = false;
_Uploading = false;
}

private async Task Clear()
{
Clearing = true;
fileName = null;
_Clearing = true;
_FileName = null;
ClearDragClass();
imageFileName = string.Empty;
_ImageFileName = string.Empty;
using var cancellationTokenSource = new CancellationTokenSource();
await SystemSettingsDataService.UpdateSystemSetting(SystemSettingGroup.OrganizationData, new NetEvent.Shared.Dto.SystemSettingValueDto { Key = SystemSetting.Key, Value = imageFileName }, cancellationTokenSource.Token).ConfigureAwait(false);
imageSrc = string.Empty;
Clearing = false;
await SystemSettingsDataService.UpdateSystemSetting(SystemSettingGroup.OrganizationData, new NetEvent.Shared.Dto.SystemSettingValueDto { Key = SystemSetting.Key, Value = _ImageFileName }, cancellationTokenSource.Token).ConfigureAwait(false);
_ImageSrc = string.Empty;
_Clearing = false;
}

private void SetDragClass()
{
DragClass = $"border-dashed";
_DragClass = $"border-dashed";
}

private void ClearDragClass()
{
DragClass = string.Empty;
_DragClass = string.Empty;
}
}
}
10 changes: 5 additions & 5 deletions NetEvent/Client/NetEvent.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@

<ItemGroup>
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" PrivateAssets="all" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" PrivateAssets="all" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.0" />
<PackageReference Include="MudBlazor" Version="6.11.2" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.1" />
<PackageReference Include="MudBlazor" Version="6.13.0" />
<PackageReference Include="MudBlazor.ThemeManager" Version="1.0.8" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Quick.AspNetCore.Components.Web.Extensions" Version="6.0.2" />
Expand Down
6 changes: 3 additions & 3 deletions NetEvent/Client/Pages/Administration/Users.razor
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<MudTabPanel Text="@Localize["Administration.Users.Roles.Title"]">
<NetEventDataGrid T="RoleDto"
MultiSelection="false"
@ref="RolesDataGrid"
@ref="_RolesDataGrid"
Items="@AllRoles"
SortMode="SortMode.Single"
Filterable="false"
Expand All @@ -87,7 +87,7 @@
<MudSpacer />
<MudTextField @bind-Value="_RoleSearchString" Placeholder="@Localize["Administration.Users.Roles.Search"]" Adornment="Adornment.Start" Immediate="true"
AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0"></MudTextField>
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Add" OnClick="RolesDataGrid!.AddNewItemAsync" />
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Add" OnClick="_RolesDataGrid!.AddNewItemAsync" />
</ToolBarContent>
<Columns>
<PropertyColumn T="RoleDto" TProperty="string" Property="x => x.Id" Title="@Localize["Administration.Users.Roles.Id"]" IsEditable="false" />
Expand Down Expand Up @@ -130,7 +130,7 @@
<TemplateColumn T="RoleDto" CellClass="d-flex justify-end">
<CellTemplate>
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Edit" OnClick="@context.Actions.StartEditingItemAsync" />
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Delete" OnClick="@(() => RolesDataGrid!.DeleteItemAsync(context.Item))" />
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Delete" OnClick="@(() => _RolesDataGrid!.DeleteItemAsync(context.Item))" />
</CellTemplate>
</TemplateColumn>
</Columns>
Expand Down
38 changes: 19 additions & 19 deletions NetEvent/Client/Pages/Administration/Users.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@ namespace NetEvent.Client.Pages.Administration
{
public partial class Users
{
[Inject]
private IUserService _UserService { get; set; } = default!;
private NetEventDataGrid<RoleDto>? _RolesDataGrid;

[Inject]
private IRoleService _RoleService { get; set; } = default!;
private IUserService UserService { get; set; } = default!;

[Inject]
private ISnackbar _Snackbar { get; set; } = default!;
private IRoleService RoleService { get; set; } = default!;

[Inject]
private IStringLocalizer<App> _Localizer { get; set; } = default!;
private ISnackbar Snackbar { get; set; } = default!;

private NetEventDataGrid<RoleDto>? RolesDataGrid;
[Inject]
private IStringLocalizer<App> Localizer { get; set; } = default!;

protected override async Task OnInitializedAsync()
{
using var cancellationTokenSource = new CancellationTokenSource();

AllUsers = await _UserService.GetUsersAsync(cancellationTokenSource.Token);
AllUsers = await UserService.GetUsersAsync(cancellationTokenSource.Token);
await LoadRoles(cancellationTokenSource.Token);
}

private async Task LoadRoles(CancellationToken cancellationToken)
{
AllRoles = await _RoleService.GetRolesAsync(cancellationToken);
AllRoles = await RoleService.GetRolesAsync(cancellationToken);
}

#region Users
Expand Down Expand Up @@ -82,16 +82,16 @@ private async Task CommittedUserChangesAsync(AdminUserDto updatedUser)
{
using var cancellationTokenSource = new CancellationTokenSource();

var result = await _UserService.UpdateUserAsync(updatedUser, cancellationTokenSource.Token).ConfigureAwait(false);
var result = await UserService.UpdateUserAsync(updatedUser, cancellationTokenSource.Token).ConfigureAwait(false);

if (result.Successful)
{
result = await _UserService.UpdateUserRoleAsync(updatedUser.Id, updatedUser.Role.Id, cancellationTokenSource.Token).ConfigureAwait(false);
result = await UserService.UpdateUserRoleAsync(updatedUser.Id, updatedUser.Role.Id, cancellationTokenSource.Token).ConfigureAwait(false);
}

if (!string.IsNullOrEmpty(result.MessageKey) && !string.IsNullOrEmpty(updatedUser.Email))
{
_Snackbar.Add(_Localizer.GetString(result.MessageKey, updatedUser.Email), result.Successful ? Severity.Success : Severity.Error);
Snackbar.Add(Localizer.GetString(result.MessageKey, updatedUser.Email), result.Successful ? Severity.Success : Severity.Error);
}
}
#endregion
Expand Down Expand Up @@ -129,16 +129,16 @@ private async Task CommittedRoleChangesAsync(RoleDto updatedRole)
ServiceResult result;
if (string.IsNullOrEmpty(updatedRole.Id))
{
result = await _RoleService.AddRoleAsync(updatedRole, cancellationTokenSource.Token).ConfigureAwait(false);
result = await RoleService.AddRoleAsync(updatedRole, cancellationTokenSource.Token).ConfigureAwait(false);
}
else
{
result = await _RoleService.UpdateRoleAsync(updatedRole, cancellationTokenSource.Token).ConfigureAwait(false);
result = await RoleService.UpdateRoleAsync(updatedRole, cancellationTokenSource.Token).ConfigureAwait(false);
}

if (!string.IsNullOrEmpty(result.MessageKey))
{
_Snackbar.Add(_Localizer.GetString(result.MessageKey, updatedRole.Name), result.Successful ? Severity.Success : Severity.Error);
Snackbar.Add(Localizer.GetString(result.MessageKey, updatedRole.Name), result.Successful ? Severity.Success : Severity.Error);
}

await LoadRoles(cancellationTokenSource.Token);
Expand All @@ -147,11 +147,11 @@ private async Task CommittedRoleChangesAsync(RoleDto updatedRole)
private async Task DeletedItemChanges(EventCallbackArgs<RoleDto> deletedRoleArgs)
{
using var cancellationTokenSource = new CancellationTokenSource();
var result = await _RoleService.DeleteRoleAsync(deletedRoleArgs.Value, cancellationTokenSource.Token).ConfigureAwait(false);
var result = await RoleService.DeleteRoleAsync(deletedRoleArgs.Value, cancellationTokenSource.Token).ConfigureAwait(false);

if (!string.IsNullOrEmpty(result.MessageKey))
{
_Snackbar.Add(_Localizer.GetString(result.MessageKey, deletedRoleArgs.Value.Name), result.Successful ? Severity.Success : Severity.Error);
Snackbar.Add(Localizer.GetString(result.MessageKey, deletedRoleArgs.Value.Name), result.Successful ? Severity.Success : Severity.Error);
}

if (!result.Successful)
Expand All @@ -164,9 +164,9 @@ private string CreateSelectionLabel(List<string> selectedValues)
{
return selectedValues.Count switch
{
int n when n == 1 => $"{selectedValues.Count} {_Localizer["Administration.Users.Roles.SelectPermissionSingular"]}",
int n when n > 1 => $"{selectedValues.Count} {_Localizer["Administration.Users.Roles.SelectPermissionPlural"]}",
_ => (string)_Localizer["Administration.Users.Roles.NothingSelected"],
int n when n == 1 => $"{selectedValues.Count} {Localizer["Administration.Users.Roles.SelectPermissionSingular"]}",
int n when n > 1 => $"{selectedValues.Count} {Localizer["Administration.Users.Roles.SelectPermissionPlural"]}",
_ => (string)Localizer["Administration.Users.Roles.NothingSelected"],
};
}
#endregion
Expand Down
6 changes: 3 additions & 3 deletions NetEvent/Server.Tests/EventManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task EventManagerTest_ValidateEventNull_Test()
using var scope = Application.Services.CreateScope();
var eventManager = scope.ServiceProvider.GetRequiredService<IEventManager>();
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
var result = await eventManager.ValidateEventAsync(null).ConfigureAwait(false);
var result = await eventManager.ValidateEventAsync(null);
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.

Assert.NotNull(result);
Expand All @@ -28,7 +28,7 @@ public async Task EventManagerTest_DeleteMissingEvent_Test()
{
using var scope = Application.Services.CreateScope();
var eventManager = scope.ServiceProvider.GetRequiredService<IEventManager>();
var result = await eventManager.DeleteAsync(Fakers.EventFaker(Fakers.VenueFaker().Generate(2)).Generate()).ConfigureAwait(false);
var result = await eventManager.DeleteAsync(Fakers.EventFaker(Fakers.VenueFaker().Generate(2)).Generate());

Assert.NotNull(result);
Assert.False(result.Succeeded);
Expand All @@ -39,7 +39,7 @@ public async Task EventManagerTest_DeleteMissingEventId_Test()
{
using var scope = Application.Services.CreateScope();
var eventManager = scope.ServiceProvider.GetRequiredService<IEventManager>();
var result = await eventManager.DeleteAsync(1337).ConfigureAwait(false);
var result = await eventManager.DeleteAsync(1337);

Assert.NotNull(result);
Assert.False(result.Succeeded);
Expand Down
Loading

0 comments on commit 74e21f7

Please sign in to comment.