Add selectable declared-param columns to LogPreview (ticket 015)
Extend GET /api/logs to derive each declared param's value per log line (regex + capture group + kind, matching that line's text) and include it as a params map on LogEntryDto, omitting entries that don't match rather than sending nulls. Add GET /api/params (list_params, mirroring list_metrics) so the frontend can discover currently-declared param names. In LogPreview, add a column-picker popover backed by that list, with the selection persisted in localStorage under `ottyl.logPreview.visibleParamColumns`. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
e48c03218f
commit
7514052048
+13
-1
@@ -102,7 +102,7 @@ pub fn router(
|
||||
.route("/api/logs", get(get_logs))
|
||||
.route("/api/timeline", get(get_timeline))
|
||||
.route("/api/stats", get(get_stats))
|
||||
.route("/api/params", post(declare_param))
|
||||
.route("/api/params", get(list_params).post(declare_param))
|
||||
.route("/api/metrics", get(list_metrics).post(declare_metric))
|
||||
.route("/api/metrics/{name}", get(get_metric_bucket_values))
|
||||
.route("/api/settings/css", get(list_css).post(import_css))
|
||||
@@ -152,6 +152,18 @@ async fn get_stats(State(state): State<ApiState>) -> impl IntoResponse {
|
||||
}
|
||||
}
|
||||
|
||||
/// `GET /api/params` — lists all declared params (name, regex, capture
|
||||
/// group, kind) as `Vec<ParamDeclarationDto>`. Mirrors `list_metrics` below
|
||||
/// (ticket 015 needed this for LogPreview's column picker; ticket 004 only
|
||||
/// exposed the equivalent for metrics).
|
||||
async fn list_params(State(state): State<ApiState>) -> impl IntoResponse {
|
||||
match ask(&state.engine, EngineQuery::ParamDeclarations).await {
|
||||
Ok(EngineResponse::ParamDeclarations(declarations)) => Json(declarations).into_response(),
|
||||
Ok(_) => StatusCode::INTERNAL_SERVER_ERROR.into_response(),
|
||||
Err(status) => status.into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
/// `POST /api/params` — declares a param. Body mirrors `DeclareParamRequest`:
|
||||
/// `{ "name": "...", "message_match_regex": "...", "capture_group": "...",
|
||||
/// "kind": "string" | "number" | "timestamp" }`. On success, also persists
|
||||
|
||||
Reference in New Issue
Block a user