Skip to content

Commit 64264a4

Browse files
authored
feat: add delete button in history (#440)
1 parent 0096a6f commit 64264a4

File tree

8 files changed

+122
-104
lines changed

8 files changed

+122
-104
lines changed

bun.lock

Lines changed: 75 additions & 65 deletions
Large diffs are not rendered by default.

knip.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
"project": ["src/**/*.ts", "src/**/*.tsx", "tests/**/*.ts"],
55
"tailwind": {
66
"entry": ["src/main.css"]
7-
},
8-
"ignoreDependencies": ["tailwind-scrollbar"]
7+
}
98
}

mise.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[tools]
22
bun = "1.2.2"
3+
4+
[env]
5+
JWT_SECRET = "JustForDevelopmentPurposesOnlyChangeMeInProduction!"

package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,36 @@
1818
"dependencies": {
1919
"@elysiajs/html": "^1.4.0",
2020
"@elysiajs/jwt": "^1.4.0",
21-
"@elysiajs/static": "^1.4.4",
22-
"@kitajs/html": "^4.2.10",
23-
"elysia": "^1.4.13",
21+
"@elysiajs/static": "^1.4.6",
22+
"@kitajs/html": "^4.2.11",
23+
"elysia": "^1.4.16",
2424
"sanitize-filename": "^1.6.3",
25-
"tar": "^7.5.1"
25+
"tar": "^7.5.2"
2626
},
2727
"module": "src/index.tsx",
2828
"type": "module",
2929
"bun-create": {
3030
"start": "bun run src/index.tsx"
3131
},
3232
"devDependencies": {
33-
"@eslint/js": "^9.38.0",
33+
"@eslint/js": "^9.39.1",
3434
"@kitajs/ts-html-plugin": "^4.1.3",
35-
"@tailwindcss/cli": "^4.1.16",
36-
"@tailwindcss/postcss": "^4.1.16",
35+
"@tailwindcss/cli": "^4.1.17",
36+
"@tailwindcss/postcss": "^4.1.17",
3737
"@types/bun": "latest",
38-
"@types/node": "^24.9.2",
39-
"@typescript-eslint/parser": "^8.46.2",
40-
"eslint": "^9.38.0",
38+
"@types/node": "^24.10.1",
39+
"@typescript-eslint/parser": "^8.46.4",
40+
"eslint": "^9.39.1",
4141
"eslint-plugin-better-tailwindcss": "^3.7.10",
42-
"globals": "^16.4.0",
43-
"knip": "^5.66.4",
42+
"globals": "^16.5.0",
43+
"knip": "^5.69.1",
4444
"npm-run-all2": "^8.0.4",
4545
"postcss": "^8.5.6",
4646
"prettier": "^3.6.2",
4747
"tailwind-scrollbar": "^4.0.2",
48-
"tailwindcss": "^4.1.16",
48+
"tailwindcss": "^4.1.17",
4949
"typescript": "^5.9.3",
50-
"typescript-eslint": "^8.46.2"
50+
"typescript-eslint": "^8.46.4"
5151
},
5252
"trustedDependencies": [
5353
"@parcel/watcher",

src/pages/deleteJob.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { userService } from "./user";
77
import { Jobs } from "../db/types";
88

99
export const deleteJob = new Elysia().use(userService).get(
10-
"/delete/:userId/:jobId",
10+
"/delete/:jobId",
1111
async ({ params, redirect, user }) => {
1212
const job = db
1313
.query("SELECT * FROM jobs WHERE user_id = ? AND id = ?")

src/pages/download.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const download = new Elysia()
1212
.get(
1313
"/download/:userId/:jobId/:fileName",
1414
async ({ params, redirect, user }) => {
15+
const userId = user.id;
1516
const job = await db
1617
.query("SELECT * FROM jobs WHERE user_id = ? AND id = ?")
1718
.get(user.id, params.jobId);
@@ -20,7 +21,6 @@ export const download = new Elysia()
2021
return redirect(`${WEBROOT}/results`, 302);
2122
}
2223
// parse from URL encoded string
23-
const userId = decodeURIComponent(params.userId);
2424
const jobId = decodeURIComponent(params.jobId);
2525
const fileName = sanitize(decodeURIComponent(params.fileName));
2626

@@ -32,8 +32,9 @@ export const download = new Elysia()
3232
},
3333
)
3434
.get(
35-
"/archive/:userId/:jobId",
35+
"/archive/:jobId",
3636
async ({ params, redirect, user }) => {
37+
const userId = user.id;
3738
const job = await db
3839
.query("SELECT * FROM jobs WHERE user_id = ? AND id = ?")
3940
.get(user.id, params.jobId);
@@ -42,7 +43,6 @@ export const download = new Elysia()
4243
return redirect(`${WEBROOT}/results`, 302);
4344
}
4445

45-
const userId = decodeURIComponent(params.userId);
4646
const jobId = decodeURIComponent(params.jobId);
4747
const outputPath = `${outputDir}${userId}/${jobId}`;
4848
const outputTar = path.join(outputPath, `converted_files_${jobId}.tar`);

src/pages/history.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import db from "../db/db";
55
import { Filename, Jobs } from "../db/types";
66
import { ALLOW_UNAUTHENTICATED, HIDE_HISTORY, LANGUAGE, WEBROOT } from "../helpers/env";
77
import { userService } from "./user";
8+
import { EyeIcon } from "../icons/eye";
9+
import { DeleteIcon } from "../icons/delete";
810

911
export const history = new Elysia().use(userService).get(
1012
"/history",
@@ -102,7 +104,7 @@ export const history = new Elysia().use(userService).get(
102104
sm:px-4
103105
`}
104106
>
105-
View
107+
Actions
106108
</th>
107109
</tr>
108110
</thead>
@@ -131,15 +133,24 @@ export const history = new Elysia().use(userService).get(
131133
<td>{job.num_files}</td>
132134
<td class="max-sm:hidden">{job.finished_files}</td>
133135
<td safe>{job.status}</td>
134-
<td>
136+
<td class="flex flex-row gap-4">
135137
<a
136138
class={`
137139
text-accent-500 underline
138140
hover:text-accent-400
139141
`}
140142
href={`${WEBROOT}/results/${job.id}`}
141143
>
142-
View
144+
<EyeIcon />
145+
</a>
146+
<a
147+
class={`
148+
text-accent-500 underline
149+
hover:text-accent-400
150+
`}
151+
href={`${WEBROOT}/delete/${job.id}`}
152+
>
153+
<DeleteIcon />
143154
</a>
144155
</td>
145156
</tr>

src/pages/results.tsx

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { JWTPayloadSpec } from "@elysiajs/jwt";
21
import { Elysia } from "elysia";
32
import { BaseHtml } from "../components/base";
43
import { Header } from "../components/header";
@@ -11,14 +10,10 @@ import { EyeIcon } from "../icons/eye";
1110
import { userService } from "./user";
1211

1312
function ResultsArticle({
14-
user,
1513
job,
1614
files,
1715
outputPath,
1816
}: {
19-
user: {
20-
id: string;
21-
} & JWTPayloadSpec;
2217
job: Jobs;
2318
files: Filename[];
2419
outputPath: string;
@@ -30,24 +25,24 @@ function ResultsArticle({
3025
<div class="flex flex-row gap-4">
3126
<a
3227
style={files.length !== job.num_files ? "pointer-events: none;" : ""}
33-
href={`${WEBROOT}/archive/${user.id}/${job.id}`}
34-
download={`converted_files_${job.id}.tar`}
35-
class="flex btn-primary flex-row gap-2 text-contrast"
28+
class="flex btn-secondary flex-row gap-2 text-contrast"
29+
href={`${WEBROOT}/delete/${job.id}`}
3630
{...(files.length !== job.num_files ? { disabled: true, "aria-busy": "true" } : "")}
3731
>
38-
<DownloadIcon /> <p>Tar</p>
32+
<DeleteIcon /> <p>Delete</p>
3933
</a>
40-
<button class="flex btn-primary flex-row gap-2 text-contrast" onclick="downloadAll()">
41-
<DownloadIcon /> <p>All</p>
42-
</button>
4334
<a
4435
style={files.length !== job.num_files ? "pointer-events: none;" : ""}
36+
href={`${WEBROOT}/archive/${job.id}`}
37+
download={`converted_files_${job.id}.tar`}
4538
class="flex btn-primary flex-row gap-2 text-contrast"
46-
href={`${WEBROOT}/delete/${user.id}/${job.id}`}
4739
{...(files.length !== job.num_files ? { disabled: true, "aria-busy": "true" } : "")}
4840
>
49-
<DeleteIcon /> <p>Delete</p>
41+
<DownloadIcon /> <p>Tar</p>
5042
</a>
43+
<button class="flex btn-primary flex-row gap-2 text-contrast" onclick="downloadAll()">
44+
<DownloadIcon /> <p>All</p>
45+
</button>
5146
</div>
5247
</div>
5348
<progress
@@ -172,7 +167,7 @@ export const results = new Elysia()
172167
sm:px-4
173168
`}
174169
>
175-
<ResultsArticle user={user} job={job} files={files} outputPath={outputPath} />
170+
<ResultsArticle job={job} files={files} outputPath={outputPath} />
176171
</main>
177172
<script src={`${WEBROOT}/results.js`} defer />
178173
</>
@@ -208,7 +203,7 @@ export const results = new Elysia()
208203
.as(Filename)
209204
.all(params.jobId);
210205

211-
return <ResultsArticle user={user} job={job} files={files} outputPath={outputPath} />;
206+
return <ResultsArticle job={job} files={files} outputPath={outputPath} />;
212207
},
213208
{ auth: true },
214209
);

0 commit comments

Comments
 (0)