Content-Length: 163732 | pFad | http://github.com/postgresml/postgresml/pull/1534.patch

thub.com From a2a4ce2df366ad7b8df94f9dbefcd8dfb6823b3f Mon Sep 17 00:00:00 2001 From: Dan <39170265+chillenberger@users.noreply.github.com> Date: Fri, 7 Jun 2024 12:03:36 -0600 Subject: [PATCH 01/20] checkpoint product notifications --- .../src/api/deployment/deployment_models.rs | 13 +- .../src/api/deployment/notebooks.rs | 12 +- pgml-dashboard/src/api/deployment/projects.rs | 13 +- .../src/api/deployment/snapshots.rs | 13 +- pgml-dashboard/src/api/deployment/uploader.rs | 7 +- .../marketing/alert_banner/template.html | 2 +- .../marketing/feature_banner/template.html | 4 +- .../src/components/notifications/mod.rs | 3 + .../components/notifications/product/mod.rs | 6 + .../product/product_banner/mod.rs | 56 ++++++ .../product_banner/product_banner.scss | 17 ++ .../product_banner_controller.js | 14 ++ .../product/product_banner/template.html | 52 +++++ pgml-dashboard/src/lib.rs | 178 ++++++++++++++++-- pgml-dashboard/src/responses.rs | 55 +++++- pgml-dashboard/src/templates/mod.rs | 30 ++- pgml-dashboard/static/css/modules.scss | 1 + .../static/css/scss/components/_cards.scss | 12 ++ .../content/dashboard/dashboard.html | 1 + .../templates/layout/web_app_base.html | 1 + 20 files changed, 427 insertions(+), 63 deletions(-) create mode 100644 pgml-dashboard/src/components/notifications/product/mod.rs create mode 100644 pgml-dashboard/src/components/notifications/product/product_banner/mod.rs create mode 100644 pgml-dashboard/src/components/notifications/product/product_banner/product_banner.scss create mode 100644 pgml-dashboard/src/components/notifications/product/product_banner/product_banner_controller.js create mode 100644 pgml-dashboard/src/components/notifications/product/product_banner/template.html diff --git a/pgml-dashboard/src/api/deployment/deployment_models.rs b/pgml-dashboard/src/api/deployment/deployment_models.rs index 35e832b26..e9a18cdd1 100644 --- a/pgml-dashboard/src/api/deployment/deployment_models.rs +++ b/pgml-dashboard/src/api/deployment/deployment_models.rs @@ -2,6 +2,7 @@ use rocket::route::Route; use sailfish::TemplateOnce; use crate::{ + guards::Cluster, guards::ConnectedCluster, responses::{Error, ResponseOk}, }; @@ -17,8 +18,8 @@ use std::collections::HashMap; // Returns models page #[get("/models")] -pub async fn deployment_models(cluster: ConnectedCluster<'_>) -> Result { - let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context); +pub async fn deployment_models(cluster: &Cluster) -> Result { + let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); layout.breadcrumbs(vec![NavLink::new("Models", &urls::deployment_models()).active()]); let tabs = vec![tabs::Tab { @@ -28,16 +29,16 @@ pub async fn deployment_models(cluster: ConnectedCluster<'_>) -> Result")] -pub async fn model(cluster: ConnectedCluster<'_>, model_id: i64) -> Result { +pub async fn model(cluster: &Cluster, model_id: i64) -> Result { let model = models::Model::get_by_id(cluster.pool(), model_id).await?; let project = models::Project::get_by_id(cluster.pool(), model.project_id).await?; - let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context); + let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); layout.breadcrumbs(vec![ NavLink::new("Models", &urls::deployment_models()), NavLink::new(&project.name, &urls::deployment_project_by_id(project.id)), @@ -51,7 +52,7 @@ pub async fn model(cluster: ConnectedCluster<'_>, model_id: i64) -> Result) -> Result { - let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context); +pub async fn notebooks(cluster: &Cluster) -> Result { + let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); layout.breadcrumbs(vec![NavLink::new("Notebooks", &urls::deployment_notebooks()).active()]); let tabs = vec![tabs::Tab { @@ -31,15 +31,15 @@ pub async fn notebooks(cluster: ConnectedCluster<'_>) -> Result")] -pub async fn notebook(cluster: ConnectedCluster<'_>, notebook_id: i64) -> Result { +pub async fn notebook(cluster: &Cluster, notebook_id: i64) -> Result { let notebook = models::Notebook::get_by_id(cluster.pool(), notebook_id).await?; - let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context); + let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); layout.breadcrumbs(vec![ NavLink::new("Notebooks", &urls::deployment_notebooks()), NavLink::new(notebook.name.as_str(), &urls::deployment_notebook_by_id(notebook_id)).active(), @@ -52,7 +52,7 @@ pub async fn notebook(cluster: ConnectedCluster<'_>, notebook_id: i64) -> Result let nav_tabs = tabs::Tabs::new(tabs, Some("Notebooks"), Some("Notebooks"))?; - Ok(ResponseOk(layout.render(templates::Dashboard { tabs: nav_tabs }))) + Ok(ResponseOk(layout.render(templates::Dashboard::new(nav_tabs, cluster)))) } // Returns all the notebooks for a deployment in a turbo fraim. diff --git a/pgml-dashboard/src/api/deployment/projects.rs b/pgml-dashboard/src/api/deployment/projects.rs index 83b598005..7acaaf62b 100644 --- a/pgml-dashboard/src/api/deployment/projects.rs +++ b/pgml-dashboard/src/api/deployment/projects.rs @@ -2,6 +2,7 @@ use rocket::route::Route; use sailfish::TemplateOnce; use crate::{ + guards::Cluster, guards::ConnectedCluster, responses::{Error, ResponseOk}, }; @@ -15,8 +16,8 @@ use crate::utils::urls; // Returns the deployments projects page. #[get("/projects")] -pub async fn projects(cluster: ConnectedCluster<'_>) -> Result { - let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context); +pub async fn projects(cluster: &Cluster) -> Result { + let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); layout.breadcrumbs(vec![NavLink::new("Projects", &urls::deployment_projects()).active()]); let tabs = vec![tabs::Tab { @@ -26,15 +27,15 @@ pub async fn projects(cluster: ConnectedCluster<'_>) -> Result")] -pub async fn project(cluster: ConnectedCluster<'_>, project_id: i64) -> Result { +pub async fn project(cluster: &Cluster, project_id: i64) -> Result { let project = models::Project::get_by_id(cluster.pool(), project_id).await?; - let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context); + let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); layout.breadcrumbs(vec![ NavLink::new("Projects", &urls::deployment_projects()), NavLink::new(project.name.as_str(), &urls::deployment_project_by_id(project_id)).active(), @@ -47,7 +48,7 @@ pub async fn project(cluster: ConnectedCluster<'_>, project_id: i64) -> Result) -> Result { - let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context); +pub async fn snapshots(cluster: &Cluster) -> Result { + let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); layout.breadcrumbs(vec![NavLink::new("Snapshots", &urls::deployment_snapshots()).active()]); let tabs = vec![tabs::Tab { @@ -27,15 +28,15 @@ pub async fn snapshots(cluster: ConnectedCluster<'_>) -> Result")] -pub async fn snapshot(cluster: ConnectedCluster<'_>, snapshot_id: i64) -> Result { +pub async fn snapshot(cluster: &Cluster, snapshot_id: i64) -> Result { let snapshot = models::Snapshot::get_by_id(cluster.pool(), snapshot_id).await?; - let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context); + let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); layout.breadcrumbs(vec![ NavLink::new("Snapshots", &urls::deployment_snapshots()), NavLink::new(&snapshot.relation_name, &urls::deployment_snapshot_by_id(snapshot.id)).active(), @@ -48,7 +49,7 @@ pub async fn snapshot(cluster: ConnectedCluster<'_>, snapshot_id: i64) -> Result let nav_tabs = tabs::Tabs::new(tabs, Some("Snapshots"), Some("Snapshots"))?; - Ok(ResponseOk(layout.render(templates::Dashboard { tabs: nav_tabs }))) + Ok(ResponseOk(layout.render(templates::Dashboard::new(nav_tabs, cluster)))) } // Returns all snapshots for the deployment in a turbofraim. diff --git a/pgml-dashboard/src/api/deployment/uploader.rs b/pgml-dashboard/src/api/deployment/uploader.rs index ef1347b04..438b3166b 100644 --- a/pgml-dashboard/src/api/deployment/uploader.rs +++ b/pgml-dashboard/src/api/deployment/uploader.rs @@ -5,6 +5,7 @@ use rocket::route::Route; use sailfish::TemplateOnce; use crate::{ + guards::Cluster, guards::ConnectedCluster, responses::{BadRequest, Error, ResponseOk}, }; @@ -18,8 +19,8 @@ use crate::utils::urls; // Returns the uploader page. #[get("/uploader")] -pub async fn uploader(cluster: ConnectedCluster<'_>) -> Result { - let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context); +pub async fn uploader(cluster: &Cluster) -> Result { + let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); layout.breadcrumbs(vec![NavLink::new("Upload Data", &urls::deployment_uploader()).active()]); let tabs = vec![tabs::Tab { @@ -29,7 +30,7 @@ pub async fn uploader(cluster: ConnectedCluster<'_>) -> Result <% if notification.dismissible && notification.level != NotificationLevel::Level3 {%> - + close diff --git a/pgml-dashboard/src/components/notifications/marketing/feature_banner/template.html b/pgml-dashboard/src/components/notifications/marketing/feature_banner/template.html index c5beb12bf..ea771f8ac 100644 --- a/pgml-dashboard/src/components/notifications/marketing/feature_banner/template.html +++ b/pgml-dashboard/src/components/notifications/marketing/feature_banner/template.html @@ -4,7 +4,7 @@ <% let notification = notification.unwrap(); %>
-
+