diff --git a/Bootstrap.Admin/HealthChecks/GCHealthCheck.cs b/Bootstrap.Admin/HealthChecks/GCHealthCheck.cs
index 3476e24b..9692f45c 100644
--- a/Bootstrap.Admin/HealthChecks/GCHealthCheck.cs
+++ b/Bootstrap.Admin/HealthChecks/GCHealthCheck.cs
@@ -28,11 +28,7 @@ namespace Bootstrap.Admin.HealthChecks
{ "Gen1Collections", GC.CollectionCount(1) },
{ "Gen2Collections", GC.CollectionCount(2) },
};
-
- var status = (allocated < 100000) ?
- HealthStatus.Healthy : HealthStatus.Unhealthy;
-
- return Task.FromResult(new HealthCheckResult(status, data: data));
+ return Task.FromResult(HealthCheckResult.Healthy("OK", data));
}
}
}
diff --git a/Bootstrap.Admin/HealthChecks/HealthChecksAppBuilderExtensions.cs b/Bootstrap.Admin/HealthChecks/HealthChecksAppBuilderExtensions.cs
index f84c4b25..f76ae8d2 100644
--- a/Bootstrap.Admin/HealthChecks/HealthChecksAppBuilderExtensions.cs
+++ b/Bootstrap.Admin/HealthChecks/HealthChecksAppBuilderExtensions.cs
@@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Builder
ResponseWriter = (context, report) =>
{
context.Response.ContentType = "application/json";
- return context.Response.WriteAsync(JsonConvert.SerializeObject(report));
+ return context.Response.WriteAsync(JsonConvert.SerializeObject(new { report.Entries.Keys, Report = report }));
},
ResultStatusCodes =
{
diff --git a/Bootstrap.Admin/Views/Admin/Healths.cshtml b/Bootstrap.Admin/Views/Admin/Healths.cshtml
index c2b205a1..d87a17c1 100644
--- a/Bootstrap.Admin/Views/Admin/Healths.cshtml
+++ b/Bootstrap.Admin/Views/Admin/Healths.cshtml
@@ -26,7 +26,7 @@
健康检查结果
diff --git a/Bootstrap.Admin/wwwroot/css/theme.css b/Bootstrap.Admin/wwwroot/css/theme.css
index acc8d797..ce2102eb 100644
--- a/Bootstrap.Admin/wwwroot/css/theme.css
+++ b/Bootstrap.Admin/wwwroot/css/theme.css
@@ -709,11 +709,19 @@ input.pending {
min-width: unset;
}
+.bs-popover-bottom .popover-header::before, .bs-popover-auto[x-placement^="bottom"] .popover-header::before {
+ border-bottom: 0;
+}
+
.popover {
max-width: 320px;
padding: 0;
}
+.popover-body .bootstrap-table {
+ margin: 0.25rem 0;
+}
+
.popover-content {
max-height: 240px;
overflow-y: auto;
diff --git a/Bootstrap.Admin/wwwroot/js/healths.js b/Bootstrap.Admin/wwwroot/js/healths.js
index 3a93eec0..2b7c8886 100644
--- a/Bootstrap.Admin/wwwroot/js/healths.js
+++ b/Bootstrap.Admin/wwwroot/js/healths.js
@@ -1,23 +1,60 @@
$(function () {
+ var healthStatus = ["不健康", "亚健康", "健康"];
+ var StatusFormatter = function (value) {
+ return healthStatus[value];
+ };
+
+ var cate = { "db": "数据库", "file": "组件文件", "mem": "内存", "Gitee": "Gitee 接口", "gc": "垃圾回收器" };
+ var CategoryFormatter = function (value) {
+ return cate[value];
+ };
+
var $table = $('table').smartTable({
sidePagination: "client",
showToggle: false,
showRefresh: false,
showColumns: false,
columns: [
- { title: "分类", field: "name", sortable: true },
- { title: "描述", field: "Description", sortable: true },
- { title: "异常信息", field: "Exception", sortable: true },
- { title: "明细数据", field: "Data", sortable: true },
- { title: "检查结果", field: "Status", sortable: false },
- { title: "耗时", field: "Duration", sortable: true }
+ { title: "分类", field: "Name", formatter: CategoryFormatter },
+ { title: "描述", field: "Description" },
+ { title: "异常信息", field: "Exception" },
+ { title: "耗时", field: "Duration" },
+ { title: "检查结果", field: "Status", formatter: StatusFormatter },
+ {
+ title: "明细数据", field: "Data", formatter: function (value, row, index) {
+ return '';
+ },
+ events: {
+ 'click .detail': function (e, value, row, index) {
+ if ($.isEmptyObject(row.Data)) return;
+
+ var $button = $(e.currentTarget);
+ if (!$button.data($.fn.popover.Constructor.DATA_KEY)) {
+ var content = $.map(row.Data, function (v, name) {
+ return $.format("{0} | {1} |
", name, v);
+ }).join("");
+ content = $.format('', content);
+ $button.popover({ title: cate[row.Name], html: true, content: content, placement: $(window).width() < 768 ? "bottom" : "left" });
+ }
+ $button.popover('show');
+ }
+ }
+ }
]
});
+ $table.bootstrapTable('showLoading');
+ $('#checkTotalEplsed').text('--');
$.bc({
url: 'healths',
callback: function (result) {
- console.log(result);
+ var data = $.map(result.Keys, function (name) {
+ return { Name: name, Duration: result.Report.Entries[name].Duration, Status: result.Report.Entries[name].Status, Exception: result.Report.Entries[name].Exception, Description: result.Report.Entries[name].Description, Data: result.Report.Entries[name].Data };
+ });
+ $table.bootstrapTable('hideLoading');
+ $table.bootstrapTable('load', data);
+ $('#checkTotalEplsed').text(result.Report.TotalDuration);
+ $.footer();
}
});
});
\ No newline at end of file