1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-09-30 00:20:13 +02:00

Fix for ANY values and settings button enablement

This commit is contained in:
Anthony Stirling 2024-01-01 13:57:22 +00:00
parent cd3cc15888
commit 04acdb3b02
2 changed files with 53 additions and 41 deletions

View File

@ -79,7 +79,7 @@ public class ConvertOfficeController {
@Operation( @Operation(
summary = "Convert a file to a PDF using LibreOffice", summary = "Convert a file to a PDF using LibreOffice",
description = description =
"This endpoint converts a given file to a PDF using LibreOffice API Input:Any Output:PDF Type:SISO") "This endpoint converts a given file to a PDF using LibreOffice API Input:ANY Output:PDF Type:SISO")
public ResponseEntity<byte[]> processFileToPDF(@ModelAttribute GeneralFile request) public ResponseEntity<byte[]> processFileToPDF(@ModelAttribute GeneralFile request)
throws Exception { throws Exception {
MultipartFile inputFile = request.getFileInput(); MultipartFile inputFile = request.getFileInput();

View File

@ -243,15 +243,25 @@ document.getElementById('addOperationBtn').addEventListener('click', function()
if (apiDocs[selectedOperation] && apiDocs[selectedOperation].post) { if (apiDocs[selectedOperation] && apiDocs[selectedOperation].post) {
const postMethod = apiDocs[selectedOperation].post; const postMethod = apiDocs[selectedOperation].post;
console.log("hasSettings", hasSettings);
// Check if parameters exist // Check if parameters exist
if (postMethod.parameters && postMethod.parameters.length > 0) { if (postMethod.parameters && postMethod.parameters.length > 0) {
hasSettings = true; hasSettings = true;
console.log("hasSettings2", hasSettings);
} else if (postMethod.requestBody && postMethod.requestBody.content['multipart/form-data']) { } else if (postMethod.requestBody && postMethod.requestBody.content['multipart/form-data']) {
// Extract the reference key // Extract the reference key
const refKey = postMethod.requestBody.content['multipart/form-data'].schema['$ref'].split('/').pop(); const refKey = postMethod.requestBody.content['multipart/form-data'].schema['$ref'].split('/').pop();
// Check if the referenced schema exists and has properties console.log("hasSettings3 ", hasSettings, refKey);
if (apiSchemas[refKey] && Object.keys(apiSchemas[refKey].properties).length > 0) { // Check if the referenced schema exists and has properties more than just its input file
if (apiSchemas[refKey]) {
const properties = apiSchemas[refKey].properties;
const propertyKeys = Object.keys(properties);
// Check if there's more than one property or if there's exactly one property and its format is not 'binary'
if (propertyKeys.length > 1 || (propertyKeys.length === 1 && properties[propertyKeys[0]].format !== 'binary')) {
hasSettings = true; hasSettings = true;
console.log("hasSettings4", hasSettings);
}
} }
} }
} }
@ -431,6 +441,7 @@ document.getElementById('addOperationBtn').addEventListener('click', function()
pipelineSettingsContent.appendChild(parameterDiv); pipelineSettingsContent.appendChild(parameterDiv);
}); });
if(hasSettings) {
let saveButton = document.createElement('button'); let saveButton = document.createElement('button');
saveButton.textContent = "Save Settings"; saveButton.textContent = "Save Settings";
saveButton.className = "btn btn-primary"; saveButton.className = "btn btn-primary";
@ -470,6 +481,7 @@ document.getElementById('addOperationBtn').addEventListener('click', function()
}); });
pipelineSettingsContent.appendChild(saveButton); pipelineSettingsContent.appendChild(saveButton);
saveButton.click(); saveButton.click();
}
//pipelineSettingsModal.style.display = "block"; //pipelineSettingsModal.style.display = "block";
//pipelineSettingsModal.getElementsByClassName("close")[0].onclick = function() { //pipelineSettingsModal.getElementsByClassName("close")[0].onclick = function() {