pipeline changes

This commit is contained in:
Anthony Stirling 2023-12-23 12:29:32 +00:00
parent eab9e3cffc
commit 93f12d1313
6 changed files with 38 additions and 12 deletions

View file

@ -28,7 +28,7 @@ public class ConvertWebsiteToPDF {
@PostMapping(consumes = "multipart/form-data", value = "/url/pdf") @PostMapping(consumes = "multipart/form-data", value = "/url/pdf")
@Operation( @Operation(
summary = "Convert a URL to a PDF", summary = "Convert a URL to a PDF",
description = "This endpoint fetches content from a URL and converts it to a PDF format." description = "This endpoint fetches content from a URL and converts it to a PDF format. Input:N/A Output:PDF Type:SISO"
) )
public ResponseEntity<byte[]> urlToPdf(@ModelAttribute UrlToPdfRequest request) throws IOException, InterruptedException { public ResponseEntity<byte[]> urlToPdf(@ModelAttribute UrlToPdfRequest request) throws IOException, InterruptedException {
String URL = request.getUrlInput(); String URL = request.getUrlInput();

View file

@ -33,7 +33,7 @@ public class ExtractController {
private static final Logger logger = LoggerFactory.getLogger(CropController.class); private static final Logger logger = LoggerFactory.getLogger(CropController.class);
@PostMapping(value = "/pdf-to-csv", consumes = "multipart/form-data") @PostMapping(value = "/pdf/csv", consumes = "multipart/form-data")
@Operation(summary = "Extracts a PDF document to csv", description = "This operation takes an input PDF file and returns CSV file of whole page. Input:PDF Output:CSV Type:SISO") @Operation(summary = "Extracts a PDF document to csv", description = "This operation takes an input PDF file and returns CSV file of whole page. Input:PDF Output:CSV Type:SISO")
public ResponseEntity<String> PdfToCsv(@ModelAttribute PDFFilePage form) public ResponseEntity<String> PdfToCsv(@ModelAttribute PDFFilePage form)
throws Exception { throws Exception {

View file

@ -5,6 +5,7 @@ import java.util.List;
import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDDocument;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -18,7 +19,7 @@ public class PDFWithPageNums extends PDFFile {
@Schema(description = "The pages to select, Supports ranges (e.g., '1,3,5-9'), or 'all' or functions in the format 'an+b' where 'a' is the multiplier of the page number 'n', and 'b' is a constant (e.g., '2n+1', '3n', '6n-5')\"") @Schema(description = "The pages to select, Supports ranges (e.g., '1,3,5-9'), or 'all' or functions in the format 'an+b' where 'a' is the multiplier of the page number 'n', and 'b' is a constant (e.g., '2n+1', '3n', '6n-5')\"")
private String pageNumbers; private String pageNumbers;
@Hidden
public List<Integer> getPageNumbersList(){ public List<Integer> getPageNumbersList(){
int pageCount = 0; int pageCount = 0;
try { try {
@ -30,6 +31,8 @@ public class PDFWithPageNums extends PDFFile {
return GeneralUtils.parsePageString(pageNumbers, pageCount); return GeneralUtils.parsePageString(pageNumbers, pageCount);
} }
@Hidden
public List<Integer> getPageNumbersList(PDDocument doc){ public List<Integer> getPageNumbersList(PDDocument doc){
int pageCount = 0; int pageCount = 0;
pageCount = doc.getNumberOfPages(); pageCount = doc.getNumberOfPages();

View file

@ -120,7 +120,16 @@ document.getElementById('submitConfigBtn').addEventListener('click', function()
let url = window.URL.createObjectURL(blob); let url = window.URL.createObjectURL(blob);
let a = document.createElement('a'); let a = document.createElement('a');
a.href = url; a.href = url;
a.download = 'outputfile';
const contentDisposition = response.headers.get('Content-Disposition');
let filename = 'download';
if (contentDisposition && contentDisposition.indexOf('attachment') !== -1) {
filename = decodeURIComponent(contentDisposition.split('filename=')[1].replace(/"/g, '')).trim();
}
a.download = filename;
document.body.appendChild(a); document.body.appendChild(a);
a.click(); a.click();
a.remove(); a.remove();
@ -173,16 +182,20 @@ fetch('v1/api-docs')
operationsByTag[tag].forEach(operationPath => { operationsByTag[tag].forEach(operationPath => {
let option = document.createElement('option'); let option = document.createElement('option');
console.log("operationPath", operationPath);
let operationPathDisplay = operationPath let operationPathDisplay = operationPath
operationPathDisplay = operationPath.replace(new RegExp("api/v1/" + tag.toLowerCase() + "/", 'i'), ""); operationPathDisplay = operationPath.replace(new RegExp("api/v1/" + tag.toLowerCase() + "/", 'i'), "");
console.log("operationPath2", operationPath);
if(operationPath.includes("/convert")){ if(operationPath.includes("/convert")){
operationPathDisplay = operationPathDisplay.replaceAll("(?<!^)/", " to "); console.log("operationPathDisplay", operationPathDisplay);
operationPathDisplay = operationPathDisplay.replace(/^\//, '').replaceAll("/", " to ");
console.log("operationPathDisplay2", operationPathDisplay);
} else { } else {
operationPathDisplay = operationPathDisplay.replace(/\//g, ''); // Remove slashes operationPathDisplay = operationPathDisplay.replace(/\//g, ''); // Remove slashes
} }
operationPathDisplay = operationPathDisplay.replaceAll(" ","-");
option.textContent = operationPathDisplay; option.textContent = operationPathDisplay;
option.value = operationPath; // Keep the value with slashes for querying option.value = operationPath; // Keep the value with slashes for querying
group.appendChild(option); group.appendChild(option);
@ -482,7 +495,7 @@ document.getElementById('addOperationBtn').addEventListener('click', function()
a.href = URL.createObjectURL(new Blob([JSON.stringify(pipelineConfig, null, 2)], { a.href = URL.createObjectURL(new Blob([JSON.stringify(pipelineConfig, null, 2)], {
type: 'application/json' type: 'application/json'
})); }));
a.download = 'pipelineConfig.json'; a.download = pipelineName + '.json';
a.style.display = 'none'; a.style.display = 'none';
document.body.appendChild(a); document.body.appendChild(a);

View file

@ -13,7 +13,7 @@
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-md-6"> <div class="col-md-6">
<h2 th:text="#{PDFToCSV.header}"></h2> <h2 th:text="#{PDFToCSV.header}"></h2>
<form id="PDFToCSVForm" th:action="@{api/v1/convert/pdf-to-csv}" method="post" enctype="multipart/form-data"> <form id="PDFToCSVForm" th:action="@{api/v1/convert/pdf/csv}" method="post" enctype="multipart/form-data">
<input id="pageId" type="hidden" name="pageId" /> <input id="pageId" type="hidden" name="pageId" />
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multiple=false, accept='application/pdf')}"></div> <div th:replace="~{fragments/common :: fileSelector(name='fileInput', multiple=false, accept='application/pdf')}"></div>
<button type="submit" class="btn btn-primary" th:text="#{PDFToCSV.submit}"></button> <button type="submit" class="btn btn-primary" th:text="#{PDFToCSV.submit}"></button>

View file

@ -34,9 +34,9 @@
<br> <br> <br> <br>
<div class="container"> <div class="container">
<div class="row justify-content-center"> <div class="row justify-content-center">
<h1>Pipeline Menu (Huge work in progress, very buggy!)</h1>
<div class="bordered-box"> <div class="bordered-box">
<div class="text-end text-top"> <div class="text-end text-top">
<button id="uploadPipelineBtn" class="btn btn-primary">Upload <button id="uploadPipelineBtn" class="btn btn-primary">Upload
@ -63,6 +63,16 @@
</div> </div>
</div> </div>
<h3>Current Limitations</h3>
<p>Cant have more than one of the same operation</p>
<p>Cant input additional files via UI</p>
<h3>How it works notes</h3>
<p>Configre pipeline config file and input files to run files against it</p>
<p>For reuse, download config file and reupload it when needed or place in /pipeline/defaultWebUIConfigs/ to auto load in webUI for all users</p>
<!-- The Modal --> <!-- The Modal -->
<div class="modal" id="pipelineSettingsModal"> <div class="modal" id="pipelineSettingsModal">