1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-11-23 07:20:09 +01:00

Pipeline fixes for json lists + delete func (#1425)

* init

* revert

* pipelines fixes for lists

* pipeline fixes to allow json lists

* formatting

* pipeline changes

* langs

---------

Co-authored-by: a <a>
This commit is contained in:
Anthony Stirling 2024-06-09 13:56:55 +01:00 committed by GitHub
parent 56fdf1f3a1
commit 63bdc0d59e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
41 changed files with 184 additions and 41 deletions

View File

@ -103,6 +103,7 @@ body:
- Chrome
- Safari
- Microsoft Edge
- Other
- type: checkboxes
id: terms
@ -111,5 +112,5 @@ body:
description: |
Please confirm that you have searched for similar issues and none of them match your problem.
options:
- label: I have verified that there are no issues related to my problem.
- label: I have verified that there are no existing issues raised related to my problem.
required: true

View File

@ -0,0 +1,43 @@
{
"name": "OCR images",
"pipeline": [
{
"operation": "/api/v1/convert/img/pdf",
"parameters": {
"fitOption": "fillPage",
"colorType": "color",
"autoRotate": true,
"fileInput": "automated"
}
},
{
"operation": "/api/v1/general/merge-pdfs",
"parameters": {
"sortType": "orderProvided",
"fileInput": "automated"
}
},
{
"operation": "/api/v1/misc/ocr-pdf",
"parameters": {
"languages": [
"eng"
],
"sidecar": false,
"deskew": false,
"clean": false,
"cleanFinal": false,
"ocrType": "skip-text",
"ocrRenderType": "hocr",
"removeImagesAfter": false,
"fileInput": "automated"
}
}
],
"_examples": {
"outputDir": "{outputFolder}/{folderName}",
"outputFileName": "{filename}-{pipelineName}-{date}-{time}"
},
"outputDir": "{outputFolder}",
"outputFileName": "{filename}"
}

View File

@ -58,7 +58,7 @@ public class CleanUrlInterceptor implements HandlerInterceptor {
// Redirect to the URL with only allowed query parameters
String redirectUrl = requestURI + "?" + newQueryString;
response.sendRedirect(request.getContextPath() + redirectUrl);
return false;
}

View File

@ -43,7 +43,7 @@ public class CustomAuthenticationFailureHandler extends SimpleUrlAuthenticationF
logger.error("Failed login attempt from IP: {}", ip);
String contextPath = request.getContextPath();
if (exception.getClass().isAssignableFrom(InternalAuthenticationServiceException.class)
|| "Password must not be null".equalsIgnoreCase(exception.getMessage())) {
response.sendRedirect(contextPath + "/login?error=oauth2AuthenticationError");

View File

@ -105,7 +105,14 @@ public class PipelineProcessor {
body.add("fileInput", file);
for (Entry<String, Object> entry : parameters.entrySet()) {
body.add(entry.getKey(), entry.getValue());
if (entry.getValue() instanceof List) {
List<?> list = (List<?>) entry.getValue();
for (Object item : list) {
body.add(entry.getKey(), item);
}
} else {
body.add(entry.getKey(), entry.getValue());
}
}
ResponseEntity<byte[]> response = sendWebRequest(url, body);
@ -167,7 +174,14 @@ public class PipelineProcessor {
}
for (Entry<String, Object> entry : parameters.entrySet()) {
body.add(entry.getKey(), entry.getValue());
if (entry.getValue() instanceof List) {
List<?> list = (List<?>) entry.getValue();
for (Object item : list) {
body.add(entry.getKey(), item);
}
} else {
body.add(entry.getKey(), entry.getValue());
}
}
ResponseEntity<byte[]> response = sendWebRequest(url, body);

View File

@ -4,8 +4,7 @@ import jakarta.servlet.http.HttpServletRequest;
public class UrlUtils {
private UrlUtils() {
}
private UrlUtils() {}
public static String getOrigin(HttpServletRequest request) {
String scheme = request.getScheme(); // http or https

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Custom
pipeline.submitButton=Submit
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Персонализиран
pipeline.submitButton=Подайте
pipeline.help=Pipeline Помощ
pipeline.scanHelp=Помощ за сканиране на папки
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Custom
pipeline.submitButton=Submit
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -1,7 +1,7 @@
###########
# Generic #
###########
# the direction that the language is written (ltr = left to right, rtl = right to left)
# the direction that the language is written (ltr=left to right, rtl = right to left)
language.direction=ltr
pdfPrompt=Vyberte PDF soubory
@ -86,6 +86,7 @@ pipeline.defaultOption=Vlastní
pipeline.submitButton=Odeslat
pipeline.help=Pomoc s pipeline
pipeline.scanHelp=Pomoc se skenováním adresáře
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #
@ -193,7 +194,7 @@ adminUserSettings.authenticated=Ověřeno
#############
# HOME-PAGE #
#############
home.desc= Vaše lokálně hostované jednotné kontaktní místo pro všechny vaše potřeby ve formátu PDF
home.desc=Vaše lokálně hostované jednotné kontaktní místo pro všechny vaše potřeby ve formátu PDF
home.searchBar=Hledej funkce...
@ -227,7 +228,7 @@ home.pdfToImage.desc=Konvertovat PDF na obrázek. (PNG, JPEG, GIF)
pdfToImage.tags=konverze,img,jpg,obrázek,fotka
home.pdfOrganiser.title=Organizovat
home.pdfOrganiser.desc=Odebrat/Přeskupit stránky v jakémkoli pořadí
home.pdfOrganiser.desc=Odebrat/Přeskupit stránky v jakémkoli pořadí
pdfOrganiser.tags=dvojitý,sudý,lichý,seřadit,přesunout
@ -724,7 +725,7 @@ repair.submit=Opravit
#flatten
flatten.title=Zploštit
flatten.header=Zploštit PDF
flatten.flattenOnlyForms=Zploštit pouze formuláře
flatten.flattenOnlyForms=Zploštit pouze formuláře
flatten.submit=Zploštit

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Benutzerdefiniert
pipeline.submitButton=Speichern
pipeline.help=Hilfe für Pipeline
pipeline.scanHelp=Hilfe zum Ordnerscan
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Custom
pipeline.submitButton=Υποβολή
pipeline.help=Βοήθεια για το Pipeline
pipeline.scanHelp=Βοήθεια για Σάρωση Φακέλων
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Custom
pipeline.submitButton=Submit
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Custom
pipeline.submitButton=Submit
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Personalizar
pipeline.submitButton=Enviar
pipeline.help=Ayuda de Canalización
pipeline.scanHelp=Ayuda de escaneado de carpetas
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Custom
pipeline.submitButton=Submit
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Personnaliser
pipeline.submitButton=Soumettre
pipeline.help=Aide Pipeline
pipeline.scanHelp=Aide analyse de dossier
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Custom
pipeline.submitButton=Submit
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -1,7 +1,7 @@
###########
# Generic #
###########
# the direction that the language is written (ltr = left to right, rtl = right to left)
# the direction that the language is written (ltr=left to right, rtl = right to left)
language.direction=ltr
pdfPrompt=Odaberi PDF(ove)
@ -86,6 +86,7 @@ pipeline.defaultOption=Prilagođeno
pipeline.submitButton=Pošalji
pipeline.help=Pipeline Pomoć
pipeline.scanHelp=Pomoć za skeniranje mapa
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Custom
pipeline.submitButton=Submit
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Custom
pipeline.submitButton=Submit
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Personalizzato
pipeline.submitButton=Invia
pipeline.help=Aiuto sulla pipeline
pipeline.scanHelp=Aiuto per la scansione delle cartelle
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=カスタム
pipeline.submitButton=送信
pipeline.help=パイプラインのヘルプ
pipeline.scanHelp=フォルダ スキャンのヘルプ
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=관습
pipeline.submitButton=전송
pipeline.help=파이프라인 도움말
pipeline.scanHelp=폴더 스캔 도움말
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Aangepast
pipeline.submitButton=Opslaan
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -1,7 +1,7 @@
###########
# Generic #
###########
# the direction that the language is written (ltr = left to right, rtl = right to left)
# the direction that the language is written (ltr=left to right, rtl = right to left)
language.direction=ltr
pdfPrompt=Velg PDF(er)
@ -86,6 +86,7 @@ pipeline.defaultOption=Tilpasset
pipeline.submitButton=Send inn
pipeline.help=Pipeline hjelp
pipeline.scanHelp=Mappe skanning hjelp
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Custom
pipeline.submitButton=Submit
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Custom
pipeline.submitButton=Submit
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Personalizar
pipeline.submitButton=Submeter
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Custom
pipeline.submitButton=Submit
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Пользовательский
pipeline.submitButton=Отправить
pipeline.help=Справка по конвейерной обработке
pipeline.scanHelp=Справка по сканированию папок
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Vlastné
pipeline.submitButton=Odoslať
pipeline.help=Pomoc s pipeline
pipeline.scanHelp=Pomoc so skenovaním priečinka
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Prilagođeno
pipeline.submitButton=Pošalji
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Custom
pipeline.submitButton=Submit
pipeline.help=Pipeline Help
pipeline.scanHelp=Folder Scanning Help
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Özel
pipeline.submitButton=Gönder
pipeline.help=Çoklu İşlemler Yardım
pipeline.scanHelp=Klasör Tarama Yardımı
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=Користувацький
pipeline.submitButton=Надіслати
pipeline.help=Довідка з конвеєрної обробки
pipeline.scanHelp=Довідка зі сканування папок
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=自定义
pipeline.submitButton=提交
pipeline.help=工作流帮助
pipeline.scanHelp=文件夹扫描帮助
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

View File

@ -86,6 +86,7 @@ pipeline.defaultOption=自訂
pipeline.submitButton=送出
pipeline.help=管道説明
pipeline.scanHelp=資料夾掃描説明
pipeline.deletePrompt=Are you sure you want to delete pipeline
######################
# Pipeline Options #

File diff suppressed because one or more lines are too long

View File

@ -96,7 +96,6 @@ document.getElementById("submitConfigBtn").addEventListener("click", function ()
for (let i = 0; i < pipelineList.length; i++) {
let operationName = pipelineList[i].querySelector(".operationName").textContent;
let parameters = operationSettings[operationName] || {};
pipelineConfig.pipeline.push({
operation: operationName,
parameters: parameters,
@ -104,7 +103,6 @@ document.getElementById("submitConfigBtn").addEventListener("click", function ()
}
let pipelineConfigJson = JSON.stringify(pipelineConfig, null, 2);
let formData = new FormData();
let fileInput = document.getElementById("fileInput-input");
@ -218,6 +216,41 @@ fetch("v1/api-docs")
});
});
document.getElementById('deletePipelineBtn').addEventListener('click', function(event) {
event.preventDefault();
let pipelineName = document.getElementById('pipelineName').value;
if (confirm(deletePipelineText + pipelineName)) {
removePipelineFromUI(pipelineName);
let key = "#Pipeline-" + pipelineName;
if (localStorage.getItem(key)) {
localStorage.removeItem(key);
}
let pipelineSelect = document.getElementById("pipelineSelect");
let modal = document.getElementById('pipelineSettingsModal');
if (modal.style.display !== 'none') {
$('#pipelineSettingsModal').modal('hide');
}
if (pipelineSelect.options.length > 0) {
pipelineSelect.selectedIndex = 0;
pipelineSelect.dispatchEvent(new Event('change'));
}
}
});
function removePipelineFromUI(pipelineName) {
let pipelineSelect = document.getElementById("pipelineSelect");
for (let i = 0; i < pipelineSelect.options.length; i++) {
console.log(pipelineSelect.options[i])
console.log("list " + pipelineSelect.options[i].innerText + " vs " + pipelineName)
if (pipelineSelect.options[i].innerText === pipelineName) {
pipelineSelect.remove(i);
break;
}
}
}
document.getElementById("addOperationBtn").addEventListener("click", function () {
let selectedOperation = document.getElementById("operationsDropdown").value;
let pipelineList = document.getElementById("pipelineList");
@ -378,18 +411,22 @@ document.getElementById("addOperationBtn").addEventListener("click", function ()
parameterInput.type = "checkbox";
if (defaultValue === true) parameterInput.checked = true;
break;
case "array":
case "object":
//TODO compare to doc and check if fileInput array? parameter.schema.format === 'binary'
parameterInput = document.createElement("textarea");
parameterInput.placeholder = `Enter a JSON formatted ${parameter.schema.type}, If this is a fileInput, it is not currently supported`;
parameterInput.className = "form-control";
break;
default:
parameterInput = document.createElement("input");
parameterInput.type = "text";
parameterInput.className = "form-control";
if (defaultValue !== undefined) parameterInput.value = defaultValue;
case "array":
// If parameter.schema.format === 'binary' is to be checked, it should be checked here
parameterInput = document.createElement("textarea");
parameterInput.placeholder = 'Enter a JSON formatted array, e.g., ["item1", "item2", "item3"]';
parameterInput.className = "form-control";
break;
case "object":
parameterInput = document.createElement("textarea");
parameterInput.placeholder = 'Enter a JSON formatted object, e.g., {"key": "value"} If this is a fileInput, it is not currently supported';
parameterInput.className = "form-control";
break;
default:
parameterInput = document.createElement("input");
parameterInput.type = "text";
parameterInput.className = "form-control";
if (defaultValue !== undefined) parameterInput.value = defaultValue;
}
}
parameterInput.id = parameter.name;
@ -441,16 +478,21 @@ document.getElementById("addOperationBtn").addEventListener("click", function ()
break;
case "array":
case "object":
if (value === null || value === "") {
settings[parameter.name] = "";
} else {
try {
settings[parameter.name] = JSON.parse(value);
} catch (err) {
console.error(`Invalid JSON format for ${parameter.name}`);
}
}
break;
if (value === null || value === "") {
settings[parameter.name] = "";
} else {
try {
const parsedValue = JSON.parse(value);
if (Array.isArray(parsedValue)) {
settings[parameter.name] = parsedValue;
} else {
settings[parameter.name] = value;
}
} catch (e) {
settings[parameter.name] = value;
}
}
break;
default:
settings[parameter.name] = value;
}
@ -558,7 +600,6 @@ function configToJson() {
parameters: parameters,
});
}
return JSON.stringify(pipelineConfig, null, 2);
}
@ -642,7 +683,13 @@ async function processPipelineConfig(configString) {
case "text":
case "textarea":
default:
input.value = JSON.stringify(operationConfig.parameters[parameterName]);
var value = operationConfig.parameters[parameterName]
if (typeof value !== 'string') {
input.value = JSON.stringify(value) ;
} else {
input.value = value;
}
}
}
});

View File

@ -16,6 +16,7 @@
/>
<script th:inline="javascript">
const saveSettings = /*[[#{pipelineOptions.saveSettings}]]*/ "";
const deletePipelineText = /*[[#{pipeline.pipeline.deletePrompt}]]*/ "Are you sure you want to delete pipeline";
</script>
</head>
@ -92,7 +93,7 @@
<!-- The Modal -->
<div class="modal" id="pipelineSettingsModal">
<div class="modal-dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content dark-card">
<!-- Modal Header -->
<div class="modal-header">
@ -158,6 +159,12 @@
<!-- Modal footer -->
<div class="modal-footer">
<button
id="deletePipelineBtn"
class="btn btn-danger"
th:text="#{delete}"
></button>
<button
id="saveBrowserPipelineBtn"
class="btn btn-success"