feat: implement system settings page in dashboard
This commit is contained in:
@@ -76,6 +76,7 @@ pub fn router(state: AppState) -> Router {
|
||||
.route("/api/system/health", get(handle_system_health))
|
||||
.route("/api/system/logs", get(handle_system_logs))
|
||||
.route("/api/system/backup", post(handle_system_backup))
|
||||
.route("/api/system/settings", get(handle_get_settings).post(handle_update_settings))
|
||||
|
||||
.with_state(dashboard_state)
|
||||
}
|
||||
@@ -686,6 +687,30 @@ async fn handle_system_backup(State(_state): State<DashboardState>) -> Json<ApiR
|
||||
})))
|
||||
}
|
||||
|
||||
async fn handle_get_settings(State(state): State<DashboardState>) -> Json<ApiResponse<serde_json::Value>> {
|
||||
let registry = &state.app_state.model_registry;
|
||||
let provider_count = registry.providers.len();
|
||||
let model_count: usize = registry.providers.values().map(|p| p.models.len()).sum();
|
||||
|
||||
Json(ApiResponse::success(serde_json::json!({
|
||||
"server": {
|
||||
"auth_tokens": state.app_state.auth_tokens,
|
||||
"version": env!("CARGO_PKG_VERSION"),
|
||||
},
|
||||
"registry": {
|
||||
"provider_count": provider_count,
|
||||
"model_count": model_count,
|
||||
},
|
||||
"database": {
|
||||
"type": "SQLite",
|
||||
}
|
||||
})))
|
||||
}
|
||||
|
||||
async fn handle_update_settings(State(_state): State<DashboardState>) -> Json<ApiResponse<serde_json::Value>> {
|
||||
Json(ApiResponse::error("Changing settings at runtime is not yet supported. Please update your config file and restart the server.".to_string()))
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
#[allow(dead_code)]
|
||||
fn mask_token(token: &str) -> String {
|
||||
|
||||
Reference in New Issue
Block a user