feat: 增加在线用户页面

This commit is contained in:
Argo Zhang 2020-02-01 16:57:46 +08:00
parent eb47622725
commit 94d3e1201e
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
3 changed files with 80 additions and 0 deletions

View File

@ -1,6 +1,7 @@
using Bootstrap.DataAccess;
using Bootstrap.Security;
using Longbow.Cache;
using Longbow.Web;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Concurrent;
@ -50,6 +51,19 @@ namespace Microsoft.AspNetCore.Builder
_displayNameCache.TryAdd((typeof(CacheItem), nameof(CacheItem.Interval)), "缓存时长(秒)");
_displayNameCache.TryAdd((typeof(CacheItem), nameof(CacheItem.ElapsedSeconds)), "已过时长(秒)");
_displayNameCache.TryAdd((typeof(CacheItem), nameof(CacheItem.Desc)), "缓存说明");
_displayNameCache.TryAdd((typeof(OnlineUser), nameof(OnlineUser.ConnectionId)), "会话Id");
_displayNameCache.TryAdd((typeof(OnlineUser), nameof(OnlineUser.UserName)), "登录名称");
_displayNameCache.TryAdd((typeof(OnlineUser), nameof(OnlineUser.DisplayName)), "显示名称");
_displayNameCache.TryAdd((typeof(OnlineUser), nameof(OnlineUser.FirstAccessTime)), "登录时间");
_displayNameCache.TryAdd((typeof(OnlineUser), nameof(OnlineUser.LastAccessTime)), "访问时间");
_displayNameCache.TryAdd((typeof(OnlineUser), nameof(OnlineUser.Method)), "请求方式");
_displayNameCache.TryAdd((typeof(OnlineUser), nameof(OnlineUser.Ip)), "主机");
_displayNameCache.TryAdd((typeof(OnlineUser), nameof(OnlineUser.Location)), "登录地点");
_displayNameCache.TryAdd((typeof(OnlineUser), nameof(OnlineUser.Browser)), "浏览器");
_displayNameCache.TryAdd((typeof(OnlineUser), nameof(OnlineUser.OS)), "操作系统");
_displayNameCache.TryAdd((typeof(OnlineUser), nameof(OnlineUser.RequestUrl)), "访问地址");
return services;
}

View File

@ -0,0 +1,37 @@
@inherits OnlineBase
<div class="card">
<div class="card-header">
<div class="d-flex align-items-center">
<span class="flex-fill">在线用户</span>
</div>
</div>
<div class="card-body">
<Table Id="online" EditModel="EditModel" ShowToolBar="true" ShowRefresh="true" TItem="Longbow.Web.OnlineUser" OnDataSourceQuery="QueryData">
<TableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.ConnectionId"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.UserName"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.DisplayName"></LgbTableHeader>
<LgbTableHeader TItem="DateTime" @bind-Value="@context.FirstAccessTime"></LgbTableHeader>
<LgbTableHeader TItem="DateTime" @bind-Value="@context.LastAccessTime"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.Method"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.Ip"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.Location"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.Browser"></LgbTableHeader>
<LgbTableHeader TItem="string" @bind-Value="@context.OS"></LgbTableHeader>
</TableHeader>
<RowTemplate>
<td>@context.ConnectionId</td>
<td>@context.UserName</td>
<td>@context.DisplayName</td>
<td>@context.FirstAccessTime</td>
<td>@context.LastAccessTime</td>
<td>@context.Method</td>
<td>@context.Ip</td>
<td>@context.Location</td>
<td>@context.Browser</td>
<td>@context.OS</td>
</RowTemplate>
</Table>
</div>
</div>

View File

@ -0,0 +1,29 @@
using Longbow.Web;
using Microsoft.AspNetCore.Components;
using System.Collections.Generic;
using System.Linq;
namespace Bootstrap.Admin.Pages.Views.Admin.Components
{
/// <summary>
/// 网站设置组件
/// </summary>
public class OnlineBase : ComponentBase
{
/// <summary>
/// 获得 EditModel 实例
/// </summary>
protected OnlineUser EditModel { get; set; } = new OnlineUser();
/// <summary>
/// IOnlineUsers 实例
/// </summary>
[Inject]
public IOnlineUsers? OnlineUSers { get; set; }
/// <summary>
/// QueryData 方法
/// </summary>
protected IEnumerable<OnlineUser> QueryData() => (OnlineUSers?.OnlineUsers ?? new OnlineUser[0]).OrderByDescending(u => u.LastAccessTime);
}
}