Browse Source

Add missing localizations

pull/19/head
EngincanV 6 years ago
parent
commit
44d7cbf8f5
  1. 10
      src/EventHub.Domain.Shared/Localization/EventHub/en.json
  2. 1
      src/EventHub.Web/Controllers/OrganizationController.cs
  3. 17
      src/EventHub.Web/Pages/Organizations/Edit.cshtml
  4. 31
      src/EventHub.Web/Pages/Organizations/Edit.js
  5. 2
      test/EventHub.Application.Tests/Organizations/OrganizationAppServiceTests.cs

10
src/EventHub.Domain.Shared/Localization/EventHub/en.json

@ -47,6 +47,14 @@
"EditOrganization": "Edit Organization", "EditOrganization": "Edit Organization",
"PersonalWebsite": "Personal Website", "PersonalWebsite": "Personal Website",
"SocialMedia": "Social Media", "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"
} }
} }

1
src/EventHub.Web/Controllers/OrganizationController.cs

@ -20,6 +20,7 @@ namespace EventHub.Web.Controllers
[HttpPost] [HttpPost]
[Authorize] [Authorize]
[Route("save-profile-picture")]
public async Task SaveProfilePicture([FromForm] OrganizationProfilePictureInput input) public async Task SaveProfilePicture([FromForm] OrganizationProfilePictureInput input)
{ {
byte[] profilePictureContent = new byte[] {}; byte[] profilePictureContent = new byte[] {};

17
src/EventHub.Web/Pages/Organizations/Edit.cshtml

@ -15,10 +15,10 @@
<ul class="nav nav-pills mt-3 mb-3" id="pills-tab" role="tablist"> <ul class="nav nav-pills mt-3 mb-3" id="pills-tab" role="tablist">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" id="profile-info-tab" data-toggle="pill" href="#profile-info" role="tab" aria-controls="profile-info" aria-selected="true">Profile Info</a> <a class="nav-link active" id="profile-info-tab" data-toggle="pill" href="#profile-info" role="tab" aria-controls="profile-info" aria-selected="true">@L["ProfileInfo"]</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" id="profile-picture-tab" data-toggle="pill" href="#profile-picture" role="tab" aria-controls="profile-picture" aria-selected="false">Profile Picture</a> <a class="nav-link" id="profile-picture-tab" data-toggle="pill" href="#profile-picture" role="tab" aria-controls="profile-picture" aria-selected="false">@L["ProfilePicture"]</a>
</li> </li>
</ul> </ul>
<div class="tab-content" id="pills-tabContent"> <div class="tab-content" id="pills-tabContent">
@ -27,15 +27,16 @@
</div> </div>
<div class="tab-pane fade" id="profile-picture" role="tabpanel" aria-labelledby="profile-picture-tab"> <div class="tab-pane fade" id="profile-picture" role="tabpanel" aria-labelledby="profile-picture-tab">
<form method="post" id="EditOrganizationProfileForm" enctype="multipart/form-data"> <form method="post" id="EditOrganizationProfileForm" enctype="multipart/form-data">
<input type="hidden" id="my-id" value="@Model.Organization.Id"/> <input type="hidden" id="organization-id" value="@Model.Organization.Id"/>
<input type="hidden" id="organization-name" value="@Model.Name" />
<abp-row> <abp-row>
<abp-column size="_12" v-align="Center"> <abp-column size="_12" v-align="Center">
<div class="form-group"> <div class="form-group">
<label>Profile Picture</label> <label>@L["ProfilePicture"]</label>
<div class="custom-file"> <div class="custom-file">
<input id="organization_id" type="file" class="custom-file-input form-control" required="required"> <input id="organization-profile-picture" type="file" class="custom-file-input form-control" required="required">
<label id="choose-cover-image" class="custom-file-label" for="customFile">Choose a profile picture...</label> <label id="choose-cover-image" class="custom-file-label" for="customFile">@L["ChooseOrganizationProfilePicture"]</label>
<small id="Organization_ProfilePictureInfoText" class="form-text text-muted mt-2">Profile picture info</small> <small id="Organization_ProfilePictureInfoText" class="form-text text-muted mt-2">@L["OrganizationProfilePictureInfo"]</small>
</div> </div>
</div> </div>
</abp-column> </abp-column>
@ -51,7 +52,7 @@
<img class="img-fluid" id="img-upload" alt=""/> <img class="img-fluid" id="img-upload" alt=""/>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-primary btn-block" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary btn-block" data-dismiss="modal">@L["Close"]</button>
</div> </div>
</div> </div>
</div> </div>

31
src/EventHub.Web/Pages/Organizations/Edit.js

@ -1,7 +1,7 @@
$(function () { $(function () {
var l = abp.localization.getResource('EventHub'); var l = abp.localization.getResource('EventHub');
var fileInput = document.getElementById("organization_id"); var fileInput = document.getElementById("organization-profile-picture");
var file; var file;
fileInput.addEventListener('change', function () { fileInput.addEventListener('change', function () {
@ -10,7 +10,7 @@ $(function () {
file = fileInput.files[0]; file = fileInput.files[0];
if(file == undefined) { if(file == undefined) {
$("#choose-cover-image").html("Choose a cover image..."); $("#choose-cover-image").html(l("ChooseOrganizationProfilePicture"));
return; return;
} }
else { else {
@ -22,18 +22,18 @@ $(function () {
if (permittedExtensions.indexOf(fileExtension) === -1) { if (permittedExtensions.indexOf(fileExtension) === -1) {
showModal = false; showModal = false;
abp.message.error('This Extension Is Not Allowed') abp.message.error(l("OrganizationProfilePictureExtensionNotAllowed"))
.then(() => { .then(() => {
$("#choose-cover-image").html("Choose a cover image..."); $("#choose-cover-image").html(l("ChooseOrganizationProfilePicture"));
file = null; file = null;
}); });
} }
//1mb //1mb
else if(file.size > 1024 * 1024) { else if(file.size > 1024 * 1024) {
showModal = false; showModal = false;
abp.message.error('The File Is Too Large') abp.message.error(l("OrganizationProfilePictureSizeExceedMessage"))
.then(() => { .then(() => {
$("#choose-cover-image").html("Choose a cover image..."); $("#choose-cover-image").html(l("ChooseOrganizationProfilePicture"));
file = null; file = null;
}); });
} }
@ -73,10 +73,11 @@ $(function () {
$("form#EditOrganizationProfileForm").submit(function (e) { $("form#EditOrganizationProfileForm").submit(function (e) {
e.preventDefault(); 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(); var formData = new FormData();
formData.append("OrganizationId", id); formData.append("OrganizationId", organizationId);
formData.append("ProfilePictureFile", file); formData.append("ProfilePictureFile", file);
$.ajax({ $.ajax({
@ -84,25 +85,25 @@ $(function () {
var xhr = new window.XMLHttpRequest(); var xhr = new window.XMLHttpRequest();
xhr.upload.addEventListener("progress", function(evt) { xhr.upload.addEventListener("progress", function(evt) {
if (evt.lengthComputable) { if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total; var percentage = evt.loaded / evt.total;
percentComplete = parseInt(percentComplete * 100); percentage = parseInt(percentage * 100);
if(percentComplete !== 100){ if(percentage !== 100){
$('#btnSubmit').prop( "disabled", true ); $('#btnSubmit').prop("disabled", true);
} }
} }
}, false); }, false);
return xhr; return xhr;
}, },
url: `/api/organization`, url: `/api/organization/save-profile-picture`,
data: formData, data: formData,
type: 'POST', type: 'POST',
contentType: false, contentType: false,
processData: false, processData: false,
success: function(data){ success: function(data){
abp.message abp.message
.success("Organization Profile Picture successfully added.") .success(l("OrganizationProfilePictureEditSuccessMessage"))
.then(data => window.location.href = "/"); .then(data => window.location.href = "/Organizations/" + organizationName);
}, },
error: function (data) { error: function (data) {
abp.message.error(data.responseJSON.error.message); abp.message.error(data.responseJSON.error.message);

2
test/EventHub.Application.Tests/Organizations/OrganizationAppServiceTests.cs

@ -111,7 +111,7 @@ namespace EventHub.Organizations
{ {
Login(_testData.UserAdminId); Login(_testData.UserAdminId);
var exception = await Assert.ThrowsAsync<AbpAuthorizationException>(() => var exception = await Assert.ThrowsAsync<BusinessException>(() =>
_organizationAppService.UpdateAsync( _organizationAppService.UpdateAsync(
_testData.OrganizationDotnetEuropeId, _testData.OrganizationDotnetEuropeId,
new UpdateOrganizationDto new UpdateOrganizationDto

Loading…
Cancel
Save