Skip to content

Dan product notifications #1534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a2a4ce2
checkpoint product notifications
chillenberger Jun 7, 2024
a555f4e
Merge branch 'master' into dan-product-notifications
chillenberger Jun 11, 2024
c9fefe0
checkpoint
chillenberger Jun 12, 2024
c432f03
Merge branch 'master' into dan-product-notifications
chillenberger Jun 12, 2024
495de99
backend working, front end design working
chillenberger Jun 12, 2024
c5b9932
add top level notices to layout
chillenberger Jun 12, 2024
4f5fdb2
add ability to show/hide modal with events and use this feature
chillenberger Jun 12, 2024
11c455b
all for many high level notifications
chillenberger Jun 14, 2024
aa26bc3
clean up code, prevent modal collision
chillenberger Jun 14, 2024
d6c598c
fmt
chillenberger Jun 14, 2024
ff02bb7
Merge branch 'master' into dan-product-notifications
chillenberger Jun 14, 2024
270032a
add product marketing banner to layout
chillenberger Jun 14, 2024
2a67b62
adn new line
chillenberger Jun 14, 2024
0e11743
404 rather than 500 on misisng pool, add comment
chillenberger Jun 14, 2024
ce2a0ee
fmt
chillenberger Jun 14, 2024
a4b3e74
make session backwards compatible
chillenberger Jun 14, 2024
e1f64d6
add tests
chillenberger Jun 16, 2024
61cb28c
clean
chillenberger Jun 16, 2024
3bfee36
Session cookie deserializaiton
levkk Jun 17, 2024
23fb688
safely unwrap context notification
chillenberger Jun 17, 2024
7bc6f65
Merge remote-tracking branch 'origin/levkk-cookie-test' into dan-noti…
chillenberger Jun 17, 2024
c641b70
clean up tests
chillenberger Jun 17, 2024
9611e77
Merge branch 'dan-patch' into dan-product-notifications
chillenberger Jun 17, 2024
8db0e2f
Merge branch 'dan-notificatioins-backwards-compatible' into dan-produ…
chillenberger Jun 17, 2024
ae54142
Merge branch 'master' into dan-product-notifications
chillenberger Jun 17, 2024
5f612ff
add test if notification is none
chillenberger Jun 17, 2024
62aa76a
fmt
chillenberger Jun 17, 2024
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
107 changes: 2 additions & 105 deletions pgml-dashboard/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions pgml-dashboard/src/api/deployment/deployment_models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use rocket::route::Route;
use sailfish::TemplateOnce;

use crate::{
guards::Cluster,
guards::ConnectedCluster,
responses::{Error, ResponseOk},
};
Expand All @@ -17,8 +18,8 @@ use std::collections::HashMap;

// Returns models page
#[get("/models")]
pub async fn deployment_models(cluster: ConnectedCluster<'_>) -> Result<ResponseOk, Error> {
let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context);
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()]);

let tabs = vec![tabs::Tab {
Expand All @@ -28,16 +29,16 @@ pub async fn deployment_models(cluster: ConnectedCluster<'_>) -> Result<Response

let nav_tabs = tabs::Tabs::new(tabs, Some("Models"), Some("Models"))?;

Ok(ResponseOk(layout.render(templates::Dashboard { tabs: nav_tabs })))
Ok(ResponseOk(layout.render(templates::Dashboard::new(nav_tabs))))
}

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

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)),
Expand All @@ -51,7 +52,7 @@ pub async fn model(cluster: ConnectedCluster<'_>, model_id: i64) -> Result<Respo

let nav_tabs = tabs::Tabs::new(tabs, Some("Models"), Some("Models"))?;

Ok(ResponseOk(layout.render(templates::Dashboard { tabs: nav_tabs })))
Ok(ResponseOk(layout.render(templates::Dashboard::new(nav_tabs))))
}

#[get("/models_turboframe")]
Expand Down
16 changes: 10 additions & 6 deletions pgml-dashboard/src/api/deployment/notebooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use crate::utils::urls;

// Returns notebook page
#[get("/notebooks")]
pub async fn notebooks(cluster: ConnectedCluster<'_>) -> Result<ResponseOk, Error> {
let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context);
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()]);

let tabs = vec![tabs::Tab {
Expand All @@ -31,15 +31,19 @@ pub async fn notebooks(cluster: ConnectedCluster<'_>) -> Result<ResponseOk, Erro

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))))
}

// Returns the specified notebook page.
#[get("/notebooks/<notebook_id>")]
pub async fn notebook(cluster: ConnectedCluster<'_>, 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.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(),
Expand All @@ -52,7 +56,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))))
}

// Returns all the notebooks for a deployment in a turbo frame.
Expand Down
17 changes: 11 additions & 6 deletions pgml-dashboard/src/api/deployment/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use rocket::route::Route;
use sailfish::TemplateOnce;

use crate::{
guards::Cluster,
guards::ConnectedCluster,
responses::{Error, ResponseOk},
};
Expand All @@ -15,8 +16,8 @@ use crate::utils::urls;

// Returns the deployments projects page.
#[get("/projects")]
pub async fn projects(cluster: ConnectedCluster<'_>) -> Result<ResponseOk, Error> {
let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context);
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()]);

let tabs = vec![tabs::Tab {
Expand All @@ -26,15 +27,19 @@ pub async fn projects(cluster: ConnectedCluster<'_>) -> Result<ResponseOk, Error

let nav_tabs = tabs::Tabs::new(tabs, Some("Notebooks"), Some("Projects"))?;

Ok(ResponseOk(layout.render(templates::Dashboard { tabs: nav_tabs })))
Ok(ResponseOk(layout.render(templates::Dashboard::new(nav_tabs))))
}

// Return the specified project page.
#[get("/projects/<project_id>")]
pub async fn project(cluster: ConnectedCluster<'_>, 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.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(),
Expand All @@ -47,7 +52,7 @@ pub async fn project(cluster: ConnectedCluster<'_>, project_id: i64) -> Result<R

let nav_tabs = tabs::Tabs::new(tabs, Some("Projects"), Some("Projects"))?;

Ok(ResponseOk(layout.render(templates::Dashboard { tabs: nav_tabs })))
Ok(ResponseOk(layout.render(templates::Dashboard::new(nav_tabs))))
}

// Returns all the deployments for the project in a turbo frame.
Expand Down
17 changes: 11 additions & 6 deletions pgml-dashboard/src/api/deployment/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use rocket::route::Route;
use sailfish::TemplateOnce;

use crate::{
guards::Cluster,
guards::ConnectedCluster,
responses::{Error, ResponseOk},
};
Expand All @@ -16,8 +17,8 @@ use std::collections::HashMap;

// Returns snapshots page
#[get("/snapshots")]
pub async fn snapshots(cluster: ConnectedCluster<'_>) -> Result<ResponseOk, Error> {
let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context);
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()]);

let tabs = vec![tabs::Tab {
Expand All @@ -27,15 +28,19 @@ pub async fn snapshots(cluster: ConnectedCluster<'_>) -> Result<ResponseOk, Erro

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))))
}

// Returns the specific snapshot page
#[get("/snapshots/<snapshot_id>")]
pub async fn snapshot(cluster: ConnectedCluster<'_>, 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.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(),
Expand All @@ -48,7 +53,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))))
}

// Returns all snapshots for the deployment in a turboframe.
Expand Down
7 changes: 4 additions & 3 deletions pgml-dashboard/src/api/deployment/uploader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use rocket::route::Route;
use sailfish::TemplateOnce;

use crate::{
guards::Cluster,
guards::ConnectedCluster,
responses::{BadRequest, Error, ResponseOk},
};
Expand All @@ -18,8 +19,8 @@ use crate::utils::urls;

// Returns the uploader page.
#[get("/uploader")]
pub async fn uploader(cluster: ConnectedCluster<'_>) -> Result<ResponseOk, Error> {
let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context);
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()]);

let tabs = vec![tabs::Tab {
Expand All @@ -29,7 +30,7 @@ pub async fn uploader(cluster: ConnectedCluster<'_>) -> Result<ResponseOk, Error

let nav_tabs = tabs::Tabs::new(tabs, Some("Upload Data"), Some("Upload Data"))?;

Ok(ResponseOk(layout.render(templates::Dashboard { tabs: nav_tabs })))
Ok(ResponseOk(layout.render(templates::Dashboard::new(nav_tabs))))
}

// Returns uploader module in a turboframe.
Expand Down
2 changes: 1 addition & 1 deletion pgml-dashboard/src/components/layouts/head/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ mod default_head_template_test {

#[test]
fn set_head() {
let mut head = Head::new()
let head = Head::new()
.title("test title")
.description("test description")
.image("image/test_image.jpg");
Expand Down
Loading