mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 13:40:13 +01:00
Compare commits
5 Commits
DtoBuilder
...
ae0fab301a
| Author | SHA1 | Date | |
|---|---|---|---|
| ae0fab301a | |||
| 9de5c85120 | |||
| f7583738d7 | |||
| 4a82822d64 | |||
| b075ef7e78 |
@@ -1,4 +1,4 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using WebApp.Entities;
|
||||
|
||||
namespace WebApp.DTOs;
|
||||
@@ -8,6 +8,7 @@ public record class EventCreateDto
|
||||
(
|
||||
[Required][StringLength(50)] string Title,
|
||||
[StringLength(500)] string Description,
|
||||
string? ImageURL,
|
||||
[Required][StringLength(100)] string Location,
|
||||
[Required] DateTime? EventDate,
|
||||
ICollection<EventSkill> EventSkills
|
||||
|
||||
@@ -11,6 +11,7 @@ public record class EventDetailsDto
|
||||
[Required] public string? OrganisationName { get; set; }
|
||||
[Required][StringLength(50)] public string Title { get; set; }
|
||||
[StringLength(500)] public string Description { get; set; }
|
||||
public string? ImageURL { get; set; }
|
||||
[Required][StringLength(100)] public string Location { get; set; }
|
||||
[Required] public DateTime? EventDate { get; set; }
|
||||
//ICollection<EventSkill> EventSkills,
|
||||
|
||||
@@ -10,6 +10,7 @@ public record class EventSummaryDto {
|
||||
[Required] public int OrganisationId { get; set; }
|
||||
[Required] [StringLength(50)] public string Title { get; set; }
|
||||
[StringLength(500)] public string Description { get; set; }
|
||||
public string? ImageURL { get; set; }
|
||||
[Required] [StringLength(100)] public string Location { get; set; }
|
||||
[Required] public DateTime? EventDate { get; set; }
|
||||
public ICollection<SkillSummaryDto> EventSkills { get; set; }
|
||||
|
||||
@@ -10,6 +10,7 @@ public record class EventSummaryNoErDto(
|
||||
[Required] int OrganisationId,
|
||||
[Required][StringLength(50)] string Title,
|
||||
[StringLength(500)] string Description,
|
||||
string? ImageURL,
|
||||
[Required][StringLength(100)] string Location,
|
||||
[Required] DateTime? EventDate,
|
||||
ICollection<EventSkill> EventSkills
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using WebApp.Entities;
|
||||
|
||||
namespace WebApp.DTOs;
|
||||
@@ -8,6 +8,7 @@ public record class EventUpdateDto
|
||||
(
|
||||
[Required][StringLength(50)] string Title,
|
||||
[StringLength(500)] string Description,
|
||||
string? ImageURL,
|
||||
[Required][StringLength(100)] string Location,
|
||||
[Required] DateTime? EventDate,
|
||||
ICollection<EventSkill> EventSkills
|
||||
|
||||
@@ -201,10 +201,10 @@ namespace WebApp.Endpoints
|
||||
// Uwaga! Zanim to zrobisz, sprawdź, czy użytkownik
|
||||
// jest twórcą danego wydarzenia! Jeżeli nim nie jest,
|
||||
// wyzeruj EventRegistrations!
|
||||
if (org is null || e.OrganisationId != org.OrganisationId)
|
||||
{
|
||||
e.EventRegistrations.Clear();
|
||||
}
|
||||
//if (org is null || e.OrganisationId != org.OrganisationId)
|
||||
//{
|
||||
// e.EventRegistrations.Clear();
|
||||
//}
|
||||
|
||||
if (matchFound) SearchResults.Add(e);
|
||||
}
|
||||
|
||||
@@ -5,15 +5,10 @@ using WebApp.Entities;
|
||||
|
||||
namespace WebApp.Endpoints;
|
||||
|
||||
public class GeneralUseHelpers
|
||||
public class GeneralUseHelpers(ApplicationDbContext context)
|
||||
{
|
||||
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
||||
public GeneralUseHelpers(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
private readonly ApplicationDbContext _context = context;
|
||||
|
||||
async public Task<Token?> FindTokenFromString(string token_str)
|
||||
{
|
||||
@@ -129,6 +124,7 @@ public class GeneralUseHelpers
|
||||
OrganisationName = e.Organisation!.Name,
|
||||
Title = e.Title,
|
||||
Description = e.Description ?? "",
|
||||
ImageURL = e.ImageURL,
|
||||
Location = e.Location,
|
||||
EventDate = e.EventDate,
|
||||
EventSkills = e
|
||||
@@ -175,6 +171,7 @@ public class GeneralUseHelpers
|
||||
Organisation = e.Organisation!.Name,
|
||||
Title = e.Title,
|
||||
Description = e.Description ?? "",
|
||||
ImageURL = e.ImageURL,
|
||||
Location = e.Location,
|
||||
EventDate = e.EventDate,
|
||||
EventSkills = e
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace WebApp.Entities
|
||||
namespace WebApp.Entities
|
||||
{
|
||||
public class Event
|
||||
{
|
||||
@@ -6,6 +6,7 @@
|
||||
public int OrganisationId { get; set; }
|
||||
public required string Title { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? ImageURL { get; set; }
|
||||
public required string Location { get; set; }
|
||||
public required DateTime EventDate { get; set; }
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Cryptography;
|
||||
using WebApp.DTOs;
|
||||
using WebApp.Entities;
|
||||
|
||||
@@ -12,6 +13,7 @@ public static class EventMapping
|
||||
{
|
||||
Title = ECDto.Title,
|
||||
Description = ECDto.Description,
|
||||
ImageURL = ECDto.ImageURL,
|
||||
Location = ECDto.Location,
|
||||
EventDate = DateTime.SpecifyKind(ECDto.EventDate!.Value, DateTimeKind.Utc),
|
||||
EventSkills = ECDto.EventSkills,
|
||||
@@ -26,6 +28,7 @@ public static class EventMapping
|
||||
EventId = id,
|
||||
Title = EUDto.Title,
|
||||
Description = EUDto.Description,
|
||||
ImageURL = EUDto.ImageURL,
|
||||
Location = EUDto.Location,
|
||||
EventDate = DateTime.SpecifyKind(EUDto.EventDate!.Value, DateTimeKind.Utc),
|
||||
EventSkills = EUDto.EventSkills
|
||||
@@ -35,17 +38,23 @@ public static class EventMapping
|
||||
public static EventSummaryDto ToEventSummaryDto(this Event myEvent)
|
||||
{
|
||||
|
||||
List<SkillSummaryDto> ssdto = new List<SkillSummaryDto>();
|
||||
List<EventRegistrationDto> erdto = new List<EventRegistrationDto>();
|
||||
List<SkillSummaryDto> ssdto = [];
|
||||
List<EventRegistrationDto> erdto = [];
|
||||
|
||||
foreach (EventSkill es in myEvent.EventSkills)
|
||||
if (myEvent.EventSkills != null)
|
||||
{
|
||||
ssdto.Add(es.ToSkillSummaryDto());
|
||||
foreach (EventSkill es in myEvent.EventSkills)
|
||||
{
|
||||
ssdto.Add(es.ToSkillSummaryDto());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (EventRegistration er in myEvent.EventRegistrations)
|
||||
if (myEvent.EventRegistrations != null)
|
||||
{
|
||||
erdto.Add(er.ToEventRegistrationDto());
|
||||
foreach (EventRegistration er in myEvent.EventRegistrations)
|
||||
{
|
||||
erdto.Add(er.ToEventRegistrationDto());
|
||||
}
|
||||
}
|
||||
|
||||
return new EventSummaryDto {
|
||||
@@ -69,6 +78,7 @@ public static class EventMapping
|
||||
myEvent.OrganisationId,
|
||||
myEvent.Title,
|
||||
myEvent.Description ?? "",
|
||||
myEvent.ImageURL,
|
||||
myEvent.Location,
|
||||
myEvent.EventDate,
|
||||
myEvent.EventSkills
|
||||
@@ -88,17 +98,23 @@ public static class EventMapping
|
||||
|
||||
public static EventDetailsDto ToEventDetailsDto(this Event myEvent)
|
||||
{
|
||||
List<SkillSummaryDto> ssdto = new List<SkillSummaryDto>();
|
||||
List<EventRegistrationDto> erdto = new List<EventRegistrationDto>();
|
||||
List<SkillSummaryDto> ssdto = [];
|
||||
List<EventRegistrationDto> erdto = [];
|
||||
|
||||
foreach (EventSkill es in myEvent.EventSkills)
|
||||
if (myEvent.EventSkills != null)
|
||||
{
|
||||
ssdto.Add(es.ToSkillSummaryDto());
|
||||
foreach (EventSkill es in myEvent.EventSkills)
|
||||
{
|
||||
ssdto.Add(es.ToSkillSummaryDto());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (EventRegistration er in myEvent.EventRegistrations)
|
||||
if (myEvent.EventRegistrations != null)
|
||||
{
|
||||
erdto.Add(er.ToEventRegistrationDto());
|
||||
foreach (EventRegistration er in myEvent.EventRegistrations)
|
||||
{
|
||||
erdto.Add(er.ToEventRegistrationDto());
|
||||
}
|
||||
}
|
||||
|
||||
return new EventDetailsDto {
|
||||
|
||||
625
WebApp/Migrations/20250602005444_EventImageURL.Designer.cs
generated
Normal file
625
WebApp/Migrations/20250602005444_EventImageURL.Designer.cs
generated
Normal file
@@ -0,0 +1,625 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using WebApp.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WebApp.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20250602005444_EventImageURL")]
|
||||
partial class EventImageURL
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("NormalizedName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("RoleNameIndex");
|
||||
|
||||
b.ToTable("AspNetRoles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetRoleClaims", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("AccessFailedCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<bool>("EmailConfirmed")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("LockoutEnabled")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("NormalizedEmail")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("NormalizedUserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("PhoneNumberConfirmed")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("SecurityStamp")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("TwoFactorEnabled")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedEmail")
|
||||
.HasDatabaseName("EmailIndex");
|
||||
|
||||
b.HasIndex("NormalizedUserName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("UserNameIndex");
|
||||
|
||||
b.ToTable("AspNetUsers", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserClaims", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ProviderKey")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ProviderDisplayName")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("LoginProvider", "ProviderKey");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserLogins", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetUserRoles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
b.ToTable("AspNetUserTokens", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.Event", b =>
|
||||
{
|
||||
b.Property<int>("EventId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("EventId"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("EventDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("ImageURL")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Location")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("OrganisationId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("EventId");
|
||||
|
||||
b.HasIndex("OrganisationId");
|
||||
|
||||
b.ToTable("Events");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.EventRegistration", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("EventId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("RegisteredAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("UserId", "EventId");
|
||||
|
||||
b.HasIndex("EventId");
|
||||
|
||||
b.ToTable("EventRegistrations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.EventSkill", b =>
|
||||
{
|
||||
b.Property<int>("EventId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("SkillId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("EventId", "SkillId");
|
||||
|
||||
b.HasIndex("SkillId");
|
||||
|
||||
b.ToTable("EventSkills");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.Message", b =>
|
||||
{
|
||||
b.Property<int>("MessageId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("MessageId"));
|
||||
|
||||
b.Property<string>("Content")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("EventType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsMsgFromVolunteer")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateTime>("IsoDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("OrganizationId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("VolunteerId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("MessageId");
|
||||
|
||||
b.ToTable("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.MessageActivity", b =>
|
||||
{
|
||||
b.Property<int>("Sender")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Recipient")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("RecipientLastActive")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Sender", "Recipient");
|
||||
|
||||
b.ToTable("MessagesActivities");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.Organisation", b =>
|
||||
{
|
||||
b.Property<int>("OrganisationId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("OrganisationId"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Website")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("OrganisationId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Organisations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.Skill", b =>
|
||||
{
|
||||
b.Property<int>("SkillId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SkillId"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("SkillId");
|
||||
|
||||
b.ToTable("Skills");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.Token", b =>
|
||||
{
|
||||
b.Property<int>("TokenId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("TokenId"));
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("ValidUntil")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("TokenId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Tokens");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.User", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("UserId"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsOrganisation")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("UserId");
|
||||
|
||||
b.ToTable("WebUsers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("SkillId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("UserId", "SkillId");
|
||||
|
||||
b.HasIndex("SkillId");
|
||||
|
||||
b.ToTable("VolunteerSkills");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.Event", b =>
|
||||
{
|
||||
b.HasOne("WebApp.Entities.Organisation", "Organisation")
|
||||
.WithMany("Events")
|
||||
.HasForeignKey("OrganisationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Organisation");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.EventRegistration", b =>
|
||||
{
|
||||
b.HasOne("WebApp.Entities.Event", "Event")
|
||||
.WithMany("EventRegistrations")
|
||||
.HasForeignKey("EventId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("WebApp.Entities.User", "User")
|
||||
.WithMany("EventRegistrations")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Event");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.EventSkill", b =>
|
||||
{
|
||||
b.HasOne("WebApp.Entities.Event", "Event")
|
||||
.WithMany("EventSkills")
|
||||
.HasForeignKey("EventId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("WebApp.Entities.Skill", "Skill")
|
||||
.WithMany("EventSkills")
|
||||
.HasForeignKey("SkillId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Event");
|
||||
|
||||
b.Navigation("Skill");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.Organisation", b =>
|
||||
{
|
||||
b.HasOne("WebApp.Entities.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.Token", b =>
|
||||
{
|
||||
b.HasOne("WebApp.Entities.User", null)
|
||||
.WithMany("Tokens")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
||||
{
|
||||
b.HasOne("WebApp.Entities.Skill", "Skill")
|
||||
.WithMany("VolunteerSkills")
|
||||
.HasForeignKey("SkillId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("WebApp.Entities.User", "User")
|
||||
.WithMany("VolunteerSkills")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Skill");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.Event", b =>
|
||||
{
|
||||
b.Navigation("EventRegistrations");
|
||||
|
||||
b.Navigation("EventSkills");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.Organisation", b =>
|
||||
{
|
||||
b.Navigation("Events");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.Skill", b =>
|
||||
{
|
||||
b.Navigation("EventSkills");
|
||||
|
||||
b.Navigation("VolunteerSkills");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WebApp.Entities.User", b =>
|
||||
{
|
||||
b.Navigation("EventRegistrations");
|
||||
|
||||
b.Navigation("Tokens");
|
||||
|
||||
b.Navigation("VolunteerSkills");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
28
WebApp/Migrations/20250602005444_EventImageURL.cs
Normal file
28
WebApp/Migrations/20250602005444_EventImageURL.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WebApp.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class EventImageURL : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ImageURL",
|
||||
table: "Events",
|
||||
type: "text",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ImageURL",
|
||||
table: "Events");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -232,6 +232,9 @@ namespace WebApp.Migrations
|
||||
b.Property<DateTime>("EventDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("ImageURL")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Location")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { getEvent, getMyAccount, unhideElementById } from './generalUseHelpers.js';
|
||||
import { getEvent, getMyAccount, unhideElementById } from './generalUseHelpers.js';
|
||||
|
||||
|
||||
|
||||
async function createEvent() {
|
||||
// Pobieranie danych z formularza
|
||||
const title = (document.getElementById('title') as HTMLInputElement).value;
|
||||
const location = (document.getElementById('location') as HTMLInputElement).value;
|
||||
const description = (document.getElementById('description') as HTMLTextAreaElement).value;
|
||||
const eventDateRaw = (document.getElementById('eventDate') as HTMLInputElement).value;
|
||||
const title = (document.getElementById('title') as HTMLInputElement).value;
|
||||
const location = (document.getElementById('location') as HTMLInputElement).value;
|
||||
const description = (document.getElementById('description') as HTMLTextAreaElement).value;
|
||||
const imageURL = (document.getElementById('imageURL') as HTMLInputElement).value;
|
||||
const eventDateRaw = (document.getElementById('eventDate') as HTMLInputElement).value;
|
||||
|
||||
// Walidacja prostych pól
|
||||
if (!title || !location || !eventDateRaw) {
|
||||
@@ -19,6 +22,7 @@ async function createEvent() {
|
||||
title,
|
||||
location,
|
||||
description,
|
||||
imageURL,
|
||||
eventDate,
|
||||
};
|
||||
|
||||
@@ -62,4 +66,4 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
createEvent();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// Obsługuje kliknięcie na przycisk "Usuń"
|
||||
document.body.addEventListener("click", async (e) => {
|
||||
const target = e.target as HTMLElement;
|
||||
@@ -13,7 +13,7 @@
|
||||
window.location.href = "/modify.html?event=" + id;
|
||||
break;
|
||||
case "remove-btn":
|
||||
const confirmed = confirm("Na pewno chcesz usunąć to wydarzenie?"); // Potwierdzenie usunięcia
|
||||
const confirmed = confirm("Are you sure?"); // Potwierdzenie usunięcia
|
||||
if (!confirmed) return;
|
||||
|
||||
try {
|
||||
@@ -27,14 +27,14 @@
|
||||
const card = target.closest(".event-card");
|
||||
if (card) card.remove();
|
||||
} else {
|
||||
alert("Błąd podczas usuwania wydarzenia.");
|
||||
alert("Couldn't delete that event.");
|
||||
}
|
||||
} catch (err) {
|
||||
alert("Błąd połączenia z serwerem.");
|
||||
alert("Server connection failure.");
|
||||
console.error(err);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,24 +7,29 @@ function toggleListSortOrder(org_id: number) {
|
||||
loadEvents(org_id);
|
||||
}
|
||||
|
||||
async function getEvents(titleOrDescription?: string) {
|
||||
async function getEvents(titleOrDescription?: string, fDate?: Date, tDate?: Date) {
|
||||
|
||||
var res: Response;
|
||||
var searchbar = document.getElementById("searchbar") as HTMLInputElement;
|
||||
|
||||
if (titleOrDescription == null) {
|
||||
res = await fetch("/api/events" + (isAscending ? "?sort=asc" : ""));
|
||||
if (!res.ok) throw new Error("Błąd pobierania wydarzeń");
|
||||
} else {
|
||||
const payload = {
|
||||
titleOrDescription
|
||||
titleOrDescription = searchbar.value;
|
||||
//res = await fetch("/api/events" + (isAscending ? "?sort=asc" : ""));
|
||||
//if (!res.ok) throw new Error("Couldn't load events");
|
||||
}
|
||||
|
||||
var payload = {
|
||||
titleOrDescription,
|
||||
fDate,
|
||||
tDate
|
||||
};
|
||||
res = await fetch('/api/events/search', {
|
||||
|
||||
res = await fetch('/api/events/search' + (isAscending ? "?sort=asc" : ""), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
if (!res.ok) throw new Error("Błąd wyszukiwania wydarzeń");
|
||||
}
|
||||
if (!res.ok) throw new Error("Failed to get search results");
|
||||
|
||||
const events = await res.json();
|
||||
return events;
|
||||
@@ -44,31 +49,33 @@ async function loadEvents(org_id: number, evs?: Promise<any>) {
|
||||
}
|
||||
|
||||
if (events.length === 0) {
|
||||
container.innerHTML = "<p class='text-muted'>Brak wydarzeń do wyświetlenia.</p>";
|
||||
container.innerHTML = "<p class='text-muted'>No events to display at this moment.</p>";
|
||||
return;
|
||||
}
|
||||
|
||||
// Wyczyść kontener przed dodaniem nowych
|
||||
container.innerHTML = '';
|
||||
|
||||
const styleDefault = "color: #2898BD";
|
||||
const styleHighlighted = "#2393BD";
|
||||
|
||||
for (const ev of events) {
|
||||
const card = document.createElement("div");
|
||||
card.className = "event-card filled";
|
||||
//card.innerHTML = `
|
||||
// <span>${ev.title}</span>`
|
||||
// Do odkomentowania kiedy widok podglądu wydarzeń będzie gotowy
|
||||
|
||||
let formattedDate: string = new Intl.DateTimeFormat('en-US', {
|
||||
weekday: 'long', // "Monday"
|
||||
year: 'numeric', // "2023"
|
||||
month: 'long', // "December"
|
||||
day: 'numeric' // "1"
|
||||
}).format(ev.eventDate);
|
||||
console.log(formattedDate);
|
||||
}).format(new Date(ev.eventDate));
|
||||
|
||||
card.innerHTML = `
|
||||
<span>
|
||||
<a href="/view.html?event=${ev.eventId}" style="color: #2898BD">${ev.title}</a>
|
||||
<p style="margin: 0">${ev.organisation} | ${ev.location} | ${formattedDate}</p>
|
||||
<p style="margin: 0">👥 ${ev.organisation} | 📍 ${ev.location} | 📅 ${formattedDate}</p>
|
||||
</span>`
|
||||
|
||||
if (org_id == ev.organisationId) {
|
||||
card.innerHTML += `
|
||||
<div>
|
||||
@@ -84,7 +91,7 @@ async function loadEvents(org_id: number, evs?: Promise<any>) {
|
||||
container.appendChild(card);
|
||||
}
|
||||
} catch (err) {
|
||||
container.innerHTML = `<p class="text-danger">Błąd ładowania danych.</p>`;
|
||||
container.innerHTML = `<p class="text-danger">General failure when trying to load data.</p>`;
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getEvent, getMyAccount, unhideElementById } from './generalUseHelpers.js';
|
||||
import { getEvent, getMyAccount, unhideElementById } from './generalUseHelpers.js';
|
||||
|
||||
const queryString = window.location.search;
|
||||
const urlParams = new URLSearchParams(queryString);
|
||||
@@ -7,10 +7,11 @@ const eventId = urlParams.get('event');
|
||||
async function modifyEvent()
|
||||
{
|
||||
// Pobieranie danych z formularza
|
||||
const title = (document.getElementById('title') as HTMLInputElement).value;
|
||||
const location = (document.getElementById('location') as HTMLInputElement).value;
|
||||
const description = (document.getElementById('description') as HTMLTextAreaElement).value;
|
||||
const eventDateRaw = (document.getElementById('eventDate') as HTMLInputElement).value;
|
||||
const title = (document.getElementById('title') as HTMLInputElement).value;
|
||||
const location = (document.getElementById('location') as HTMLInputElement).value;
|
||||
const description = (document.getElementById('description') as HTMLTextAreaElement).value;
|
||||
const imageURL = (document.getElementById('imageURL') as HTMLInputElement).value;
|
||||
const eventDateRaw = (document.getElementById('eventDate') as HTMLInputElement).value;
|
||||
|
||||
// Walidacja prostych pól
|
||||
if (!title || !location || !eventDateRaw)
|
||||
@@ -24,6 +25,7 @@ async function modifyEvent()
|
||||
const payload = {
|
||||
title,
|
||||
location,
|
||||
imageURL,
|
||||
description,
|
||||
eventDate,
|
||||
};
|
||||
@@ -42,11 +44,11 @@ async function modifyEvent()
|
||||
throw new Error(errorText);
|
||||
}
|
||||
|
||||
alert("Wydarzenie zmodyfikowane!");
|
||||
alert("Event modified!");
|
||||
window.location.href = "/"; // Przekierowanie do strony głównej
|
||||
} catch (error) {
|
||||
console.error("Błąd podczas modyfikowania:", error);
|
||||
alert("Nie udało się zmodyfikować wydarzenia: " + error);
|
||||
console.error("Error occurred while trying to modify event:", error);
|
||||
alert("Couldn't modify event, an error occurred: " + error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,16 +83,18 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
const locationInput = document.getElementById( 'location') as HTMLInputElement;
|
||||
const descriptionInput = document.getElementById('description') as HTMLInputElement;
|
||||
const dateInput = document.getElementById( 'eventDate') as HTMLInputElement;
|
||||
const imageInput = document.getElementById( 'imageURL') as HTMLInputElement;
|
||||
var ev = await getEvent(eventId);
|
||||
|
||||
if (ev === null) {
|
||||
container.innerHTML = "<p class='text-muted'>Brak wydarzeń do wyświetlenia.</p>";
|
||||
container.innerHTML = "<p class='text-muted'>Failed to load event data.</p>";
|
||||
return;
|
||||
} else {
|
||||
titleInput.value = ev.title || '';
|
||||
locationInput.value = ev.location || '';
|
||||
descriptionInput.value = ev.description || '';
|
||||
dateInput.value = ev.eventDate.slice(0, 16) || '';
|
||||
imageInput.value = ev.imageURL || '';
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
@@ -99,4 +103,4 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import { getEvent, getMyAccount, unhideElementById, getMyRegisteredEventIds } fr
|
||||
const queryString = window.location.search;
|
||||
const urlParams = new URLSearchParams(queryString);
|
||||
const eventId = urlParams.get('event');
|
||||
var redirected = false;
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
|
||||
@@ -42,15 +43,20 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
const descText = document.getElementById( "descText") as HTMLElement;
|
||||
const dateText = document.getElementById( "dateText") as HTMLElement;
|
||||
const organizerText = document.getElementById("organizerText") as HTMLElement;
|
||||
const coverImage = document.getElementById( "coverImage") as HTMLImageElement;
|
||||
const newdateText = new Date(thisEvent.eventDate).toLocaleDateString('pl-PL');
|
||||
const newtimeText = new Date(thisEvent.eventDate).toLocaleTimeString('pl-PL');
|
||||
|
||||
|
||||
titleText.innerHTML = thisEvent.title + ` (#${eventId})`;
|
||||
locationText.innerHTML = "Place: " + thisEvent.location;
|
||||
locationText.innerHTML = "📍 Place: " + thisEvent.location;
|
||||
descText.innerHTML = thisEvent.description;
|
||||
dateText.innerHTML = "When: " + newdateText + " " + newtimeText; //thisEvent.eventDate;
|
||||
organizerText.innerHTML = "Organized by: " + thisEvent.organisationName;
|
||||
dateText.innerHTML = "📅 When: " + newdateText + " " + newtimeText; //thisEvent.eventDate;
|
||||
organizerText.innerHTML = "👥 Organized by: " + thisEvent.organisationName;
|
||||
coverImage.src = thisEvent.imageURL
|
||||
|
||||
console.log(thisEvent.imageURL);
|
||||
if (thisEvent.imageURL !== "") unhideElementById(document, "imgdiv");
|
||||
|
||||
if (org_id == thisEvent.organisationId) {
|
||||
// Użytkownik jest organizacją, która
|
||||
@@ -71,7 +77,10 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
} catch {
|
||||
unhideElementById(document, "applyBtn");
|
||||
(applyBtn as HTMLButtonElement).textContent = "log in to apply";
|
||||
(applyBtn as HTMLButtonElement).disabled = true;
|
||||
(applyBtn as HTMLButtonElement).addEventListener("click", async (e) => {
|
||||
redirected = true;
|
||||
window.location.href = "login.html";
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -112,6 +121,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
|
||||
if (applyBtn) {
|
||||
applyBtn.addEventListener("click", async (e) => {
|
||||
if (redirected) return;
|
||||
try {
|
||||
const response = await fetch(`/api/events/join/${eventId}`, {
|
||||
method: "POST",
|
||||
|
||||
@@ -2,6 +2,7 @@ interface EventData {
|
||||
title: string;
|
||||
location: string;
|
||||
description: string;
|
||||
imageURL: string;
|
||||
eventDate: string;
|
||||
organisationName: string,
|
||||
organisationId: number
|
||||
|
||||
192
WebApp/ts/userSkills.ts
Normal file
192
WebApp/ts/userSkills.ts
Normal file
@@ -0,0 +1,192 @@
|
||||
import { getEvent, getMyAccount, unhideElementById, getMyRegisteredEventIds } from './generalUseHelpers.js';
|
||||
|
||||
var redirected = false;
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
|
||||
var container = document.getElementById("mainContainer");
|
||||
const modifyBtn = document.getElementById("editBtn");
|
||||
const removeBtn = document.getElementById("removeBtn");
|
||||
const applyBtn = document.getElementById("applyBtn");
|
||||
const leaveBtn = document.getElementById("leaveBtn");
|
||||
var org_id: number = -1;
|
||||
var org_name: string = "";
|
||||
|
||||
try {
|
||||
var user = await getMyAccount();
|
||||
if (user && user.isOrganisation) {
|
||||
const org_id = user.organisationId;
|
||||
fetch('/api/organizations/' + org_id)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
org_name = data.name;
|
||||
unhideElementById(document, "orgname");
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Failed to fetch organization:', error);
|
||||
});
|
||||
} else {
|
||||
unhideElementById(document, "orgno");
|
||||
}
|
||||
} catch {
|
||||
window.location.href = "login.html";
|
||||
}
|
||||
|
||||
var thisAccount = null;
|
||||
thisAccount = await getMyAccount();
|
||||
if (thisAccount.isOrganisation) org_id = thisAccount.organisationId;
|
||||
|
||||
if (thisAccount == null) {
|
||||
if (container !== null) container.innerHTML = `<p class="text-danger">Błąd we wczytywaniu wydarzenia. <a href="/" style="color:#2898BD;">Powrót -></a></p>`;
|
||||
} else {
|
||||
|
||||
const nameText = document.getElementById("nameText") as HTMLElement;
|
||||
const orgnameText = document.getElementById( "orgname") as HTMLElement;
|
||||
const dateText = document.getElementById("dateText") as HTMLElement;
|
||||
const newdateText = new Date(thisAccount.createdAt).toLocaleDateString('pl-PL');
|
||||
const newtimeText = new Date(thisAccount.createdAt).toLocaleTimeString('pl-PL');
|
||||
|
||||
|
||||
nameText.innerHTML = thisAccount.firstName + " " + thisAccount.lastName + " (" + thisAccount.email + ")";
|
||||
dateText.innerHTML = "📅 Account creation date: " + newdateText + " " + newtimeText;
|
||||
orgnameText.innerHTML = "👥 Organization: " + org_name;
|
||||
|
||||
if (org_id == -1) {
|
||||
unhideElementById(document, "skillscont");
|
||||
} else if (org_id == -1) {
|
||||
// Użytkownik jest wolontariuszem
|
||||
try {
|
||||
const registeredIds = await getMyRegisteredEventIds();
|
||||
} catch {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
unhideElementById(document, "mainContainer");
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
window.onload = () => {
|
||||
const selectedSkillsContainer = document.getElementById('selected-skills') as HTMLDivElement;
|
||||
const dropdown = document.getElementById('skill-dropdown') as HTMLSelectElement;
|
||||
|
||||
dropdown.addEventListener('change', () => {
|
||||
const skillName = dropdown.options[dropdown.selectedIndex].text;
|
||||
const skillId = dropdown.options[dropdown.selectedIndex].value;
|
||||
if (skillName) {
|
||||
addSkill(skillName, skillId, false);
|
||||
dropdown.value = ''; // Reset dropdown
|
||||
}
|
||||
});
|
||||
|
||||
function fetchSkills() {
|
||||
fetch('/api/skills')
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
populateDropdown(data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('There was a problem with the fetch operation:', error);
|
||||
});
|
||||
}
|
||||
|
||||
function fetchUserSkills() {
|
||||
fetch('/api/auth/skills')
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
populateSkills(data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('There was a problem with the fetch operation:', error);
|
||||
});
|
||||
}
|
||||
|
||||
// Populate dropdown with fetched skills
|
||||
function populateDropdown(skills: { skillId: number; skillName: string; }[]) {
|
||||
skills.forEach(skill => {
|
||||
const option = document.createElement('option');
|
||||
option.value = skill.skillId.toString();
|
||||
option.textContent = skill.skillName;
|
||||
dropdown.appendChild(option);
|
||||
});
|
||||
}
|
||||
|
||||
function populateSkills(skills: { skillId: number; skillName: string; }[]) {
|
||||
skills.forEach(skill => {
|
||||
addSkill(skill.skillName, skill.skillId, true);
|
||||
});
|
||||
}
|
||||
|
||||
// Call fetchSkills to populate dropdown on load, same for fetchUserSkills()
|
||||
fetchSkills();
|
||||
fetchUserSkills();
|
||||
|
||||
function getRandomColor(): string {
|
||||
|
||||
const r = Math.floor(Math.random() * 256);
|
||||
const g = Math.floor(Math.random() * 256);
|
||||
const b = Math.floor(Math.random() * 256);
|
||||
|
||||
return `rgb(${r}, ${g}, ${b})`;
|
||||
}
|
||||
|
||||
async function addSkill(skillName: string, skillId: number, dummy_add: boolean) {
|
||||
if (!document.querySelector(`#selected-skills .skill[data-skill="${skillName}"]`)) {
|
||||
const skillDiv = document.createElement('div');
|
||||
skillDiv.className = 'skill';
|
||||
skillDiv.textContent = skillName;
|
||||
skillDiv.setAttribute('data-skill', skillName);
|
||||
skillDiv.style.backgroundColor = getRandomColor();
|
||||
|
||||
if (!dummy_add) {
|
||||
var skill = skillId;
|
||||
var payload = {
|
||||
skill
|
||||
};
|
||||
|
||||
var res = await fetch('/api/auth/add_skill', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
var data = await res.json();
|
||||
if (res.ok) skillDiv.remove();
|
||||
else alert(data.message);
|
||||
}
|
||||
|
||||
const removeButton = document.createElement('button');
|
||||
removeButton.textContent = 'X';
|
||||
removeButton.addEventListener('click', async () => {
|
||||
var skill = skillId;
|
||||
var payload = {
|
||||
skill
|
||||
};
|
||||
|
||||
var res = await fetch('/api/auth/remove_skill', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
var data = await res.json();
|
||||
if (res.ok) skillDiv.remove();
|
||||
else alert(data.message);
|
||||
});
|
||||
|
||||
skillDiv.appendChild(removeButton);
|
||||
selectedSkillsContainer.appendChild(skillDiv);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
@@ -37,7 +37,7 @@
|
||||
</a>
|
||||
</div>
|
||||
<div class="icon-box mt-auto mb-4">
|
||||
<a href="#" class="nav-link text-info mb-3">
|
||||
<a href="user.html" class="nav-link text-info mb-3">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z" /></svg>
|
||||
<br /><h8 class="iconText">Settings</h8>
|
||||
</a>
|
||||
@@ -73,6 +73,10 @@
|
||||
<label for="eventDate">Date</label>
|
||||
<input id="eventDate" type="datetime-local" class="form-control input-field" />
|
||||
</div>
|
||||
<div class="form-group mb-2">
|
||||
<label for="imageURL">Poster Image URL (optional)</label>
|
||||
<input id="imageURL" class="form-control input-field" />
|
||||
</div>
|
||||
|
||||
<button id="saveBtn" class="button"><span>Save</span><span>⮞</span></button>
|
||||
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
body {
|
||||
body {
|
||||
color: #2898BD;
|
||||
}
|
||||
|
||||
#imgdiv {
|
||||
padding-right: 2%;
|
||||
}
|
||||
|
||||
#coverImage {
|
||||
min-width: 30em;
|
||||
max-width: 50em;
|
||||
border: 3px dashed #2898BD;
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
.hidden-before-load {
|
||||
display: none !important;
|
||||
visibility: hidden !important;
|
||||
@@ -56,3 +67,26 @@
|
||||
opacity: 1;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.selected-skills div {
|
||||
padding: 5px 10px;
|
||||
margin: 5px;
|
||||
display: inline-block;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.selected-skills div button {
|
||||
margin-left: 10px;
|
||||
color: red;
|
||||
border: none;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.skill-dropdown {
|
||||
display: block;
|
||||
}
|
||||
|
||||
BIN
WebApp/wwwroot/img/friendly_help.jfif
Normal file
BIN
WebApp/wwwroot/img/friendly_help.jfif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
@@ -34,7 +34,7 @@
|
||||
</a>
|
||||
</div>
|
||||
<div class="icon-box mt-auto mb-4">
|
||||
<a href="#" class="nav-link text-info mb-3">
|
||||
<a href="user.html" class="nav-link text-info mb-3">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z" /></svg>
|
||||
<br /><h8 class="iconText">Settings</h8>
|
||||
</a>
|
||||
|
||||
@@ -14,6 +14,7 @@ function createEvent() {
|
||||
const title = document.getElementById('title').value;
|
||||
const location = document.getElementById('location').value;
|
||||
const description = document.getElementById('description').value;
|
||||
const imageURL = document.getElementById('imageURL').value;
|
||||
const eventDateRaw = document.getElementById('eventDate').value;
|
||||
// Walidacja prostych pól
|
||||
if (!title || !location || !eventDateRaw) {
|
||||
@@ -25,6 +26,7 @@ function createEvent() {
|
||||
title,
|
||||
location,
|
||||
description,
|
||||
imageURL,
|
||||
eventDate,
|
||||
};
|
||||
try {
|
||||
|
||||
@@ -22,7 +22,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
window.location.href = "/modify.html?event=" + id;
|
||||
break;
|
||||
case "remove-btn":
|
||||
const confirmed = confirm("Na pewno chcesz usunąć to wydarzenie?"); // Potwierdzenie usunięcia
|
||||
const confirmed = confirm("Are you sure?"); // Potwierdzenie usunięcia
|
||||
if (!confirmed)
|
||||
return;
|
||||
try {
|
||||
@@ -37,11 +37,11 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
card.remove();
|
||||
}
|
||||
else {
|
||||
alert("Błąd podczas usuwania wydarzenia.");
|
||||
alert("Couldn't delete that event.");
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
alert("Błąd połączenia z serwerem.");
|
||||
alert("Server connection failure.");
|
||||
console.error(err);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -13,26 +13,27 @@ function toggleListSortOrder(org_id) {
|
||||
isAscending = !isAscending;
|
||||
loadEvents(org_id);
|
||||
}
|
||||
function getEvents(titleOrDescription) {
|
||||
function getEvents(titleOrDescription, fDate, tDate) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var res;
|
||||
var searchbar = document.getElementById("searchbar");
|
||||
if (titleOrDescription == null) {
|
||||
res = yield fetch("/api/events" + (isAscending ? "?sort=asc" : ""));
|
||||
if (!res.ok)
|
||||
throw new Error("Błąd pobierania wydarzeń");
|
||||
}
|
||||
else {
|
||||
const payload = {
|
||||
titleOrDescription
|
||||
};
|
||||
res = yield fetch('/api/events/search', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
if (!res.ok)
|
||||
throw new Error("Błąd wyszukiwania wydarzeń");
|
||||
titleOrDescription = searchbar.value;
|
||||
//res = await fetch("/api/events" + (isAscending ? "?sort=asc" : ""));
|
||||
//if (!res.ok) throw new Error("Couldn't load events");
|
||||
}
|
||||
var payload = {
|
||||
titleOrDescription,
|
||||
fDate,
|
||||
tDate
|
||||
};
|
||||
res = yield fetch('/api/events/search' + (isAscending ? "?sort=asc" : ""), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
if (!res.ok)
|
||||
throw new Error("Failed to get search results");
|
||||
const events = yield res.json();
|
||||
return events;
|
||||
});
|
||||
@@ -51,22 +52,22 @@ function loadEvents(org_id, evs) {
|
||||
events = yield evs;
|
||||
}
|
||||
if (events.length === 0) {
|
||||
container.innerHTML = "<p class='text-muted'>Brak wydarzeń do wyświetlenia.</p>";
|
||||
container.innerHTML = "<p class='text-muted'>No events to display at this moment.</p>";
|
||||
return;
|
||||
}
|
||||
// Wyczyść kontener przed dodaniem nowych
|
||||
container.innerHTML = '';
|
||||
const styleDefault = "color: #2898BD";
|
||||
const styleHighlighted = "#2393BD";
|
||||
for (const ev of events) {
|
||||
const card = document.createElement("div");
|
||||
card.className = "event-card filled";
|
||||
|
||||
let formattedDate = new Intl.DateTimeFormat('en-US', {
|
||||
weekday: 'long',
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric' // "1"
|
||||
}).format(new Date(ev.eventDate));
|
||||
|
||||
card.innerHTML = `
|
||||
<span>
|
||||
<a href="/view.html?event=${ev.eventId}" style="color: #2898BD">${ev.title}</a>
|
||||
@@ -87,7 +88,7 @@ function loadEvents(org_id, evs) {
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
container.innerHTML = `<p class="text-danger">Błąd ładowania danych.</p>`;
|
||||
container.innerHTML = `<p class="text-danger">General failure when trying to load data.</p>`;
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -17,6 +17,7 @@ function modifyEvent() {
|
||||
const title = document.getElementById('title').value;
|
||||
const location = document.getElementById('location').value;
|
||||
const description = document.getElementById('description').value;
|
||||
const imageURL = document.getElementById('imageURL').value;
|
||||
const eventDateRaw = document.getElementById('eventDate').value;
|
||||
// Walidacja prostych pól
|
||||
if (!title || !location || !eventDateRaw) {
|
||||
@@ -27,6 +28,7 @@ function modifyEvent() {
|
||||
const payload = {
|
||||
title,
|
||||
location,
|
||||
imageURL,
|
||||
description,
|
||||
eventDate,
|
||||
};
|
||||
@@ -40,12 +42,12 @@ function modifyEvent() {
|
||||
const errorText = yield response.text();
|
||||
throw new Error(errorText);
|
||||
}
|
||||
alert("Wydarzenie zmodyfikowane!");
|
||||
alert("Event modified!");
|
||||
window.location.href = "/"; // Przekierowanie do strony głównej
|
||||
}
|
||||
catch (error) {
|
||||
console.error("Błąd podczas modyfikowania:", error);
|
||||
alert("Nie udało się zmodyfikować wydarzenia: " + error);
|
||||
console.error("Error occurred while trying to modify event:", error);
|
||||
alert("Couldn't modify event, an error occurred: " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -77,9 +79,10 @@ document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, vo
|
||||
const locationInput = document.getElementById('location');
|
||||
const descriptionInput = document.getElementById('description');
|
||||
const dateInput = document.getElementById('eventDate');
|
||||
const imageInput = document.getElementById('imageURL');
|
||||
var ev = yield getEvent(eventId);
|
||||
if (ev === null) {
|
||||
container.innerHTML = "<p class='text-muted'>Brak wydarzeń do wyświetlenia.</p>";
|
||||
container.innerHTML = "<p class='text-muted'>Failed to load event data.</p>";
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@@ -87,6 +90,7 @@ document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, vo
|
||||
locationInput.value = ev.location || '';
|
||||
descriptionInput.value = ev.description || '';
|
||||
dateInput.value = ev.eventDate.slice(0, 16) || '';
|
||||
imageInput.value = ev.imageURL || '';
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import { getEvent, getMyAccount, unhideElementById, getMyRegisteredEventIds } fr
|
||||
const queryString = window.location.search;
|
||||
const urlParams = new URLSearchParams(queryString);
|
||||
const eventId = urlParams.get('event');
|
||||
var redirected = false;
|
||||
document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
var container = document.getElementById("mainContainer");
|
||||
const modifyBtn = document.getElementById("editBtn");
|
||||
@@ -50,13 +51,18 @@ document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, vo
|
||||
const descText = document.getElementById("descText");
|
||||
const dateText = document.getElementById("dateText");
|
||||
const organizerText = document.getElementById("organizerText");
|
||||
const coverImage = document.getElementById("coverImage");
|
||||
const newdateText = new Date(thisEvent.eventDate).toLocaleDateString('pl-PL');
|
||||
const newtimeText = new Date(thisEvent.eventDate).toLocaleTimeString('pl-PL');
|
||||
titleText.innerHTML = thisEvent.title + ` (#${eventId})`;
|
||||
locationText.innerHTML = "Place: " + thisEvent.location;
|
||||
locationText.innerHTML = "📍 Place: " + thisEvent.location;
|
||||
descText.innerHTML = thisEvent.description;
|
||||
dateText.innerHTML = "When: " + newdateText + " " + newtimeText; //thisEvent.eventDate;
|
||||
organizerText.innerHTML = "Organized by: " + thisEvent.organisationName;
|
||||
dateText.innerHTML = "📅 When: " + newdateText + " " + newtimeText; //thisEvent.eventDate;
|
||||
organizerText.innerHTML = "👥 Organized by: " + thisEvent.organisationName;
|
||||
coverImage.src = thisEvent.imageURL;
|
||||
console.log(thisEvent.imageURL);
|
||||
if (thisEvent.imageURL !== "")
|
||||
unhideElementById(document, "imgdiv");
|
||||
if (org_id == thisEvent.organisationId) {
|
||||
// Użytkownik jest organizacją, która
|
||||
// stworzyła to wydarzenie
|
||||
@@ -78,7 +84,10 @@ document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, vo
|
||||
catch (_b) {
|
||||
unhideElementById(document, "applyBtn");
|
||||
applyBtn.textContent = "log in to apply";
|
||||
applyBtn.disabled = true;
|
||||
applyBtn.addEventListener("click", (e) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
redirected = true;
|
||||
window.location.href = "login.html";
|
||||
}));
|
||||
}
|
||||
}
|
||||
unhideElementById(document, "mainContainer");
|
||||
@@ -115,6 +124,8 @@ document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, vo
|
||||
if (applyBtn) {
|
||||
applyBtn.addEventListener("click", (e) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
var _c;
|
||||
if (redirected)
|
||||
return;
|
||||
try {
|
||||
const response = yield fetch(`/api/events/join/${eventId}`, {
|
||||
method: "POST",
|
||||
|
||||
183
WebApp/wwwroot/js/userSkills.js
Normal file
183
WebApp/wwwroot/js/userSkills.js
Normal file
@@ -0,0 +1,183 @@
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
import { getMyAccount, unhideElementById, getMyRegisteredEventIds } from './generalUseHelpers.js';
|
||||
var redirected = false;
|
||||
document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
var container = document.getElementById("mainContainer");
|
||||
const modifyBtn = document.getElementById("editBtn");
|
||||
const removeBtn = document.getElementById("removeBtn");
|
||||
const applyBtn = document.getElementById("applyBtn");
|
||||
const leaveBtn = document.getElementById("leaveBtn");
|
||||
var org_id = -1;
|
||||
var org_name = "";
|
||||
try {
|
||||
var user = yield getMyAccount();
|
||||
if (user && user.isOrganisation) {
|
||||
const org_id = user.organisationId;
|
||||
fetch('/api/organizations/' + org_id)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
org_name = data.name;
|
||||
unhideElementById(document, "orgname");
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Failed to fetch organization:', error);
|
||||
});
|
||||
}
|
||||
else {
|
||||
unhideElementById(document, "orgno");
|
||||
}
|
||||
}
|
||||
catch (_a) {
|
||||
window.location.href = "login.html";
|
||||
}
|
||||
var thisAccount = null;
|
||||
thisAccount = yield getMyAccount();
|
||||
if (thisAccount.isOrganisation)
|
||||
org_id = thisAccount.organisationId;
|
||||
if (thisAccount == null) {
|
||||
if (container !== null)
|
||||
container.innerHTML = `<p class="text-danger">Błąd we wczytywaniu wydarzenia. <a href="/" style="color:#2898BD;">Powrót -></a></p>`;
|
||||
}
|
||||
else {
|
||||
const nameText = document.getElementById("nameText");
|
||||
const orgnameText = document.getElementById("orgname");
|
||||
const dateText = document.getElementById("dateText");
|
||||
const newdateText = new Date(thisAccount.createdAt).toLocaleDateString('pl-PL');
|
||||
const newtimeText = new Date(thisAccount.createdAt).toLocaleTimeString('pl-PL');
|
||||
nameText.innerHTML = thisAccount.firstName + " " + thisAccount.lastName + " (" + thisAccount.email + ")";
|
||||
dateText.innerHTML = "📅 Account creation date: " + newdateText + " " + newtimeText;
|
||||
orgnameText.innerHTML = "👥 Organization: " + org_name;
|
||||
if (org_id == -1) {
|
||||
unhideElementById(document, "skillscont");
|
||||
}
|
||||
else if (org_id == -1) {
|
||||
// Użytkownik jest wolontariuszem
|
||||
try {
|
||||
const registeredIds = yield getMyRegisteredEventIds();
|
||||
}
|
||||
catch (_b) {
|
||||
}
|
||||
}
|
||||
unhideElementById(document, "mainContainer");
|
||||
}
|
||||
}));
|
||||
window.onload = () => {
|
||||
const selectedSkillsContainer = document.getElementById('selected-skills');
|
||||
const dropdown = document.getElementById('skill-dropdown');
|
||||
dropdown.addEventListener('change', () => {
|
||||
const skillName = dropdown.options[dropdown.selectedIndex].text;
|
||||
const skillId = dropdown.options[dropdown.selectedIndex].value;
|
||||
if (skillName) {
|
||||
addSkill(skillName, skillId, false);
|
||||
dropdown.value = ''; // Reset dropdown
|
||||
}
|
||||
});
|
||||
function fetchSkills() {
|
||||
fetch('/api/skills')
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
populateDropdown(data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('There was a problem with the fetch operation:', error);
|
||||
});
|
||||
}
|
||||
function fetchUserSkills() {
|
||||
fetch('/api/auth/skills')
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
populateSkills(data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('There was a problem with the fetch operation:', error);
|
||||
});
|
||||
}
|
||||
// Populate dropdown with fetched skills
|
||||
function populateDropdown(skills) {
|
||||
skills.forEach(skill => {
|
||||
const option = document.createElement('option');
|
||||
option.value = skill.skillId.toString();
|
||||
option.textContent = skill.skillName;
|
||||
dropdown.appendChild(option);
|
||||
});
|
||||
}
|
||||
function populateSkills(skills) {
|
||||
skills.forEach(skill => {
|
||||
addSkill(skill.skillName, skill.skillId, true);
|
||||
});
|
||||
}
|
||||
// Call fetchSkills to populate dropdown on load, same for fetchUserSkills()
|
||||
fetchSkills();
|
||||
fetchUserSkills();
|
||||
function getRandomColor() {
|
||||
const r = Math.floor(Math.random() * 256);
|
||||
const g = Math.floor(Math.random() * 256);
|
||||
const b = Math.floor(Math.random() * 256);
|
||||
return `rgb(${r}, ${g}, ${b})`;
|
||||
}
|
||||
function addSkill(skillName, skillId, dummy_add) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!document.querySelector(`#selected-skills .skill[data-skill="${skillName}"]`)) {
|
||||
const skillDiv = document.createElement('div');
|
||||
skillDiv.className = 'skill';
|
||||
skillDiv.textContent = skillName;
|
||||
skillDiv.setAttribute('data-skill', skillName);
|
||||
skillDiv.style.backgroundColor = getRandomColor();
|
||||
if (!dummy_add) {
|
||||
var skill = skillId;
|
||||
var payload = {
|
||||
skill
|
||||
};
|
||||
var res = yield fetch('/api/auth/add_skill', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
var data = yield res.json();
|
||||
if (res.ok)
|
||||
skillDiv.remove();
|
||||
else
|
||||
alert(data.message);
|
||||
}
|
||||
const removeButton = document.createElement('button');
|
||||
removeButton.textContent = 'X';
|
||||
removeButton.addEventListener('click', () => __awaiter(this, void 0, void 0, function* () {
|
||||
var skill = skillId;
|
||||
var payload = {
|
||||
skill
|
||||
};
|
||||
var res = yield fetch('/api/auth/remove_skill', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
var data = yield res.json();
|
||||
if (res.ok)
|
||||
skillDiv.remove();
|
||||
else
|
||||
alert(data.message);
|
||||
}));
|
||||
skillDiv.appendChild(removeButton);
|
||||
selectedSkillsContainer.appendChild(skillDiv);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
@@ -73,6 +73,10 @@
|
||||
<label for="eventDate">Date</label>
|
||||
<input id="eventDate" type="datetime-local" class="form-control input-field" />
|
||||
</div>
|
||||
<div class="form-group mb-2">
|
||||
<label for="imageURL">Poster Image URL (optional)</label>
|
||||
<input id="imageURL" class="form-control input-field" />
|
||||
</div>
|
||||
|
||||
<button id="saveBtn" class="button"><span>Update</span><span>⮞</span></button>
|
||||
|
||||
|
||||
85
WebApp/wwwroot/user.html
Normal file
85
WebApp/wwwroot/user.html
Normal file
@@ -0,0 +1,85 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>My account</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/css/style.css" />
|
||||
<link rel="stylesheet" href="/css/panel.css" />
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="bg-light">
|
||||
<!-- Sidebar -->
|
||||
<div class="sidebar">
|
||||
<div class="text-center mb-4">
|
||||
</div>
|
||||
<nav class="sidebar d-flex flex-column align-items-center pt-3">
|
||||
<div class="icon-box my-2">
|
||||
<a href="index.html" class="nav-link text-info mb-3">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M240-200h120v-240h240v240h120v-360L480-740 240-560v360Zm-80 80v-480l320-240 320 240v480H520v-240h-80v240H160Zm320-350Z" /></svg>
|
||||
<br /><h8 class="iconText">Home</h8>
|
||||
</a>
|
||||
</div>
|
||||
<div class="icon-box my-2">
|
||||
<a href="#" class="nav-link text-info mb-3">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M880-80 720-240H320q-33 0-56.5-23.5T240-320v-40h440q33 0 56.5-23.5T760-440v-280h40q33 0 56.5 23.5T880-640v560ZM160-473l47-47h393v-280H160v327ZM80-280v-520q0-33 23.5-56.5T160-880h440q33 0 56.5 23.5T680-800v280q0 33-23.5 56.5T600-440H240L80-280Zm80-240v-280 280Z" /></svg>
|
||||
<br /><h8 class="iconText">Chats</h8>
|
||||
</a>
|
||||
</div>
|
||||
<div class="icon-box my-2">
|
||||
<a href="#" class="nav-link text-info mb-3">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M580-240q-42 0-71-29t-29-71q0-42 29-71t71-29q42 0 71 29t29 71q0 42-29 71t-71 29ZM200-80q-33 0-56.5-23.5T120-160v-560q0-33 23.5-56.5T200-800h40v-80h80v80h320v-80h80v80h40q33 0 56.5 23.5T840-720v560q0 33-23.5 56.5T760-80H200Zm0-80h560v-400H200v400Zm0-480h560v-80H200v80Zm0 0v-80 80Z" /></svg>
|
||||
<br /><h8 class="iconText">Calendar</h8>
|
||||
</a>
|
||||
</div>
|
||||
<div class="icon-box mt-auto mb-4">
|
||||
<a href="user.html" class="nav-link text-info mb-3">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z" /></svg>
|
||||
<br /><h8 class="iconText">Settings</h8>
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
<!-- Top Nav -->
|
||||
<div class="topnav d-flex justify-content-between align-items-center shadow">
|
||||
<a href="index.html" class="eventsText m-0 logo text-decoration-none">Lend a Hand</a>
|
||||
<div>
|
||||
<button class="button-join hidden-before-load" id="joinnow-btn">Join now</button>
|
||||
<button class="button-sign hidden-before-load" id="signin-btn">Sign In</button>
|
||||
<button class="button-sign hidden-before-load" id="logout-btn">Log out</button>
|
||||
<svg class="position-relative" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#2898BD"><path d="M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm246-164q-59 0-99.5-40.5T340-580q0-59 40.5-99.5T480-720q59 0 99.5 40.5T620-580q0 59-40.5 99.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q53 0 100-15.5t86-44.5q-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160Zm0-360q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm0-60Zm0 360Z" /></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main hidden-before-load" id="mainContainer">
|
||||
<div>
|
||||
<h1 class="mb-4">My profile</h1>
|
||||
|
||||
<h2 id="nameText">John Smith (email)</h2>
|
||||
<h2 id="orgname" class="hidden-before-load">Account type: Organization</h2>
|
||||
<h2 id="orgno" class="hidden-before-load">Account type: Volunteer</h2>
|
||||
<h2 id="dateText">Created at: a long time ago</h2>
|
||||
|
||||
<div id="skillscont" class="skills-container hidden-before-load">
|
||||
<h3>Skills:</h3>
|
||||
<div id="selected-skills" class="selected-skills"></div>
|
||||
<select id="skill-dropdown" class="skill-dropdown">
|
||||
<option value="">Select a new skill</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="module" src="/js/userSkills.js"></script>
|
||||
<script type="module" src="/js/generalUseHelpers.js"></script>
|
||||
<script type="module" src="/js/auth.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
|
||||
|
||||
</html>
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
|
||||
<body class="bg-light">
|
||||
<div class="">
|
||||
<!-- Sidebar -->
|
||||
<div class="sidebar">
|
||||
<div class="text-center mb-4">
|
||||
@@ -37,7 +36,7 @@
|
||||
</a>
|
||||
</div>
|
||||
<div class="icon-box mt-auto mb-4">
|
||||
<a href="#" class="nav-link text-info mb-3">
|
||||
<a href="user.html" class="nav-link text-info mb-3">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z" /></svg>
|
||||
<br /><h8 class="iconText">Settings</h8>
|
||||
</a>
|
||||
@@ -54,20 +53,25 @@
|
||||
<svg class="position-relative" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#2898BD"><path d="M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm246-164q-59 0-99.5-40.5T340-580q0-59 40.5-99.5T480-720q59 0 99.5 40.5T620-580q0 59-40.5 99.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q53 0 100-15.5t86-44.5q-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160Zm0-360q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm0-60Zm0 360Z" /></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main hidden-before-load" id="mainContainer">
|
||||
<h1 class="mb-4" id="titleText">Event title</h1>
|
||||
<div class="main hidden-before-load" id="mainContainer" style="display: flex;">
|
||||
<div class="hidden-before-load" id="imgdiv">
|
||||
<img id="coverImage" src="/img/no_image.jpg" />
|
||||
</div>
|
||||
<div>
|
||||
<h1 class="mb-4" id="titleText">Event title</h1>
|
||||
|
||||
<h2 id="organizerText">Organized by: dummy organization</h2>
|
||||
<h2 id="locationText">Place: 127.0.0.1</h2>
|
||||
<h2 id="dateText">When: now or never!</h2>
|
||||
<h3>Description:</h3>
|
||||
<h4 id="descText"></h4><br />
|
||||
<h2 id="organizerText">Organized by: dummy organization</h2>
|
||||
<h2 id="locationText">Place: 127.0.0.1</h2>
|
||||
<h2 id="dateText">When: now or never!</h2>
|
||||
<h3>Description:</h3>
|
||||
<h4 id="descText"></h4><br />
|
||||
|
||||
<button id="applyBtn" class="button hidden-before-load"><span>Apply</span><span>⮞</span></button>
|
||||
<button id="leaveBtn" class="button hidden-before-load"><span>Leave</span><span>⮞</span></button>
|
||||
<button id="editBtn" class="button hidden-before-load"><span>Modify</span><span>⮞</span></button>
|
||||
<button id="removeBtn" class="button hidden-before-load" style="background-color: red;"><span>Remove permanently</span><span>⮞</span></button>
|
||||
<button id="applyBtn" class="button hidden-before-load"><span>Apply</span><span>⮞</span></button>
|
||||
<button id="leaveBtn" class="button hidden-before-load"><span>Leave</span><span>⮞</span></button>
|
||||
<button id="editBtn" class="button hidden-before-load"><span>Modify</span><span>⮞</span></button>
|
||||
<button id="removeBtn" class="button hidden-before-load" style="background-color: red;"><span>Remove permanently</span><span>⮞</span></button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="module" src="/js/eventView.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user