Skip to content

Commit

Permalink
Merge branch 'main' into feature/posts
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsPilgaard committed Dec 15, 2024
2 parents 14031d3 + 5146d11 commit 060c01f
Show file tree
Hide file tree
Showing 29 changed files with 195 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.ElmahIo" Version="5.2.50" />
<PackageReference Include="Serilog.Sinks.Grafana.Loki" Version="8.3.0" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="4.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/shared/Jordnaer.Shared/Jordnaer.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.0.0" />
<PackageReference Include="NetEscapades.EnumGenerators" Version="1.0.0-beta09" />
<PackageReference Include="NetEscapades.EnumGenerators" Version="1.0.0-beta11" />
<PackageReference Include="Refit.HttpClientFactory" Version="8.0.0" />
<PackageReference Include="MassTransit.Abstractions" Version="8.3.3" />
</ItemGroup>
Expand Down
26 changes: 0 additions & 26 deletions src/web/Jordnaer/Components/Account/Pages/Logout.razor

This file was deleted.

52 changes: 27 additions & 25 deletions src/web/Jordnaer/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="da">

<head>
<MetadataComponent Title="Mini Møder"
<MetadataComponent Title="Mini Møder"
Description="Et online mødested for børnefamilier"
Tags="minimøder, mini møder, socialmedia, homeschooling, playdate, playgroup, village, community, socialtmedia, hjemmeskole, hjemmepasning, legeaftale, legegruppe, landsby, fællesskab, trivsel, netværk, børnefamilie, legestue, unschooling, børn, forældre" />

Expand All @@ -20,30 +20,32 @@
<meta name="theme-color" content="#ffffff">

<meta name="og:title" content="Mini Møder" />
<meta name="og:site_name" content="Mini Møder" />
<meta name="og:description" content="Et online mødested for børnefamilier" />
<meta name="og:image" content="images/minimoeder_logo_payoff.png" />
<meta name="og:image" content="@Assets["images/minimoeder_logo_payoff_ogimage.png"]" />
<meta name="og:locale" content="da_DK" />

<meta name="google-site-verification" content="_2XlYiQaPnb6j4QvZhJPB-XwnnQKOkpzs_hmU3EHY8g" />
<meta name="facebook-domain-verification" content="ispr6bue0cvuoatohe859eubl32ujh" />

<link preload="true" href="css/landing-page.css" rel="stylesheet" asp-append-version="true" />
<link preload="true" href="css/fonts.css" rel="stylesheet" asp-append-version="true" />
<link preload="true" href="css/app.css" rel="stylesheet" asp-append-version="true" />
<link preload="true" href="@Assets["css/landing-page.css"]" rel="stylesheet" />
<link preload="true" href="@Assets["css/fonts.css"]" rel="stylesheet" />
<link preload="true" href="@Assets["css/app.css"]" rel="stylesheet" />

@*Fancy stuff to speed up loading*@
<link rel="preload" href="bootstrap/bootstrap.min.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<link rel="stylesheet" href="bootstrap/bootstrap.min.css" asp-append-version="true">
<link rel="preload" href="_content/MudBlazor/MudBlazor.min.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<link rel="stylesheet" href="_content/MudBlazor/MudBlazor.min.css" asp-append-version="true">
<link rel="preload" href="@Assets["bootstrap/bootstrap.min.css"]" as="style" onload="this.onload=null;this.rel='stylesheet'">
<link rel="stylesheet" href="@Assets["bootstrap/bootstrap.min.css"]">
<link rel="preload" href="@Assets["_content/MudBlazor/MudBlazor.min.css"]" as="style" onload="this.onload=null;this.rel='stylesheet'">
<link rel="stylesheet" href="@Assets["_content/MudBlazor/MudBlazor.min.css"]">

@*Fancy CSS speed hacks https://pagespeedchecklist.com/asynchronous-css*@
<link rel="stylesheet" href="//cdn.quilljs.com/1.3.6/quill.snow.css" media="print" onload="this.onload=null;this.removeAttribute('media');" asp-append-version="true">
<link rel="stylesheet" href="//cdn.quilljs.com/1.3.6/quill.bubble.css" media="print" onload="this.onload=null;this.removeAttribute('media');" asp-append-version="true">
<link rel="stylesheet" href="_content/CodeBeam.MudBlazor.Extensions/MudExtensions.min.css" media="print" onload="this.onload=null;this.removeAttribute('media');">
<link rel="stylesheet" href="css/chat.css" media="print" onload="this.onload=null;this.removeAttribute('media');" asp-append-version="true">
<link rel="stylesheet" href="Jordnaer.styles.css" media="print" onload="this.onload=null;this.removeAttribute('media');" asp-append-version="true">

