From 0e11743bc339362743323b690326ee184553e85e Mon Sep 17 00:00:00 2001 From: Dan <39170265+chillenberger@users.noreply.github.com> Date: Fri, 14 Jun 2024 13:31:24 -0600 Subject: [PATCH 1/2] 404 rather than 500 on misisng pool, add comment --- pgml-dashboard/src/api/deployment/deployment_models.rs | 4 ++-- pgml-dashboard/src/api/deployment/notebooks.rs | 4 ++-- pgml-dashboard/src/api/deployment/projects.rs | 4 ++-- pgml-dashboard/src/api/deployment/snapshots.rs | 4 ++-- pgml-dashboard/src/api/deployment/uploader.rs | 2 +- pgml-dashboard/src/guards.rs | 1 + 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pgml-dashboard/src/api/deployment/deployment_models.rs b/pgml-dashboard/src/api/deployment/deployment_models.rs index 8f88a3f91..3fe66c8a7 100644 --- a/pgml-dashboard/src/api/deployment/deployment_models.rs +++ b/pgml-dashboard/src/api/deployment/deployment_models.rs @@ -18,7 +18,7 @@ use std::collections::HashMap; // Returns models page #[get("/models")] -pub async fn deployment_models(cluster: &Cluster) -> Result { +pub async fn deployment_models(cluster: &Cluster, _connected: ConnectedCluster<'_>) -> Result { let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); layout.breadcrumbs(vec![NavLink::new("Models", &urls::deployment_models()).active()]); @@ -34,7 +34,7 @@ pub async fn deployment_models(cluster: &Cluster) -> Result { // Returns models page #[get("/models/")] -pub async fn model(cluster: &Cluster, model_id: i64) -> Result { +pub async fn model(cluster: &Cluster, model_id: i64, _connected: ConnectedCluster<'_>) -> 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?; diff --git a/pgml-dashboard/src/api/deployment/notebooks.rs b/pgml-dashboard/src/api/deployment/notebooks.rs index c376995f6..06faf00ec 100644 --- a/pgml-dashboard/src/api/deployment/notebooks.rs +++ b/pgml-dashboard/src/api/deployment/notebooks.rs @@ -20,7 +20,7 @@ use crate::utils::urls; // Returns notebook page #[get("/notebooks")] -pub async fn notebooks(cluster: &Cluster) -> Result { +pub async fn notebooks(cluster: &Cluster, _connected: ConnectedCluster<'_>) -> Result { let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); layout.breadcrumbs(vec![NavLink::new("Notebooks", &urls::deployment_notebooks()).active()]); @@ -36,7 +36,7 @@ pub async fn notebooks(cluster: &Cluster) -> Result { // Returns the specified notebook page. #[get("/notebooks/")] -pub async fn notebook(cluster: &Cluster, notebook_id: i64) -> Result { +pub async fn notebook(cluster: &Cluster, notebook_id: i64, _connected: ConnectedCluster<'_>) -> Result { let notebook = models::Notebook::get_by_id(cluster.pool(), notebook_id).await?; let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); diff --git a/pgml-dashboard/src/api/deployment/projects.rs b/pgml-dashboard/src/api/deployment/projects.rs index 9204d52e4..f4f5e5867 100644 --- a/pgml-dashboard/src/api/deployment/projects.rs +++ b/pgml-dashboard/src/api/deployment/projects.rs @@ -16,7 +16,7 @@ use crate::utils::urls; // Returns the deployments projects page. #[get("/projects")] -pub async fn projects(cluster: &Cluster) -> Result { +pub async fn projects(cluster: &Cluster, _connected: ConnectedCluster<'_>) -> Result { let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); layout.breadcrumbs(vec![NavLink::new("Projects", &urls::deployment_projects()).active()]); @@ -32,7 +32,7 @@ pub async fn projects(cluster: &Cluster) -> Result { // Return the specified project page. #[get("/projects/")] -pub async fn project(cluster: &Cluster, project_id: i64) -> Result { +pub async fn project(cluster: &Cluster, project_id: i64, _connected: ConnectedCluster<'_>) -> Result { let project = models::Project::get_by_id(cluster.pool(), project_id).await?; let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); diff --git a/pgml-dashboard/src/api/deployment/snapshots.rs b/pgml-dashboard/src/api/deployment/snapshots.rs index 2240cef90..d3b1b2d65 100644 --- a/pgml-dashboard/src/api/deployment/snapshots.rs +++ b/pgml-dashboard/src/api/deployment/snapshots.rs @@ -17,7 +17,7 @@ use std::collections::HashMap; // Returns snapshots page #[get("/snapshots")] -pub async fn snapshots(cluster: &Cluster) -> Result { +pub async fn snapshots(cluster: &Cluster, _connected: ConnectedCluster<'_>) -> Result { let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); layout.breadcrumbs(vec![NavLink::new("Snapshots", &urls::deployment_snapshots()).active()]); @@ -33,7 +33,7 @@ pub async fn snapshots(cluster: &Cluster) -> Result { // Returns the specific snapshot page #[get("/snapshots/")] -pub async fn snapshot(cluster: &Cluster, snapshot_id: i64) -> Result { +pub async fn snapshot(cluster: &Cluster, snapshot_id: i64, _connected: ConnectedCluster<'_>) -> Result { let snapshot = models::Snapshot::get_by_id(cluster.pool(), snapshot_id).await?; let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); diff --git a/pgml-dashboard/src/api/deployment/uploader.rs b/pgml-dashboard/src/api/deployment/uploader.rs index fdad1665d..41f148007 100644 --- a/pgml-dashboard/src/api/deployment/uploader.rs +++ b/pgml-dashboard/src/api/deployment/uploader.rs @@ -19,7 +19,7 @@ use crate::utils::urls; // Returns the uploader page. #[get("/uploader")] -pub async fn uploader(cluster: &Cluster) -> Result { +pub async fn uploader(cluster: &Cluster, _connected: ConnectedCluster<'_>) -> Result { let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); layout.breadcrumbs(vec![NavLink::new("Upload Data", &urls::deployment_uploader()).active()]); diff --git a/pgml-dashboard/src/guards.rs b/pgml-dashboard/src/guards.rs index e7b48bf60..3e8d4fb94 100644 --- a/pgml-dashboard/src/guards.rs +++ b/pgml-dashboard/src/guards.rs @@ -82,6 +82,7 @@ pub struct ConnectedCluster<'a> { pub inner: &'a Cluster, } +// 404 rather than 500 if the cluster is not connected. #[rocket::async_trait] impl<'r> FromRequest<'r> for ConnectedCluster<'r> { type Error = (); From ce2a0ee719e8f4f92dc2173376f4efdd5bd57a5e Mon Sep 17 00:00:00 2001 From: Dan <39170265+chillenberger@users.noreply.github.com> Date: Fri, 14 Jun 2024 13:47:33 -0600 Subject: [PATCH 2/2] fmt --- pgml-dashboard/src/api/deployment/notebooks.rs | 6 +++++- pgml-dashboard/src/api/deployment/projects.rs | 6 +++++- pgml-dashboard/src/api/deployment/snapshots.rs | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pgml-dashboard/src/api/deployment/notebooks.rs b/pgml-dashboard/src/api/deployment/notebooks.rs index 06faf00ec..25701c0ca 100644 --- a/pgml-dashboard/src/api/deployment/notebooks.rs +++ b/pgml-dashboard/src/api/deployment/notebooks.rs @@ -36,7 +36,11 @@ pub async fn notebooks(cluster: &Cluster, _connected: ConnectedCluster<'_>) -> R // Returns the specified notebook page. #[get("/notebooks/")] -pub async fn notebook(cluster: &Cluster, notebook_id: i64, _connected: ConnectedCluster<'_>) -> Result { +pub async fn notebook( + cluster: &Cluster, + notebook_id: i64, + _connected: ConnectedCluster<'_>, +) -> Result { let notebook = models::Notebook::get_by_id(cluster.pool(), notebook_id).await?; let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); diff --git a/pgml-dashboard/src/api/deployment/projects.rs b/pgml-dashboard/src/api/deployment/projects.rs index f4f5e5867..3a1e060e0 100644 --- a/pgml-dashboard/src/api/deployment/projects.rs +++ b/pgml-dashboard/src/api/deployment/projects.rs @@ -32,7 +32,11 @@ pub async fn projects(cluster: &Cluster, _connected: ConnectedCluster<'_>) -> Re // Return the specified project page. #[get("/projects/")] -pub async fn project(cluster: &Cluster, project_id: i64, _connected: ConnectedCluster<'_>) -> Result { +pub async fn project( + cluster: &Cluster, + project_id: i64, + _connected: ConnectedCluster<'_>, +) -> Result { let project = models::Project::get_by_id(cluster.pool(), project_id).await?; let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); diff --git a/pgml-dashboard/src/api/deployment/snapshots.rs b/pgml-dashboard/src/api/deployment/snapshots.rs index d3b1b2d65..ed87d48e7 100644 --- a/pgml-dashboard/src/api/deployment/snapshots.rs +++ b/pgml-dashboard/src/api/deployment/snapshots.rs @@ -33,7 +33,11 @@ pub async fn snapshots(cluster: &Cluster, _connected: ConnectedCluster<'_>) -> R // Returns the specific snapshot page #[get("/snapshots/")] -pub async fn snapshot(cluster: &Cluster, snapshot_id: i64, _connected: ConnectedCluster<'_>) -> Result { +pub async fn snapshot( + cluster: &Cluster, + snapshot_id: i64, + _connected: ConnectedCluster<'_>, +) -> Result { let snapshot = models::Snapshot::get_by_id(cluster.pool(), snapshot_id).await?; let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy