From 8409b847f800ba883cc728e1e7d0958e9530fd8a Mon Sep 17 00:00:00 2001 From: Amadeusz Nowak Date: Mon, 13 May 2024 22:34:16 +0200 Subject: [PATCH 01/10] (#57) fix problem with getting all students for admin --- .../src/MiniSpace.Web/Areas/Students/IStudentsService.cs | 2 +- .../src/MiniSpace.Web/Areas/Students/StudentsService.cs | 4 ++-- .../src/MiniSpace.Web/Pages/Admin/ManageStudents.razor | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Students/IStudentsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Students/IStudentsService.cs index d6a8e8c0c..1cbed12d1 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Students/IStudentsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Students/IStudentsService.cs @@ -12,7 +12,7 @@ public interface IStudentsService Task UpdateStudentDto(Guid studentId); void ClearStudentDto(); Task GetStudentAsync(Guid studentId); - Task> GetStudentsAsync(); + Task> GetStudentsAsync(); Task UpdateStudentAsync(Guid studentId, string profileImage, string description, bool emailNotifications); Task> CompleteStudentRegistrationAsync(Guid studentId, string profileImage, string description, DateTime dateOfBirth, bool emailNotifications); diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Students/StudentsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Students/StudentsService.cs index 2d1afedaa..a5ec57ac8 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Students/StudentsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Students/StudentsService.cs @@ -39,10 +39,10 @@ public async Task GetStudentAsync(Guid studentId) return await _httpClient.GetAsync($"students/{studentId}"); } - public Task> GetStudentsAsync() + public Task> GetStudentsAsync() { _httpClient.SetAccessToken(_identityService.JwtDto.AccessToken); - return _httpClient.GetAsync>("students"); + return _httpClient.GetAsync>("students"); } public Task UpdateStudentAsync(Guid studentId, string profileImage, string description, bool emailNotifications) diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/ManageStudents.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/ManageStudents.razor index 2b404f309..c99579b5f 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/ManageStudents.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/ManageStudents.razor @@ -70,7 +70,8 @@ { adminId = IdentityService.GetCurrentUserId(); - students = await StudentsService.GetStudentsAsync(); + var paginatedResponse = await StudentsService.GetStudentsAsync(); + students = paginatedResponse.Results; totalStudents = students.Count(); } From e73c35cd1f883730caf0e9dc2e8b110dcc212b2c Mon Sep 17 00:00:00 2001 From: Amadeusz Nowak Date: Tue, 14 May 2024 00:04:54 +0200 Subject: [PATCH 02/10] (#57) provide suitable handling with local and universal time --- .../Pages/Account/CompleteRegistration.razor | 2 +- .../Pages/Account/ShowAccount.razor | 4 +- .../Pages/Account/UpdateAccount.razor | 59 ------------------- .../Admin/Dialogs/ManageStudentDialog.razor | 2 +- .../Pages/Admin/ManageStudents.razor | 13 +++- .../{EventAdd.razor => EventCreate.razor} | 10 ++-- .../Pages/Events/EventUpdate.razor | 18 +++--- .../Pages/Events/EventsOrganize.razor | 12 ++-- .../Pages/Events/EventsSearch.razor | 8 +-- .../Pages/Friends/FriendsDetails.razor | 4 +- .../Pages/Friends/FriendsRequests.razor | 6 +- .../Pages/Friends/FriendsSearch.razor | 4 +- .../Pages/Friends/SentRequests.razor | 6 +- .../Pages/Posts/PostCreate.razor | 2 +- 14 files changed, 55 insertions(+), 95 deletions(-) delete mode 100644 MiniSpace.Web/src/MiniSpace.Web/Pages/Account/UpdateAccount.razor rename MiniSpace.Web/src/MiniSpace.Web/Pages/Events/{EventAdd.razor => EventCreate.razor} (97%) diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Account/CompleteRegistration.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Account/CompleteRegistration.razor index a0803adf5..6566fe092 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Account/CompleteRegistration.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Account/CompleteRegistration.razor @@ -75,7 +75,7 @@ { var response = await StudentsService.CompleteStudentRegistrationAsync(completeRegistrationModel.StudentId, completeRegistrationModel.ProfileImage, completeRegistrationModel.Description, - completeRegistrationModel.DateOfBirth, completeRegistrationModel.EmailNotifications); + completeRegistrationModel.DateOfBirth.ToUniversalTime(), completeRegistrationModel.EmailNotifications); // Handle the post-sign-up logic, such as redirection or displaying a success message if (response.ErrorMessage != null) { diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Account/ShowAccount.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Account/ShowAccount.razor index 74059e468..9e320d9df 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Account/ShowAccount.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Account/ShowAccount.razor @@ -35,10 +35,10 @@ Value="@studentDto.NumberOfFriends" Disabled="true"/> + Value="@studentDto.DateOfBirth.ToLocalTime()" Disabled="true"/> + Value="@studentDto.CreatedAt.ToLocalTime()" Disabled="true"/> diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Account/UpdateAccount.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Account/UpdateAccount.razor deleted file mode 100644 index 305743c01..000000000 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Account/UpdateAccount.razor +++ /dev/null @@ -1,59 +0,0 @@ -@page "/account/update" -@using MiniSpace.Web.Areas.Students -@using MiniSpace.Web.DTO -@inject IIdentityService IdentityService -@inject IStudentsService StudentsService -@inject NavigationManager NavigationManager - -

Update some data in your account:

- -@if (showError) -{ -
- Failed to sign in. Please check your credentials and try again. -
-} - - - - - - @if (studentDto.Id != Guid.Empty) - { -
- - -
- -
- - -
- - - } - else - { -

Loading...

- } -
- -@code { - private StudentDto studentDto = new(); - private bool showError = false; - - protected override async Task OnInitializedAsync() - { - if (IdentityService.IsAuthenticated) - { - studentDto = StudentsService.StudentDto; - } - } - - private async Task HandleUpdateStudent() - { - await StudentsService.UpdateStudentAsync(studentDto.Id, studentDto.ProfileImage, - studentDto.Description, studentDto.EmailNotifications); - NavigationManager.NavigateTo("/account"); - } -} diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/Dialogs/ManageStudentDialog.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/Dialogs/ManageStudentDialog.razor index 62d8380d5..907395c3d 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/Dialogs/ManageStudentDialog.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/Dialogs/ManageStudentDialog.razor @@ -103,7 +103,7 @@ Profile image - diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/ManageStudents.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/ManageStudents.razor index c99579b5f..e3ceee6cd 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/ManageStudents.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/ManageStudents.razor @@ -44,8 +44,16 @@ - - + + + + + + @@ -54,6 +62,7 @@ @code { private const string dateFormat = "dd/MM/yyyy HH:mm"; + private const string shortDateFormat = "dd/MM/yyyy"; private int pageSize = 5; IEnumerable pageSizeOptions = new int[] { 5, 10, 20, 40}; diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventAdd.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventCreate.razor similarity index 97% rename from MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventAdd.razor rename to MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventCreate.razor index da81391ab..9ca53f353 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventAdd.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventCreate.razor @@ -1,4 +1,4 @@ -@page "/events/add" +@page "/events/create" @using MiniSpace.Web.Areas.Identity @using MiniSpace.Web.Areas.Events @using MiniSpace.Web.Areas.Http @@ -12,7 +12,7 @@ @inject IErrorMapperService ErrorMapperService @inject NavigationManager NavigationManager -

Add new event

+

Create new event

@if (!pageInitialized) { @@ -212,12 +212,12 @@ { var response = await EventsService.AddEventAsync(Guid.Empty, addEventModel.Name, addEventModel.OrganizerId, addEventModel.OrganizationId, - addEventModel.StartDate.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), - addEventModel.EndDate.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + addEventModel.StartDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + addEventModel.EndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), addEventModel.BuildingName, addEventModel.Street, addEventModel.BuildingNumber, addEventModel.ApartmentNumber, addEventModel.City, addEventModel.ZipCode, addEventModel.Description, addEventModel.Capacity, addEventModel.Fee, addEventModel.Category, - publishInfo == 2 ? addEventModel.PublishDate.ToString("yyyy-MM-ddTHH:mm:ss.fffZ") : string.Empty); + publishInfo == 2 ? addEventModel.PublishDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ") : string.Empty); if (response.ErrorMessage != null) { diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventUpdate.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventUpdate.razor index 85ac9b694..cf3d23504 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventUpdate.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventUpdate.razor @@ -38,7 +38,7 @@ + ShowTime="true" MinutesStep="5" DateFormat="@dateFormat" /> @@ -72,7 +72,7 @@ + ShowTime="true" MinutesStep="5" DateFormat="@dateFormat" /> @@ -107,7 +107,7 @@ { + ShowTime="true" MinutesStep="5" DateFormat="@dateFormat" /> @@ -147,6 +147,8 @@ [Parameter] public string EventId { get; set; } + private const string dateFormat = "dd/MM/yyyy HH:mm"; + private Guid organizerId; private EventDto eventDto; private bool pageInitialized = false; @@ -185,8 +187,8 @@ updateEventModel.EventId = eventDto.Id; updateEventModel.Name = eventDto.Name; updateEventModel.OrganizerId = eventDto.Organizer.Id; - updateEventModel.StartDate = eventDto.StartDate; - updateEventModel.EndDate = eventDto.EndDate; + updateEventModel.StartDate = eventDto.StartDate.ToLocalTime(); + updateEventModel.EndDate = eventDto.EndDate.ToLocalTime(); updateEventModel.BuildingName = eventDto.Location.BuildingName; updateEventModel.Street = eventDto.Location.Street; updateEventModel.BuildingNumber = eventDto.Location.BuildingNumber; @@ -206,12 +208,12 @@ { var response = await EventsService.UpdateEventAsync(updateEventModel.EventId, updateEventModel.Name, updateEventModel.OrganizerId, - updateEventModel.StartDate.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), - updateEventModel.EndDate.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + updateEventModel.StartDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + updateEventModel.EndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), updateEventModel.BuildingName, updateEventModel.Street, updateEventModel.BuildingNumber, updateEventModel.ApartmentNumber, updateEventModel.City, updateEventModel.ZipCode, updateEventModel.Description, updateEventModel.Capacity, updateEventModel.Fee, updateEventModel.Category, - publishInfo == 2 ? updateEventModel.PublishDate.ToString("yyyy-MM-ddTHH:mm:ss.fffZ") : string.Empty); + publishInfo == 2 ? updateEventModel.PublishDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ") : string.Empty); if (response.ErrorMessage != null) { diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor index 8e5ab86db..f47e8337c 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor @@ -20,8 +20,8 @@
- + @@ -121,8 +121,8 @@ var tmp = await EventsService.SearchOrganizerEventsAsync(searchOrganizerEventsModel.OrganizerId, searchOrganizerEventsModel.Name, searchOrganizerEventsModel.State, - searchOrganizerEventsModel.DateFrom.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), - searchOrganizerEventsModel.DateTo.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + searchOrganizerEventsModel.DateFrom.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + searchOrganizerEventsModel.DateTo.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), searchOrganizerEventsModel.Pageable); if (tmp.Content != null) { @@ -147,8 +147,8 @@ var tmp = await EventsService.SearchOrganizerEventsAsync(searchOrganizerEventsModel.OrganizerId, searchOrganizerEventsModel.Name, searchOrganizerEventsModel.State, - searchOrganizerEventsModel.DateFrom.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), - searchOrganizerEventsModel.DateTo.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + searchOrganizerEventsModel.DateFrom.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + searchOrganizerEventsModel.DateTo.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), searchOrganizerEventsModel.Pageable); events = tmp.Content.Content; StateHasChanged(); diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor index b8e45309f..5ea43a752 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor @@ -113,8 +113,8 @@ var tmp = await EventsService.SearchEventsAsync(searchEventsModel.Name, searchEventsModel.Organizer, searchEventsModel.Category, searchEventsModel.State, searchEventsModel.Friends, searchEventsModel.FriendsEngagementType, - searchEventsModel.DateFrom.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), - searchEventsModel.DateTo.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + searchEventsModel.DateFrom.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + searchEventsModel.DateTo.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), searchEventsModel.Pageable); if (tmp.Content != null) { @@ -139,8 +139,8 @@ var tmp = await EventsService.SearchEventsAsync(searchEventsModel.Name, searchEventsModel.Organizer, searchEventsModel.Category, searchEventsModel.State, searchEventsModel.Friends, searchEventsModel.FriendsEngagementType, - searchEventsModel.DateFrom.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), - searchEventsModel.DateTo.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + searchEventsModel.DateFrom.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + searchEventsModel.DateTo.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), searchEventsModel.Pageable); events = tmp.Content.Content; StateHasChanged(); diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Friends/FriendsDetails.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Friends/FriendsDetails.razor index b789c3b44..f6ba8e504 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Friends/FriendsDetails.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Friends/FriendsDetails.razor @@ -20,9 +20,9 @@ else

