Skip to content

Commit

Permalink
make progress visable and only show registration if enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
C4illin committed May 29, 2024
1 parent b134b19 commit ff17602
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 20 deletions.
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,5 @@ COPY --from=install /temp/prod/node_modules node_modules
# COPY --from=prerelease /app/package.json .
COPY . .

# create folder data
RUN mkdir -p /app/data && chmod 755 /app/data

EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "./src/index.tsx" ]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ services:
image: ghcr.io/c4illin/convertx:main
ports:
- "3000:3000"
environment: # Defaults are listed below
environment: # Defaults are listed below. All are optional.
- ACCOUNT_REGISTRATION=false # true or false, doesn't matter for the first account (e.g. keep this to false if you only want one account)
- JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234
- JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234 # will use randomUUID() by default
- HTTP_ALLOWED=false # setting this to true is unsafe, only set this to true locally
volumes:
- convertx:/app/data
Expand Down
3 changes: 2 additions & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
volumes:
- ./data:/app/data
environment:
NODE_ENV: production
- ACCOUNT_REGISTRATION=true
- JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234
ports:
- 3000:3000
17 changes: 11 additions & 6 deletions src/components/header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export const Header = ({ loggedIn }: { loggedIn?: boolean }) => {
export const Header = ({
loggedIn,
accountRegistration,
}: { loggedIn?: boolean; accountRegistration?: boolean }) => {
let rightNav: JSX.Element;
if (loggedIn) {
rightNav = (
Expand All @@ -17,15 +20,17 @@ export const Header = ({ loggedIn }: { loggedIn?: boolean }) => {
<li>
<a href="/login">Login</a>
</li>
<li>
<a href="/register">Register</a>
</li>
{accountRegistration && (
<li>
<a href="/register">Register</a>
</li>
)}
</ul>
);
}

return (
<header class="container">
<header className="container">
<nav>
<ul>
<li>
Expand All @@ -45,4 +50,4 @@ export const Header = ({ loggedIn }: { loggedIn?: boolean }) => {
</nav>
</header>
);
};
};
2 changes: 1 addition & 1 deletion src/converters/vips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function convert(
// }

return new Promise((resolve, reject) => {
exec(`vips copy ${filePath} ${targetPath}`, (error, stdout, stderr) => {
exec(`vips copy "${filePath}" "${targetPath}"`, (error, stdout, stderr) => {
if (error) {
reject(`error: ${error}`);
}
Expand Down
4 changes: 4 additions & 0 deletions src/helpers/normalizeFiletype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const normalizeFiletype = (filetype: string): string => {
return "html";
case "tex":
return "latex";
case "md":
return "markdown";
default:
return lowercaseFiletype;
}
Expand All @@ -21,6 +23,8 @@ export const normalizeOutputFiletype = (filetype: string): string => {
return "jpg";
case "latex":
return "tex";
case "markdown":
return "md";
default:
return lowercaseFiletype;
}
Expand Down
24 changes: 18 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const app = new Elysia()

return (
<BaseHtml title="ConvertX | Register">
<Header />
<Header accountRegistration={ACCOUNT_REGISTRATION} />
<main class="container">
<article>
<form method="post">
Expand All @@ -180,6 +180,7 @@ const app = new Elysia()
type="email"
name="email"
placeholder="Email"
autocomplete="email"
required
/>
</label>
Expand All @@ -189,6 +190,7 @@ const app = new Elysia()
type="password"
name="password"
placeholder="Password"
autocomplete="new-password"
required
/>
</label>
Expand Down Expand Up @@ -273,7 +275,7 @@ const app = new Elysia()

return (
<BaseHtml title="ConvertX | Login">
<Header />
<Header accountRegistration={ACCOUNT_REGISTRATION} />
<main class="container">
<article>
<form method="post">
Expand All @@ -284,6 +286,7 @@ const app = new Elysia()
type="email"
name="email"
placeholder="Email"
autocomplete="email"
required
/>
</label>
Expand All @@ -293,6 +296,7 @@ const app = new Elysia()
type="password"
name="password"
placeholder="Password"
autocomplete="current-password"
required
/>
</label>
Expand Down Expand Up @@ -789,8 +793,12 @@ const app = new Elysia()
type="button"
style={{ width: "10rem", float: "right" }}
onclick="downloadAll()"
{...(files.length !== job.num_files && { disabled: true })}>
Download All
{...(files.length !== job.num_files
? { disabled: true, "aria-busy": "true" }
: "")}>
{files.length === job.num_files
? "Download All"
: "Converting..."}
</button>
</div>
</div>
Expand Down Expand Up @@ -877,8 +885,12 @@ const app = new Elysia()
type="button"
style={{ width: "10rem", float: "right" }}
onclick="downloadAll()"
{...(files.length !== job.num_files && { disabled: true })}>
Download All
{...(files.length !== job.num_files
? { disabled: true, "aria-busy": "true" }
: "")}>
{files.length === job.num_files
? "Download All"
: "Converting..."}
</button>
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/public/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ window.downloadAll = function () {
};
const jobId = window.location.pathname.split("/").pop();
const main = document.querySelector("main");
const progressElem = document.querySelector("progress");
let progressElem = document.querySelector("progress");

const refreshData = () => {
// console.log("Refreshing data...", progressElem.value, progressElem.max);
if (progressElem.value !== progressElem.max) {
fetch(`/progress/${jobId}`, {
method: "POST",
Expand All @@ -28,6 +29,8 @@ const refreshData = () => {

setTimeout(refreshData, 1000);
}

progressElem = document.querySelector("progress");
};

refreshData();

0 comments on commit ff17602

Please sign in to comment.