Skip to content

Commit

Permalink
109 fix bugs from mudblazor 7 update (#110)
Browse files Browse the repository at this point in the history
* fix: Fixed a bug when deleting images related to maps

* fix: Fixed issues with new mudblazor version 7

---------

Co-authored-by: Fenrikur <3359222+Fenrikur@users.noreply.github.com>
  • Loading branch information
Metawolve and Fenrikur authored Jul 18, 2024
1 parent 6fe2618 commit ed90c3b
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 28 deletions.
14 changes: 6 additions & 8 deletions src/Eurofurence.App.Backoffice/Components/ImageDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@
</MudImage>
</MudItem>
<MudItem xs="6">
<MudFileUpload T="IBrowserFile" Context="fileInput" FilesChanged="UploadImage">
<ButtonTemplate>
<MudButton HtmlTag="label"
Variant="Variant.Filled"
<MudFileUpload T="IBrowserFile" FilesChanged="UploadImage">
<ActivatorContent>
<MudButton Variant="Variant.Filled"
Color="Color.Primary"
StartIcon="@Icons.Material.Filled.CloudUpload"
Class="mb-2"
for="@fileInput">
Class="mb-2">
Upload Image
</MudButton>
</ButtonTemplate>
</ActivatorContent>
</MudFileUpload>
<MudTextField Value="Record.Id" Label="ID" ReadOnly="true"/>
<MudTextField T="string" Value="Record.InternalReference" Label="Name" ReadOnly="true"/>
Expand Down Expand Up @@ -170,7 +168,7 @@
await LoadImageSourceAsync();
}

private async void Close()
private void Close()
{
MudDialog.Close(DialogResult.Ok(true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@
<MudTabPanel Icon="@Icons.Material.Outlined.Image" Text="Images">
<MudToolBar>
<MudSpacer />
<MudFileUpload T="IBrowserFile" Context="fileInput" FilesChanged="UploadImage">
<ButtonTemplate>
<MudButton HtmlTag="label"
Variant="Variant.Filled"
<MudFileUpload T="IBrowserFile" FilesChanged="UploadImage">
<ActivatorContent>
<MudButton Variant="Variant.Filled"
Color="Color.Primary"
StartIcon="@Icons.Material.Filled.CloudUpload"
for="@fileInput">
StartIcon="@Icons.Material.Filled.CloudUpload">
Upload Image
</MudButton>
</ButtonTemplate>
</ActivatorContent>
</MudFileUpload>
</MudToolBar>
@if (Record.Images != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
private bool _formIsValid;
private MudForm? _form;

protected override async Task OnInitializedAsync()
protected override void OnInitialized()
{
if (Record == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

private void Cancel() => MudDialog.Cancel();

private async void Save()
private void Save()
{
if (Record == null)
{
Expand Down
7 changes: 3 additions & 4 deletions src/Eurofurence.App.Backoffice/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<MudThemeProvider Theme="@EFMudTheme" />
<MudDialogProvider />
<MudSnackbarProvider />
<MudPopoverProvider />

<MudLayout>
<MudAppBar Elevation="1">
Expand All @@ -27,14 +28,12 @@

MudTheme EFMudTheme = new()
{
Palette = new Palette()
PaletteLight = new PaletteLight
{
Primary = "#69a3a2",
Secondary = "#a2c5c4",
AppbarBackground = "#005953",
//Define other properties here.
},

}
};

void DrawerToggle()
Expand Down
1 change: 0 additions & 1 deletion src/Eurofurence.App.Backoffice/Pages/Images.razor
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@

@code {
private string? _imageSearch;
private int _selectedPage = 1;
private IEnumerable<ImageRecord> _images = new List<ImageRecord>();
private List<KeyValuePair<Guid, string>> _imageContents = [];
private MudDataGrid<ImageRecord>? _dataGrid;
Expand Down
2 changes: 1 addition & 1 deletion src/Eurofurence.App.Backoffice/Pages/KnowledgeBase.razor
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<MudSpacer/>
<MudButton Variant="Variant.Filled" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Add" @onclick="AddKnowledgeGroup">New Group</MudButton>
</MudToolBar>
<MudList Clickable="true">
<MudList T="string" Clickable="true">
<MudListItem @onclick="() => _selectedGroup = null">
<MudCard Style="background-color: transparent">
<MudCardHeader>
Expand Down
3 changes: 0 additions & 3 deletions src/Eurofurence.App.Backoffice/wwwroot/appsettings.json

This file was deleted.

2 changes: 2 additions & 0 deletions src/Eurofurence.App.Domain.Model/Images/ImageRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Runtime.Serialization;
using Eurofurence.App.Domain.Model.ArtistsAlley;
using Eurofurence.App.Domain.Model.Fursuits;
using Eurofurence.App.Domain.Model.Maps;

namespace Eurofurence.App.Domain.Model.Images
{
Expand Down Expand Up @@ -35,5 +36,6 @@ public class ImageRecord : EntityBase

public List<FursuitBadgeRecord> FursuitBadges { get; set; } = new();
public List<TableRegistrationRecord> TableRegistrations { get; set; } = new();
public List<MapRecord> Maps { get; set; } = new();
}
}
13 changes: 11 additions & 2 deletions src/Eurofurence.App.Server.Services/Images/ImageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public override async Task DeleteOneAsync(Guid id)
var entity = await _appDbContext.Images
.Include(i => i.FursuitBadges)
.Include(i => i.TableRegistrations)
.Include(i => i.Maps)
.ThenInclude(m => m.Entries)
.FirstOrDefaultAsync(entity => entity.Id == id);

_appDbContext.Remove(entity);
Expand All @@ -71,9 +73,16 @@ public override async Task DeleteOneAsync(Guid id)

public override async Task DeleteAllAsync()
{
var imageIds = await _appDbContext.Images.Select(image => image.Id.ToString()).ToListAsync();
var images = _appDbContext.Images
.Include(i => i.FursuitBadges)
.Include(i => i.TableRegistrations)
.Include(i => i.Maps)
.ThenInclude(m => m.Entries);
var imageIds = await images.Select(image => image.Id.ToString()).ToListAsync();
await DeleteFilesFromMinIoAsync(_minIoConfiguration.Bucket, imageIds);
await base.DeleteAllAsync();
_appDbContext.Images.RemoveRange(images);
await _storageService.ResetDeltaStartAsync();
await _appDbContext.SaveChangesAsync();
}

public async Task<ImageRecord> InsertImageAsync(string internalReference, Stream stream)
Expand Down

0 comments on commit ed90c3b

Please sign in to comment.