Skip to content

Commit

Permalink
chore: formatted code with leptosfmt and rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ShubhranshuSanjeev committed May 2, 2024
1 parent 31a08ba commit aa8cbce
Show file tree
Hide file tree
Showing 19 changed files with 485 additions and 386 deletions.
2 changes: 1 addition & 1 deletion crates/context_aware_config/src/api/context/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,4 +523,4 @@ async fn bulk_operations(
Ok(()) // Commit the transaction
})?;
Ok(Json(response))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@ async fn get(db_conn: DbConnection) -> superposition::Result<Json<Vec<DefaultCon

let result: Vec<DefaultConfig> = default_configs.get_results(&mut conn)?;
Ok(Json(result))
}
}
2 changes: 1 addition & 1 deletion crates/frontend/src/components/alert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ pub fn alert(alert: Alert) -> impl IntoView {
<span>{alert.text}</span>
</div>
}
}
}
222 changes: 120 additions & 102 deletions crates/frontend/src/components/default_config_form/default_config_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,72 +181,79 @@ where
<label class="label">
<span class="label-text">Set Schema</span>
</label>
<select
name="schemaType[]"
on:change=move |ev| {
set_show_labels.set(true);
match event_target_value(&ev).as_str() {
"number" => {
set_config_type.set("number".to_string());
}
"decimal" => {
set_config_type.set("decimal".to_string());
}
"boolean" => {
set_config_type.set("boolean".to_string());
}
"enum" => {
set_config_type.set("enum".to_string());
set_config_pattern.set(format!("{:?}", vec!["android", "web", "ios"]));
}
"pattern" => {
set_config_type.set("pattern".to_string());
set_config_pattern.set(".*".to_string());
}
_ => {
set_config_type.set("other".to_string());
set_config_pattern.set("".to_string());
}
};
}

class="select select-bordered w-full max-w-md"
>
<option disabled selected>
Choose Schema Type
</option>
<select
name="schemaType[]"
on:change=move |ev| {
set_show_labels.set(true);
match event_target_value(&ev).as_str() {
"number" => {
set_config_type.set("number".to_string());
}
"decimal" => {
set_config_type.set("decimal".to_string());
}
"boolean" => {
set_config_type.set("boolean".to_string());
}
"enum" => {
set_config_type.set("enum".to_string());
set_config_pattern
.set(format!("{:?}", vec!["android", "web", "ios"]));
}
"pattern" => {
set_config_type.set("pattern".to_string());
set_config_pattern.set(".*".to_string());
}
_ => {
set_config_type.set("other".to_string());
set_config_pattern.set("".to_string());
}
};
}

<option
value="number"
selected=move || { config_type.get() == "number".to_string() }
>
"Number"
</option>
<option
value="decimal"
selected=move || { config_type.get() == "decimal".to_string() }
>
"Decimal (16 digits)"
</option>
<option
value="boolean"
selected=move || { config_type.get() == "boolean".to_string() }
class="select select-bordered w-full max-w-md"
>
"Boolean"
</option>
<option value="enum" selected=move || { config_type.get() == "enum".to_string() }>
"String (Enum)"
</option>
<option
value="pattern"
selected=move || { config_type.get() == "pattern".to_string() }
>
"String (regex)"
</option>
<option value="other" selected=move || { config_type.get() == "other".to_string() }>
"Other"
</option>
</select>
<option disabled selected>
Choose Schema Type
</option>

<option
value="number"
selected=move || { config_type.get() == "number".to_string() }
>
"Number"
</option>
<option
value="decimal"
selected=move || { config_type.get() == "decimal".to_string() }
>
"Decimal (16 digits)"
</option>
<option
value="boolean"
selected=move || { config_type.get() == "boolean".to_string() }
>
"Boolean"
</option>
<option
value="enum"
selected=move || { config_type.get() == "enum".to_string() }
>
"String (Enum)"
</option>
<option
value="pattern"
selected=move || { config_type.get() == "pattern".to_string() }
>
"String (regex)"
</option>
<option
value="other"
selected=move || { config_type.get() == "other".to_string() }
>
"Other"
</option>
</select>
</div>

<div class="divider"></div>
Expand Down Expand Up @@ -275,7 +282,8 @@ where
<div class="divider"></div>
</Show>

<Show when=move || { show_labels.get() && (config_type.get() != "number")
<Show when=move || {
show_labels.get() && (config_type.get() != "number")
&& (config_type.get() != "decimal")
}>
<div class="form-control">
Expand All @@ -300,9 +308,7 @@ where
<Show when=move || (config_type.get() != "boolean")>
<div class="form-control">
<label class="label">
<span class="label-text">
{config_type.get()}
</span>
<span class="label-text">{config_type.get()}</span>
</label>
<textarea
type="text"
Expand All @@ -325,44 +331,56 @@ where
}}

<Suspense>
{move || {
let functions = functions_resource.get().unwrap_or(vec![]);
let mut function_names: Vec<FunctionsName> = vec![];
functions.into_iter().for_each(|ele| {
function_names.push(ele.function_name);
});
function_names.sort();
function_names.insert(0, "None".to_string());
view! {
<div class="form-control">
<div class="gap-1">
<label class="label flex-col justify-center items-start">
<span class="label-text">Function Name</span>
<span class="label-text text-slate-400">Assign Function validation to your key</span>
</label>
{move || {
let functions = functions_resource.get().unwrap_or(vec![]);
let mut function_names: Vec<FunctionsName> = vec![];
functions
.into_iter()
.for_each(|ele| {
function_names.push(ele.function_name);
});
function_names.sort();
function_names.insert(0, "None".to_string());
view! {
<div class="form-control">
<div class="gap-1">
<label class="label flex-col justify-center items-start">
<span class="label-text">Function Name</span>
<span class="label-text text-slate-400">
Assign Function validation to your key
</span>
</label>
</div>

<div class="mt-2">
<Dropdown
dropdown_width="w-100"
dropdown_icon="".to_string()
dropdown_text=function_name
.get()
.and_then(|v| match v {
Value::String(s) => Some(s),
_ => None,
})
.map_or("Add Function".to_string(), |v| v.to_string())
dropdown_direction=DropdownDirection::Down
dropdown_btn_type=DropdownBtnType::Select
dropdown_options=function_names
on_select=Box::new(handle_select_dropdown_option)
/>
</div>
</div>
}
}}

<div class="mt-2">
<Dropdown
dropdown_width="w-100"
dropdown_icon="".to_string()
dropdown_text={function_name.get().and_then(|v| match v {
Value::String(s) => Some(s),
_ => None,
}).map_or("Add Function".to_string(), |v| v.to_string())}
dropdown_direction=DropdownDirection::Down
dropdown_btn_type=DropdownBtnType::Select
dropdown_options=function_names
on_select=Box::new(handle_select_dropdown_option)
/>
</ div>
</ div>
}
}}
</ Suspense>
</Suspense>

<div class="form-control grid w-full justify-end">
<Button class="pl-[70px] pr-[70px]".to_string() text="Submit".to_string() on_click=on_submit/>
<Button
class="pl-[70px] pr-[70px]".to_string()
text="Submit".to_string()
on_click=on_submit
/>
</div>

{
Expand Down
Loading

0 comments on commit aa8cbce

Please sign in to comment.