Description: @student.Description

Number of Friends: @student.NumberOfFriends

-

Date of Birth: @student.DateOfBirth.ToString("yyyy-MM-dd")

+

Date of Birth: @student.DateOfBirth.ToLocalTime().ToString("yyyy-MM-dd")

State: @student.State

-

Joined: @student.CreatedAt.ToString("yyyy-MM-dd")

+

Joined: @student.CreatedAt.ToLocalTime().ToString("yyyy-MM-dd")

} diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Friends/FriendsRequests.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Friends/FriendsRequests.razor index c9cfda16e..09dda0f96 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Friends/FriendsRequests.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Friends/FriendsRequests.razor @@ -21,7 +21,11 @@ else if (incomingRequests.Any()) - + + + - + + + diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Posts/PostCreate.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Posts/PostCreate.razor index 29865e975..c7901269f 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Posts/PostCreate.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Posts/PostCreate.razor @@ -99,7 +99,7 @@ var response = await PostsService.CreatePostAsync(Guid.Empty, createPostModel.EventId, createPostModel.OrganizerId, createPostModel.TextContent, createPostModel.MediaContent, publishInfo == 2 ? "ToBePublished" : "Published", - publishInfo == 2 ? createPostModel.PublishDate : null); + publishInfo == 2 ? createPostModel.PublishDate.ToUniversalTime() : null); if (response.ErrorMessage != null) { From 0e1a62f481f4b860e286c87e8ecf7e0e24f4d72d Mon Sep 17 00:00:00 2001 From: Amadeusz Nowak Date: Tue, 14 May 2024 00:32:01 +0200 Subject: [PATCH 03/10] (#57) fix date format and remove state cancelled in events filtering --- .../Pages/Events/Dialogs/EventsOrganizeDialog.razor | 5 ++--- .../Pages/Events/Dialogs/EventsSearchDialog.razor | 5 ++--- .../src/MiniSpace.Web/Pages/Events/EventsOrganize.razor | 2 +- .../src/MiniSpace.Web/Pages/Events/EventsSearch.razor | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsOrganizeDialog.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsOrganizeDialog.razor index 1f7103eb9..427cd4b79 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsOrganizeDialog.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsOrganizeDialog.razor @@ -14,7 +14,7 @@
- + @@ -27,7 +27,7 @@ - + @@ -62,7 +62,6 @@ [ "", "Published", - "Cancelled", "Archived" ]; diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsSearchDialog.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsSearchDialog.razor index 1e81295da..e02aea5f0 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsSearchDialog.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsSearchDialog.razor @@ -17,7 +17,7 @@ - + @@ -33,7 +33,7 @@ - + @@ -82,7 +82,6 @@ [ "", "Published", - "Cancelled", "Archived" ]; diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor index f47e8337c..610c211a0 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor @@ -91,7 +91,7 @@ { Name = "", State = "", - DateFrom = new DateTime(2024, 04, 14), + DateFrom = new DateTime(2024, 05, 14), DateTo = new DateTime(2024, 05, 31), Pageable = new PageableDto() { diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor index 5ea43a752..41e476995 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor @@ -88,7 +88,7 @@ State = "", Friends = [], FriendsEngagementType = "", - DateFrom = new DateTime(2024, 04, 14), + DateFrom = new DateTime(2024, 05, 14), DateTo = new DateTime(2024, 05, 31), Pageable = new PageableDto() { From d0b124c196e98df89cab65e40b166e976b195f45 Mon Sep 17 00:00:00 2001 From: Amadeusz Nowak Date: Tue, 14 May 2024 01:00:28 +0200 Subject: [PATCH 04/10] (#57) fix selection of sort direction --- .../Events/Dialogs/EventsOrganizeDialog.razor | 22 +++++++++++++------ .../Events/Dialogs/EventsSearchDialog.razor | 21 +++++++++++++----- .../Pages/Events/EventsOrganize.razor | 2 +- .../Pages/Events/EventsSearch.razor | 2 +- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsOrganizeDialog.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsOrganizeDialog.razor index 427cd4b79..cc94e44c9 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsOrganizeDialog.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsOrganizeDialog.razor @@ -14,7 +14,7 @@ - + @@ -27,10 +27,11 @@ - + - + @@ -57,7 +58,6 @@ private SearchOrganizerEventsModel TempSearchOrganizerEventsModel { get; set; } - private List states = [ "", @@ -65,10 +65,18 @@ "Archived" ]; - private List directions = + private List> directions = + [ + new KeyValuePair("Descending", "des"), + new KeyValuePair("Ascending", "asc") + ]; + + private List> sortParameters = [ - "Ascending", - "Descending" + new KeyValuePair("Name", "name"), + new KeyValuePair("Description", "description"), + new KeyValuePair("Start date", "startDate"), + new KeyValuePair("End date", "endDate"), ]; protected override async Task OnInitializedAsync() diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsSearchDialog.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsSearchDialog.razor index e02aea5f0..ab5635479 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsSearchDialog.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsSearchDialog.razor @@ -17,7 +17,7 @@
- + @@ -33,10 +33,11 @@ - + - + @@ -85,10 +86,18 @@ "Archived" ]; - private List directions = + private List> directions = [ - "Ascending", - "Descending" + new KeyValuePair("Descending", "des"), + new KeyValuePair("Ascending", "asc") + ]; + + private List> sortParameters = + [ + new KeyValuePair("Name", "name"), + new KeyValuePair("Description", "description"), + new KeyValuePair("Start date", "startDate"), + new KeyValuePair("End date", "endDate"), ]; protected override async Task OnInitializedAsync() diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor index 610c211a0..7162df0c4 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor @@ -100,7 +100,7 @@ Sort = new SortDto() { SortBy = new List() { "dateFrom" }, - Direction = "Ascending" + Direction = "des" } } }; diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor index 41e476995..429f7b96e 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor @@ -97,7 +97,7 @@ Sort = new SortDto() { SortBy = new List() { "dateFrom" }, - Direction = "Ascending" + Direction = "des" } } }; From 7764af6d2c851eef8cb32c9fddc17e29412e1127 Mon Sep 17 00:00:00 2001 From: Amadeusz Nowak Date: Tue, 14 May 2024 17:12:46 +0200 Subject: [PATCH 05/10] (#57) add selection of sorting parameters in events filtering --- .../Events/Dialogs/EventsOrganizeDialog.razor | 39 ++++++++++++++++- .../Events/Dialogs/EventsSearchDialog.razor | 42 +++++++++++++++++-- .../Pages/Events/EventsOrganize.razor | 2 +- .../Pages/Events/EventsSearch.razor | 2 +- 4 files changed, 78 insertions(+), 7 deletions(-) diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsOrganizeDialog.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsOrganizeDialog.razor index cc94e44c9..9fa8fd28a 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsOrganizeDialog.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsOrganizeDialog.razor @@ -37,6 +37,25 @@ + + + + + Not selected parameters: + + + Sorting parameters (order important): + + + + + + @@ -71,18 +90,32 @@ new KeyValuePair("Ascending", "asc") ]; - private List> sortParameters = + private List> initialSortParams = [ new KeyValuePair("Name", "name"), - new KeyValuePair("Description", "description"), new KeyValuePair("Start date", "startDate"), new KeyValuePair("End date", "endDate"), ]; + private IEnumerable> notSelectedSortParams = []; + private IEnumerable> selectedSortParams = []; + protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); TempSearchOrganizerEventsModel = SearchOrganizerEventsModel.DeepClone(); + + List> selectedTmp = new(); + + foreach (var value in TempSearchOrganizerEventsModel.Pageable.Sort.SortBy) + { + var element = initialSortParams.FirstOrDefault(sortParam => sortParam.Value == value); + initialSortParams.Remove(element); + selectedTmp.Add(element); + } + + notSelectedSortParams = initialSortParams; + selectedSortParams = selectedTmp; } private void HandleFiltering() @@ -93,6 +126,8 @@ SearchOrganizerEventsModel.DateFrom = TempSearchOrganizerEventsModel.DateFrom; SearchOrganizerEventsModel.DateTo = TempSearchOrganizerEventsModel.DateTo; SearchOrganizerEventsModel.Pageable = TempSearchOrganizerEventsModel.Pageable.DeepClone(); + SearchOrganizerEventsModel.Pageable.Sort.SortBy = selectedSortParams != null + ? selectedSortParams.Select(sortParam => sortParam.Value) : []; DialogService.Close(true); } diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsSearchDialog.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsSearchDialog.razor index ab5635479..d3be7dfd9 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsSearchDialog.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/EventsSearchDialog.razor @@ -42,7 +42,26 @@ - + + + + + + Not selected parameters: + + + Sorting parameters (order important): + + + + + + @@ -92,18 +111,33 @@ new KeyValuePair("Ascending", "asc") ]; - private List> sortParameters = + private List> initialSortParams = [ new KeyValuePair("Name", "name"), - new KeyValuePair("Description", "description"), + new KeyValuePair("Capacity", "capacity"), new KeyValuePair("Start date", "startDate"), new KeyValuePair("End date", "endDate"), ]; + private IEnumerable> notSelectedSortParams = []; + private IEnumerable> selectedSortParams = []; + protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); TempSearchEventsModel = SearchEventsModel.DeepClone(); + + List> selectedTmp = new(); + + foreach (var value in TempSearchEventsModel.Pageable.Sort.SortBy) + { + var element = initialSortParams.FirstOrDefault(sortParam => sortParam.Value == value); + initialSortParams.Remove(element); + selectedTmp.Add(element); + } + + notSelectedSortParams = initialSortParams; + selectedSortParams = selectedTmp; } private void HandleFiltering() @@ -115,6 +149,8 @@ SearchEventsModel.DateFrom = TempSearchEventsModel.DateFrom; SearchEventsModel.DateTo = TempSearchEventsModel.DateTo; SearchEventsModel.Pageable = TempSearchEventsModel.Pageable.DeepClone(); + SearchEventsModel.Pageable.Sort.SortBy = selectedSortParams != null + ? selectedSortParams.Select(sortParam => sortParam.Value) : []; DialogService.Close(true); } diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor index 7162df0c4..39a79e17f 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor @@ -99,7 +99,7 @@ Size = 5, Sort = new SortDto() { - SortBy = new List() { "dateFrom" }, + SortBy = new List() { "name" }, Direction = "des" } } diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor index 429f7b96e..d928ce3b2 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor @@ -96,7 +96,7 @@ Size = 5, Sort = new SortDto() { - SortBy = new List() { "dateFrom" }, + SortBy = new List() { "name" }, Direction = "des" } } From 9734ae1194ae49bf98677fcac4e14298134959b9 Mon Sep 17 00:00:00 2001 From: Amadeusz Nowak Date: Thu, 16 May 2024 22:00:09 +0200 Subject: [PATCH 06/10] (#57) add showing event participant lists for organizer --- .../Areas/Events/EventsService.cs | 18 +++++ .../Areas/Events/IEventsService.cs | 3 + .../DTO/Wrappers/EventParticipantsDto.cs | 12 +++ .../MiniSpace.Web/Pages/Events/Event.razor | 77 +++++++++++++++++-- 4 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 MiniSpace.Web/src/MiniSpace.Web/DTO/Wrappers/EventParticipantsDto.cs diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs index 86d766afd..ac117ae0c 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs @@ -98,5 +98,23 @@ public Task>>> SearchOrganiz return _httpClient.PostAsync>>("events/search/organizer", new (name, organizerId, dateFrom, dateTo, state, pageable)); } + + public Task GetEventParticipants(Guid eventId) + { + _httpClient.SetAccessToken(_identityService.JwtDto.AccessToken); + return _httpClient.GetAsync($"events/{eventId}/participants"); + } + + public Task AddEventParticipant(Guid eventId, Guid studentId, string studentName) + { + _httpClient.SetAccessToken(_identityService.JwtDto.AccessToken); + return _httpClient.PostAsync($"events/{eventId}/participants", new {eventId, studentId, studentName}); + } + + public Task RemoveEventParticipant(Guid eventId, Guid participantId) + { + _httpClient.SetAccessToken(_identityService.JwtDto.AccessToken); + return _httpClient.DeleteAsync($"events/{eventId}/participants?participantId={participantId}"); + } } } \ No newline at end of file diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs index 25cfc42f3..66aac1c8a 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs @@ -30,5 +30,8 @@ Task>>> SearchEventsAsync(st string dateTo, PageableDto pageable); Task>>> SearchOrganizerEventsAsync(Guid organizerId, string name, string state, string dateFrom, string dateTo, PageableDto pageable); + Task GetEventParticipants(Guid eventId); + Task AddEventParticipant(Guid eventId, Guid studentId, string studentName); + Task RemoveEventParticipant(Guid eventId, Guid participantId); } } \ No newline at end of file diff --git a/MiniSpace.Web/src/MiniSpace.Web/DTO/Wrappers/EventParticipantsDto.cs b/MiniSpace.Web/src/MiniSpace.Web/DTO/Wrappers/EventParticipantsDto.cs new file mode 100644 index 000000000..6263d516b --- /dev/null +++ b/MiniSpace.Web/src/MiniSpace.Web/DTO/Wrappers/EventParticipantsDto.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; + +namespace MiniSpace.Web.DTO.Wrappers +{ + public class EventParticipantsDto + { + public Guid EventId { get; set; } + public IEnumerable InterestedStudents { get; set; } + public IEnumerable SignedUpStudents { get; set; } + } +} \ No newline at end of file diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor index 5eafb9ae7..0ee939dd3 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor @@ -107,7 +107,7 @@ } - + @if (pageInitialized && !posts.Any()) @@ -158,8 +158,49 @@ - - + @if (IdentityService.IsAuthenticated && !IsUserEventOrganizer(ev)) + { + + + } + + @if (IdentityService.IsAuthenticated && IsUserEventOrganizer(ev)) + { + + + + + + + + + + + + + + + + + + + + + } @@ -176,6 +217,12 @@ private bool pageInitialized = false; IEnumerable posts; + + private int participantPageSize = 10; + IEnumerable participantPageSizeOptions = new int[] { 10, 20, 40}; + RadzenDataGrid signedUpDataGrid; + List signedUpStudents; + List interestedStudents; protected override async Task OnInitializedAsync() { @@ -211,14 +258,27 @@ return; } - pageInitialized = false; switch (index) { case 0: posts = await PostsService.GetPostsAsync(ev.Id); break; + case 3: + if (IsUserEventOrganizer(ev)) + { + var eventParticipantsDto = await EventsService.GetEventParticipants(ev.Id); + signedUpStudents = eventParticipantsDto.SignedUpStudents.ToList(); + } + break; + case 4: + if (IsUserEventOrganizer(ev)) + { + var eventParticipantsDto = await EventsService.GetEventParticipants(ev.Id); + interestedStudents = eventParticipantsDto.InterestedStudents.ToList(); + } + break; } - pageInitialized = true; + StateHasChanged(); } private async Task OpenEventDetailsDialog(EventDto eventDto) @@ -259,4 +319,11 @@ eventDto.IsInterested = false; StateHasChanged(); } + + private async void RemoveEventParticipant(EventDto eventDto, ParticipantDto participant) + { + await EventsService.RemoveEventParticipant(ev.Id, participant.StudentId); + signedUpStudents.Remove(participant); + await signedUpDataGrid.Reload(); + } } \ No newline at end of file From baa3c4d1a5ec4ad210bc824c5e683c1d9abea59c Mon Sep 17 00:00:00 2001 From: Amadeusz Nowak Date: Thu, 16 May 2024 23:21:02 +0200 Subject: [PATCH 07/10] (#57) add showing signed up and interested friends in event --- .../Admin/Dialogs/ManageStudentDialog.razor | 3 +- .../Dialogs/ParticipantDetailsDialog.razor | 150 ++++++++++++++++++ .../MiniSpace.Web/Pages/Events/Event.razor | 85 ++++++++-- 3 files changed, 223 insertions(+), 15 deletions(-) create mode 100644 MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/ParticipantDetailsDialog.razor diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/Dialogs/ManageStudentDialog.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/Dialogs/ManageStudentDialog.razor index 907395c3d..7050e4de6 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/Dialogs/ManageStudentDialog.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/Dialogs/ManageStudentDialog.razor @@ -142,7 +142,7 @@ Date of birth - @(StudentDto.DateOfBirth.ToLocalTime().ToString(dateFormat)) + @(StudentDto.DateOfBirth.ToLocalTime().ToString(shortDateFormat)) @@ -172,6 +172,7 @@ public StudentDto StudentDto { get; set; } private const string dateFormat = "dd/MM/yyyy HH:mm"; + private const string shortDateFormat = "dd/MM/yyyy"; protected override async Task OnInitializedAsync() { diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/ParticipantDetailsDialog.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/ParticipantDetailsDialog.razor new file mode 100644 index 000000000..53f576ed1 --- /dev/null +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/ParticipantDetailsDialog.razor @@ -0,0 +1,150 @@ +@page "/events/{EventId}/participants/{ParticipantDto.Id}/details" +@using MiniSpace.Web.Areas.Students +@using Radzen +@using MiniSpace.Web.DTO +@inject DialogService DialogService +@inject IIdentityService IdentityService +@inject IStudentsService StudentsService + +@if (dialogInitialized) +{ + + + + + + Identification + + + + + + + + + + + + + + + + + + + + + + + + + + Personal info + + + + + + + First name + @(studentDto.FirstName) + + + + Last name + @(studentDto.LastName) + + + + + + Email + @(studentDto.Email) + + + + Description + @(studentDto.Description) + + + + + + + + + + + + + + + + + Other info + + + + + + + Status + @(studentDto.State.Normalize()) + + + + Email notifications + @(studentDto.EmailNotifications) + + + + + + Date of birth + @(studentDto.DateOfBirth.ToLocalTime().ToString(shortDateFormat)) + + + + Created at + @(studentDto.CreatedAt.ToLocalTime().ToString(dateFormat)) + + + + + + + + + + + + + + + + + + +} + +@code { + [Parameter] + public string EventId { get; set; } + [Parameter] + public ParticipantDto ParticipantDto { get; set; } + + private StudentDto studentDto = new(); + private bool dialogInitialized = false; + + private const string dateFormat = "dd/MM/yyyy HH:mm"; + private const string shortDateFormat = "dd/MM/yyyy"; + + protected override async Task OnInitializedAsync() + { + studentDto = await StudentsService.GetStudentAsync(ParticipantDto.StudentId); + await base.OnInitializedAsync(); + dialogInitialized = true; + } +} diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor index 0ee939dd3..d6eb49452 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor @@ -160,8 +160,43 @@ @if (IdentityService.IsAuthenticated && !IsUserEventOrganizer(ev)) { + + + + + + + + + + + - + + + + + + + + + } @if (IdentityService.IsAuthenticated && IsUserEventOrganizer(ev)) @@ -169,19 +204,20 @@ + Data="@signedUpStudents" ColumnWidth="100px" LogicalFilterOperator="LogicalFilterOperator.Or"> - - - + @@ -190,13 +226,19 @@ + Data="@interestedStudents" ColumnWidth="100px" LogicalFilterOperator="LogicalFilterOperator.Or"> - - + + + + @@ -292,6 +334,21 @@ }); } + private async Task OpenParticipantDetailsDialog(ParticipantDto participantDto, string term) + { + await DialogService.OpenAsync($"Details of the {term}:", + new Dictionary() + { + { "EventId", EventId }, + { "ParticipantDto", participantDto } + }, + new DialogOptions() + { + Width = "700px", Height = "600px", Resizable = true, Draggable = true, + AutoFocusFirstElement = false + }); + } + private async void SignUpToEvent(EventDto eventDto) { await EventsService.SignUpToEventAsync(eventDto.Id, studentId); @@ -322,7 +379,7 @@ private async void RemoveEventParticipant(EventDto eventDto, ParticipantDto participant) { - await EventsService.RemoveEventParticipant(ev.Id, participant.StudentId); + await EventsService.RemoveEventParticipant(eventDto.Id, participant.StudentId); signedUpStudents.Remove(participant); await signedUpDataGrid.Reload(); } From f4120ca96ed2fc1bc69df416a809aa2d34b93896 Mon Sep 17 00:00:00 2001 From: Amadeusz Nowak Date: Fri, 17 May 2024 00:03:30 +0200 Subject: [PATCH 08/10] (#57) add option of deleting an event --- .../Areas/Events/EventsService.cs | 6 ++++ .../Areas/Events/IEventsService.cs | 1 + .../Events/Dialogs/DeleteEventDialog.razor | 33 +++++++++++++++++++ .../MiniSpace.Web/Pages/Events/Event.razor | 14 +++++++- 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/DeleteEventDialog.razor diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs index ac117ae0c..ff7b5433b 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs @@ -53,6 +53,12 @@ public Task> UpdateEventAsync(Guid eventId, string name, Gu capacity, fee, category, publishDate}); } + public Task DeleteEventAsync(Guid eventId) + { + _httpClient.SetAccessToken(_identityService.JwtDto.AccessToken); + return _httpClient.DeleteAsync($"events/{eventId}"); + } + public Task SignUpToEventAsync(Guid eventId, Guid studentId) { _httpClient.SetAccessToken(_identityService.JwtDto.AccessToken); diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs index 66aac1c8a..cb99681c2 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs @@ -20,6 +20,7 @@ Task> UpdateEventAsync(Guid eventId, string name, Guid orga string startDate, string endDate, string buildingName, string street, string buildingNumber, string apartmentNumber, string city, string zipCode, string description, int capacity, decimal fee, string category, string publishDate); + Task DeleteEventAsync(Guid eventId); Task SignUpToEventAsync(Guid eventId, Guid studentId); Task CancelSignUpToEventAsync(Guid eventId, Guid studentId); Task ShowInterestInEventAsync(Guid eventId, Guid studentId); diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/DeleteEventDialog.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/DeleteEventDialog.razor new file mode 100644 index 000000000..9d50e22bf --- /dev/null +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/DeleteEventDialog.razor @@ -0,0 +1,33 @@ +@page "/events/{EventId}/delete" +@using MiniSpace.Web.Areas.Events +@using Radzen +@inject DialogService DialogService +@inject IEventsService EventsService +@inject NavigationManager NavigationManager + + + + + + + + + + + +@code { + [Parameter] + public Guid EventId { get; set; } + + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + } + + private async void DeleteEvent(Guid eventId) + { + await EventsService.DeleteEventAsync(eventId); + DialogService.Close(true); + NavigationManager.NavigateTo("/events/organize"); + } +} \ No newline at end of file diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor index d6eb49452..73b088022 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor @@ -97,7 +97,8 @@ - + @@ -334,6 +335,17 @@ }); } + private async Task OpenDeleteEventDialog(Guid postId) + { + await DialogService.OpenAsync("Are you sure? This action cannot be undone!", + new Dictionary() { {"EventId", new Guid(EventId) } }, + new DialogOptions() + { + Width = "500px", Height = "100px", Resizable = true, Draggable = true, + AutoFocusFirstElement = false + }); + } + private async Task OpenParticipantDetailsDialog(ParticipantDto participantDto, string term) { await DialogService.OpenAsync($"Details of the {term}:", From 40fc65820c9ca048f00e360facf35bc037507f6e Mon Sep 17 00:00:00 2001 From: Amadeusz Nowak Date: Fri, 17 May 2024 00:56:26 +0200 Subject: [PATCH 09/10] (#57) update event card to differ colors depend on status --- .../Components/RadzenEventCard.razor | 46 +++++++++++++++++ .../MiniSpace.Web/Pages/Events/Events.razor | 51 ++----------------- .../Pages/Events/EventsOrganize.razor | 28 +--------- .../Pages/Events/EventsSearch.razor | 32 +++--------- 4 files changed, 57 insertions(+), 100 deletions(-) create mode 100644 MiniSpace.Web/src/MiniSpace.Web/Components/RadzenEventCard.razor diff --git a/MiniSpace.Web/src/MiniSpace.Web/Components/RadzenEventCard.razor b/MiniSpace.Web/src/MiniSpace.Web/Components/RadzenEventCard.razor new file mode 100644 index 000000000..24e89a8a7 --- /dev/null +++ b/MiniSpace.Web/src/MiniSpace.Web/Components/RadzenEventCard.razor @@ -0,0 +1,46 @@ +@using MiniSpace.Web.DTO +@inject NavigationManager NavigationManager + + + + + Name + @(Event.Name) + + + Status + @switch (Event.Status) + { + case "Published": + @Event.Status + break; + case "Archived": + @Event.Status + break; + default: + @Event.Status + break; + } + + + + + Start date + @(Event.StartDate.ToLocalTime().ToString(dateFormat)) + + + End date + @(Event.EndDate.ToLocalTime().ToString(dateFormat)) + + +
+
+ +@code +{ + [Parameter] + public EventDto Event { get; set; } + + private const string dateFormat = "dd/MM/yyyy HH:mm"; +} diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Events.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Events.razor index c728a2e12..92b594267 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Events.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Events.razor @@ -2,6 +2,7 @@ @using MiniSpace.Web.Areas.Students @using MiniSpace.Web.DTO @using MiniSpace.Web.Areas.Events +@using MiniSpace.Web.Components @using MiniSpace.Web.Pages.Events.Dialogs @using Radzen @using DialogOptions = Radzen.DialogOptions @@ -30,30 +31,7 @@ }
@@ -65,30 +43,7 @@ } diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor index 39a79e17f..31390f846 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsOrganize.razor @@ -1,6 +1,7 @@ @page "/events/organize" @using MiniSpace.Web.Areas.Events @using MiniSpace.Web.Areas.Students +@using MiniSpace.Web.Components @using MiniSpace.Web.DTO @using MiniSpace.Web.DTO.Wrappers @using MiniSpace.Web.Models.Events @@ -48,30 +49,7 @@ @@ -85,8 +63,6 @@ } @code { - private const string dateFormat = "dd/MM/yyyy HH:mm"; - private SearchOrganizerEventsModel searchOrganizerEventsModel = new() { Name = "", diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor index d928ce3b2..fdf011728 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor @@ -2,6 +2,7 @@ @using MiniSpace.Web.Areas.Identity @using MiniSpace.Web.Areas.Events @using MiniSpace.Web.Areas.Students +@using MiniSpace.Web.Components @using MiniSpace.Web.DTO @using MiniSpace.Web.DTO.Wrappers @using MiniSpace.Web.Models.Events @@ -35,44 +36,23 @@ @if (pageInitialized && totalElements != 0) { - } @if (pageInitialized && totalElements != 0) { - } From fb640ea2be0e757222c5e03ee804292b0f33d766 Mon Sep 17 00:00:00 2001 From: Amadeusz Nowak Date: Fri, 17 May 2024 02:00:16 +0200 Subject: [PATCH 10/10] (#57) update follow events page to handle GetStudentEvents update --- .../Areas/Events/EventsService.cs | 5 +- .../Areas/Events/IEventsService.cs | 3 +- .../MiniSpace.Web/Pages/Events/Events.razor | 96 --------- .../Pages/Events/EventsFollow.razor | 192 ++++++++++++++++++ .../Pages/Events/EventsSearch.razor | 2 - .../src/MiniSpace.Web/Shared/MainLayout.razor | 2 +- 6 files changed, 198 insertions(+), 102 deletions(-) delete mode 100644 MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Events.razor create mode 100644 MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsFollow.razor diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs index ff7b5433b..28b671b5f 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs @@ -25,11 +25,12 @@ public Task GetEventAsync(Guid eventId) return _httpClient.GetAsync($"events/{eventId}"); } - public Task>> GetStudentEventsAsync(Guid studentId, int numberOfResults) + public Task>> GetStudentEventsAsync(Guid studentId, + string engagementType, int page, int numberOfResults) { _httpClient.SetAccessToken(_identityService.JwtDto.AccessToken); return _httpClient.GetAsync>>( - $"events/student/{studentId}?numberOfResults={numberOfResults}"); + $"events/student/{studentId}?engagementType={engagementType}&page={page}&numberOfResults={numberOfResults}"); } public Task> AddEventAsync(Guid eventId, string name, Guid organizerId, Guid organizationId, diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs index cb99681c2..777401816 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs @@ -11,7 +11,8 @@ namespace MiniSpace.Web.Areas.Events public interface IEventsService { Task GetEventAsync(Guid eventId); - Task>> GetStudentEventsAsync(Guid studentId, int numberOfResults); + Task>> GetStudentEventsAsync(Guid studentId, + string engagementType, int page, int numberOfResults); Task> AddEventAsync(Guid eventId, string name, Guid organizerId, Guid organizationId, string startDate, string endDate, string buildingName, string street, string buildingNumber, string apartmentNumber, string city, string zipCode, string description, int capacity, decimal fee, diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Events.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Events.razor deleted file mode 100644 index 92b594267..000000000 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Events.razor +++ /dev/null @@ -1,96 +0,0 @@ -@page "/events" -@using MiniSpace.Web.Areas.Students -@using MiniSpace.Web.DTO -@using MiniSpace.Web.Areas.Events -@using MiniSpace.Web.Components -@using MiniSpace.Web.Pages.Events.Dialogs -@using Radzen -@using DialogOptions = Radzen.DialogOptions -@using DialogService = Radzen.DialogService -@inject DialogService DialogService -@inject IIdentityService IdentityService -@inject IEventsService EventsService -@inject NavigationManager NavigationManager - -

Follow events

- -@if (!pageInitialized) -{ -

Loading...

-} - -@if (pageInitialized && studentId != Guid.Empty) -{ - - - - - @if (totalSignedUpElements == 0) - { -

You haven't been signed up for any event yet.

- } - - - -
- - - @if (totalInterestedElements == 0) - { -

You haven't been interested in any event yet.

- } - - - -
-
-
-
-} - -@code { - private const string dateFormat = "dd/MM/yyyy HH:mm"; - - private Guid studentId; - private bool pageInitialized = false; - - private int numberOfResults = 10; - - int totalSignedUpElements = 0; - IEnumerable signedUpEvents; - - int totalInterestedElements = 0; - IEnumerable interestedEvents; - - protected override async Task OnInitializedAsync() - { - if (IdentityService.IsAuthenticated) - { - studentId = IdentityService.GetCurrentUserId(); - - var tmp = await EventsService.GetStudentEventsAsync(studentId, numberOfResults); - if (tmp != null) - { - signedUpEvents = tmp.Content.Where(ev => ev.IsSignedUp); - totalSignedUpElements = signedUpEvents.Count(); - - interestedEvents = tmp.Content.Where(ev => ev.IsInterested); - totalInterestedElements = interestedEvents.Count(); - } - else - { - signedUpEvents = new List(); - totalSignedUpElements = 0; - - interestedEvents = new List(); - totalInterestedElements = 0; - } - } - - pageInitialized = true; - } -} diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsFollow.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsFollow.razor new file mode 100644 index 000000000..05de994b0 --- /dev/null +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsFollow.razor @@ -0,0 +1,192 @@ +@page "/events/follow" +@using MiniSpace.Web.Areas.Students +@using MiniSpace.Web.DTO +@using MiniSpace.Web.Areas.Events +@using MiniSpace.Web.Components +@using MiniSpace.Web.Pages.Events.Dialogs +@using MudBlazor +@using Radzen +@using DialogOptions = Radzen.DialogOptions +@using DialogService = Radzen.DialogService +@using Orientation = Radzen.Orientation +@inject DialogService DialogService +@inject IIdentityService IdentityService +@inject IEventsService EventsService +@inject NavigationManager NavigationManager + +

Follow events

+ +@if (!pageInitialized) +{ +

Loading...

+} + +@if (pageInitialized && studentId != Guid.Empty) +{ + + + + + @if (signedUpTotalElements == 0) + { +

You haven't been signed up for any event yet.

+ } + else + { + + + + + + + + + + + + } +
+ + + @if (interestedInTotalElements == 0) + { +

You haven't been interested in any event yet.

+ } + else + { + + + + + + + + + + + + } +
+
+
+
+} + +@code { + private Guid studentId; + private bool pageInitialized = false; + + int signedUpPageNumber = 1; + int signedUpPageSize = 5; + int signedUpTotalPages = 0; + int signedUpTotalElements = 0; + IEnumerable signedUpEvents; + + int interestedInPageNumber = 1; + int interestedInPageSize = 5; + int interestedInTotalPages = 0; + int interestedInTotalElements = 0; + IEnumerable interestedInEvents; + + protected override async Task OnInitializedAsync() + { + if (IdentityService.IsAuthenticated) + { + studentId = IdentityService.GetCurrentUserId(); + + var tmp = await EventsService.GetStudentEventsAsync(studentId, "SignedUp", + signedUpPageNumber, signedUpPageSize); + if (tmp != null) + { + signedUpTotalPages = tmp.TotalPages; + signedUpTotalElements = tmp.TotalElements; + signedUpEvents = tmp.Content; + } + else + { + signedUpTotalPages = 0; + signedUpTotalElements = 0; + signedUpEvents = new List(); + } + } + + pageInitialized = true; + } + + private async void OnChange(int index) + { + if (!IdentityService.IsAuthenticated) + { + return; + } + + switch (index) + { + case 0: + var tmp = await EventsService.GetStudentEventsAsync(studentId, "SignedUp", + signedUpPageNumber, signedUpPageSize); + if (tmp != null) + { + signedUpTotalPages = tmp.TotalPages; + signedUpTotalElements = tmp.TotalElements; + signedUpEvents = tmp.Content; + } + else + { + signedUpTotalPages = 0; + signedUpTotalElements = 0; + signedUpEvents = new List(); + } + break; + case 1: + tmp = await EventsService.GetStudentEventsAsync(studentId, "InterestedIn", + interestedInPageNumber, interestedInPageSize); + if (tmp != null) + { + interestedInTotalPages = tmp.TotalPages; + interestedInTotalElements = tmp.TotalElements; + interestedInEvents = tmp.Content; + } + else + { + interestedInTotalPages = 0; + interestedInTotalElements = 0; + interestedInEvents = new List(); + } + break; + } + StateHasChanged(); + } + + private async void SignedUpSelectedPageChanged(int pageNumber) + { + signedUpPageNumber = pageNumber; + + var tmp = await EventsService.GetStudentEventsAsync(studentId, "SignedUp", + signedUpPageNumber, signedUpPageSize); + signedUpEvents = tmp.Content; + StateHasChanged(); + } + + private async void InterestedInSelectedPageChanged(int pageNumber) + { + interestedInPageNumber = pageNumber; + + var tmp = await EventsService.GetStudentEventsAsync(studentId, "InterestedIn", + interestedInPageNumber, interestedInPageSize); + interestedInEvents = tmp.Content; + StateHasChanged(); + } +} diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor index fdf011728..ec7f167d4 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/EventsSearch.razor @@ -58,8 +58,6 @@ } @code { - private const string dateFormat = "dd/MM/yyyy HH:mm"; - private SearchEventsModel searchEventsModel = new() { Name = "", diff --git a/MiniSpace.Web/src/MiniSpace.Web/Shared/MainLayout.razor b/MiniSpace.Web/src/MiniSpace.Web/Shared/MainLayout.razor index 2dbc18f34..6dfbbb5f6 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Shared/MainLayout.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Shared/MainLayout.razor @@ -79,7 +79,7 @@ + Click="@(() => NavigationManager.NavigateTo("events/follow"))"/> @if (IdentityService.GetCurrentUserRole() == "organizer")