feat: 增加通知管理页面

This commit is contained in:
Argo Zhang 2020-02-07 17:41:42 +08:00
parent 0a13ba4744
commit 8d8e3977ac
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
3 changed files with 120 additions and 1 deletions

View File

@ -386,7 +386,7 @@ namespace Bootstrap.Admin.Pages.Components
/// <summary>
/// 查询按钮调用此方法
/// </summary>
protected void Query()
public void Query()
{
if (OnQuery != null)
{

View File

@ -0,0 +1,29 @@
@inherits NotificationsBase
<div class="card">
<div class="card-header">
<span>查询结果</span>
</div>
<div class="card-body">
<Table @ref="Table" Id="noti" TItem="Bootstrap.DataAccess.User" ShowToolBar="true" ShowRefresh="true" ShowExtendButtons="true" EditModel="DataContext" OnQuery="Query">
<TableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.UserName" class="text-nowrap"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.DisplayName" class="text-nowrap"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.Description"></LgbTableHeader>
<LgbTableHeader TItem="DateTime" @bind-Value="@context.RegisterTime"></LgbTableHeader>
</TableHeader>
<RowTemplate>
<td>@context.UserName</td>
<td>@context.DisplayName</td>
<td>@context.Description</td>
<td>@context.RegisterTime</td>
</RowTemplate>
<ButtonTemplate>
<div class="btn-group"
<button class="btn btn-success btn-sm" data-toggle="tooltip" title="同意授权" @onclick="e => Approve(context.Id)"><i class="fa fa-check"></i><span>同意</span></button>
<button class="btn btn-danger btn-sm" data-toggle="tooltip" title="拒绝授权" @onclick="e => Reject(context.Id)"><i class="fa fa-remove"></i><span>拒绝</span></button>
</div>
</ButtonTemplate>
</Table>
</div>
</div>

View File

@ -0,0 +1,90 @@
using Bootstrap.Admin.Pages.Components;
using Bootstrap.DataAccess;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using System.Linq;
namespace Bootstrap.Admin.Pages.Views.Admin.Components
{
/// <summary>
/// 消息通知组件
/// </summary>
public class NotificationsBase : ComponentBase
{
/// <summary>
/// 获得 授权服务
/// </summary>
[Inject]
protected AuthenticationStateProvider? AuthenticationStateProvider { get; set; }
/// <summary>
/// 获得/设置 编辑类型实例
/// </summary>
protected User DataContext { get; set; } = new User();
/// <summary>
/// 获得/设置 用户登录名
/// </summary>
protected string? UserName { get; set; }
/// <summary>
/// 获得/设置 Table 实例
/// </summary>
protected TableBase<User>? Table { get; set; }
/// <summary>
/// OnInitializedAsync 方法
/// </summary>
/// <returns></returns>
protected override async System.Threading.Tasks.Task OnInitializedAsync()
{
if (AuthenticationStateProvider != null)
{
var state = await AuthenticationStateProvider.GetAuthenticationStateAsync();
UserName = state?.User.Identity.Name;
}
}
/// <summary>
/// 数据查询方法
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
protected QueryData<User> Query(QueryPageOptions options)
{
var data = UserHelper.RetrieveNewUsers();
return new QueryData<User>()
{
Items = data,
PageIndex = 1,
PageItems = data.Count(),
TotalCount = data.Count()
};
}
/// <summary>
/// 批准新用户方法
/// </summary>
protected void Approve(string? userId)
{
if (!string.IsNullOrEmpty(userId) && !string.IsNullOrEmpty(UserName))
{
UserHelper.Approve(userId, UserName);
Table?.Query();
}
}
/// <summary>
/// 拒绝新用户方法
/// </summary>
protected void Reject(string? userId)
{
if (!string.IsNullOrEmpty(userId) && !string.IsNullOrEmpty(UserName))
{
UserHelper.Reject(userId, UserName);
Table?.Query();
}
}
}
}