diff --git a/src/EventHub.Domain.Shared/Localization/EventHub/en.json b/src/EventHub.Domain.Shared/Localization/EventHub/en.json
index 25f2ca7..58841e8 100644
--- a/src/EventHub.Domain.Shared/Localization/EventHub/en.json
+++ b/src/EventHub.Domain.Shared/Localization/EventHub/en.json
@@ -47,6 +47,14 @@
"EditOrganization": "Edit Organization",
"PersonalWebsite": "Personal Website",
"SocialMedia": "Social Media",
- "EventHub:NotAuthorizedToUpdateOrganizationProfile": "You are not authorized to update the \"{OrganizationName}\" organization."
+ "EventHub:NotAuthorizedToUpdateOrganizationProfile": "You are not authorized to update the \"{OrganizationName}\" organization.",
+ "OrganizationProfilePictureEditSuccessMessage": "The organization's profile picture has been changed successfully.",
+ "ChooseOrganizationProfilePicture": "Choose organization profile picture...",
+ "OrganizationProfilePictureSizeExceedMessage": "The file is too large to upload. Max file size: 1MB.",
+ "OrganizationProfilePictureExtensionNotAllowed": "This file extension is not allowed. Allowed extensions: png, jpg, jpeg",
+ "ProfileInfo": "Profile Info",
+ "ProfilePicture": "Profile Picture",
+ "OrganizationProfilePictureInfo": "Upload 16:9 aspect ratio pictures for the best view. Maximum file size: 1MB.",
+ "Close": "Close"
}
}
diff --git a/src/EventHub.Web/Controllers/OrganizationController.cs b/src/EventHub.Web/Controllers/OrganizationController.cs
index 4b5ce93..14f7667 100644
--- a/src/EventHub.Web/Controllers/OrganizationController.cs
+++ b/src/EventHub.Web/Controllers/OrganizationController.cs
@@ -20,6 +20,7 @@ namespace EventHub.Web.Controllers
[HttpPost]
[Authorize]
+ [Route("save-profile-picture")]
public async Task SaveProfilePicture([FromForm] OrganizationProfilePictureInput input)
{
byte[] profilePictureContent = new byte[] {};
diff --git a/src/EventHub.Web/Pages/Organizations/Edit.cshtml b/src/EventHub.Web/Pages/Organizations/Edit.cshtml
index 7d22d5f..1357fc2 100644
--- a/src/EventHub.Web/Pages/Organizations/Edit.cshtml
+++ b/src/EventHub.Web/Pages/Organizations/Edit.cshtml
@@ -15,10 +15,10 @@
@@ -27,15 +27,16 @@
diff --git a/src/EventHub.Web/Pages/Organizations/Edit.js b/src/EventHub.Web/Pages/Organizations/Edit.js
index 684f78d..3506144 100644
--- a/src/EventHub.Web/Pages/Organizations/Edit.js
+++ b/src/EventHub.Web/Pages/Organizations/Edit.js
@@ -1,7 +1,7 @@
$(function () {
var l = abp.localization.getResource('EventHub');
- var fileInput = document.getElementById("organization_id");
+ var fileInput = document.getElementById("organization-profile-picture");
var file;
fileInput.addEventListener('change', function () {
@@ -10,7 +10,7 @@ $(function () {
file = fileInput.files[0];
if(file == undefined) {
- $("#choose-cover-image").html("Choose a cover image...");
+ $("#choose-cover-image").html(l("ChooseOrganizationProfilePicture"));
return;
}
else {
@@ -22,18 +22,18 @@ $(function () {
if (permittedExtensions.indexOf(fileExtension) === -1) {
showModal = false;
- abp.message.error('This Extension Is Not Allowed')
+ abp.message.error(l("OrganizationProfilePictureExtensionNotAllowed"))
.then(() => {
- $("#choose-cover-image").html("Choose a cover image...");
+ $("#choose-cover-image").html(l("ChooseOrganizationProfilePicture"));
file = null;
});
}
//1mb
else if(file.size > 1024 * 1024) {
showModal = false;
- abp.message.error('The File Is Too Large')
+ abp.message.error(l("OrganizationProfilePictureSizeExceedMessage"))
.then(() => {
- $("#choose-cover-image").html("Choose a cover image...");
+ $("#choose-cover-image").html(l("ChooseOrganizationProfilePicture"));
file = null;
});
}
@@ -73,10 +73,11 @@ $(function () {
$("form#EditOrganizationProfileForm").submit(function (e) {
e.preventDefault();
- var id = document.getElementById("my-id").value;
+ var organizationId = document.getElementById("organization-id").value;
+ var organizationName = document.getElementById("organization-name").value;
var formData = new FormData();
- formData.append("OrganizationId", id);
+ formData.append("OrganizationId", organizationId);
formData.append("ProfilePictureFile", file);
$.ajax({
@@ -84,25 +85,25 @@ $(function () {
var xhr = new window.XMLHttpRequest();
xhr.upload.addEventListener("progress", function(evt) {
if (evt.lengthComputable) {
- var percentComplete = evt.loaded / evt.total;
- percentComplete = parseInt(percentComplete * 100);
- if(percentComplete !== 100){
- $('#btnSubmit').prop( "disabled", true );
+ var percentage = evt.loaded / evt.total;
+ percentage = parseInt(percentage * 100);
+ if(percentage !== 100){
+ $('#btnSubmit').prop("disabled", true);
}
}
}, false);
return xhr;
},
- url: `/api/organization`,
+ url: `/api/organization/save-profile-picture`,
data: formData,
type: 'POST',
contentType: false,
processData: false,
success: function(data){
abp.message
- .success("Organization Profile Picture successfully added.")
- .then(data => window.location.href = "/");
+ .success(l("OrganizationProfilePictureEditSuccessMessage"))
+ .then(data => window.location.href = "/Organizations/" + organizationName);
},
error: function (data) {
abp.message.error(data.responseJSON.error.message);
diff --git a/test/EventHub.Application.Tests/Organizations/OrganizationAppServiceTests.cs b/test/EventHub.Application.Tests/Organizations/OrganizationAppServiceTests.cs
index 607ded8..e46cc0a 100644
--- a/test/EventHub.Application.Tests/Organizations/OrganizationAppServiceTests.cs
+++ b/test/EventHub.Application.Tests/Organizations/OrganizationAppServiceTests.cs
@@ -111,7 +111,7 @@ namespace EventHub.Organizations
{
Login(_testData.UserAdminId);
- var exception = await Assert.ThrowsAsync(() =>
+ var exception = await Assert.ThrowsAsync(() =>
_organizationAppService.UpdateAsync(
_testData.OrganizationDotnetEuropeId,
new UpdateOrganizationDto