Browse Source

Basic Blazor CRUD for identity-user

pull/5399/head
Ahmet Çotur 6 years ago
parent
commit
199204bcd3
  1. 163
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor

163
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor

@ -1,14 +1,155 @@
@page "/identity/users"
@attribute [Authorize]
@using Microsoft.AspNetCore.Authorization
@using Microsoft.Extensions.Localization
@using Volo.Abp.Application.Dtos
@using Volo.Abp.Identity.Localization
@inherits BlazorisePageBase<IIdentityUserAppService, IdentityUserDto, Guid, GetIdentityUsersInput, IdentityUserCreateDto, IdentityUserUpdateDto>
@inject IStringLocalizer<IdentityResource> L
<h3>UserManagement</h3>
@if (Entities != null)
{
<ul>
@foreach (var user in Entities)
{
<li>@user.UserName</li>
}
</ul>
}
@* ************************* PAGE HEADER ************************* *@
<Row>
<Column ColumnSize="ColumnSize.Is6">
<h1>@L["Users"]</h1>
</Column>
<Column ColumnSize="ColumnSize.Is6">
<Paragraph Alignment="TextAlignment.Right">
<Button Color="Color.Primary" Clicked="OpenCreateModal">@L["NewUser"]</Button>
</Paragraph>
</Column>
</Row>
@* ************************* DATA GRID ************************* *@
<DataGrid TItem="IdentityUserDto"
Data="Entities"
ReadData="OnDataGridReadAsync"
TotalItems="TotalCount"
ShowPager="true"
PageSize="@LimitedResultRequestDto.DefaultMaxResultCount">
<DataGridColumns>
<DataGridColumn Width="150px" TItem="IdentityUserDto" Field="@nameof(IdentityUserDto.UserName)" Sortable="false" Caption="@L["Actions"].Value">
<DisplayTemplate>
<Dropdown>
<DropdownToggle Color="Color.Primary">
@L["Actions"]
</DropdownToggle>
<DropdownMenu>
<DropdownItem Clicked="() => OpenEditModalAsync(context.As<IdentityUserDto>().Id)">@L["Edit"]</DropdownItem>
<DropdownDivider/>
<DropdownItem Clicked="() => DeleteEntityAsync(context.As<IdentityUserDto>())">@L["Delete"]</DropdownItem>
</DropdownMenu>
</Dropdown>
</DisplayTemplate>
</DataGridColumn>
<DataGridColumn TItem="IdentityUserDto" Field="@nameof(IdentityUserDto.UserName)" Caption="@L["UserName"].Value">
<DisplayTemplate>
@(context.As<IdentityUserDto>().UserName)
</DisplayTemplate>
</DataGridColumn>
<DataGridColumn TItem="IdentityUserDto" Field="@nameof(IdentityUserDto.Email)" Caption="@L["Email"].Value">
<DisplayTemplate>
@(context.As<IdentityUserDto>().Email)
</DisplayTemplate>
</DataGridColumn>
<DataGridColumn TItem="IdentityUserDto" Field="@nameof(IdentityUserDto.PhoneNumber)" Caption="@L["PhoneNumber"].Value">
<DisplayTemplate>
@(context.As<IdentityUserDto>().PhoneNumber)
</DisplayTemplate>
</DataGridColumn>
</DataGridColumns>
</DataGrid>
@* ************************* CREATE MODAL ************************* *@
<Modal @ref="CreateModal">
<ModalBackdrop />
<ModalContent IsCentered="true">
<ModalHeader>
<ModalTitle>@L["NewUser"]</ModalTitle>
<CloseButton Clicked="CloseCreateModal" />
</ModalHeader>
<ModalBody>
<Field>
<FieldLabel>@L["DisplayName:UserName"]</FieldLabel>
<TextEdit @bind-text="NewEntity.UserName" />
</Field>
<Field>
<FieldLabel>@L["DisplayName:Name"]</FieldLabel>
<TextEdit @bind-text="NewEntity.Name" />
</Field>
<Field>
<FieldLabel>@L["DisplayName:Surname"]</FieldLabel>
<TextEdit @bind-text="NewEntity.Surname" />
</Field>
<Field>
<FieldLabel>@L["DisplayName:Password"]</FieldLabel>
<TextEdit @bind-text="NewEntity.Password" />
</Field>
<Field>
<FieldLabel>@L["DisplayName:Email"]</FieldLabel>
<TextEdit @bind-text="NewEntity.Email" />
</Field>
<Field>
<FieldLabel>@L["DisplayName:PhoneNumber"]</FieldLabel>
<TextEdit @bind-text="NewEntity.PhoneNumber" />
</Field>
<Field>
<Check TValue="bool" @bind-checked="NewEntity.LockoutEnabled">@L["DisplayName:LockoutEnabled"]</Check>
</Field>
<Field>
<Check TValue="bool" @bind-checked="NewEntity.TwoFactorEnabled">@L["DisplayName:TwoFactorEnabled"]</Check>
</Field>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="CloseCreateModal">@L["Cancel"]</Button>
<Button Color="Color.Primary" Clicked="CreateEntityAsync">@L["Save"]</Button>
</ModalFooter>
</ModalContent>
</Modal>
@* ************************* EDIT MODAL ************************* *@
<Modal @ref="EditModal">
<ModalBackdrop />
<ModalContent IsCentered="true">
<ModalHeader>
<ModalTitle>role</ModalTitle>
<CloseButton Clicked="CloseEditModal" />
</ModalHeader>
<ModalBody>
<input type="hidden" name="ConcurrencyStamp" @bind-value="EditingEntity.ConcurrencyStamp" />
<Field>
<FieldLabel>@L["DisplayName:UserName"]</FieldLabel>
<TextEdit @bind-text="EditingEntity.UserName" />
</Field>
<Field>
<FieldLabel>@L["DisplayName:Name"]</FieldLabel>
<TextEdit @bind-text="EditingEntity.Name" />
</Field>
<Field>
<FieldLabel>@L["DisplayName:Surname"]</FieldLabel>
<TextEdit @bind-text="EditingEntity.Surname" />
</Field>
<Field>
<FieldLabel>@L["DisplayName:Password"]</FieldLabel>
<TextEdit @bind-text="EditingEntity.Password" />
</Field>
<Field>
<FieldLabel>@L["DisplayName:Email"]</FieldLabel>
<TextEdit @bind-text="EditingEntity.Email" />
</Field>
<Field>
<FieldLabel>@L["DisplayName:PhoneNumber"]</FieldLabel>
<TextEdit @bind-text="EditingEntity.PhoneNumber" />
</Field>
<Field>
<Check TValue="bool" @bind-checked="EditingEntity.LockoutEnabled">@L["DisplayName:LockoutEnabled"]</Check>
</Field>
<Field>
<Check TValue="bool" @bind-checked="EditingEntity.TwoFactorEnabled">@L["DisplayName:TwoFactorEnabled"]</Check>
</Field>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="CloseEditModal">@L["Cancel"]</Button>
<Button Color="Color.Primary" Clicked="UpdateEntityAsync">@L["Save"]</Button>
</ModalFooter>
</ModalContent>
</Modal>
Loading…
Cancel
Save