<link rel="stylesheet" href="@Assets["https://cdn.quilljs.com/1.3.6/quill.snow.css"]" media="print" onload="this.onload=null;this.removeAttribute('media');">
<link rel="stylesheet" href="@Assets["https://cdn.quilljs.com/1.3.6/quill.bubble.css"]" media="print" onload="this.onload=null;this.removeAttribute('media');">
<link rel="stylesheet" href="@Assets["_content/CodeBeam.MudBlazor.Extensions/MudExtensions.min.css"]" media="print" onload="this.onload=null;this.removeAttribute('media');">
<link rel="stylesheet" href="@Assets["css/chat.css"]" media="print" onload="this.onload=null;this.removeAttribute('media');">
<link rel="stylesheet" href="@Assets["Jordnaer.styles.css"]" media="print" onload="this.onload=null;this.removeAttribute('media');">

<ImportMap />

<HeadOutlet @rendermode="RenderModeForPage" />

@*<GrafanaFaro />*@
Expand All @@ -58,17 +60,17 @@
https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/signalr?view=aspnetcore-7.0#automatically-refresh-the-page-when-server-side-reconnection-fails
*@
<div id="reconnect-modal" style="display: none;"></div>
<script src="_framework/blazor.web.js" autostart="false" asp-append-version="true"></script>
<script src="js/boot.js" asp-append-version="true"></script>
<script src="@Assets["_framework/blazor.web.js"]" autostart="false"></script>
<script src="@Assets["js/boot.js"]"></script>

<script src="_content/MudBlazor/MudBlazor.min.js" asp-append-version="true"></script>
<script async src="js/scroll.js" asp-append-version="true"></script>
<script async src="js/utilities.js" asp-append-version="true"></script>
<script async src="_content/CodeBeam.MudBlazor.Extensions/MudExtensions.min.js" asp-append-version="true"></script>
<script src="@Assets["_content/MudBlazor/MudBlazor.min.js"]"></script>
<script async src="@Assets["js/scroll.js"]"></script>
<script async src="@Assets["js/utilities.js"]"></script>
<script async src="@Assets["_content/CodeBeam.MudBlazor.Extensions/MudExtensions.min.js"]"></script>

<script async src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
<script async src="_content/WYSIWYGTextEditor/quill-blot-formatter.min.js"></script>
<script async src="_content/WYSIWYGTextEditor/BlazorQuill.js"></script>
<script async src="@Assets["https://cdn.quilljs.com/1.3.6/quill.js"]"></script>
<script async src="@Assets["_content/WYSIWYGTextEditor/quill-blot-formatter.min.js"]"></script>
<script async src="@Assets["_content/WYSIWYGTextEditor/BlazorQuill.js"]"></script>
</body>

