From 3a85b730363a0bbec589883ef36c4933f2678e37 Mon Sep 17 00:00:00 2001 From: Dan <39170265+chillenberger@users.noreply.github.com> Date: Fri, 6 Oct 2023 16:49:07 -0600 Subject: [PATCH 1/2] fix web app content area width, ellipses, fix formatting, fix left nav over top nav on scroll --- pgml-dashboard/src/api/chatbot.rs | 15 +++- pgml-dashboard/src/components/chatbot/mod.rs | 75 ++++++++++--------- pgml-dashboard/src/components/star/mod.rs | 2 +- .../static/css/scss/abstracts/variables.scss | 3 + .../static/css/scss/components/_navs.scss | 2 +- .../static/css/scss/layout/_containers.scss | 6 ++ .../templates/layout/web_app_base.html | 8 +- 7 files changed, 66 insertions(+), 45 deletions(-) diff --git a/pgml-dashboard/src/api/chatbot.rs b/pgml-dashboard/src/api/chatbot.rs index 4eaf8b5fd..a608edaaa 100644 --- a/pgml-dashboard/src/api/chatbot.rs +++ b/pgml-dashboard/src/api/chatbot.rs @@ -121,7 +121,13 @@ struct Document { } impl Document { - fn new(text: String, role: ChatRole, user_id: String, model: ChatbotBrain, knowledge_base: KnowledgeBase) -> Document { + fn new( + text: String, + role: ChatRole, + user_id: String, + model: ChatbotBrain, + knowledge_base: KnowledgeBase, + ) -> Document { let id = rand::thread_rng() .sample_iter(&Alphanumeric) .take(32) @@ -225,7 +231,7 @@ pub async fn wrapped_chatbot_get_answer( ChatRole::User, user.chatbot_session_id.clone(), brain, - knowledge_base + knowledge_base, ); let collection = knowledge_base.collection(); @@ -317,7 +323,7 @@ pub async fn wrapped_chatbot_get_answer( ChatRole::Bot, user.chatbot_session_id.clone(), brain, - knowledge_base + knowledge_base, )) .unwrap() .into(), @@ -327,7 +333,8 @@ pub async fn wrapped_chatbot_get_answer( tokio::spawn(async move { history_collection .upsert_documents(new_history_messages, None) - .await.expect("Failed to upsert user history"); + .await + .expect("Failed to upsert user history"); }); Ok(answer) diff --git a/pgml-dashboard/src/components/chatbot/mod.rs b/pgml-dashboard/src/components/chatbot/mod.rs index 9e7ea0b73..c0ad3ae25 100644 --- a/pgml-dashboard/src/components/chatbot/mod.rs +++ b/pgml-dashboard/src/components/chatbot/mod.rs @@ -10,30 +10,42 @@ use sailfish::TemplateOnce; type ExampleQuestions = [(&'static str, [(&'static str, &'static str); 4]); 4]; const EXAMPLE_QUESTIONS: ExampleQuestions = [ - ("PostgresML", [ - ("PostgresML", "sample question continued"), - ("PostgresML", "sample question continued"), - ("PostgresML", "sample question continued"), - ("PostgresML", "sample question continued"), - ]), - ("PyTorch", [ - ("PyTorch", "sample question continued"), - ("PyTorch", "sample question continued"), - ("PyTorch", "sample question continued"), - ("PyTorch", "sample question continued"), - ]), - ("Rust", [ - ("Rust", "sample question continued"), - ("Rust", "sample question continued"), - ("Rust", "sample question continued"), - ("Rust", "sample question continued"), - ]), - ("PostgreSQL", [ - ("PostgreSQL", "sample question continued"), - ("PostgreSQL", "sample question continued"), - ("PostgreSQL", "sample question continued"), - ("PostgreSQL", "sample question continued"), - ]), + ( + "PostgresML", + [ + ("PostgresML", "sample question continued"), + ("PostgresML", "sample question continued"), + ("PostgresML", "sample question continued"), + ("PostgresML", "sample question continued"), + ], + ), + ( + "PyTorch", + [ + ("PyTorch", "sample question continued"), + ("PyTorch", "sample question continued"), + ("PyTorch", "sample question continued"), + ("PyTorch", "sample question continued"), + ], + ), + ( + "Rust", + [ + ("Rust", "sample question continued"), + ("Rust", "sample question continued"), + ("Rust", "sample question continued"), + ("Rust", "sample question continued"), + ], + ), + ( + "PostgreSQL", + [ + ("PostgreSQL", "sample question continued"), + ("PostgreSQL", "sample question continued"), + ("PostgreSQL", "sample question continued"), + ("PostgreSQL", "sample question continued"), + ], + ), ]; const KNOWLEDGE_BASES: [&'static str; 0] = [ @@ -44,18 +56,9 @@ const KNOWLEDGE_BASES: [&'static str; 0] = [ ]; const KNOWLEDGE_BASES_WITH_LOGO: [KnowledgeBaseWithLogo; 4] = [ - KnowledgeBaseWithLogo::new( - "PostgresML", - "/dashboard/static/images/owl_gradient.svg", - ), - KnowledgeBaseWithLogo::new( - "PyTorch", - "/dashboard/static/images/logos/pytorch.svg", - ), - KnowledgeBaseWithLogo::new( - "Rust", - "/dashboard/static/images/logos/rust.svg", - ), + KnowledgeBaseWithLogo::new("PostgresML", "/dashboard/static/images/owl_gradient.svg"), + KnowledgeBaseWithLogo::new("PyTorch", "/dashboard/static/images/logos/pytorch.svg"), + KnowledgeBaseWithLogo::new("Rust", "/dashboard/static/images/logos/rust.svg"), KnowledgeBaseWithLogo::new( "PostgreSQL", "/dashboard/static/images/logos/postgresql.svg", diff --git a/pgml-dashboard/src/components/star/mod.rs b/pgml-dashboard/src/components/star/mod.rs index 63a5f99bc..31dda9a71 100644 --- a/pgml-dashboard/src/components/star/mod.rs +++ b/pgml-dashboard/src/components/star/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; -use pgml_components::component; use once_cell::sync::Lazy; +use pgml_components::component; use sailfish::TemplateOnce; #[derive(TemplateOnce, Default)] diff --git a/pgml-dashboard/static/css/scss/abstracts/variables.scss b/pgml-dashboard/static/css/scss/abstracts/variables.scss index f2cb64d45..8d52a6788 100644 --- a/pgml-dashboard/static/css/scss/abstracts/variables.scss +++ b/pgml-dashboard/static/css/scss/abstracts/variables.scss @@ -209,6 +209,9 @@ $nav-pills-border-radius: calc(#{$border-radius} / 2); $left-nav-w: 17rem; $left-nav-w-collapsed: 88px; +// WebApp Content Container +$webapp-content-max-width: 1224px; + //Grid $enable-cssgrid: true; $enable-shadows: true; diff --git a/pgml-dashboard/static/css/scss/components/_navs.scss b/pgml-dashboard/static/css/scss/components/_navs.scss index 5f8b703d5..ca7c78394 100644 --- a/pgml-dashboard/static/css/scss/components/_navs.scss +++ b/pgml-dashboard/static/css/scss/components/_navs.scss @@ -9,7 +9,7 @@ height: $navbar-height; position: fixed; top: 0px; - z-index: $zindex-fixed; + z-index: calc($zindex-fixed + 1); } .navbar { diff --git a/pgml-dashboard/static/css/scss/layout/_containers.scss b/pgml-dashboard/static/css/scss/layout/_containers.scss index 160dd5727..15c5d998d 100644 --- a/pgml-dashboard/static/css/scss/layout/_containers.scss +++ b/pgml-dashboard/static/css/scss/layout/_containers.scss @@ -145,3 +145,9 @@ width: $left-nav-w; } } + +.webapp-content-max-width-container { + max-width: $webapp-content-max-width; + margin-left: 0px; + min-height: calc(100vh - $navbar-height - 1px); + } diff --git a/pgml-dashboard/templates/layout/web_app_base.html b/pgml-dashboard/templates/layout/web_app_base.html index 62cdb94a5..31113c8e4 100644 --- a/pgml-dashboard/templates/layout/web_app_base.html +++ b/pgml-dashboard/templates/layout/web_app_base.html @@ -32,12 +32,14 @@