feat: 增加健康检查开关
This commit is contained in:
parent
8142953979
commit
12f63aac31
|
@ -31,6 +31,7 @@ namespace Bootstrap.Admin.Models
|
||||||
IPCachePeriod = DictHelper.RetrieveLocaleIPSvrCachePeriod();
|
IPCachePeriod = DictHelper.RetrieveLocaleIPSvrCachePeriod();
|
||||||
EnableDemo = DictHelper.RetrieveSystemModel();
|
EnableDemo = DictHelper.RetrieveSystemModel();
|
||||||
AdminPathBase = DictHelper.RetrievePathBase();
|
AdminPathBase = DictHelper.RetrievePathBase();
|
||||||
|
EnableHealth = DictHelper.RetrieveHealth();
|
||||||
|
|
||||||
var dicts = DictHelper.RetrieveDicts();
|
var dicts = DictHelper.RetrieveDicts();
|
||||||
Apps = DictHelper.RetrieveApps().Where(d => !d.Key.Equals("BA", StringComparison.OrdinalIgnoreCase)).Select(k =>
|
Apps = DictHelper.RetrieveApps().Where(d => !d.Key.Equals("BA", StringComparison.OrdinalIgnoreCase)).Select(k =>
|
||||||
|
@ -109,5 +110,10 @@ namespace Bootstrap.Admin.Models
|
||||||
/// 获得/设置 系统应用程序集合
|
/// 获得/设置 系统应用程序集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<(string Key, string Name, string Url)> Apps { get; set; }
|
public IEnumerable<(string Key, string Name, string Url)> Apps { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得/设置 是否开启健康检查
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableHealth { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Mvc.Versioning;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
@ -129,7 +130,10 @@ namespace Bootstrap.Admin
|
||||||
{
|
{
|
||||||
endpoints.MapHub<SignalRHub>("/NotiHub");
|
endpoints.MapHub<SignalRHub>("/NotiHub");
|
||||||
endpoints.MapHub<TaskLogHub>("/TaskLogHub");
|
endpoints.MapHub<TaskLogHub>("/TaskLogHub");
|
||||||
endpoints.MapBootstrapHealthChecks();
|
endpoints.MapBootstrapHealthChecks("/Healths", configure: op =>
|
||||||
|
{
|
||||||
|
op.Predicate = new Func<HealthCheckRegistration, bool>(reg => DictHelper.RetrieveHealth());
|
||||||
|
});
|
||||||
endpoints.MapBlazorHub();
|
endpoints.MapBlazorHub();
|
||||||
endpoints.MapFallbackToPage("/_Host");
|
endpoints.MapFallbackToPage("/_Host");
|
||||||
endpoints.MapDefaultControllerRoute();
|
endpoints.MapDefaultControllerRoute();
|
||||||
|
|
|
@ -113,6 +113,10 @@
|
||||||
<label class="control-label" for="tableHeader">固定表头</label>
|
<label class="control-label" for="tableHeader">固定表头</label>
|
||||||
<input id="tableHeader" hidden type="checkbox" data-default-val="@Model.FixedTableHeader" data-toggle="toggle" data-width="120" data-onstyle="success" data-on="固定" data-off="跟随" />
|
<input id="tableHeader" hidden type="checkbox" data-default-val="@Model.FixedTableHeader" data-toggle="toggle" data-width="120" data-onstyle="success" data-on="固定" data-off="跟随" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group col-6">
|
||||||
|
<label class="control-label" for="health">健康检查</label>
|
||||||
|
<input id="health" hidden type="checkbox" data-default-val="@Model.EnableHealth" data-toggle="toggle" data-width="120" data-onstyle="success" data-on="开启" data-off="关闭" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer text-right">
|
<div class="modal-footer text-right">
|
||||||
|
|
|
@ -59,11 +59,13 @@ $(function () {
|
||||||
var uiSettings = $('#sider').prop('checked') ? "1" : "0";
|
var uiSettings = $('#sider').prop('checked') ? "1" : "0";
|
||||||
var cardTitle = $('#cardTitle').prop('checked') ? "1" : "0";
|
var cardTitle = $('#cardTitle').prop('checked') ? "1" : "0";
|
||||||
var fixedTableHeader = $('#tableHeader').prop('checked') ? "1" : "0";
|
var fixedTableHeader = $('#tableHeader').prop('checked') ? "1" : "0";
|
||||||
|
var enableHealth = $('#health').prop('checked') ? "1" : "0";
|
||||||
$.bc({
|
$.bc({
|
||||||
url: Settings.url, data: [
|
url: Settings.url, data: [
|
||||||
{ name: 'ShowCardTitle', code: cardTitle },
|
{ name: 'ShowCardTitle', code: cardTitle },
|
||||||
{ name: 'ShowSideBar', code: uiSettings },
|
{ name: 'ShowSideBar', code: uiSettings },
|
||||||
{ name: 'FixedTableHeader', code: fixedTableHeader }
|
{ name: 'FixedTableHeader', code: fixedTableHeader },
|
||||||
|
{ name: 'EnableHealth', code: enableHealth }
|
||||||
], title: '保存网站设置', method: "post",
|
], title: '保存网站设置', method: "post",
|
||||||
callback: function (result) {
|
callback: function (result) {
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
|
@ -319,5 +319,11 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string RetrievePathBase() => DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "网站设置" && d.Name == "后台地址" && d.Define == 0)?.Code ?? "";
|
public string RetrievePathBase() => DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "网站设置" && d.Name == "后台地址" && d.Define == 0)?.Code ?? "";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得字典表健康检查是否开启
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool RetrieveHealth() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "网站设置" && d.Name == "健康检查" && d.Define == 0)?.Code ?? "0") == "1";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,8 @@ namespace Bootstrap.DataAccess
|
||||||
["TraceLog"] = "访问日志保留时长",
|
["TraceLog"] = "访问日志保留时长",
|
||||||
["CookiePeriod"] = "Cookie保留时长",
|
["CookiePeriod"] = "Cookie保留时长",
|
||||||
["IPCachePeriod"] = "IP请求缓存时长",
|
["IPCachePeriod"] = "IP请求缓存时长",
|
||||||
["AppPath"] = "后台地址"
|
["AppPath"] = "后台地址",
|
||||||
|
["EnableHealth"] = "健康检查"
|
||||||
};
|
};
|
||||||
var ret = SaveSettings(items.Where(i => cache.Any(c => c.Key == i.Name)).Select(i => new BootstrapDict()
|
var ret = SaveSettings(items.Where(i => cache.Any(c => c.Key == i.Name)).Select(i => new BootstrapDict()
|
||||||
{
|
{
|
||||||
|
@ -384,6 +385,12 @@ namespace Bootstrap.DataAccess
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string RetrievePathBase() => DbContextManager.Create<Dict>()?.RetrievePathBase() ?? "";
|
public static string RetrievePathBase() => DbContextManager.Create<Dict>()?.RetrievePathBase() ?? "";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得字典表健康检查是否开启
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool RetrieveHealth() => DbContextManager.Create<Dict>()?.RetrieveHealth() ?? true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存前台应用配置信息
|
/// 保存前台应用配置信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue