Browse Source

Merge pull request #17049 from abpframework/issue-16909

Add extra properties to User Edit Modal
pull/17068/head
Alper Ebiçoğlu 3 years ago
committed by GitHub
parent
commit
e2983ed5fd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs
  2. 9
      modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json
  3. 9
      modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json
  4. 4
      modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs
  5. 46
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml
  6. 37
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs

4
modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs

@ -27,10 +27,14 @@ public class IdentityUserDto : ExtensibleFullAuditedEntityDto<Guid>, IMultiTenan
public bool IsActive { get; set; }
public bool LockoutEnabled { get; set; }
public int AccessFailedCount { get; set; }
public DateTimeOffset? LockoutEnd { get; set; }
public string ConcurrencyStamp { get; set; }
public int EntityVersion { get; set; }
public DateTimeOffset? LastPasswordChangeTime { get; set; }
}

9
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json

@ -113,6 +113,13 @@
"Description:Abp.Identity.SignIn.EnablePhoneNumberConfirmation": "Whether the phoneNumber can be confirmed by the user.",
"Description:Abp.Identity.SignIn.RequireConfirmedPhoneNumber": "Whether a confirmed telephone number is required to sign in.",
"Description:Abp.Identity.User.IsUserNameUpdateEnabled": "Whether the username can be updated by the user.",
"Description:Abp.Identity.User.IsEmailUpdateEnabled": "Whether the email can be updated by the user."
"Description:Abp.Identity.User.IsEmailUpdateEnabled": "Whether the email can be updated by the user.",
"Details": "Details",
"CreatedBy": "Created by",
"ModifiedBy": "Modified by",
"ModificationTime": "Modification time",
"PasswordUpdateTime": "Password update time",
"LockoutEndTime": "Lockout end time",
"FailedAccessCount": "Failed access count"
}
}

9
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json

@ -113,6 +113,13 @@
"Description:Abp.Identity.SignIn.EnablePhoneNumberConfirmation": "Oturum açmak için telefon numarası gerekli",
"Description:Abp.Identity.SignIn.RequireConfirmedPhoneNumber": "Oturum açmak için onaylanmış bir telefon numarasının gerekli olup olmadığı.",
"Description:Abp.Identity.User.IsUserNameUpdateEnabled": "Kullanıcı adının, kullanıcının kendisi tarafından güncellenebilirliği.",
"Description:Abp.Identity.User.IsEmailUpdateEnabled": "E-posta alanının, kullanıcının kendisi tarafından güncellenebilirliği"
"Description:Abp.Identity.User.IsEmailUpdateEnabled": "E-posta alanının, kullanıcının kendisi tarafından güncellenebilirliği",
"Details": "Detaylar",
"CreatedBy": "Oluşturan",
"ModifiedBy": "Düzenleyen",
"ModificationTime": "Düzenleme zamanı",
"PasswordUpdateTime": "Şifre güncelleme zamanı",
"LockoutEndTime": "Kilitlenme bitiş zamanı",
"FailedAccessCount": "Başarısız giriş denemesi sayısı"
}
}

4
modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs

@ -35,6 +35,10 @@ public class AbpIdentityWebAutoMapperProfile : Profile
CreateMap<IdentityRoleDto, EditUserModalModel.AssignedRoleViewModel>()
.ForMember(dest => dest.IsAssigned, opt => opt.Ignore());
CreateMap<IdentityUserDto, EditUserModalModel.DetailViewModel>()
.ForMember(dest => dest.CreatedBy, opt => opt.Ignore())
.ForMember(dest => dest.ModifiedBy, opt => opt.Ignore());
}
protected virtual void CreateRoleMappings()

46
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml

