-
-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/posts #421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feature/posts #421
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
abd8d32
add dev settings and feature flags for posts
NielsPilgaard 8b0ca9d
make 90% of the backend for posts (not groupposts yet)
NielsPilgaard e12efcc
add error handling
NielsPilgaard 7797602
add todos
NielsPilgaard 1bf2dc8
initial draft of the post page, mostly copy paste
NielsPilgaard bcff743
split into components
NielsPilgaard f8851b9
more post work
NielsPilgaard db5b46a
Update CreatePostComponent.razor
NielsPilgaard 17aa5e7
fixes
NielsPilgaard 8a40302
register post services
NielsPilgaard 14031d3
Merge branch 'main' into feature/posts
NielsPilgaard 060c01f
Merge branch 'main' into feature/posts
NielsPilgaard a8cf723
remove lighthouse CI
NielsPilgaard 1c724b6
Merge branch 'main' into feature/posts
NielsPilgaard 0ac19b4
Merge branch 'main' into feature/posts
NielsPilgaard 2595509
Merge branch 'main' into feature/posts
NielsPilgaard 3ab038e
Remove Jordnaer.Shared.Infrastructure
NielsPilgaard ed9804d
Create add-migration.ps1
NielsPilgaard b75a503
add migration
NielsPilgaard 7dbfb7d
update drop_all_tables
NielsPilgaard 605fe5f
add index on zipcode for posts
NielsPilgaard 3716aca
Switch to in-memory mass transit
NielsPilgaard f72462f
Update WebApplicationBuilderExtensions.cs
NielsPilgaard ae67e13
Update PostSearchService.cs
NielsPilgaard 7d396f6
Update PostService.cs
NielsPilgaard b119403
Merge branch 'main' into feature/posts
NielsPilgaard edfb6e1
Merge branch 'main' into feature/posts
NielsPilgaard 2472994
Merge branch 'main' into feature/posts
NielsPilgaard b527645
Update ChatNotificationService.cs
NielsPilgaard cb4bde8
tiny refactors
NielsPilgaard c3d2e6d
remove interface we don't need
NielsPilgaard 1a68118
add category for test purposes
NielsPilgaard 87abebe
simplify
NielsPilgaard 4b23dea
Merge branch 'main' into feature/posts
NielsPilgaard 67cb945
category search bugfix for posts aswell
NielsPilgaard 6af6226
Merge branch 'main' into feature/posts
NielsPilgaard a4f632a
Merge branch 'main' into feature/posts
NielsPilgaard f4486da
retry csproj merge
NielsPilgaard 5eb95ea
Merge branch 'main' into feature/posts
NielsPilgaard 0093ec5
Update Jordnaer.csproj
NielsPilgaard a14292d
clear unused usings (merge misshap)
NielsPilgaard c06fce2
minor improvements here and there
NielsPilgaard 5683015
Merge branch 'main' into feature/posts
NielsPilgaard 3400368
update nugets
NielsPilgaard 566cd50
fix e2e tests looking for old placeholder
NielsPilgaard 09ce194
Create EnumExtensions.cs
NielsPilgaard 6499500
Fix Group Members page to allow updates
NielsPilgaard 48a380b
update nugets
NielsPilgaard 9988770
move logout button to profile page
NielsPilgaard 2353fd9
improve ux
NielsPilgaard 3ce112b
add safety
NielsPilgaard 40719f2
remove redundant enum extensions class
NielsPilgaard 7977f5c
Update website_frontend_ci.yml
NielsPilgaard fce1059
Update Jordnaer.E2E.Tests.csproj
NielsPilgaard 32d9c58
Merge branch 'main' into feature/posts
NielsPilgaard ca4fcc8
Update _Imports.razor
NielsPilgaard 319e1d7
Merge branch 'feature/posts' of https://github.com/NielsPilgaard/Jord…
NielsPilgaard f3ea4fa
cleanup save/revert code
NielsPilgaard e16532c
Update website_frontend_ci.yml
NielsPilgaard e72cfb9
Update website_frontend_ci.yml
NielsPilgaard 8e7b8f5
safer OnInitializedAsync
NielsPilgaard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
15 changes: 0 additions & 15 deletions
15
src/shared/Jordnaer.Shared.Infrastructure/Jordnaer.Shared.Infrastructure.csproj
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,30 @@ | ||
| using System.ComponentModel.DataAnnotations.Schema; | ||
| using System.ComponentModel.DataAnnotations; | ||
|
|
||
| namespace Jordnaer.Shared; | ||
|
|
||
| public class GroupPost | ||
| { | ||
|
|
||
| [Key] | ||
| [DatabaseGenerated(DatabaseGeneratedOption.None)] | ||
| public required Guid Id { get; init; } | ||
|
|
||
| [StringLength(1000, ErrorMessage = "Opslag må højest være 1000 karakterer lang.")] | ||
| [Required(AllowEmptyStrings = false, ErrorMessage = "Opslag skal have mindst 1 karakter.")] | ||
| public required string Text { get; init; } | ||
|
|
||
| public DateTimeOffset CreatedUtc { get; init; } = DateTimeOffset.UtcNow; | ||
|
|
||
| public int? ZipCode { get; set; } | ||
|
|
||
| [ForeignKey(nameof(UserProfile))] | ||
| public required string UserProfileId { get; init; } = null!; | ||
|
|
||
| public UserProfile UserProfile { get; init; } = null!; | ||
|
|
||
| [ForeignKey(nameof(Group))] | ||
| public required Guid GroupId { get; init; } | ||
|
|
||
| public Group Group { get; init; } = null!; | ||
| } |
This file contains hidden or 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,30 @@ | ||
| using System.ComponentModel.DataAnnotations; | ||
| using System.ComponentModel.DataAnnotations.Schema; | ||
| using Microsoft.EntityFrameworkCore; | ||
|
|
||
| namespace Jordnaer.Shared; | ||
|
|
||
| [Index(nameof(ZipCode))] | ||
| public class Post | ||
| { | ||
| [Key] | ||
| [DatabaseGenerated(DatabaseGeneratedOption.None)] | ||
| public required Guid Id { get; init; } | ||
|
|
||
| [StringLength(1000, ErrorMessage = "Opslag må højest være 1000 karakterer lang.")] | ||
| [Required(AllowEmptyStrings = false, ErrorMessage = "Opslag skal have mindst 1 karakter.")] | ||
| public required string Text { get; set; } | ||
|
|
||
| public DateTimeOffset CreatedUtc { get; set; } = DateTimeOffset.UtcNow; | ||
|
|
||
| public int? ZipCode { get; set; } | ||
|
|
||
| public string? City { get; set; } | ||
|
|
||
| [ForeignKey(nameof(UserProfile))] | ||
| public required string UserProfileId { get; set; } = null!; | ||
|
|
||
| public UserProfile UserProfile { get; init; } = null!; | ||
|
|
||
| public List<Category> Categories { get; set; } = []; | ||
| } |
This file contains hidden or 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,8 @@ | ||
| namespace Jordnaer.Shared; | ||
|
|
||
| public class PostCategory | ||
| { | ||
| public required Guid PostId { get; set; } | ||
|
|
||
| public required int CategoryId { get; set; } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,22 +1,22 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.ComponentModel.DataAnnotations; | ||
| using System.Linq; | ||
| using System.ComponentModel.DataAnnotations; | ||
| using System.Reflection; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Jordnaer.Shared.Extensions; | ||
| public static class EnumExtensions | ||
| { | ||
| public static DisplayAttribute? GetDisplayAttribute(this Enum enumValue) | ||
| { | ||
| return enumValue.GetType() | ||
| .GetField(enumValue.ToString())?.GetCustomAttribute<DisplayAttribute>(); | ||
| .GetField(enumValue.ToString())? | ||
| .GetCustomAttribute<DisplayAttribute>(); | ||
| } | ||
|
|
||
| public static string GetDisplayName(this Enum enumValue) | ||
| { | ||
| return enumValue.GetDisplayAttribute()?.Name ?? enumValue.ToString(); | ||
| } | ||
|
|
||
| public static string? ToDisplayName<T>(this T enumValue) where T : Enum => | ||
| enumValue.GetDisplayAttribute()? | ||
| .GetName(); | ||
| } |
This file contains hidden or 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,24 @@ | ||
| namespace Jordnaer.Shared; | ||
|
|
||
| public static class PostExtensions | ||
| { | ||
| public static PostDto ToPostDto(this Post post) | ||
| { | ||
| return new PostDto | ||
| { | ||
| Id = post.Id, | ||
| Text = post.Text, | ||
| CreatedUtc = post.CreatedUtc, | ||
| Author = new UserSlim | ||
| { | ||
| Id = post.UserProfileId, | ||
| ProfilePictureUrl = post.UserProfile.ProfilePictureUrl, | ||
| UserName = post.UserProfile.UserName, | ||
| DisplayName = post.UserProfile.DisplayName | ||
| }, | ||
| City = post.City, | ||
| ZipCode = post.ZipCode, | ||
| Categories = post.Categories.Select(category => category.Name).ToList() | ||
| }; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,21 @@ | ||
| using System.ComponentModel.DataAnnotations; | ||
|
|
||
| namespace Jordnaer.Shared; | ||
|
|
||
| public class PostDto | ||
| { | ||
| public required Guid Id { get; init; } | ||
|
|
||
| [StringLength(1000, ErrorMessage = "Opslag må højest være 1000 karakterer lang.")] | ||
| [Required(AllowEmptyStrings = false, ErrorMessage = "Opslag skal have mindst 1 karakter.")] | ||
| public required string Text { get; init; } | ||
|
|
||
| public int? ZipCode { get; set; } | ||
| public string? City { get; set; } | ||
|
|
||
| public DateTimeOffset CreatedUtc { get; init; } | ||
|
|
||
| public required UserSlim Author { get; init; } | ||
|
|
||
| public List<string> Categories { get; set; } = []; | ||
| } |
This file contains hidden or 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,57 @@ | ||
| using System.ComponentModel.DataAnnotations; | ||
|
|
||
| namespace Jordnaer.Shared; | ||
|
|
||
| public class PostSearchFilter | ||
| { | ||
| public string? Contents { get; set; } | ||
| public string[]? Categories { get; set; } = []; | ||
|
|
||
| /// <summary> | ||
| /// Only show user results within this many kilometers of the <see cref="Location"/>. | ||
| /// </summary> | ||
| [Range(1, 50, ErrorMessage = "Afstand skal være mellem 1 og 50 km")] | ||
| [LocationRequired] | ||
| public int? WithinRadiusKilometers { get; set; } | ||
|
|
||
| [RadiusRequired] | ||
| public string? Location { get; set; } | ||
|
|
||
| public int PageNumber { get; set; } = 1; | ||
| public int PageSize { get; set; } = 10; | ||
| } | ||
|
|
||
| file class RadiusRequiredAttribute : ValidationAttribute | ||
| { | ||
| protected override ValidationResult IsValid(object? value, ValidationContext validationContext) | ||
| { | ||
| var postSearchFilter = (PostSearchFilter)validationContext.ObjectInstance; | ||
|
|
||
| if (postSearchFilter.WithinRadiusKilometers is null && string.IsNullOrEmpty(postSearchFilter.Location)) | ||
| { | ||
| return ValidationResult.Success!; | ||
| } | ||
|
|
||
| return postSearchFilter.WithinRadiusKilometers is null | ||
| ? new ValidationResult("Radius skal vælges når et område er valgt.") | ||
| : ValidationResult.Success!; | ||
| } | ||
| } | ||
|
|
||
| file class LocationRequiredAttribute : ValidationAttribute | ||
| { | ||
| protected override ValidationResult IsValid(object? value, ValidationContext validationContext) | ||
| { | ||
| var postSearchFilter = (PostSearchFilter)validationContext.ObjectInstance; | ||
|
|
||
| if (postSearchFilter.WithinRadiusKilometers is null && string.IsNullOrEmpty(postSearchFilter.Location)) | ||
| { | ||
| return ValidationResult.Success!; | ||
|
|
||
| } | ||
|
|
||
| return string.IsNullOrEmpty(postSearchFilter.Location) | ||
| ? new ValidationResult("Område skal vælges når en radius er valgt.") | ||
| : ValidationResult.Success!; | ||
| } | ||
| } | ||
|
NielsPilgaard marked this conversation as resolved.
|
||
This file contains hidden or 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 Jordnaer.Shared; | ||
|
|
||
| public class PostSearchResult | ||
| { | ||
| public List<PostDto> Posts { get; set; } = []; | ||
| public int TotalCount { get; set; } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.