</html>
Expand Down
1 change: 0 additions & 1 deletion src/web/Jordnaer/Database/DatabaseInitialyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public static async Task<List<Category>> InsertCategoriesAsync(this JordnaerDbCo
{
new() {Name = "Legeaftale"},
new() {Name = "Hjemmeskole"},
new() {Name = "Legegruppe"},
new() {Name = "Privat Dagpleje"},
new() {Name = "Forældregruppe"},
new() {Name = "Sportsaktiviteter"},
Expand Down
4 changes: 2 additions & 2 deletions src/web/Jordnaer/Features/Ad/SponsorAd.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<div class="image-ad-wrapper">
<div class="image-with-label">
<MudHidden Breakpoint="Breakpoint.SmAndDown" Invert>
<MudImage Src="@MobileImagePath" Fluid="Fluid" Alt="@ImageAlt" Class="@Class" loading="lazy" />
<MudImage Src="@MobileImagePath" Height="450" Alt="@ImageAlt" Class="@Class" loading="lazy" />
</MudHidden>
<MudHidden Breakpoint="Breakpoint.SmAndDown">
<MudImage Src="@DesktopImagePath" Fluid="Fluid" Alt="@ImageAlt" Class="@Class" loading="lazy" />
<MudImage Src="@DesktopImagePath" Height="500" Alt="@ImageAlt" Class="@Class" loading="lazy" />
</MudHidden>
<div class="image-ad-label">Sponsor reklame</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/web/Jordnaer/Features/Ad/SponsorAd.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
position: absolute;
top: 20px;
right: 0;
background-color: rgba(0, 0, 0, 0.25);
background-color: rgba(0, 0, 0, 0.35);
color: white;
padding: 5px 10px;
border-radius: 5px;
Expand Down
24 changes: 14 additions & 10 deletions src/web/Jordnaer/Features/Category/CategorySelector.razor
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
@inject ICategoryCache CategoryCache

<MudSelectExtended ItemCollection="_allCategories"
T="string"
Label="Kategorier"
Placeholder="Vælg"
MultiSelection="true"
ValuePresenter="ValuePresenter.Chip"
AnchorOrigin="Origin.BottomCenter"
SelectedValues="Categories"
SelectedValuesChanged="SelectedCategoriesChanged">
</MudSelectExtended>
<MudChipSet T="string"
Style="display: flex; flex-wrap: wrap; justify-content: center;"
SelectionMode="SelectionMode.MultiSelection"
SelectedValues="Categories"
CheckMark
Color="Color.Tertiary"
SelectedColor="Color.Success"
SelectedValuesChanged="SelectedCategoriesChanged"
Variant="Variant.Outlined">
@foreach (var category in _allCategories)
{
<MudChip Text="@category" Value="@category" />
}
</MudChipSet>
@code
{
private List<string> _allCategories = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<MudTextField @bind-Value="Filter.Name" Placeholder="Gruppenavn" Label="Søg på navn" Clearable/>
</MudItem>

<MudItem xs="12" sm="11" md="10" lg="9" xl="8" Class="mt-8">
<MudItem xs="12" sm="11" md="10" lg="9" xl="8" Class="mt-6">

<MudButtonGroup OverrideStyles="false" Style="width: 100%;">
<MudButton FullWidth
Expand Down
14 changes: 5 additions & 9 deletions src/web/Jordnaer/Features/Images/FacebookPictureDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,11 @@ await response.Content.ReadFromJsonAsync<FacebookProfilePictureResponse>(
return ProfileConstants.Default_Profile_Picture;
}

var resizedImage = await imageService.ResizeImageAsync(imageStream, cancellationToken);

var imageUrl =
await imageService.UploadImageAsync(accessTokenAcquired.UserId,
ProfileImageService.UserProfilePicturesContainerName,
resizedImage,
cancellationToken);

await resizedImage.DisposeAsync();
var imageUrl = await imageService.UploadImageAsync(
accessTokenAcquired.UserId,
ProfileImageService.UserProfilePicturesContainerName,
imageStream,
cancellationToken);

return imageUrl;
}
Expand Down
11 changes: 5 additions & 6 deletions src/web/Jordnaer/Features/Images/GooglePictureDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ public sealed class GooglePictureDownloader(
return ProfileConstants.Default_Profile_Picture;
}

await using var resizedImage = await imageService.ResizeImageAsync(imageStream, cancellationToken);

var imageUrl = await imageService.UploadImageAsync(accessTokenAcquired.UserId,
ProfileImageService.UserProfilePicturesContainerName,
resizedImage,
cancellationToken);
var imageUrl = await imageService.UploadImageAsync(
accessTokenAcquired.UserId,
ProfileImageService.UserProfilePicturesContainerName,
imageStream,
cancellationToken);

return imageUrl;
}
Expand Down
17 changes: 10 additions & 7 deletions src/web/Jordnaer/Features/Images/ImageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public async Task DeleteImageAsync(string blobName, string containerName,

public async Task<Stream?> GetImageStreamFromUrlAsync(string url, CancellationToken cancellationToken = default)
{

var client = httpClientFactory.CreateClient(HttpClients.Default);
var response = await client.GetAsync(url, cancellationToken);

Expand All @@ -111,17 +110,21 @@ public async Task DeleteImageAsync(string blobName, string containerName,
return await response.Content.ReadAsStreamAsync(cancellationToken);
}

[Obsolete("Should probably not be used in this form, it worsens the image quality." +
"We should enforce a 1x1 pixel ratio instead, so we can scale up and down.")]
public async Task<Stream> ResizeImageAsync(Stream imageAsStream, CancellationToken cancellationToken = default)
{
// 0 maintains aspect ratio
const int width = 0;
const int height = 200;

using var image = await Image.LoadAsync(imageAsStream, cancellationToken);

var outputStream = new MemoryStream();
if (image.Height > 800)
{
// 0 maintains aspect ratio
const int width = 0;
const int height = 200;
image.Mutate(img => img.Resize(width, height));
}

image.Mutate(img => img.Resize(width, height));
var outputStream = new MemoryStream();

await image.SaveAsync(outputStream, new WebpEncoder(), cancellationToken);

Expand Down
13 changes: 5 additions & 8 deletions src/web/Jordnaer/Features/Images/MicrosoftPictureDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@ public sealed class MicrosoftPictureDownloader(

await using var imageAsStream = await response.Content.ReadAsStreamAsync(cancellationToken);

var resizedImage = await imageService.ResizeImageAsync(imageAsStream, cancellationToken);

var imageUrl = await imageService.UploadImageAsync(accessTokenAcquired.UserId,
ProfileImageService.UserProfilePicturesContainerName,
resizedImage,
cancellationToken);

await resizedImage.DisposeAsync();
var imageUrl = await imageService.UploadImageAsync(
accessTokenAcquired.UserId,
ProfileImageService.UserProfilePicturesContainerName,
imageAsStream,
cancellationToken);

return imageUrl;
}
Expand Down
2 changes: 1 addition & 1 deletion src/web/Jordnaer/Features/Profile/ChildProfileCard.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<MudCard Elevation="3">
<MudCard Elevation="3" Style="background-color:rgba(207,193,166,0.20)">
<MudCardContent>
<MudImage Src="@Child.PictureUrl" loading="lazy" />
<MudTextField Label="Navn" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.AccountCircle" ReadOnly T="string" Text="@Child.DisplayName" />
Expand Down
5 changes: 3 additions & 2 deletions src/web/Jordnaer/Features/Profile/OpenChat.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
<MudButton Disabled="Disabled"
EndIcon="@(_isMessageSent ? Icons.Material.Filled.Check : Icons.Material.Filled.Message)"
OnClick="OpenOrStartChat"
Color="@(_isMessageSent ? Color.Success : Color.Primary)"
Color="@(_isMessageSent ? Color.Tertiary : Color.Success)"
Size="Size.Large"
Class="mb-5">
Variant="Disabled ? Variant.Outlined : Variant.Filled"
Class="mb-5 ml-3">
@(_isMessageSent ? "Besked sendt" : "Send Besked")
</MudButton>

Expand Down
2 changes: 1 addition & 1 deletion src/web/Jordnaer/Features/Profile/UserProfileCard.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<MudCard Elevation="3">
<MudCard Elevation="3" Style="background-color:rgba(207,193,166,0.20)">
<MudCardContent>

<MudImage
Expand Down
8 changes: 8 additions & 0 deletions src/web/Jordnaer/Features/SEO/MetadataComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
{
<meta name="og:image" content="images/mini-moeder-logo.png" />
}

@if (!string.IsNullOrEmpty(Type))
{
<meta name="og:type" content="@Type" />
}

@if (!string.IsNullOrEmpty(Tags))
{
Expand All @@ -40,6 +45,9 @@
[Parameter]
public string? Image { get; set; }

[Parameter]
public string? Type { get; set; }

[Parameter]
public string? Tags { get; set; } // Comma separated list
}
28 changes: 2 additions & 26 deletions src/web/Jordnaer/Features/Search/ZipCodeAutoComplete.razor
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@

private static readonly NumberFormatInfo FloatNumberFormat = new() { CurrencyDecimalSeparator = "." };
private bool _locationSetOnInitialized = false;

protected override async Task OnInitializedAsync()
{
if (DisableSmartCompletion)
{
return;
}

await SetLocationToUsersZipCode();
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
Expand All @@ -70,7 +60,7 @@
longitude.ToString(FloatNumberFormat),
latitude.ToString(FloatNumberFormat));

if (response.IsSuccessStatusCode)
if (response.IsSuccessful)
{
var location = $"{response.Content.Nr} {response.Content.Navn}";
await LocationValueChanged(location);
Expand All @@ -86,25 +76,11 @@
}
}

private async Task SetLocationToUsersZipCode()
{
var profile = await ProfileCache.GetProfileAsync();
if (profile?.ZipCode is null)
{
return;
}

var location = $"{profile.ZipCode} {profile.City}";
await LocationValueChanged(location);

_locationSetOnInitialized = true;
}

public async Task<IEnumerable<string>> SearchForZipCodes(string value, CancellationToken cancellationToken)
{
var searchResponse = await DataForsyningenClient.GetZipCodesWithAutoComplete(value, cancellationToken);

return searchResponse.IsSuccessStatusCode
return searchResponse.IsSuccessful
? searchResponse.Content!.Select(response => response.ToString())
: [];
}
Expand Down
Loading

0 comments on commit 060c01f

Please sign in to comment.