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",
"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"
}
}

1
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[] {};

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">
<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 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>
</ul>
<div class="tab-content" id="pills-tabContent">
@ -27,15 +27,16 @@
</div>
<div class="tab-pane fade" id="profile-picture" role="tabpanel" aria-labelledby="profile-picture-tab">
<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-column size="_12" v-align="Center">
<div class="form-group">
<label>Profile Picture</label>
<label>@L["ProfilePicture"]</label>
<div class="custom-file">
<input id="organization_id" 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>
<small id="Organization_ProfilePictureInfoText" class="form-text text-muted mt-2">Profile picture info</small>
<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">@L["ChooseOrganizationProfilePicture"]</label>
<small id="Organization_ProfilePictureInfoText" class="form-text text-muted mt-2">@L["OrganizationProfilePictureInfo"]</small>
</div>
</div>
</abp-column>
@ -51,7 +52,7 @@
<img class="img-fluid" id="img-upload" alt=""/>
</div>
<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>

31
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);

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

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

Loading…
Cancel
Save