Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CAP
Commits
a82790c1
Commit
a82790c1
authored
Sep 11, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add SubscriberPage
parent
9166f2b8
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
325 additions
and
15 deletions
+325
-15
DashboardContext.cs
src/DotNetCore.CAP/Dashboard/DashboardContext.cs
+5
-0
DashboardRequest.cs
src/DotNetCore.CAP/Dashboard/DashboardRequest.cs
+1
-2
DashboardRoutes.cs
src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs
+1
-1
HtmlHelper.cs
src/DotNetCore.CAP/Dashboard/HtmlHelper.cs
+67
-0
IDashboardDispatcher.cs
src/DotNetCore.CAP/Dashboard/IDashboardDispatcher.cs
+1
-1
IMonitoringApi.cs
src/DotNetCore.CAP/Dashboard/IMonitoringApi.cs
+0
-2
SubscriberPage.cshtml
src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.cshtml
+22
-9
SubscriberPage.generated.cs
...otNetCore.CAP/Dashboard/Pages/SubscriberPage.generated.cs
+221
-0
RazorPage.cs
src/DotNetCore.CAP/Dashboard/RazorPage.cs
+4
-0
DotNetCore.CAP.csproj
src/DotNetCore.CAP/DotNetCore.CAP.csproj
+3
-0
No files found.
src/DotNetCore.CAP/Dashboard/DashboardContext.cs
View file @
a82790c1
...
...
@@ -18,12 +18,16 @@ namespace DotNetCore.CAP.Dashboard
}
public
IStorage
Storage
{
get
;
}
public
DashboardOptions
Options
{
get
;
}
public
Match
UriMatch
{
get
;
set
;
}
public
DashboardRequest
Request
{
get
;
protected
set
;
}
public
DashboardResponse
Response
{
get
;
protected
set
;
}
public
IServiceProvider
RequestServices
{
get
;
protected
set
;
}
}
public
sealed
class
CapDashboardContext
:
DashboardContext
...
...
@@ -39,6 +43,7 @@ namespace DotNetCore.CAP.Dashboard
HttpContext
=
httpContext
;
Request
=
new
CapDashboardRequest
(
httpContext
);
Response
=
new
CapDashboardResponse
(
httpContext
);
RequestServices
=
httpContext
.
RequestServices
;
}
public
HttpContext
HttpContext
{
get
;
}
...
...
src/DotNetCore.CAP/Dashboard/DashboardRequest.cs
View file @
a82790c1
...
...
@@ -25,7 +25,7 @@ namespace DotNetCore.CAP.Dashboard
public
CapDashboardRequest
(
HttpContext
context
)
{
if
(
context
==
null
)
throw
new
ArgumentNullException
(
nameof
(
context
));
_context
=
context
;
_context
=
context
;
}
public
override
string
Method
=>
_context
.
Request
.
Method
;
...
...
@@ -34,7 +34,6 @@ namespace DotNetCore.CAP.Dashboard
public
override
string
LocalIpAddress
=>
_context
.
Connection
.
LocalIpAddress
.
ToString
();
public
override
string
RemoteIpAddress
=>
_context
.
Connection
.
RemoteIpAddress
.
ToString
();
public
override
string
GetQuery
(
string
key
)
=>
_context
.
Request
.
Query
[
key
];
public
override
async
Task
<
IList
<
string
>>
GetFormValuesAsync
(
string
key
)
{
var
form
=
await
_context
.
Request
.
ReadFormAsync
();
...
...
src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs
View file @
a82790c1
...
...
@@ -133,7 +133,7 @@ namespace DotNetCore.CAP.Dashboard
Routes
.
AddRazorPage
(
"/received/(?<StatusName>.+)"
,
x
=>
new
ReceivedPage
(
x
.
Groups
[
"StatusName"
].
Value
));
Routes
.
AddRazorPage
(
"/subscribers"
,
x
=>
new
SubscriberPage
());
//Routes.AddRazorPage("/jobs/failed", x => new FailedJobsPage());
//Routes.AddClientBatchCommand(
...
...
src/DotNetCore.CAP/Dashboard/HtmlHelper.cs
View file @
a82790c1
...
...
@@ -218,6 +218,73 @@ namespace DotNetCore.CAP.Dashboard
$"<span class=\"labe label-defult text-uppercase\" title=\"
{
serverId
}
\">
{
shortenedId
}
</span>"
);
}
public
NonEscapedString
MethodEscaped
(
MethodInfo
method
)
{
var
outputString
=
string
.
Empty
;
var
@public
=
"<span style=\"color:blue\">public </span>"
;
var
key
=
Hignlight
(
method
.
ReturnType
);
var
name
=
method
.
Name
;
string
paramType
=
null
;
string
paramName
=
null
;
string
paramString
=
string
.
Empty
;
var
@params
=
method
.
GetParameters
();
if
(
@params
.
Length
==
1
)
{
var
firstParam
=
@params
[
0
];
var
firstParamType
=
firstParam
.
ParameterType
;
paramType
=
Hignlight
(
firstParamType
);
paramName
=
firstParam
.
Name
;
}
if
(
paramType
==
null
)
{
paramString
=
"(){ }"
;
}
else
{
paramString
=
$"(
{
paramType
}
{
paramName
}
)
{{
}}
"
;
}
outputString
=
@public
+
key
+
name
+
paramString
;
return
new
NonEscapedString
(
outputString
);
}
public
string
Hignlight
(
Type
type
)
{
if
(
type
.
Name
==
"Void"
)
{
return
HighligthKey
(
type
.
Name
.
ToLower
());
}
if
(
Helper
.
IsComplexType
(
type
))
{
return
HighligthClass
(
type
.
Name
);
}
if
(
type
.
IsPrimitive
||
type
.
Equals
(
typeof
(
string
))
||
type
.
Equals
(
typeof
(
decimal
)))
{
return
HighligthKey
(
type
.
Name
.
ToLower
());
}
else
{
return
HighligthClass
(
type
.
Name
);
}
}
private
string
HighligthClass
(
string
key
)
{
return
$"<span style=\"color:#07c1be\">
{
key
}
</span>"
;
}
private
string
HighligthKey
(
string
key
)
{
return
$"<span style=\"color:blue\">
{
key
}
</span>"
;
}
//private static readonly StackTraceHtmlFragments StackTraceHtmlFragments = new StackTraceHtmlFragments
//{
// BeforeFrame = "<span class='st-frame'>" , AfterFrame = "</span>",
...
...
src/DotNetCore.CAP/Dashboard/IDashboardDispatcher.cs
View file @
a82790c1
...
...
@@ -7,6 +7,6 @@ namespace DotNetCore.CAP.Dashboard
{
public
interface
IDashboardDispatcher
{
Task
Dispatch
(
DashboardContext
context
);
Task
Dispatch
(
DashboardContext
context
);
}
}
src/DotNetCore.CAP/Dashboard/IMonitoringApi.cs
View file @
a82790c1
...
...
@@ -6,8 +6,6 @@ namespace DotNetCore.CAP.Dashboard
{
public
interface
IMonitoringApi
{
IList
<
SubscriberDto
>
Subscribers
();
StatisticsDto
GetStatistics
();
IList
<
MessageDto
>
Messages
(
MessageQueryDto
queryDto
);
...
...
src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.cshtml
View file @
a82790c1
@* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True *@
@using System
@using System.Linq
@using DotNetCore.CAP.Internal
@using DotNetCore.CAP.Dashboard
@using DotNetCore.CAP.Dashboard.Pages
@using DotNetCore.CAP.Dashboard.Resources
@inherits RazorPage
@{
Layout = new LayoutPage(Strings.S
erv
ersPage_Title);
Layout = new LayoutPage(Strings.S
ubscrib
ersPage_Title);
var
monitor = Storage.GetMonitoringApi()
;
var subscribers =
monitor.Subscribers
();
var
cache = RequestServices.GetService(typeof(MethodMatcherCache)) as MethodMatcherCache
;
var subscribers =
cache.GetCandidatesMethodsOfGroupNameGrouped
();
}
<div class="row">
...
...
@@ -28,16 +27,30 @@
<table class="table">
<thead>
<tr>
<th>名称</th>
<th>方法</th>
<th width="20%">分组</th>
<th>
<table class="table subscribe-table margin-bottom-zero"><tr><td width="40%">名称</td><td>方法</td></tr></table>
</th>
</tr>
</thead>
<tbody>
@foreach (var subscriber in subscribers)
{
<tr>
<td>@subscriber.Name</td>
<td>@subscriber.Method</td>
<td style="vertical-align:middle;font-weight:bold;">@subscriber.Key</td>
<td>
<table class="table subscribe-table table-condensed margin-bottom-zero">
@foreach (var column in subscriber.Value)
{
<tr>
<td width="40%">@column.Attribute.Name</td>
<td><span style="color:#00bcd4">@column.ImplTypeInfo.Name</span>:
@Html.MethodEscaped(column.MethodInfo)
</td>
</tr>
}
</table>
</td>
</tr>
}
</tbody>
...
...
src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.generated.cs
0 → 100644
View file @
a82790c1
#
pragma
warning
disable
1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace
DotNetCore.CAP.Dashboard.Pages
{
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
#
line
3
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
using
DotNetCore.CAP.Dashboard
;
#
line
default
#
line
hidden
#
line
4
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
using
DotNetCore.CAP.Dashboard.Pages
;
#
line
default
#
line
hidden
#
line
5
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
using
DotNetCore.CAP.Dashboard.Resources
;
#
line
default
#
line
hidden
#
line
2
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
using
DotNetCore.CAP.Internal
;
#
line
default
#
line
hidden
[
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"RazorGenerator"
,
"2.0.0.0"
)]
internal
partial
class
SubscriberPage
:
RazorPage
{
#line hidden
public
override
void
Execute
()
{
WriteLiteral
(
"\r\n"
);
#
line
7
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
Layout
=
new
LayoutPage
(
Strings
.
SubscribersPage_Title
);
var
cache
=
RequestServices
.
GetService
(
typeof
(
MethodMatcherCache
))
as
MethodMatcherCache
;
var
subscribers
=
cache
.
GetCandidatesMethodsOfGroupNameGrouped
();
#
line
default
#
line
hidden
WriteLiteral
(
"\r\n<div class=\"row\">\r\n <div class=\"col-md-12\">\r\n <h1 class=\"page-header\""
+
">订阅列表</h1>\r\n\r\n"
);
#
line
18
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
if
(
subscribers
.
Count
==
0
)
{
#
line
default
#
line
hidden
WriteLiteral
(
" <div class=\"alert alert-warning\">\r\n "
);
#
line
21
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
Write
(
Strings
.
ServersPage_NoServers
);
#
line
default
#
line
hidden
WriteLiteral
(
"\r\n </div>\r\n"
);
#
line
23
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
}
else
{
#
line
default
#
line
hidden
WriteLiteral
(
@" <div class=""table-responsive"">
<table class=""table"">
<thead>
<tr>
<th width=""20%"">分组</th>
<th>
<table class=""table subscribe-table margin-bottom-zero""><tr><td width=""40%"">名称</td><td>方法</td></tr></table>
</th>
</tr>
</thead>
<tbody>
"
);
#
line
37
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
foreach
(
var
subscriber
in
subscribers
)
{
#
line
default
#
line
hidden
WriteLiteral
(
" <tr>\r\n <td style=\"vert"
+
"ical-align:middle;font-weight:bold;\">"
);
#
line
40
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
Write
(
subscriber
.
Key
);
#
line
default
#
line
hidden
WriteLiteral
(
"</td>\r\n <td>\r\n "
+
"<table class=\"table subscribe-table table-condensed margin-bottom-zero\">\r\n"
);
#
line
43
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
foreach
(
var
column
in
subscriber
.
Value
)
{
#
line
default
#
line
hidden
WriteLiteral
(
" <tr>\r\n "
+
" <td width=\"40%\">"
);
#
line
46
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
Write
(
column
.
Attribute
.
Name
);
#
line
default
#
line
hidden
WriteLiteral
(
"</td>\r\n <td><span style=\"color:#00"
+
"bcd4\">"
);
#
line
47
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
Write
(
column
.
ImplTypeInfo
.
Name
);
#
line
default
#
line
hidden
WriteLiteral
(
"</span>: \r\n "
);
#
line
48
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
Write
(
Html
.
MethodEscaped
(
column
.
MethodInfo
));
#
line
default
#
line
hidden
WriteLiteral
(
"\r\n </td>\r\n "
+
" </tr>\r\n"
);
#
line
51
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
}
#
line
default
#
line
hidden
WriteLiteral
(
" </table>\r\n </t"
+
"d>\r\n </tr>\r\n"
);
#
line
55
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
}
#
line
default
#
line
hidden
WriteLiteral
(
" </tbody>\r\n </table>\r\n </div>\r\n"
);
#
line
59
"..\..\Dashboard\Pages\SubscriberPage.cshtml"
}
#
line
default
#
line
hidden
WriteLiteral
(
" </div>\r\n</div>"
);
}
}
}
#pragma warning restore 1591
src/DotNetCore.CAP/Dashboard/RazorPage.cs
View file @
a82790c1
...
...
@@ -41,6 +41,8 @@ namespace DotNetCore.CAP.Dashboard
internal
DashboardRequest
Request
{
private
get
;
set
;
}
internal
DashboardResponse
Response
{
private
get
;
set
;
}
internal
IServiceProvider
RequestServices
{
get
;
private
set
;
}
public
string
RequestPath
=>
Request
.
Path
;
/// <exclude />
...
...
@@ -65,6 +67,7 @@ namespace DotNetCore.CAP.Dashboard
AppPath
=
parentPage
.
AppPath
;
StatsPollingInterval
=
parentPage
.
StatsPollingInterval
;
Url
=
parentPage
.
Url
;
RequestServices
=
parentPage
.
RequestServices
;
GenerationTime
=
parentPage
.
GenerationTime
;
_statisticsLazy
=
parentPage
.
_statisticsLazy
;
...
...
@@ -74,6 +77,7 @@ namespace DotNetCore.CAP.Dashboard
{
Request
=
context
.
Request
;
Response
=
context
.
Response
;
RequestServices
=
context
.
RequestServices
;
Storage
=
context
.
Storage
;
AppPath
=
context
.
Options
.
AppPath
;
...
...
src/DotNetCore.CAP/DotNetCore.CAP.csproj
View file @
a82790c1
...
...
@@ -123,6 +123,9 @@
<Compile Update="Dashboard\Pages\HomePage.cs">
<DependentUpon>HomePage.cshtml</DependentUpon>
</Compile>
<Compile Update="Dashboard\Pages\SubscriberPage.generated.cs">
<DependentUpon>SubscriberPage.cshtml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Dashboard\Content\resx\Strings.resx">
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment