From e5cb9aa848009ea22c1385e4d33b7edf372979fb Mon Sep 17 00:00:00 2001 From: Ahmad Mujahid <55625580+AhmadMuj@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:25:16 +0400 Subject: feat: Add PDF screenshot generation and display (#995) * Updated pdf2json to 3.1.5 * Extract and store a screenshot from PDF files using pdf2pic * Installing graphicsmagick and ghostscript * Generate Missing PDF screenshot with tidyAssets worker for backward support * Display PDF screenshot instead of the PDF in web if it exists. * Display PDF screenshot in mobile app if exists. * Updated pnpm-lock.yaml * Removed console.log * Revert the unnecessary changes in package.json * Revert pnpm-lock changes * Prevent rendering PDF files if the screenshot is not generated * refactor: replace useEffect with useMemo for section initialization * feat: show PDF file download button and handle large PDFs by defaulting to screenshot view * feat: add file size to openapi spec * feature: Add Assets preprocessing in fix mode to admin actions * i18n: add reprocess_assets_fix_mode translation * i18n: Add missing ar translations * A bunch of fixes * Fix openspec schema --------- Co-authored-by: Mohamed Bassem --- apps/web/components/admin/AdminActions.tsx | 22 ++++ .../components/dashboard/bookmarks/AssetCard.tsx | 28 ++++- .../dashboard/preview/AssetContentSection.tsx | 131 ++++++++++++++++----- .../components/dashboard/preview/AttachmentBox.tsx | 1 + apps/web/lib/i18n/locales/ar/translation.json | 33 +++++- apps/web/lib/i18n/locales/da/translation.json | 3 +- apps/web/lib/i18n/locales/de/translation.json | 3 +- apps/web/lib/i18n/locales/en/translation.json | 3 +- apps/web/lib/i18n/locales/es/translation.json | 3 +- apps/web/lib/i18n/locales/fr/translation.json | 3 +- apps/web/lib/i18n/locales/gl/translation.json | 3 +- apps/web/lib/i18n/locales/hr/translation.json | 3 +- apps/web/lib/i18n/locales/hu/translation.json | 3 +- apps/web/lib/i18n/locales/it/translation.json | 3 +- apps/web/lib/i18n/locales/pl/translation.json | 3 +- apps/web/lib/i18n/locales/ru/translation.json | 3 +- apps/web/lib/i18n/locales/tr/translation.json | 3 +- apps/web/lib/i18n/locales/zh/translation.json | 3 +- apps/web/lib/i18n/locales/zhtw/translation.json | 3 +- 19 files changed, 204 insertions(+), 53 deletions(-) (limited to 'apps/web') diff --git a/apps/web/components/admin/AdminActions.tsx b/apps/web/components/admin/AdminActions.tsx index 34b3d63a..fb151ac8 100644 --- a/apps/web/components/admin/AdminActions.tsx +++ b/apps/web/components/admin/AdminActions.tsx @@ -37,6 +37,21 @@ export default function AdminActions() { }, }); + const { mutate: reprocessAssetsFixMode, isPending: isReprocessingPending } = + api.admin.reprocessAssetsFixMode.useMutation({ + onSuccess: () => { + toast({ + description: "Reprocessing enqueued", + }); + }, + onError: (e) => { + toast({ + variant: "destructive", + description: e.message, + }); + }, + }); + const { mutate: reRunInferenceOnAllBookmarks, isPending: isInferencePending, @@ -124,6 +139,13 @@ export default function AdminActions() { > {t("admin.actions.reindex_all_bookmarks")} + reprocessAssetsFixMode()} + > + {t("admin.actions.reprocess_assets_fix_mode")} + r.assetType === "assetScreenshot", + )?.id; + if (!screenshotAssetId) { + return ( +
+ +
+ ); + } return ( -