diff --git a/backend/Cargo.toml b/backend/Cargo.toml index a8ec1b9..a8f4d05 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -6,8 +6,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -axum = { version = "0.7.2", features = ["macros"] } -tower-http = { version = "0.5.0", features = ["cors"] } +axum = { version = "0.7", features = ["macros"] } +tower-http = { version = "0.5", features = ["cors"] } tokio = { version = "1", features = ["full"] } sqlx = { version = "0.7", features = ["postgres", "uuid", "json", "chrono", "runtime-tokio", "tls-native-tls"] } tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } diff --git a/backend/src/main.rs b/backend/src/main.rs index 20660b6..0923a64 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -3,11 +3,11 @@ use std::fs::File; use std::sync::Arc; use axum::{Extension, Router}; -use axum::http::{StatusCode, Uri}; +use axum::http::{Method, StatusCode, Uri}; use axum::routing::{get, post}; use clap::Parser; use sqlx::postgres::PgPoolOptions; -use tower_http::cors::{Any, CorsLayer}; +use tower_http::cors::{AllowHeaders, Any, CorsLayer}; use tracing::{error, info}; use tracing::log::warn; use tracing_subscriber::layer::SubscriberExt; @@ -113,7 +113,12 @@ async fn main() { .layer(Extension(yaml_config)) .layer(Extension(tx)) .layer(Extension(pg_pool)) - .layer(CorsLayer::new().allow_origin(Any)); + .layer( + CorsLayer::new() + .allow_origin(Any) + .allow_methods(vec![Method::GET, Method::POST, Method::PUT, Method::DELETE, Method::OPTIONS]) + .allow_headers(AllowHeaders::any()) + ); //.route("/catalog/:id", get(catalog::get_catalog_by_id)) //.route("/catalog", post(catalog::create_catalog)); diff --git a/frontend/src/components/self-service/SelfServiceRunTable.tsx b/frontend/src/components/self-service/SelfServiceRunTable.tsx index b145b49..8befd02 100644 --- a/frontend/src/components/self-service/SelfServiceRunTable.tsx +++ b/frontend/src/components/self-service/SelfServiceRunTable.tsx @@ -1,14 +1,23 @@ import {classNames, millisToHumanTime} from "@/lib/utils.ts"; -const statuses = { - QUEUED: 'text-orange-400 bg-orange-400/10', - RUNNING: 'text-cyan-400 bg-cyan-400/10', - SUCCESS: 'text-green-400 bg-green-400/10', - FAILURE: 'text-rose-400 bg-rose-400/10' -} +function getStatusStyle(status: string): string { + if (status === 'QUEUED') { + return 'text-orange-400 bg-orange-400/10' + } -interface Props { - runs: any[] + if (status === 'RUNNING') { + return 'text-cyan-400 bg-cyan-400/10' + } + + if (status === 'SUCCESS') { + return 'text-green-400 bg-green-400/10' + } + + if (status === 'FAILURE') { + return 'text-rose-400 bg-rose-400/10' + } + + return 'text-gray-400 bg-gray-400/10' } function getTotalExecutionTime(tasks: any[]): number { @@ -39,6 +48,10 @@ function totalSuccessTasks(tasks: any[]): number { }, 0) } +interface Props { + runs: any[] +} + export default function SelfServiceRunTable({runs}: Props): JSX.Element { return (