diff --git a/crates/context_aware_config/src/api/type_templates/handlers.rs b/crates/context_aware_config/src/api/type_templates/handlers.rs index 0e1d3397..70835af8 100644 --- a/crates/context_aware_config/src/api/type_templates/handlers.rs +++ b/crates/context_aware_config/src/api/type_templates/handlers.rs @@ -22,6 +22,7 @@ pub fn endpoints() -> Scope { .service(create_type) .service(update_type) .service(delete_type) + .service(get_type) } #[post("")] @@ -145,3 +146,17 @@ async fn list_types( "data": custom_types }))) } + +#[get("/{type_name}")] +async fn get_type( + db_conn: DbConnection, + path: Path, +) -> superposition::Result { + let DbConnection(mut conn) = db_conn; + let type_name: String = path.into_inner().into(); + + let custom_type = dsl::type_templates + .find(type_name) + .get_result::(&mut conn)?; + Ok(HttpResponse::Ok().json(custom_type)) +} diff --git a/crates/frontend/src/api.rs b/crates/frontend/src/api.rs index 88a9e2e7..421d3fc0 100644 --- a/crates/frontend/src/api.rs +++ b/crates/frontend/src/api.rs @@ -4,7 +4,7 @@ use superposition_types::Config; use crate::{ types::{ ConfigVersionListResponse, DefaultConfig, Dimension, ExperimentResponse, - ExperimentsResponse, FetchTypeTemplateResponse, FunctionResponse, ListFilters, + ExperimentsResponse, FetchTypeTemplateResponse, FunctionResponse, ListFilters, TypeTemplate, }, utils::{ construct_request_headers, get_host, parse_json_response, request, @@ -277,3 +277,23 @@ pub async fn fetch_types( .await .map_err(err_handler) } + +pub async fn fetch_type( + tenant: &str, + name: &str, +) -> Result { + let host = use_host_server(); + let url = format!("{host}/types/{name}"); + let err_handler = |e: String| ServerFnError::new(e.to_string()); + let response = request::<()>( + url, + reqwest::Method::GET, + None, + construct_request_headers(&[("x-tenant", &tenant)]).map_err(err_handler)?, + ) + .await + .map_err(err_handler)?; + parse_json_response::(response) + .await + .map_err(err_handler) +} diff --git a/crates/frontend/src/app.rs b/crates/frontend/src/app.rs index 1b151072..dca4e892 100755 --- a/crates/frontend/src/app.rs +++ b/crates/frontend/src/app.rs @@ -6,12 +6,14 @@ use serde_json::json; use crate::hoc::layout::Layout; use crate::pages::config_version::ConfigVersion; use crate::pages::config_version_list::ConfigVersionList; -use crate::pages::create_experiment::CreateExperiment; use crate::pages::dimensions::Dimensions; use crate::pages::experiment_list::ExperimentList; use crate::pages::function::{ function_create::CreateFunctionView, function_list::FunctionList, FunctionPage, }; +use crate::pages::new_custom_types::NewCustomTypes; +use crate::pages::new_experiment::NewExperiment; +use crate::pages::update_custom_types::UpdateCustomTypes; use crate::pages::{ context_override::ContextOverride, custom_types::TypesPage, default_config::DefaultConfig, experiment::ExperimentPage, home::Home, @@ -105,6 +107,18 @@ pub fn app(app_envs: Envs) -> impl IntoView { } /> + + + + } + } + /> + impl IntoView { view=move || { view! { - + } } @@ -189,6 +203,18 @@ pub fn app(app_envs: Envs) -> impl IntoView { } /> + + + + } + } + /> + impl IntoView { } /> + + + + } + } + /> + + + + + } + } + /> + -
-