From f0c39d3736cf6a0e64bfc44fd732d1ed270f4e82 Mon Sep 17 00:00:00 2001 From: Thanh Pham Date: Sun, 30 Apr 2023 19:37:57 -0400 Subject: [PATCH 1/8] added PDF extraction - first commit --- .gitignore | 7 + packages/client/hmi-client/src/api/api.ts | 6 +- .../src/components/documents/Document.vue | 526 ------------------ .../extracting/drag-n-drop-importer.vue | 256 +++++++++ .../components/extracting/file-preview.vue | 122 ++++ .../components/tera-project-overview.vue | 199 ++++++- .../client/hmi-client/src/types/common.ts | 7 + .../client/hmi-client/src/utils/log-buffer.ts | 8 +- .../extraction-server/docker/Dockerfile | 21 + .../extraction-server/docker/requirements.txt | 9 + .../extraction-server/pdfs/drylab.pdf | Bin 0 -> 1371239 bytes .../pdfs/samplecertifiedpdf.pdf | Bin 0 -> 58063 bytes .../pdfs/samplesecured_256bitaes_pdf.pdf | Bin 0 -> 21634 bytes .../pdfs/sampleunsecuredpdf.pdf | Bin 0 -> 22057 bytes packages/services/extraction-server/run.sh | 66 +++ .../services/extraction-server/src/app.py | 227 ++++++++ .../extraction-server/src/pdf_extraction.py | 126 +++++ .../extraction-server/src/supervisord.conf | 22 + packages/services/hmi-server/build.gradle | 1 + .../PDFExtractionServiceProxy.java | 33 ++ .../PDFExtractionMultipartBody.java | 14 + .../PDFExtractionResource.java | 50 ++ .../PDFExtractionUrlToPDFForm.java | 20 + .../src/main/resources/application.properties | 1 + 24 files changed, 1189 insertions(+), 532 deletions(-) delete mode 100644 packages/client/hmi-client/src/components/documents/Document.vue create mode 100644 packages/client/hmi-client/src/components/extracting/drag-n-drop-importer.vue create mode 100644 packages/client/hmi-client/src/components/extracting/file-preview.vue create mode 100644 packages/services/extraction-server/docker/Dockerfile create mode 100644 packages/services/extraction-server/docker/requirements.txt create mode 100644 packages/services/extraction-server/pdfs/drylab.pdf create mode 100644 packages/services/extraction-server/pdfs/samplecertifiedpdf.pdf create mode 100644 packages/services/extraction-server/pdfs/samplesecured_256bitaes_pdf.pdf create mode 100644 packages/services/extraction-server/pdfs/sampleunsecuredpdf.pdf create mode 100755 packages/services/extraction-server/run.sh create mode 100644 packages/services/extraction-server/src/app.py create mode 100644 packages/services/extraction-server/src/pdf_extraction.py create mode 100644 packages/services/extraction-server/src/supervisord.conf create mode 100644 packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/proxies/pdfextractionservice/PDFExtractionServiceProxy.java create mode 100644 packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/pdfextractionservice/PDFExtractionMultipartBody.java create mode 100644 packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/pdfextractionservice/PDFExtractionResource.java create mode 100644 packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/pdfextractionservice/PDFExtractionUrlToPDFForm.java diff --git a/.gitignore b/.gitignore index 780ef86453..186083f84d 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,10 @@ build # MISC create.sql .eslintcache + +# Python +__pycache__/ +response.txt +response.zip +output +uploads diff --git a/packages/client/hmi-client/src/api/api.ts b/packages/client/hmi-client/src/api/api.ts index b9ae6bb408..8bfe2410e9 100644 --- a/packages/client/hmi-client/src/api/api.ts +++ b/packages/client/hmi-client/src/api/api.ts @@ -33,18 +33,18 @@ API.interceptors.response.use( const status = error.response.status; switch (status) { case 500: - logger.error(msg, { + logger.error(msg.toString(), { showToast: false, toastTitle: `${ToastSummaries.SERVICE_UNAVAILABLE} (${status})` }); break; default: - logger.error(msg, { + logger.error(msg.toString(), { showToast: false, toastTitle: `${ToastSummaries.NETWORK_ERROR} (${status})` }); } - return null; // return null + return null; } ); diff --git a/packages/client/hmi-client/src/components/documents/Document.vue b/packages/client/hmi-client/src/components/documents/Document.vue deleted file mode 100644 index 468dc746e7..0000000000 --- a/packages/client/hmi-client/src/components/documents/Document.vue +++ /dev/null @@ -1,526 +0,0 @@ - - - - diff --git a/packages/client/hmi-client/src/components/extracting/drag-n-drop-importer.vue b/packages/client/hmi-client/src/components/extracting/drag-n-drop-importer.vue new file mode 100644 index 0000000000..93ba73a097 --- /dev/null +++ b/packages/client/hmi-client/src/components/extracting/drag-n-drop-importer.vue @@ -0,0 +1,256 @@ + + + + + diff --git a/packages/client/hmi-client/src/components/extracting/file-preview.vue b/packages/client/hmi-client/src/components/extracting/file-preview.vue new file mode 100644 index 0000000000..cb8f728fc3 --- /dev/null +++ b/packages/client/hmi-client/src/components/extracting/file-preview.vue @@ -0,0 +1,122 @@ + + + + diff --git a/packages/client/hmi-client/src/page/project/components/tera-project-overview.vue b/packages/client/hmi-client/src/page/project/components/tera-project-overview.vue index d619a75d89..513a5f0de3 100644 --- a/packages/client/hmi-client/src/page/project/components/tera-project-overview.vue +++ b/packages/client/hmi-client/src/page/project/components/tera-project-overview.vue @@ -49,6 +49,7 @@ size="large" icon="pi pi-cloud-upload" class="p-button p-button-secondary quick-link-button" + @click="openImportModal" />