@ -83,8 +83,54 @@
}
</div>
</abp-tab>
<abp-tab title="@L["Details"].Value">
<div class="mt-3">
<div class="mb-3">
<span class="fw-bold">@L["CreatedBy"] :</span> @ConvertUserFriendlyFormat(Model.Detail.CreatedBy)
</div>
<div class="mb-3">
<span class="fw-bold">@L["CreationTime"] :</span> @ConvertUserFriendlyFormat(Model.Detail.CreationTime)
</div>
<div class="mb-3">
<span class="fw-bold">@L["ModifiedBy"] :</span> @ConvertUserFriendlyFormat(Model.Detail.ModifiedBy)
</div>
<div class="mb-3">
<span class="fw-bold">@L["ModificationTime"] :</span> @ConvertUserFriendlyFormat(Model.Detail.LastModificationTime)
</div>
<div class="mb-3">
<span class="fw-bold">@L["PasswordUpdateTime"] :</span> @ConvertUserFriendlyFormat(Model.Detail.LastPasswordChangeTime)
</div>
<div class="mb-3">
<span class="fw-bold">@L["LockoutEndTime"] :</span> @ConvertUserFriendlyFormat(Model.Detail.LockoutEnd)
</div>
<div class="mb-3">
<span class="fw-bold">@L["FailedAccessCount"] :</span> @Model.Detail.AccessFailedCount
</div>
</div>
</abp-tab>
</abp-tabs>
</abp-modal-body>
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer>
</abp-modal>
</form>
@functions
{
const string DateTimeFormat = "MMMM dd, yyyy — HH:mm";
const string DefaultEmptyValue = "-";
static string ConvertUserFriendlyFormat(DateTime? dateTime)
{
return dateTime == null ? DefaultEmptyValue : dateTime.Value.ToUniversalTime().ToString(DateTimeFormat);
}
static string ConvertUserFriendlyFormat(DateTimeOffset? dateTime)
{
return dateTime == null ? DefaultEmptyValue : dateTime.Value.UtcDateTime.ToString(DateTimeFormat);
}
static string ConvertUserFriendlyFormat(string value)
{
return value.IsNullOrWhiteSpace() ? DefaultEmptyValue : value;
}
}

37
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs

@ -19,6 +19,8 @@ public class EditModalModel : IdentityPageModel
[BindProperty]
public AssignedRoleViewModel[] Roles { get; set; }
public DetailViewModel Detail { get; set; }
protected IIdentityUserAppService IdentityUserAppService { get; }
@ -29,7 +31,9 @@ public class EditModalModel : IdentityPageModel
public virtual async Task<IActionResult> OnGetAsync(Guid id)
{
UserInfo = ObjectMapper.Map<IdentityUserDto, UserInfoViewModel>(await IdentityUserAppService.GetAsync(id));
var user = await IdentityUserAppService.GetAsync(id);
UserInfo = ObjectMapper.Map<IdentityUserDto, UserInfoViewModel>(user);
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>((await IdentityUserAppService.GetAssignableRolesAsync()).Items);
@ -41,9 +45,25 @@ public class EditModalModel : IdentityPageModel
role.IsAssigned = true;
}
}
Detail = ObjectMapper.Map<IdentityUserDto, DetailViewModel>(user);
Detail.CreatedBy = await GetUserNameOrNullAsync(user.CreatorId);
Detail.ModifiedBy = await GetUserNameOrNullAsync(user.LastModifierId);
return Page();
}
private async Task<string> GetUserNameOrNullAsync(Guid? userId)
{
if (!userId.HasValue)
{
return null;
}
var user = await IdentityUserAppService.GetAsync(userId.Value);
return user.UserName;
}
public virtual async Task<IActionResult> OnPostAsync()
{
@ -100,4 +120,19 @@ public class EditModalModel : IdentityPageModel
public bool IsAssigned { get; set; }
}
public class DetailViewModel
{
public string CreatedBy { get; set; }
public DateTime? CreationTime { get; set; }
public string ModifiedBy { get; set; }
public DateTime? LastModificationTime { get; set; }
public DateTimeOffset? LastPasswordChangeTime { get; set; }
public DateTimeOffset? LockoutEnd { get; set; }
public int AccessFailedCount { get; set; }
}
}

Loading…
Cancel
Save