-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: experiment filters in UI #424
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
use std::time::Duration; | ||
|
||
use chrono::{DateTime, Utc}; | ||
use leptos::*; | ||
use serde_json::{json, Map, Value}; | ||
|
||
|
@@ -475,6 +476,56 @@ pub fn monaco_input( | |
} | ||
} | ||
|
||
#[component] | ||
pub fn date_input( | ||
id: String, | ||
class: String, | ||
name: String, | ||
on_change: Callback<DateTime<Utc>, ()>, | ||
#[prop(into, default = Utc::now().format("%Y-%m-%d").to_string())] value: String, | ||
#[prop(default = false)] disabled: bool, | ||
#[prop(default = false)] required: bool, | ||
#[prop(into, default = String::from("2020-01-01"))] min: String, | ||
#[prop(into, default = Utc::now().format("%Y-%m-%d").to_string())] max: String, | ||
) -> impl IntoView { | ||
let (error_rs, error_ws) = create_signal::<String>(String::new()); | ||
view! { | ||
<div class="flex flex-col gap-1"> | ||
<input | ||
id=id | ||
name=name | ||
type="date" | ||
class=format!("input input-bordered {}", class) | ||
required=required | ||
disabled=disabled | ||
min=min | ||
max=max | ||
value=value | ||
on:change=move |e| { | ||
let date = format!("{}T00:00:00Z", event_target_value(&e)); | ||
logging::log!("The date selected is: {}", date); | ||
match DateTime::parse_from_rfc3339(&date) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the user can't really type anything & all the input is via the calender-widget, I think we can just unwrap w/o any consequences. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They can still programmatically change the field in inspect, better safe than sorry. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
Ok(v) => { | ||
on_change.call(v.to_utc()); | ||
} | ||
Err(e) => { | ||
logging::log!("error occurred: {:?}", e); | ||
error_ws.set(e.to_string()); | ||
}, | ||
} | ||
} | ||
/> | ||
<Show when=move || !error_rs.get().is_empty() > | ||
<span class="flex gap-2 px-4 text-xs font-semibold text-red-600"> | ||
<i class="ri-close-circle-line"></i> | ||
{move || error_rs.get()} | ||
</span> | ||
</Show> | ||
|
||
</div> | ||
} | ||
} | ||
|
||
#[component] | ||
pub fn input( | ||
value: Value, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Little bit confused by this filter, isn't the
context
column a json? How does this exactly work?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take an example:
Lets say you want to find the second one, the query formed will look like:
FAQs
Q. The type is JSON, but you're using LIKE which needs text. How does this work?
A. The
::text
does the conversionQ. Why not just do the whole context?
A. Imagine single searches, like
If I searched by the whole context, it would only match records that had this structure,
and would ignore records like these:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a bit compute heavy, so we should think about a conservative
LIMIT
clause here.PS: @knutties looks like we CAN query w/ JSON as well :P