treewide: fix various UI bugs; optimize crypto dependencies & format
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: If8fe8b38c1d9c4fecd40ff71f88d2ae06a6a6964
This commit is contained in:
parent
764aafa88d
commit
3ccddce7fd
178 changed files with 58285 additions and 54241 deletions
|
|
@ -1,34 +1,38 @@
|
|||
use axum::Json;
|
||||
use axum::extract::{Path, State};
|
||||
|
||||
use crate::error::ApiError;
|
||||
use crate::state::AppState;
|
||||
use axum::{
|
||||
Json,
|
||||
extract::{Path, State},
|
||||
};
|
||||
use pinakes_core::jobs::Job;
|
||||
|
||||
use crate::{error::ApiError, state::AppState};
|
||||
|
||||
pub async fn list_jobs(State(state): State<AppState>) -> Json<Vec<Job>> {
|
||||
Json(state.job_queue.list().await)
|
||||
Json(state.job_queue.list().await)
|
||||
}
|
||||
|
||||
pub async fn get_job(
|
||||
State(state): State<AppState>,
|
||||
Path(id): Path<uuid::Uuid>,
|
||||
State(state): State<AppState>,
|
||||
Path(id): Path<uuid::Uuid>,
|
||||
) -> Result<Json<Job>, ApiError> {
|
||||
state.job_queue.status(id).await.map(Json).ok_or_else(|| {
|
||||
pinakes_core::error::PinakesError::NotFound(format!("job not found: {id}")).into()
|
||||
})
|
||||
state.job_queue.status(id).await.map(Json).ok_or_else(|| {
|
||||
pinakes_core::error::PinakesError::NotFound(format!("job not found: {id}"))
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn cancel_job(
|
||||
State(state): State<AppState>,
|
||||
Path(id): Path<uuid::Uuid>,
|
||||
State(state): State<AppState>,
|
||||
Path(id): Path<uuid::Uuid>,
|
||||
) -> Result<Json<serde_json::Value>, ApiError> {
|
||||
let cancelled = state.job_queue.cancel(id).await;
|
||||
if cancelled {
|
||||
Ok(Json(serde_json::json!({ "cancelled": true })))
|
||||
} else {
|
||||
Err(pinakes_core::error::PinakesError::NotFound(format!(
|
||||
"job not found or already finished: {id}"
|
||||
))
|
||||
.into())
|
||||
}
|
||||
let cancelled = state.job_queue.cancel(id).await;
|
||||
if cancelled {
|
||||
Ok(Json(serde_json::json!({ "cancelled": true })))
|
||||
} else {
|
||||
Err(
|
||||
pinakes_core::error::PinakesError::NotFound(format!(
|
||||
"job not found or already finished: {id}"
|
||||
))
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue