From b842ffd7abdef754b19394233c59a3053553c609 Mon Sep 17 00:00:00 2001 From: Xiangpeng Hao Date: Fri, 27 Dec 2024 10:19:31 -0600 Subject: [PATCH] ux update --- index.html | 3 + src/file_reader.rs | 30 ++---- src/main.rs | 13 +-- src/query_input.rs | 4 +- src/query_results.rs | 237 ++++++++++++++++++++++--------------------- 5 files changed, 146 insertions(+), 141 deletions(-) diff --git a/index.html b/index.html index f1cec4b..d65d0ea 100644 --- a/index.html +++ b/index.html @@ -34,6 +34,9 @@ } + + + diff --git a/src/file_reader.rs b/src/file_reader.rs index de93b4c..43bb875 100644 --- a/src/file_reader.rs +++ b/src/file_reader.rs @@ -37,7 +37,7 @@ async fn update_file( parquet_table_setter: WriteSignal>, ) { let object_store = &*INMEMORY_STORE; - let path = Path::parse(format!("{}.parquet", parquet_table.table_name)).unwrap(); + let path = Path::parse(format!("{}", parquet_table.table_name)).unwrap(); let payload = PutPayload::from_bytes(parquet_table.bytes.clone()); object_store.put(&path, payload).await.unwrap(); parquet_table_setter.set(Some(parquet_table)); @@ -155,11 +155,7 @@ pub fn FileReader( let file_reader = web_sys::FileReader::new().unwrap(); let file_reader_clone = file_reader.clone(); - let table_name = file - .name() - .strip_suffix(".parquet") - .unwrap_or(&file.name()) - .to_string(); + let table_name = file.name(); let onload = Closure::wrap(Box::new(move |_: web_sys::Event| { let table_name = table_name.clone(); @@ -196,8 +192,6 @@ pub fn FileReader( .split('/') .last() .unwrap_or("uploaded.parquet") - .strip_suffix(".parquet") - .unwrap_or("uploaded") .to_string(); leptos::task::spawn_local(async move { @@ -243,8 +237,6 @@ pub fn FileReader( .split('/') .last() .unwrap_or("uploaded.parquet") - .strip_suffix(".parquet") - .unwrap_or("uploaded") .to_string(); leptos::task::spawn_local(async move { @@ -315,7 +307,7 @@ pub fn FileReader( let base = "py-2 px-1 border-b-2 font-medium text-sm"; if let Some(active_t) = active_tab.get() { if active_t == "file" { - return format!("{} border-blue-500 text-blue-600", base); + return format!("{} border-green-500 text-green-600", base); } } format!( @@ -332,7 +324,7 @@ pub fn FileReader( let base = "py-2 px-1 border-b-2 font-medium text-sm"; if let Some(active_t) = active_tab.get() { if active_t == "url" { - return format!("{} border-blue-500 text-blue-600", base); + return format!("{} border-green-500 text-green-600", base); } } format!( @@ -349,7 +341,7 @@ pub fn FileReader( let base = "py-2 px-1 border-b-2 font-medium text-sm"; if let Some(active_t) = active_tab.get() { if active_t == "s3" { - return format!("{} border-blue-500 text-blue-600", base); + return format!("{} border-green-500 text-green-600", base); } } format!( @@ -420,11 +412,11 @@ pub fn FileReader( set_url.set(event_target_value(&ev)); } prop:value=url - class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500" /> @@ -454,7 +446,7 @@ pub fn FileReader( type="text" on:input=on_s3_bucket_change prop:value=s3_bucket - class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500" />
@@ -465,7 +457,7 @@ pub fn FileReader( type="text" on:input=on_s3_region_change prop:value=s3_region - class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500" />
@@ -476,13 +468,13 @@ pub fn FileReader( type="text" on:input=on_s3_file_path_change prop:value=s3_file_path - class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500" />
diff --git a/src/main.rs b/src/main.rs index abea870..3cb1dd7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -225,6 +225,8 @@ fn App() -> impl IntoView { .and_then(|table| ParquetReader::new(table).ok()) }); + let (force_update_user_input, set_force_update_user_input) = signal(false); + Effect::watch( parquet_reader, move |reader, old_reader, _| { @@ -240,9 +242,8 @@ fn App() -> impl IntoView { } None => match user_input.get() { Some(user_input) => { - // force update - let new_input = format!("{} ", user_input); - set_user_input.set(Some(new_input)); + set_user_input.set(Some(user_input)); + set_force_update_user_input.set(true); } None => { logging::log!("{}", reader.info().to_string()); @@ -257,9 +258,9 @@ fn App() -> impl IntoView { ); Effect::watch( - user_input, - move |user_input, _, _| { - let Some(user_input_str) = user_input else { + move || (force_update_user_input.get(), user_input.get()), + move |(_, user_input_str), _, _| { + let Some(user_input_str) = user_input_str else { return; }; diff --git a/src/query_input.rs b/src/query_input.rs index 890453a..38bf501 100644 --- a/src/query_input.rs +++ b/src/query_input.rs @@ -33,7 +33,7 @@ pub(crate) async fn execute_query_inner( ctx.register_object_store(object_store_url.as_ref(), object_store); ctx.register_parquet( table_name, - &format!("mem:///{}.parquet", table_name), + &format!("mem:///{}", table_name), ParquetReadOptions::default(), ) .await?; @@ -101,7 +101,7 @@ pub fn QueryInput( on:input=move |ev| set_input_value(Some(event_target_value(&ev))) prop:value=input_value on:keydown=key_down - class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500" />
- + - + - + + + "Execution plan" + + + + + +
+
+ +
+
{sql_clone}