[control] Overview for the UI: who is looking (viewer) and the underlying pause reason, so the UI offers the right action

This commit is contained in:
2026-11-07 23:44:25 +01:00
parent f9dd2247f8
commit aed5fbfcff
3 changed files with 30 additions and 4 deletions
+14 -1
View File
@@ -128,7 +128,11 @@ fn replay(st: &AppState, s: Stored) -> Response {
#[utoipa::path(get, path = "/api/v1/overview", tag = "overview",
responses((status = 200, body = Overview), (status = 304, description = "Unchanged since the ETag"), (status = 401, body = ErrorEnvelope)),
security(("bearer" = [])))]
pub async fn overview(State(st): Shared, headers: HeaderMap) -> Result<Response, ApiError> {
pub async fn overview(
State(st): Shared,
Extension(actor): Extension<Actor>,
headers: HeaderMap,
) -> Result<Response, ApiError> {
let c = &st.ctl;
let (status, error, since) = {
let h = c
@@ -227,6 +231,7 @@ pub async fn overview(State(st): Shared, headers: HeaderMap) -> Result<Response,
repo: Some(repo_view(c, &head)),
intermediate: super::pki::intermediate_view(c),
site,
paused_reason: c.effective_pause().map(|p| p.code),
paused: c.effective_pause().map(|p| {
if p.code == "engine.caddy" {
Blocked {
@@ -251,6 +256,14 @@ pub async fn overview(State(st): Shared, headers: HeaderMap) -> Result<Response,
),
}),
rev: Some(head),
viewer: Some(Viewer {
via: if actor.token_id.starts_with("user:") {
"authelia".into()
} else {
"token".into()
},
name: actor.name.clone(),
}),
};
let body = serde_json::to_vec(&ov).map_err(|e| ApiError::internal(e.to_string()))?;
let etag = format!("\"{}\"", &sha256_hex(&body)[..32]);
+12
View File
@@ -528,9 +528,21 @@ pub struct Overview {
pub intermediate: Option<super::pki::IntermediateView>,
pub site: Option<SiteView>,
pub paused: Option<Blocked>,
/// Why changes are paused: the underlying code (`apply.needs_attention`, `control.files_unwritten`,
/// `repo.unreadable`, `engine.caddy`, …), so the UI can offer the right action.
pub paused_reason: Option<String>,
/// Set when control cannot read health from edge (`health.unavailable`).
pub health_error: Option<Blocked>,
pub rev: Option<String>,
/// Who is looking: the Authelia user (through edge) or the API token's name.
pub viewer: Option<Viewer>,
}
#[derive(Debug, Clone, Serialize, ToSchema)]
pub struct Viewer {
pub name: String,
/// `authelia` or `token`.
pub via: String,
}
pub fn added_at(c: &Control, hostname: &str) -> Option<String> {