From ff176028d1be98d3822147cedc6e0613d1dd50e6 Mon Sep 17 00:00:00 2001 From: C4illin Date: Wed, 29 May 2024 13:52:00 +0200 Subject: [PATCH] make progress visable and only show registration if enabled --- Dockerfile | 3 --- README.md | 4 ++-- compose.yaml | 3 ++- src/components/header.tsx | 17 +++++++++++------ src/converters/vips.ts | 2 +- src/helpers/normalizeFiletype.ts | 4 ++++ src/index.tsx | 24 ++++++++++++++++++------ src/public/results.js | 5 ++++- 8 files changed, 42 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 224d0ed..0bb17c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] \ No newline at end of file diff --git a/README.md b/README.md index 51922c2..70070f1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/compose.yaml b/compose.yaml index 4fd02bb..0941302 100644 --- a/compose.yaml +++ b/compose.yaml @@ -5,6 +5,7 @@ services: volumes: - ./data:/app/data environment: - NODE_ENV: production + - ACCOUNT_REGISTRATION=true + - JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234 ports: - 3000:3000 diff --git a/src/components/header.tsx b/src/components/header.tsx index d81b0b1..6ed5aa1 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -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 = ( @@ -17,15 +20,17 @@ export const Header = ({ loggedIn }: { loggedIn?: boolean }) => {
  • Login
  • -
  • - Register -
  • + {accountRegistration && ( +
  • + Register +
  • + )} ); } return ( -
    +
    ); -}; +}; \ No newline at end of file diff --git a/src/converters/vips.ts b/src/converters/vips.ts index d1944df..5522d44 100644 --- a/src/converters/vips.ts +++ b/src/converters/vips.ts @@ -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}`); } diff --git a/src/helpers/normalizeFiletype.ts b/src/helpers/normalizeFiletype.ts index d04083b..9b4cc1d 100644 --- a/src/helpers/normalizeFiletype.ts +++ b/src/helpers/normalizeFiletype.ts @@ -8,6 +8,8 @@ export const normalizeFiletype = (filetype: string): string => { return "html"; case "tex": return "latex"; + case "md": + return "markdown"; default: return lowercaseFiletype; } @@ -21,6 +23,8 @@ export const normalizeOutputFiletype = (filetype: string): string => { return "jpg"; case "latex": return "tex"; + case "markdown": + return "md"; default: return lowercaseFiletype; } diff --git a/src/index.tsx b/src/index.tsx index 61aa20b..d58f34e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -169,7 +169,7 @@ const app = new Elysia() return ( -
    +
    @@ -180,6 +180,7 @@ const app = new Elysia() type="email" name="email" placeholder="Email" + autocomplete="email" required /> @@ -189,6 +190,7 @@ const app = new Elysia() type="password" name="password" placeholder="Password" + autocomplete="new-password" required /> @@ -273,7 +275,7 @@ const app = new Elysia() return ( -
    +
    @@ -284,6 +286,7 @@ const app = new Elysia() type="email" name="email" placeholder="Email" + autocomplete="email" required /> @@ -293,6 +296,7 @@ const app = new Elysia() type="password" name="password" placeholder="Password" + autocomplete="current-password" required /> @@ -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..."} @@ -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..."} diff --git a/src/public/results.js b/src/public/results.js index 662e06d..71bce55 100644 --- a/src/public/results.js +++ b/src/public/results.js @@ -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", @@ -28,6 +29,8 @@ const refreshData = () => { setTimeout(refreshData, 1000); } + + progressElem = document.querySelector("progress"); }; refreshData();