make progress visable and only show registration if enabled

This commit is contained in:
C4illin
2024-05-29 13:52:00 +02:00
parent b134b19876
commit ff176028d1
8 changed files with 42 additions and 20 deletions

View File

@@ -47,8 +47,5 @@ COPY --from=install /temp/prod/node_modules node_modules
# COPY --from=prerelease /app/package.json . # COPY --from=prerelease /app/package.json .
COPY . . COPY . .
# create folder data
RUN mkdir -p /app/data && chmod 755 /app/data
EXPOSE 3000/tcp EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "./src/index.tsx" ] ENTRYPOINT [ "bun", "run", "./src/index.tsx" ]

View File

@@ -31,9 +31,9 @@ services:
image: ghcr.io/c4illin/convertx:main image: ghcr.io/c4illin/convertx:main
ports: ports:
- "3000:3000" - "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) - 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 - HTTP_ALLOWED=false # setting this to true is unsafe, only set this to true locally
volumes: volumes:
- convertx:/app/data - convertx:/app/data

View File

@@ -5,6 +5,7 @@ services:
volumes: volumes:
- ./data:/app/data - ./data:/app/data
environment: environment:
NODE_ENV: production - ACCOUNT_REGISTRATION=true
- JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234
ports: ports:
- 3000:3000 - 3000:3000

View File

@@ -1,4 +1,7 @@
export const Header = ({ loggedIn }: { loggedIn?: boolean }) => { export const Header = ({
loggedIn,
accountRegistration,
}: { loggedIn?: boolean; accountRegistration?: boolean }) => {
let rightNav: JSX.Element; let rightNav: JSX.Element;
if (loggedIn) { if (loggedIn) {
rightNav = ( rightNav = (
@@ -17,15 +20,17 @@ export const Header = ({ loggedIn }: { loggedIn?: boolean }) => {
<li> <li>
<a href="/login">Login</a> <a href="/login">Login</a>
</li> </li>
<li> {accountRegistration && (
<a href="/register">Register</a> <li>
</li> <a href="/register">Register</a>
</li>
)}
</ul> </ul>
); );
} }
return ( return (
<header class="container"> <header className="container">
<nav> <nav>
<ul> <ul>
<li> <li>

View File

@@ -115,7 +115,7 @@ export function convert(
// } // }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
exec(`vips copy ${filePath} ${targetPath}`, (error, stdout, stderr) => { exec(`vips copy "${filePath}" "${targetPath}"`, (error, stdout, stderr) => {
if (error) { if (error) {
reject(`error: ${error}`); reject(`error: ${error}`);
} }

View File

@@ -8,6 +8,8 @@ export const normalizeFiletype = (filetype: string): string => {
return "html"; return "html";
case "tex": case "tex":
return "latex"; return "latex";
case "md":
return "markdown";
default: default:
return lowercaseFiletype; return lowercaseFiletype;
} }
@@ -21,6 +23,8 @@ export const normalizeOutputFiletype = (filetype: string): string => {
return "jpg"; return "jpg";
case "latex": case "latex":
return "tex"; return "tex";
case "markdown":
return "md";
default: default:
return lowercaseFiletype; return lowercaseFiletype;
} }

View File

@@ -169,7 +169,7 @@ const app = new Elysia()
return ( return (
<BaseHtml title="ConvertX | Register"> <BaseHtml title="ConvertX | Register">
<Header /> <Header accountRegistration={ACCOUNT_REGISTRATION} />
<main class="container"> <main class="container">
<article> <article>
<form method="post"> <form method="post">
@@ -180,6 +180,7 @@ const app = new Elysia()
type="email" type="email"
name="email" name="email"
placeholder="Email" placeholder="Email"
autocomplete="email"
required required
/> />
</label> </label>
@@ -189,6 +190,7 @@ const app = new Elysia()
type="password" type="password"
name="password" name="password"
placeholder="Password" placeholder="Password"
autocomplete="new-password"
required required
/> />
</label> </label>
@@ -273,7 +275,7 @@ const app = new Elysia()
return ( return (
<BaseHtml title="ConvertX | Login"> <BaseHtml title="ConvertX | Login">
<Header /> <Header accountRegistration={ACCOUNT_REGISTRATION} />
<main class="container"> <main class="container">
<article> <article>
<form method="post"> <form method="post">
@@ -284,6 +286,7 @@ const app = new Elysia()
type="email" type="email"
name="email" name="email"
placeholder="Email" placeholder="Email"
autocomplete="email"
required required
/> />
</label> </label>
@@ -293,6 +296,7 @@ const app = new Elysia()
type="password" type="password"
name="password" name="password"
placeholder="Password" placeholder="Password"
autocomplete="current-password"
required required
/> />
</label> </label>
@@ -789,8 +793,12 @@ const app = new Elysia()
type="button" type="button"
style={{ width: "10rem", float: "right" }} style={{ width: "10rem", float: "right" }}
onclick="downloadAll()" onclick="downloadAll()"
{...(files.length !== job.num_files && { disabled: true })}> {...(files.length !== job.num_files
Download All ? { disabled: true, "aria-busy": "true" }
: "")}>
{files.length === job.num_files
? "Download All"
: "Converting..."}
</button> </button>
</div> </div>
</div> </div>
@@ -877,8 +885,12 @@ const app = new Elysia()
type="button" type="button"
style={{ width: "10rem", float: "right" }} style={{ width: "10rem", float: "right" }}
onclick="downloadAll()" onclick="downloadAll()"
{...(files.length !== job.num_files && { disabled: true })}> {...(files.length !== job.num_files
Download All ? { disabled: true, "aria-busy": "true" }
: "")}>
{files.length === job.num_files
? "Download All"
: "Converting..."}
</button> </button>
</div> </div>
</div> </div>

View File

@@ -13,9 +13,10 @@ window.downloadAll = function () {
}; };
const jobId = window.location.pathname.split("/").pop(); const jobId = window.location.pathname.split("/").pop();
const main = document.querySelector("main"); const main = document.querySelector("main");
const progressElem = document.querySelector("progress"); let progressElem = document.querySelector("progress");
const refreshData = () => { const refreshData = () => {
// console.log("Refreshing data...", progressElem.value, progressElem.max);
if (progressElem.value !== progressElem.max) { if (progressElem.value !== progressElem.max) {
fetch(`/progress/${jobId}`, { fetch(`/progress/${jobId}`, {
method: "POST", method: "POST",
@@ -28,6 +29,8 @@ const refreshData = () => {
setTimeout(refreshData, 1000); setTimeout(refreshData, 1000);
} }
progressElem = document.querySelector("progress");
}; };
refreshData(); refreshData();