diff --git a/frontend/src/pages/jobs/index.vue b/frontend/src/pages/jobs/index.vue index e5ae5cf..ac38189 100644 --- a/frontend/src/pages/jobs/index.vue +++ b/frontend/src/pages/jobs/index.vue @@ -3,6 +3,7 @@ + :to="{ path: (item as Job).log_url.replace('https://buildit.aosc.io/logs/', '/web-logs/') }" + style="margin-right: 5px;margin-bottom: 5px;"> mdi:mdi-history View Log + + mdi:mdi-restart + + Restart + + + + Job restarted as #{{ newJobID }} + @@ -179,6 +196,7 @@ export default { data: () => ({ + page: 1, itemsPerPage: 25, headers: [ { title: 'Status', key: 'status', sortable: false }, @@ -189,15 +207,25 @@ loading: true, totalItems: 0, serverItems: [], + jobRestartSnackbar: false, + newJobID: 0, }), methods: { - async loadItems (opts: LoadItemsOpts) { + async loadItems () { this.loading = true; - let url = hostname + `/api/job/list?page=${opts.page}&items_per_page=${opts.itemsPerPage}`; + let url = hostname + `/api/job/list?page=${this.page}&items_per_page=${this.itemsPerPage}`; let data = (await axios.get(url)).data; this.totalItems = data.total_items; this.serverItems = data.items; this.loading = false; + }, + async restartJob (id: number) { + let data = (await axios.post(hostname + `/api/job/restart`, { + job_id: id, + })).data; + this.newJobID = data.job_id; + this.jobRestartSnackbar = true; + await this.loadItems(); } } } diff --git a/server/src/main.rs b/server/src/main.rs index 395f8e9..d28d866 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -8,8 +8,7 @@ use diesel::r2d2::Pool; use server::bot::{answer, Command}; use server::recycler::recycler_worker; use server::routes::{ - dashboard_status, job_info, job_list, ping, pipeline_info, pipeline_list, pipeline_new_pr, - worker_info, worker_job_update, worker_list, worker_poll, AppState, + dashboard_status, job_info, job_list, job_restart, ping, pipeline_info, pipeline_list, pipeline_new_pr, worker_info, worker_job_update, worker_list, worker_poll, AppState }; use server::routes::{pipeline_new, worker_heartbeat}; use server::routes::{pipeline_status, worker_status}; @@ -67,7 +66,7 @@ async fn main() -> anyhow::Result<()> { .route("/api/pipeline/info", get(pipeline_info)) .route("/api/job/list", get(job_list)) .route("/api/job/info", get(job_info)) - .route("/api/job/info", post(job_restart)) + .route("/api/job/restart", post(job_restart)) .route("/api/worker/heartbeat", post(worker_heartbeat)) .route("/api/worker/poll", post(worker_poll)) .route("/api/worker/job_update", post(worker_job_update)) @@ -103,6 +102,8 @@ async fn main() -> anyhow::Result<()> { let cors = CorsLayer::new() // allow `GET` and `POST` when accessing the resource .allow_methods([Method::GET, Method::POST]) + // allow `Content-Type: application/json` + .allow_headers([axum::http::header::CONTENT_TYPE]) // allow requests from any origin .allow_origin(Any); app = app.layer(cors); diff --git a/server/src/routes/job.rs b/server/src/routes/job.rs index 0ab0535..261fc4c 100644 --- a/server/src/routes/job.rs +++ b/server/src/routes/job.rs @@ -231,6 +231,6 @@ pub async fn job_restart( } Ok(Json(JobRestartResponse { - job_id: created_job.id, + job_id: new_job.id, })) }