Skip to content
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

Specification implementation -- Merge 'dev' into main branch #14

Merged
merged 102 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
bafa7ed
Adding the basic version of wasm project
SaintAngeLs Jun 2, 2024
532f99d
Add wasm to the solution
SaintAngeLs Jun 2, 2024
bb90c9d
(#2) add layout of sign up page
an2508374 Jun 4, 2024
0d0dc24
(#2) update colors of buttons and navmenu
an2508374 Jun 4, 2024
130a15e
(#2) add layout of sign in page
an2508374 Jun 4, 2024
75ee5b5
(#3) add endpoint for signup
eggwhat Jun 7, 2024
5becbd1
(#3) update signup
eggwhat Jun 8, 2024
4c43593
(#3) fix user document
eggwhat Jun 8, 2024
9d20499
(#3) update request
eggwhat Jun 8, 2024
d17b273
(#3) fix issue with exception
eggwhat Jun 8, 2024
2827295
(#3) fix template
eggwhat Jun 9, 2024
a4b5758
(#3) add service global injection
eggwhat Jun 9, 2024
5f3bbbc
(#3) update sign up and token
eggwhat Jun 9, 2024
4f9a7d5
Merge remote-tracking branch 'remotes/origin/main' into dev
SaintAngeLs Jun 9, 2024
375dd3d
Merge remote-tracking branch 'remotes/origin/lambdas' into dev
SaintAngeLs Jun 9, 2024
a36764e
Merge remote-tracking branch 'remotes/origin/frontend' into dev
SaintAngeLs Jun 9, 2024
dc7ddf8
Merge remote-tracking branch 'origin/lambdas' into frontend
an2508374 Jun 9, 2024
db9b2a5
(#3) fix issue with passing userId
eggwhat Jun 9, 2024
073493f
(#2) add custom http client
an2508374 Jun 9, 2024
de018f3
(#2) add identity service
an2508374 Jun 9, 2024
ffacd99
(#3) fix image request
eggwhat Jun 9, 2024
7402670
(#2) register services in Program.cs
an2508374 Jun 9, 2024
d7da510
(#2) add appsettings.json
an2508374 Jun 9, 2024
31d0f6f
(#2) update Program.cs file
an2508374 Jun 9, 2024
749b4b7
(#2) update MainLayout to not open SignIn and SignUp in new tabs
an2508374 Jun 9, 2024
57bc0d7
(#2) update model and page for SignUp
an2508374 Jun 9, 2024
14024bc
(#2) remove nullable from csproj file
an2508374 Jun 9, 2024
3b8d8ae
(#2) add handling of sign in and sign up
an2508374 Jun 10, 2024
454cf15
(#3) add tags for images
eggwhat Jun 10, 2024
caee4d7
Merge remote-tracking branch 'remotes/origin/frontend' into dev
SaintAngeLs Jun 10, 2024
e9c750f
(#3) update dbHelper
eggwhat Jun 10, 2024
5d12ad6
(#2) update path of appsettings.json
an2508374 Jun 10, 2024
2435cf6
(#2) add NavLinks to MainLayout page
an2508374 Jun 10, 2024
f3c50e1
(#2) update url to ApiGateway
an2508374 Jun 10, 2024
46f127e
(#3) fix get images
eggwhat Jun 11, 2024
3dfe81c
(#3) fix path for request
eggwhat Jun 11, 2024
a2bd69b
(#2) add handling of authentication state in MainLayout
an2508374 Jun 10, 2024
541e49a
(#2) add circular progress bar to be showed during sign in and sign up
an2508374 Jun 13, 2024
bf64b44
(#2) remove .idea directory from git
an2508374 Jun 13, 2024
aaead6f
(#2) update layout for authenticated user
an2508374 Jun 13, 2024
20d605e
(#3) add search image request
eggwhat Jun 13, 2024
d8fd626
(#3) add pagination
eggwhat Jun 13, 2024
880c37c
(#3) add pagination and sorting
eggwhat Jun 13, 2024
9a8e6d5
(#2) add ImagesService in Areas, Dtos and SearchImagesModel
an2508374 Jun 13, 2024
fb9407c
(#2) add first version of page for showing images
an2508374 Jun 13, 2024
93dde65
(#2) fix error handling during sign in and sign up
an2508374 Jun 14, 2024
1c99bbb
(#6) fix error handling
eggwhat Jun 14, 2024
c20bad7
Merge remote-tracking branch 'remotes/origin/frontend' into dev
SaintAngeLs Jun 14, 2024
cc96274
(#3) add request for deleting image
eggwhat Jun 14, 2024
6572f15
(#2) update url of ApiGateway
an2508374 Jun 14, 2024
93aa788
Merge remote-tracking branch 'remotes/origin/lambdas' into dev
SaintAngeLs Jun 14, 2024
0455907
(#3) update iam policy
eggwhat Jun 14, 2024
8e68af8
(#2) update http client and fix handling of http response for sign in
an2508374 Jun 14, 2024
6a1507d
(#3) update cloudformation template
eggwhat Jun 14, 2024
04f6c81
(#2) fix handling of http response for search images
an2508374 Jun 14, 2024
fffbb2b
Adding console write line in sign in for Identiry service
SaintAngeLs Jun 14, 2024
d226828
Resolving the conflicts
SaintAngeLs Jun 14, 2024
531e6e0
Remove Wather file
SaintAngeLs Jun 14, 2024
2876f81
Add upload image tab
SaintAngeLs Jun 14, 2024
f41499c
Remove redundant files
SaintAngeLs Jun 14, 2024
cce90b6
fix blazor wasm in dev
an2508374 Jun 14, 2024
4eec6d1
Basic version of Mudblazor file upload
SaintAngeLs Jun 14, 2024
a26107f
Merge pull request #7 from eggwhat/frontend
SaintAngeLs Jun 14, 2024
2b939e3
(#3) update template
eggwhat Jun 14, 2024
1152b64
(#8) update index files for the correct version of the mudblazor include
SaintAngeLs Jun 14, 2024
0564c66
(#3) fix issue with authorizer invoking lambda permissions
eggwhat Jun 14, 2024
ce01e0b
(#3) update pagination
eggwhat Jun 14, 2024
ffa845c
(#2) fix MudFileUpload component at page for uploading images
an2508374 Jun 15, 2024
ca7d563
(#2) update url of ApiGateway
an2508374 Jun 15, 2024
099bf13
(#2) update handling of http response for search images
an2508374 Jun 15, 2024
d9e2c43
(#2) update layout of page for searching images
an2508374 Jun 15, 2024
2224a3e
Add UploadImage razor
SaintAngeLs Jun 15, 2024
6ceecd3
Conflicts resolv e
SaintAngeLs Jun 15, 2024
2f5290a
Adding the cropper helper to the upload images
SaintAngeLs Jun 15, 2024
c4c88a6
(#2) make MudBlazor to be installed with themes
an2508374 Jun 15, 2024
ea5f739
(#2) update Logout method to remove all items from local storage
an2508374 Jun 15, 2024
c055f29
(#9) add unit test for generating token
eggwhat Jun 15, 2024
aa130c3
(#2) add dialog for filtering images by criteria
an2508374 Jun 15, 2024
95a3679
(#2) fix filtering images by tags
an2508374 Jun 15, 2024
83dbddd
adding the image service in the Upload image razor component
SaintAngeLs Jun 15, 2024
dae01d5
Adding the cropper helper
SaintAngeLs Jun 15, 2024
149701d
(#9) add tests for signup
eggwhat Jun 15, 2024
6db9bea
(#9) add tests for image upload
eggwhat Jun 15, 2024
27100a9
Integration sending data to lambda wia js function
SaintAngeLs Jun 15, 2024
36ff877
(#9) add tests for get images
eggwhat Jun 15, 2024
f6c0f73
(#9) add tests for delete image
eggwhat Jun 15, 2024
62dd7e9
(#2) add option of filtering images by custom tags
an2508374 Jun 15, 2024
48927cc
(#2) add dialog for showing an image
an2508374 Jun 15, 2024
ff76ea5
(#3) fix issue with constuctor
eggwhat Jun 15, 2024
148ba80
(#2) add option of deleting an image
an2508374 Jun 15, 2024
d32926c
(#2) update url of ApiGateway
an2508374 Jun 16, 2024
c301aaa
(#10) add bucket to cloudformation
eggwhat Jun 16, 2024
6942dea
Update the razor page for images upload, appsettings update
SaintAngeLs Jun 16, 2024
043f2a8
UploadImage visual update
SaintAngeLs Jun 16, 2024
ad61e66
Enabling specifiv images formats only
SaintAngeLs Jun 16, 2024
b9cd546
(#11) Add the footer commponent
SaintAngeLs Jun 16, 2024
2d7e8b3
(#3) fix issue with dispose s3client
eggwhat Jun 16, 2024
5131eef
Update the styles for the cropper
SaintAngeLs Jun 16, 2024
8600fd6
Add the redirection after success
SaintAngeLs Jun 16, 2024
83df556
Conflicts resolve
SaintAngeLs Jun 16, 2024
594b3ac
Final conflicts resolve
SaintAngeLs Jun 16, 2024
650f393
Merge pull request #13 from eggwhat/lambdas
SaintAngeLs Jun 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cataloguify/Cataloguify.Client/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
16 changes: 16 additions & 0 deletions Cataloguify/Cataloguify.Client/Areas/Identity/IIdentityService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Cataloguify.Client.DTO;
using Cataloguify.Client.HttpClients;

namespace Cataloguify.Client.Areas.Identity;

public interface IIdentityService
{
string Token { get; }
string Email { get; }
string Username { get; }
bool IsAuthenticated { get; set; }

Task<HttpResponse<object>> SignUpAsync(string email, string username, string password);
Task<HttpResponse<TokenDto>> SignInAsync(string email, string password);
Task Logout();
}
77 changes: 77 additions & 0 deletions Cataloguify/Cataloguify.Client/Areas/Identity/IdentityService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System.IdentityModel.Tokens.Jwt;
using Blazored.LocalStorage;
using Cataloguify.Client.DTO;
using Microsoft.AspNetCore.Components;
using Cataloguify.Client.HttpClients;

namespace Cataloguify.Client.Areas.Identity;

public class IdentityService : IIdentityService
{
private readonly IHttpClient _httpClient;
private readonly JwtSecurityTokenHandler _jwtHandler;
private readonly ILocalStorageService _localStorage;
private readonly NavigationManager _navigationManager;

public string Token { get; private set;}
public string Email { get; private set; }
public string Username { get; private set; }
public bool IsAuthenticated { get; set; }

public IdentityService(IHttpClient httpClient, ILocalStorageService localStorage,
NavigationManager navigationManager)
{
_httpClient = httpClient;
_jwtHandler = new JwtSecurityTokenHandler();
_localStorage = localStorage;
_navigationManager = navigationManager;
}

public async Task<HttpResponse<object>> SignUpAsync(string email, string username, string password)
{
return await _httpClient.PostAsync<object, object>("prod/sign-up",
new { email, username, password });
}

public async Task<HttpResponse<TokenDto>> SignInAsync(string email, string password)
{
var response = await _httpClient.PostAsync<object, TokenDto>("prod/generate-token", new { email, password });
if (response.ErrorMessage != null)
{
return response;
}

Token = response.Content.AccessToken;
await _localStorage.SetItemAsStringAsync("Token", Token);

var jwtToken = _jwtHandler.ReadJwtToken(Token);
var payload = jwtToken.Payload;
Email = payload.Claims.FirstOrDefault(c => c.Type == "http:https://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress")?.Value;
Username = payload.Claims.FirstOrDefault(c => c.Type == "http:https://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
IsAuthenticated = true;

await _localStorage.SetItemAsStringAsync("Email", email ?? string.Empty);
await _localStorage.SetItemAsStringAsync("Username", Username ?? string.Empty);
await _localStorage.SetItemAsStringAsync("IsAuthenticated", IsAuthenticated.ToString());

return response;
}

public async Task Logout()
{
Token = null;
await _localStorage.RemoveItemAsync("Token");

Email = null;
await _localStorage.RemoveItemAsync("Email");

Username = null;
await _localStorage.RemoveItemAsync("Username");

IsAuthenticated = false;
await _localStorage.SetItemAsStringAsync("IsAuthenticated", IsAuthenticated.ToString());

await _localStorage.RemoveItemAsync("searchImagesCriteria");
_navigationManager.NavigateTo("signin", forceLoad: true);
}
}
12 changes: 12 additions & 0 deletions Cataloguify/Cataloguify.Client/Areas/Images/IImagesService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Cataloguify.Client.DTO;
using Cataloguify.Client.HttpClients;

namespace Cataloguify.Client.Areas.Images;

public interface IImagesService
{
Task<HttpResponse<object>> UploadImageAsync(string image);
Task<HttpResponse<PageableDto>> SearchImagesAsync(IEnumerable<string> tags, int page,
int results, string sortOrder);
Task DeleteImageAsync(Guid eventId);
}
69 changes: 69 additions & 0 deletions Cataloguify/Cataloguify.Client/Areas/Images/ImagesService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using System.Threading.Tasks;
using Blazored.LocalStorage;
using Cataloguify.Client.DTO;
using Cataloguify.Client.HttpClients;
using Microsoft.Extensions.Logging;
using System.Net.Http.Json;

namespace Cataloguify.Client.Areas.Images
{
public class ImagesService : IImagesService
{
private readonly IHttpClient _httpClient;
private readonly ILocalStorageService _localStorage;
private readonly ILogger<ImagesService> _logger;

public ImagesService(IHttpClient httpClient, ILocalStorageService localStorage, ILogger<ImagesService> logger)
{
_httpClient = httpClient;
_localStorage = localStorage;
_logger = logger;
}

public async Task<HttpResponse<object>> UploadImageAsync(string base64Image)
{
try
{
var token = await _localStorage.GetItemAsStringAsync("Token");
_httpClient.SetAccessToken(token);
var imageData = new { image = base64Image };

_logger.LogInformation($"Sending image to API: {System.Text.Json.JsonSerializer.Serialize(imageData)}");
var response = await _httpClient.PostAsJsonAsync("prod/upload-image", imageData);

if (response.IsSuccessStatusCode)
{
_logger.LogInformation("Image uploaded successfully!");
var content = await response.Content.ReadFromJsonAsync<object>();
return new HttpResponse<object>(content);
}
else
{
_logger.LogError($"Failed to upload image. Status Code: {response.StatusCode}");
return new HttpResponse<object>(new ErrorMessage($"Failed with status code: {response.StatusCode}"));
}
}
catch (Exception ex)
{
_logger.LogError($"Exception occurred: {ex.Message}");
return new HttpResponse<object>(new ErrorMessage(ex.Message));
}
}



public async Task<HttpResponse<PageableDto>> SearchImagesAsync(IEnumerable<string> tags, int page, int results, string sortOrder)
{
_httpClient.SetAccessToken(await _localStorage.GetItemAsStringAsync("Token"));
return await _httpClient.PostAsync<object, PageableDto>("prod/images", new { tags, page, results, sortOrder });
}


public async Task DeleteImageAsync(Guid imageKey)
{
_httpClient.SetAccessToken(await _localStorage.GetItemAsStringAsync("Token"));
await _httpClient.DeleteAsync($"prod/images?imageKey={imageKey}");
}
}
}
23 changes: 23 additions & 0 deletions Cataloguify/Cataloguify.Client/Cataloguify.Client.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="Chronos.Blazor.Cropper" Version="1.2.16" />
<PackageReference Include="Cropper.Blazor" Version="1.3.2" />
<PackageReference Include="Blazorise" Version="1.5.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="MudBlazor" Version="6.20.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Polly" Version="8.4.0" />
<PackageReference Include="Radzen.Blazor" Version="4.32.4" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.0" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions Cataloguify/Cataloguify.Client/Cataloguify.Client.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cataloguify.Client", "Cataloguify.Client.csproj", "{97D9A8DB-E70E-44F8-AFBE-85A35B13D70E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{97D9A8DB-E70E-44F8-AFBE-85A35B13D70E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97D9A8DB-E70E-44F8-AFBE-85A35B13D70E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97D9A8DB-E70E-44F8-AFBE-85A35B13D70E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97D9A8DB-E70E-44F8-AFBE-85A35B13D70E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FC048B20-FFF4-448C-8CC2-EA90352B4194}
EndGlobalSection
EndGlobal
11 changes: 11 additions & 0 deletions Cataloguify/Cataloguify.Client/DTO/ImageDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Cataloguify.Client.DTO;

public class ImageDto
{
public Guid ImageKey { get; set; }
public Guid UserId { get; set; }
public string ImageUrl { get; set; }
public IEnumerable<string> Tags { get; set; }
public DateTime UploadedAt { get; set; }
public bool DeleteSubmitted { get; set; }
}
9 changes: 9 additions & 0 deletions Cataloguify/Cataloguify.Client/DTO/PageableDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Cataloguify.Client.DTO;

public class PageableDto
{
public int Page { get; set; }
public int Results { get; set; }
public int TotalPages { get; set; }
public IEnumerable<ImageDto> Content { get; set; }
}
8 changes: 8 additions & 0 deletions Cataloguify/Cataloguify.Client/DTO/ResponseDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Cataloguify.Client.DTO;

public class ResponseDto
{
public string Body { get; set; }
public int StatusCode { get; set; }
public bool IsBase64Encoded { get; set; }
}
6 changes: 6 additions & 0 deletions Cataloguify/Cataloguify.Client/DTO/TokenDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Cataloguify.Client.DTO;

public class TokenDto
{
public string AccessToken;
}
Loading