🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pgml-dashboard/src/api/deployment/deployment_models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::collections::HashMap;

// Returns models page
#[get("/models")]
pub async fn deployment_models(cluster: &Cluster) -> Result<ResponseOk, Error> {
pub async fn deployment_models(cluster: &Cluster, _connected: ConnectedCluster<'_>) -> Result<ResponseOk, Error> {
let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster);
layout.breadcrumbs(vec![NavLink::new("Models", &urls::deployment_models()).active()]);

Expand All @@ -34,7 +34,7 @@ pub async fn deployment_models(cluster: &Cluster) -> Result<ResponseOk, Error> {

// Returns models page
#[get("/models/<model_id>")]
pub async fn model(cluster: &Cluster, model_id: i64) -> Result<ResponseOk, Error> {
pub async fn model(cluster: &Cluster, model_id: i64, _connected: ConnectedCluster<'_>) -> Result<ResponseOk, Error> {
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?;

Expand Down
8 changes: 6 additions & 2 deletions pgml-dashboard/src/api/deployment/notebooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::utils::urls;

// Returns notebook page
#[get("/notebooks")]
pub async fn notebooks(cluster: &Cluster) -> Result<ResponseOk, Error> {
pub async fn notebooks(cluster: &Cluster, _connected: ConnectedCluster<'_>) -> Result<ResponseOk, Error> {
let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster);
layout.breadcrumbs(vec![NavLink::new("Notebooks", &urls::deployment_notebooks()).active()]);

Expand All @@ -36,7 +36,11 @@ pub async fn notebooks(cluster: &Cluster) -> Result<ResponseOk, Error> {

// Returns the specified notebook page.
#[get("/notebooks/<notebook_id>")]
pub async fn notebook(cluster: &Cluster, notebook_id: i64) -> Result<ResponseOk, Error> {
pub async fn notebook(
cluster: &Cluster,
notebook_id: i64,
_connected: ConnectedCluster<'_>,
) -> Result<ResponseOk, Error> {
let notebook = models::Notebook::get_by_id(cluster.pool(), notebook_id).await?;

let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster);
Expand Down
8 changes: 6 additions & 2 deletions pgml-dashboard/src/api/deployment/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::utils::urls;

// Returns the deployments projects page.
#[get("/projects")]
pub async fn projects(cluster: &Cluster) -> Result<ResponseOk, Error> {
pub async fn projects(cluster: &Cluster, _connected: ConnectedCluster<'_>) -> Result<ResponseOk, Error> {
let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster);
layout.breadcrumbs(vec![NavLink::new("Projects", &urls::deployment_projects()).active()]);

Expand All @@ -32,7 +32,11 @@ pub async fn projects(cluster: &Cluster) -> Result<ResponseOk, Error> {

// Return the specified project page.
#[get("/projects/<project_id>")]
pub async fn project(cluster: &Cluster, project_id: i64) -> Result<ResponseOk, Error> {
pub async fn project(
cluster: &Cluster,
project_id: i64,
_connected: ConnectedCluster<'_>,
) -> Result<ResponseOk, Error> {
let project = models::Project::get_by_id(cluster.pool(), project_id).await?;

let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster);
Expand Down
8 changes: 6 additions & 2 deletions pgml-dashboard/src/api/deployment/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::collections::HashMap;

// Returns snapshots page
#[get("/snapshots")]
pub async fn snapshots(cluster: &Cluster) -> Result<ResponseOk, Error> {
pub async fn snapshots(cluster: &Cluster, _connected: ConnectedCluster<'_>) -> Result<ResponseOk, Error> {
let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster);
layout.breadcrumbs(vec![NavLink::new("Snapshots", &urls::deployment_snapshots()).active()]);

Expand All @@ -33,7 +33,11 @@ pub async fn snapshots(cluster: &Cluster) -> Result<ResponseOk, Error> {

// Returns the specific snapshot page
#[get("/snapshots/<snapshot_id>")]
pub async fn snapshot(cluster: &Cluster, snapshot_id: i64) -> Result<ResponseOk, Error> {
pub async fn snapshot(
cluster: &Cluster,
snapshot_id: i64,
_connected: ConnectedCluster<'_>,
) -> Result<ResponseOk, Error> {
let snapshot = models::Snapshot::get_by_id(cluster.pool(), snapshot_id).await?;

let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster);
Expand Down
2 changes: 1 addition & 1 deletion pgml-dashboard/src/api/deployment/uploader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::utils::urls;

// Returns the uploader page.
#[get("/uploader")]
pub async fn uploader(cluster: &Cluster) -> Result<ResponseOk, Error> {
pub async fn uploader(cluster: &Cluster, _connected: ConnectedCluster<'_>) -> Result<ResponseOk, Error> {
let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster);
layout.breadcrumbs(vec![NavLink::new("Upload Data", &urls::deployment_uploader()).active()]);

Expand Down
1 change: 1 addition & 0 deletions pgml-dashboard/src/guards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ();
Expand Down