diff --git a/src/EventHub.Application.Contracts/Events/EventDetailDto.cs b/src/EventHub.Application.Contracts/Events/EventDetailDto.cs index e8f17dd..973c958 100644 --- a/src/EventHub.Application.Contracts/Events/EventDetailDto.cs +++ b/src/EventHub.Application.Contracts/Events/EventDetailDto.cs @@ -9,6 +9,8 @@ namespace EventHub.Events public string OrganizationDisplayName { get; set; } + public string OwnerEmail { get; set; } + public string Title { get; set; } public string Description { get; set; } diff --git a/src/EventHub.Application/Events/EventAppService.cs b/src/EventHub.Application/Events/EventAppService.cs index 43b9a71..3f66981 100644 --- a/src/EventHub.Application/Events/EventAppService.cs +++ b/src/EventHub.Application/Events/EventAppService.cs @@ -164,6 +164,7 @@ namespace EventHub.Events dto.OrganizationName = organization.Name; dto.OrganizationDisplayName = organization.DisplayName; + dto.OwnerEmail = (await _userRepository.GetAsync(organization.OwnerUserId)).Email; dto.CoverImageContent = await GetCoverImageAsync(dto.Id); return dto; diff --git a/src/EventHub.Domain.Shared/Localization/EventHub/en.json b/src/EventHub.Domain.Shared/Localization/EventHub/en.json index 5d4d44f..a6c1518 100644 --- a/src/EventHub.Domain.Shared/Localization/EventHub/en.json +++ b/src/EventHub.Domain.Shared/Localization/EventHub/en.json @@ -56,7 +56,7 @@ "OrganizationProfilePictureInfo": "Upload 16:9 aspect ratio pictures for the best view. Maximum file size: 1MB.", "Close": "Close", "EventHub:CapacityOfEventFull": "\"{EventTitle}\" event capacity is full!", - "GoToEventAddress": "Go to Event Address", + "GoToOnlineAddress": "Go to Online Address", "AttendeesCanSeeEventLocation": "Only attendees can see the event's {0}.", "LoginToSeeLocation": "Login to see location", "LocationHasNotSpecifiedYet": "Event {0} has not been specified yet.", diff --git a/src/EventHub.Web/Pages/Events/Components/EventsArea/Default.cshtml b/src/EventHub.Web/Pages/Events/Components/EventsArea/Default.cshtml index 2762308..79c679e 100644 --- a/src/EventHub.Web/Pages/Events/Components/EventsArea/Default.cshtml +++ b/src/EventHub.Web/Pages/Events/Components/EventsArea/Default.cshtml @@ -6,7 +6,7 @@ - @if (Model.IsPagination && Model.TotalCount >= 10 && Model.TotalCount > Model.Events.Count) + @if (Model.IsPagination && Model.TotalCount > Model.MaxResultCount && Model.TotalCount > Model.Events.Count) {
diff --git a/src/EventHub.Web/Pages/Events/Components/EventsArea/EventsAreaViewComponent.cs b/src/EventHub.Web/Pages/Events/Components/EventsArea/EventsAreaViewComponent.cs index 73348ca..a640fe6 100644 --- a/src/EventHub.Web/Pages/Events/Components/EventsArea/EventsAreaViewComponent.cs +++ b/src/EventHub.Web/Pages/Events/Components/EventsArea/EventsAreaViewComponent.cs @@ -14,8 +14,6 @@ namespace EventHub.Web.Pages.Events.Components.EventsArea public class EventsAreaViewComponent : AbpViewComponent { private readonly IEventAppService _eventAppService; - - public List Events { get; set; } public EventsAreaViewComponent(IEventAppService eventAppService) { diff --git a/src/EventHub.Web/Pages/Events/Components/LocationArea/Default.cshtml b/src/EventHub.Web/Pages/Events/Components/LocationArea/Default.cshtml index dcd6e18..175334e 100644 --- a/src/EventHub.Web/Pages/Events/Components/LocationArea/Default.cshtml +++ b/src/EventHub.Web/Pages/Events/Components/LocationArea/Default.cshtml @@ -10,7 +10,7 @@ { if (Model.OnlineLink != null) { - @L["GoToEventAddress"] + @L["GoToOnlineAddress"] } else { diff --git a/src/EventHub.Web/Pages/Events/Detail.cshtml b/src/EventHub.Web/Pages/Events/Detail.cshtml index 7304331..a1394eb 100644 --- a/src/EventHub.Web/Pages/Events/Detail.cshtml +++ b/src/EventHub.Web/Pages/Events/Detail.cshtml @@ -33,7 +33,7 @@ {

@Model.Event.Title - +

@@ -44,11 +44,9 @@ } @await Component.InvokeAsync(typeof(LocationAreaViewComponent), new {eventId = Model.Event.Id}) -
Organizers
+
Owner
- - - +
@await Component.InvokeAsync(typeof(RegistrationAreaViewComponent), new {eventId = Model.Event.Id})
diff --git a/src/EventHub.Web/Pages/Events/New.cshtml b/src/EventHub.Web/Pages/Events/New.cshtml index 32ccba2..11a7505 100644 --- a/src/EventHub.Web/Pages/Events/New.cshtml +++ b/src/EventHub.Web/Pages/Events/New.cshtml @@ -2,14 +2,12 @@ @inject IHtmlLocalizer L @using EventHub.Localization @using Microsoft.AspNetCore.Mvc.Localization -@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal @model EventHub.Web.Pages.Events.NewPageModel @section scripts { - + } -

@L["NewEvent"]

@if (!Model.Organizations.Any()) { @@ -19,31 +17,111 @@ } else { -
- - - - - - - - -
- - -
- - - - - - - - - event-cover-image-preview - - - -} +
+
+
+
+ +
+
+

Create New Event

+
+
+
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+

Cover Image

+
+
+
+
+
+
+

For horizontal format 600x300 sized upload images.

+ + +
+
+
+
+
+ +
+ +
+
+ + +
+
+
+ +
+
+
+ + +
+
+
+ +
+ + +
+ +
+
+
+
+
+
+
+
+
+} \ No newline at end of file diff --git a/src/EventHub.Web/Pages/Events/New.cshtml.cs b/src/EventHub.Web/Pages/Events/New.cshtml.cs index f062e4c..b45b3d8 100644 --- a/src/EventHub.Web/Pages/Events/New.cshtml.cs +++ b/src/EventHub.Web/Pages/Events/New.cshtml.cs @@ -50,7 +50,38 @@ namespace EventHub.Web.Pages.Events await FillCountriesAsync(); FillLanguages(); } + + public async Task OnPostAsync() + { + try + { + ValidateModel(); + + var input = ObjectMapper.Map(Event); + if (Event.CoverImageFile != null && Event.CoverImageFile.Length > 0) + { + using (var memoryStream = new MemoryStream()) + { + await Event.CoverImageFile.CopyToAsync(memoryStream); + input.CoverImageContent = memoryStream.ToArray(); + } + } + + var eventDto = await _eventAppService.CreateAsync(input); + + return RedirectToPage("/Events/Detail", new {url = eventDto.UrlCode}); + } + catch (Exception exception) + { + ShowAlert(exception); + await FillOrganizationsAsync(); + await FillCountriesAsync(); + FillLanguages(); + return Page(); + } + } + private async Task FillOrganizationsAsync() { var result = await _organizationAppService.GetMyOrganizationsAsync(); @@ -92,36 +123,6 @@ namespace EventHub.Web.Pages.Events } ).ToList(); } - public async Task OnPostAsync() - { - try - { - ValidateModel(); - - var input = ObjectMapper.Map(Event); - - if (Event.CoverImageFile != null && Event.CoverImageFile.Length > 0) - { - using (var memoryStream = new MemoryStream()) - { - await Event.CoverImageFile.CopyToAsync(memoryStream); - input.CoverImageContent = memoryStream.ToArray(); - } - } - - var eventDto = await _eventAppService.CreateAsync(input); - - return RedirectToPage("/Events/Detail", new {url = eventDto.UrlCode}); - } - catch (Exception exception) - { - ShowAlert(exception); - await FillOrganizationsAsync(); - await FillCountriesAsync(); - FillLanguages(); - return Page(); - } - } public class NewEventViewModel { @@ -134,10 +135,12 @@ namespace EventHub.Web.Pages.Events public string Title { get; set; } [Required] - public DateTime StartTime { get; set; } + [DataType(DataType.DateTime)] + public DateTime StartTime { get; set; } = DateTime.Now; [Required] - public DateTime EndTime { get; set; } + [DataType(DataType.DateTime)] + public DateTime EndTime { get; set; } = DateTime.Now; [Required] [StringLength(EventConsts.MaxDescriptionLength, MinimumLength = EventConsts.MinDescriptionLength)] @@ -151,7 +154,8 @@ namespace EventHub.Web.Pages.Events [AllowedExtensions(new string[] { ".jpg", ".png", ".jpeg" })] public IFormFile CoverImageFile { get; set; } - public bool IsOnline { get; set; } + [Required] + public bool? IsOnline { get; set; } [CanBeNull] [StringLength(EventConsts.MaxOnlineLinkLength, MinimumLength = EventConsts.MinOnlineLinkLength)] diff --git a/src/EventHub.Web/Pages/Events/New.js b/src/EventHub.Web/Pages/Events/New.js index 0ce9021..73738ad 100644 --- a/src/EventHub.Web/Pages/Events/New.js +++ b/src/EventHub.Web/Pages/Events/New.js @@ -1,48 +1,63 @@ $(function () { var l = abp.localization.getResource('EventHub'); - - $("#Event_CountryId").prepend(""); - $("#Event_Language").prepend(""); - - $('#Event_IsOnline').click(function() { - if ($(this).is(':checked')) { - $("#event-link-group").show(); - $("#event-location-group").hide(); + + var isOnline = $("#Event_IsOnline option:selected").val() + if (isOnline === "True") { + $(".event-link-group").show(); + $(".event-location-group").hide(); + }else{ + $(".event-link-group").hide(); + $(".event-location-group").show(); + } + + $('#Event_IsOnline').on('change', '', function() { + var isOnline = $("#Event_IsOnline option:selected").val() + if (isOnline === "True") { + $(".event-link-group").show(); + $(".event-location-group").hide(); }else{ - $("#event-link-group").hide(); - $("#event-location-group").show(); + $(".event-link-group").hide(); + $(".event-location-group").show(); } }); + var infoArea = document.getElementById( 'upload-label' ); var fileInput = document.getElementById('Event_CoverImageFile'); var file; fileInput.addEventListener('change', function () { - var showModal = true; + var showFile = true; file = fileInput.files[0]; + if (file === undefined){ + $('#Event_CoverImageFile').val(''); + $('#imageResult').attr('src', '#'); + infoArea.textContent = 'Choose file' + return; + } + var permittedExtensions = ["jpg", "jpeg", "png"] var fileExtension = $(this).val().split('.').pop(); if (permittedExtensions.indexOf(fileExtension) === -1) { - showModal = false; + showFile = false; abp.message.error(l('EventCoverImageExtensionNotAllowed')) - .then(() => { + .then(() => { $('#Event_CoverImageFile').val(''); file = null; }); } else if(file.size > 1024*1024) { - showModal = false; + showFile = false; abp.message.error(l('EventCoverImageSizeExceedMessage')) - .then(() => { + .then(() => { $('#Event_CoverImageFile').val(''); file = null; }); } var img = new Image(); - img.onload = function() { + img.onload = function () { var imageError = true; var sizes = { width: this.width, @@ -50,22 +65,22 @@ $(function () { }; URL.revokeObjectURL(this.src); - if(showModal && imageError) { + if(showFile && imageError) { readURL(file); - $('#cover-image-preview-modal').modal('show'); } } var objectURL = URL.createObjectURL(file); img.src = objectURL; }); - + function readURL(input) { if (input) { var reader = new FileReader(); reader.onload = function (e) { - $('#img-upload').attr('src', e.target.result); + $('#imageResult').attr('src', e.target.result); + infoArea.textContent = 'File name: ' + input.name; } reader.readAsDataURL(input); diff --git a/src/EventHub.Web/Pages/Organizations/Components/OrganizationsArea/_organizationListSection.cshtml b/src/EventHub.Web/Pages/Organizations/Components/OrganizationsArea/_organizationListSection.cshtml new file mode 100644 index 0000000..eca2ff4 --- /dev/null +++ b/src/EventHub.Web/Pages/Organizations/Components/OrganizationsArea/_organizationListSection.cshtml @@ -0,0 +1,28 @@ +@model List + +@foreach (var organization in Model) +{ +
+
+ @if (organization.ProfilePictureContent == null) + { + @organization.Name + } + else + { + @organization.Name + } +
+
+
+
@organization.DisplayName
+

+ @organization.Description +

+
+ Details +
+
+
+
+} \ No newline at end of file diff --git a/src/EventHub.Web/Pages/Organizations/New.js b/src/EventHub.Web/Pages/Organizations/New.js index e1c6952..721b8d5 100644 --- a/src/EventHub.Web/Pages/Organizations/New.js +++ b/src/EventHub.Web/Pages/Organizations/New.js @@ -1,23 +1,33 @@ $(function () { var l = abp.localization.getResource('EventHub'); + var infoArea = document.getElementById( 'upload-label' ); var fileInput = document.getElementById('Organization_ProfilePictureFile'); var file; fileInput.addEventListener('change', function () { - + var showFile = true; file = fileInput.files[0]; + if (file === undefined){ + $('#Organization_ProfilePictureFile').val(''); + $('#imageResult').attr('src', '#'); + infoArea.textContent = 'Choose file' + return; + } + var permittedExtensions = ["jpg", "jpeg", "png"] var fileExtension = $(this).val().split('.').pop(); if (permittedExtensions.indexOf(fileExtension) === -1) { - abp.message.error(l('OrganizationCoverImageExtensionNotAllowed')) + showFile = false; + abp.message.error(l('OrganizationProfilePictureExtensionNotAllowed')) .then(() => { $('#Organization_ProfilePictureFile').val(''); file = null; }); } else if (file.size > 1024 * 1024) { - abp.message.error(l('OrganizationCoverImageSizeExceedMessage')) + showFile = false; + abp.message.error(l('OrganizationProfilePictureSizeExceedMessage')) .then(() => { $('#Organization_ProfilePictureFile').val(''); file = null; @@ -33,7 +43,7 @@ $(function () { }; URL.revokeObjectURL(this.src); - if (imageError) { + if (showFile && imageError) { readURL(file); } } @@ -48,6 +58,7 @@ $(function () { reader.onload = function (e) { $('#imageResult').attr('src', e.target.result); + infoArea.textContent = 'File name: ' + input.name; } reader.readAsDataURL(input);