mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-11 03:39:49 +08:00
refactor(health): add dashboard overview and related drill-down
- Replace health monitor tabs with a dashboard layout - Add related health drill-down for endpoint, model, and provider cards - Render provider health as cards and hide empty monitors
This commit is contained in:
@@ -2,9 +2,10 @@ use super::{
|
||||
build_api_format_health_monitor_payload, build_model_health_monitor_payload,
|
||||
build_public_auth_modules_status_payload, build_public_catalog_models_payload,
|
||||
build_public_catalog_search_models_payload, build_public_providers_payload,
|
||||
capability_detail_by_name, ldap_module_config_is_valid, sanitize_public_model_config_for_user,
|
||||
serialize_public_capability, supported_capability_names, ApiFormatHealthMonitorOptions,
|
||||
ModelHealthMonitorOptions, PUBLIC_CAPABILITY_DEFINITIONS,
|
||||
build_related_health_monitor_payload, capability_detail_by_name, ldap_module_config_is_valid,
|
||||
sanitize_public_model_config_for_user, serialize_public_capability, supported_capability_names,
|
||||
ApiFormatHealthMonitorOptions, HealthMonitorRelationDimension, ModelHealthMonitorOptions,
|
||||
PUBLIC_CAPABILITY_DEFINITIONS,
|
||||
};
|
||||
use crate::control::GatewayPublicRequestContext;
|
||||
use crate::handlers::shared::{
|
||||
@@ -477,6 +478,77 @@ pub(crate) async fn maybe_build_local_public_support_response(
|
||||
.await?;
|
||||
return Some(Json(payload).into_response());
|
||||
}
|
||||
|
||||
if decision.route_kind.as_deref() == Some("health_related")
|
||||
&& request_context.request_path == "/api/public/health/related"
|
||||
{
|
||||
let Some(dimension) =
|
||||
query_param_value(request_context.request_query_string.as_deref(), "dimension")
|
||||
.and_then(|value| HealthMonitorRelationDimension::parse(&value))
|
||||
else {
|
||||
return Some(
|
||||
(
|
||||
http::StatusCode::BAD_REQUEST,
|
||||
Json(json!({ "detail": "dimension 必须是 endpoint 或 model" })),
|
||||
)
|
||||
.into_response(),
|
||||
);
|
||||
};
|
||||
if matches!(dimension, HealthMonitorRelationDimension::Provider) {
|
||||
return Some(
|
||||
(
|
||||
http::StatusCode::BAD_REQUEST,
|
||||
Json(json!({ "detail": "公开健康监控不支持 provider 维度" })),
|
||||
)
|
||||
.into_response(),
|
||||
);
|
||||
}
|
||||
let Some(value) =
|
||||
query_param_value(request_context.request_query_string.as_deref(), "value")
|
||||
.map(|value| value.trim().to_string())
|
||||
.filter(|value| !value.is_empty())
|
||||
else {
|
||||
return Some(
|
||||
(
|
||||
http::StatusCode::BAD_REQUEST,
|
||||
Json(json!({ "detail": "value 不能为空" })),
|
||||
)
|
||||
.into_response(),
|
||||
);
|
||||
};
|
||||
let lookback_hours = query_param_value(
|
||||
request_context.request_query_string.as_deref(),
|
||||
"lookback_hours",
|
||||
)
|
||||
.and_then(|value| value.parse::<u64>().ok())
|
||||
.filter(|value| (1..=168).contains(value))
|
||||
.unwrap_or(6);
|
||||
let related_limit = query_param_value(
|
||||
request_context.request_query_string.as_deref(),
|
||||
"related_limit",
|
||||
)
|
||||
.and_then(|value| value.parse::<usize>().ok())
|
||||
.filter(|value| (1..=50).contains(value))
|
||||
.unwrap_or(8);
|
||||
let per_item_limit = query_param_value(
|
||||
request_context.request_query_string.as_deref(),
|
||||
"per_item_limit",
|
||||
)
|
||||
.and_then(|value| value.parse::<usize>().ok())
|
||||
.filter(|value| (10..=500).contains(value))
|
||||
.unwrap_or(100);
|
||||
let payload = build_related_health_monitor_payload(
|
||||
state,
|
||||
lookback_hours,
|
||||
dimension,
|
||||
&value,
|
||||
related_limit,
|
||||
per_item_limit,
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
return Some(Json(payload).into_response());
|
||||
}
|
||||
}
|
||||
|
||||
if decision.route_family.as_deref() == Some("capabilities") {
|
||||
|
||||
Reference in New Issue
Block a user