Skip to content

Commit 6e2399e

Browse files
committed
fix: changed to patch and fixed job path call on table
1 parent 28bfdf0 commit 6e2399e

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { Sidequest } from "sidequest";
2+
import { MyJob } from "./main_job.js";
3+
4+
await Sidequest.start();
5+
await Sidequest.build(MyJob).availableAt(new Date(9999999999999)).enqueue();

main_job.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Job } from "sidequest";
2+
3+
export class MyJob extends Job {
4+
async run() {
5+
await new Promise((resolve) => setTimeout(resolve, 5_000));
6+
return { test: true };
7+
}
8+
}

packages/dashboard/src/resources/jobs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobsRouter.get("/:id", async (req, res) => {
100100
}
101101
});
102102

103-
jobsRouter.post("/:id/run", async (req, res) => {
103+
jobsRouter.patch("/:id/run", async (req, res) => {
104104
const backend = getBackend();
105105

106106
const jobId = parseInt(req.params.id);

packages/dashboard/src/views/pages/job.ejs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<section class="space-y-6"
22
id="job-details"
3-
hx-get="/job/<%= job.id %>"
3+
hx-get="/jobs/<%= job.id %>"
44
hx-swap="outerHTML"
5-
hx-trigger="every 3s"
5+
hx-trigger="every 3s, runJob"
66
>
77
<div class="flex w-full">
88
<h1 class="text-2xl font-bold flex-1">
@@ -19,6 +19,9 @@
1919
</span>
2020
</h1>
2121
<div class="flex justify-end space-x-2">
22+
<% if (job.available_at > new Date()) { %>
23+
<button type="button" class="btn btn-sm btn-outline" hx-patch="/jobs/<%= job.id %>/run"><i data-feather="play" class="w-4 h-4"></i>Run</button>
24+
<% } %>
2225
<button class="btn btn-sm btn-outline"><i data-feather="x" class="w-4 h-4"></i>Cancel</button>
2326
<button class="btn btn-sm btn-outline"><i data-feather="refresh-ccw" class="w-4 h-4"></i>Re-Run</button>
2427
<button class="btn btn-sm btn-outline"><i data-feather="trash" class="w-4 h-4"></i>Delete</button>

packages/dashboard/src/views/partials/jobs-table.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<td class="px-4 py-3 text-base-content"><%= job.claimed_by || '-' %></td>
3737
<% if (job.available_at > new Date()) { %>
3838
<td class="px-4 py-3">
39-
<button type="button" class="btn btn-sm" hx-post="/jobs/<%= job.id %>/run">Run</button>
39+
<button type="button" class="btn btn-sm" hx-patch="/jobs/<%= job.id %>/run">Run</button>
4040
</td>
4141
<% } %>
4242
</tr>

0 commit comments

Comments
 (0)