浏览代码

Fix Dashboard metric not update #811 (#819)

master
luox78 3 年前
committed by GitHub
父节点
当前提交
75e9df813f
找不到此签名对应的密钥 GPG 密钥 ID: 4AEE18F83AFDEB23
共有 3 个文件被更改,包括 19 次插入6 次删除
  1. +12
    -0
      src/DotNetCore.CAP.Dashboard/JsonSerializeOptions.cs
  2. +2
    -2
      src/DotNetCore.CAP.Dashboard/JsonStats.cs
  3. +5
    -4
      src/DotNetCore.CAP.Dashboard/Pages/HomePage.cshtml

+ 12
- 0
src/DotNetCore.CAP.Dashboard/JsonSerializeOptions.cs 查看文件

@@ -0,0 +1,12 @@
using System.Text.Json;

namespace DotNetCore.CAP.Dashboard
{
public static class JsonSerializeOptions
{
public static JsonSerializerOptions Default = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
}
}

+ 2
- 2
src/DotNetCore.CAP.Dashboard/JsonStats.cs 查看文件

@@ -24,8 +24,8 @@ namespace DotNetCore.CAP.Dashboard
var value = metric.Func(page);
result.Add(metric.Name, value);
}
var serialized = JsonSerializer.Serialize(result);
var serialized = JsonSerializer.Serialize(result, JsonSerializeOptions.Default);

context.Response.ContentType = "application/json";
await context.Response.WriteAsync(serialized);


+ 5
- 4
src/DotNetCore.CAP.Dashboard/Pages/HomePage.cshtml 查看文件

@@ -1,5 +1,6 @@
@* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True *@
@using System.Text.Json
@using DotNetCore.CAP.Dashboard
@using DotNetCore.CAP.Dashboard.Pages
@using DotNetCore.CAP.Dashboard.Resources
@using DotNetCore.CAP.Messages
@@ -52,12 +53,12 @@
</h3>

<div id="historyGraph"
data-published-succeeded="@JsonSerializer.Serialize(publishedSucceeded)"
data-published-failed="@JsonSerializer.Serialize(publishedFailed)"
data-published-succeeded="@JsonSerializer.Serialize(publishedSucceeded, JsonSerializeOptions.Default)"
data-published-failed="@JsonSerializer.Serialize(publishedFailed, JsonSerializeOptions.Default)"
data-published-succeeded-string="@Strings.HomePage_GraphHover_PSucceeded"
data-published-failed-string="@Strings.HomePage_GraphHover_PFailed"
data-received-succeeded="@JsonSerializer.Serialize(receivedSucceeded)"
data-received-failed="@JsonSerializer.Serialize(receivedFailed)"
data-received-succeeded="@JsonSerializer.Serialize(receivedSucceeded, JsonSerializeOptions.Default)"
data-received-failed="@JsonSerializer.Serialize(receivedFailed, JsonSerializeOptions.Default)"
data-received-succeeded-string="@Strings.HomePage_GraphHover_RSucceeded"
data-received-failed-string="@Strings.HomePage_GraphHover_RFailed">
</div>


正在加载...
取消
保存