initial commit

This commit is contained in:
saikumarjetti 2025-03-12 00:24:49 +05:30
parent 07f55c4fe0
commit 167849fe2d
2 changed files with 29 additions and 2 deletions

View File

@ -71,6 +71,10 @@ public class StampController {
int position = request.getPosition(); // Updated to use 1-9 positioning logic int position = request.getPosition(); // Updated to use 1-9 positioning logic
float overrideX = request.getOverrideX(); // New field for X override float overrideX = request.getOverrideX(); // New field for X override
float overrideY = request.getOverrideY(); // New field for Y override float overrideY = request.getOverrideY(); // New field for Y override
// Check if the file input is null or empty
if (request.getFileInput() == null || request.getFileInput().isEmpty()) {
return ResponseEntity.badRequest().body("PDF file is missing.".getBytes());
}
String customColor = request.getCustomColor(); String customColor = request.getCustomColor();
float marginFactor; float marginFactor;

View File

@ -27,8 +27,8 @@
<span class="material-symbols-rounded tool-header-icon security">approval</span> <span class="material-symbols-rounded tool-header-icon security">approval</span>
<span class="tool-header-text" th:text="#{AddStampRequest.header}"></span> <span class="tool-header-text" th:text="#{AddStampRequest.header}"></span>
</div> </div>
<form method="post" enctype="multipart/form-data" th:action="@{'/api/v1/misc/add-stamp'}"> <form id="stampFormGroup" method="post" enctype="multipart/form-data" th:action="@{'/api/v1/misc/add-stamp'}">
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multipleInputsForSingleRequest=false, accept='application/pdf')}"></div> <div th:replace="~{fragments/common :: fileSelector(name='fileInput', multipleInputsForSingleRequest=false, accept='application/pdf', notRequired=true)}"></div>
<br> <br>
<div class="mb-3"> <div class="mb-3">
<label for="pageOrder" th:text="#{pageSelectionPrompt}"></label> <label for="pageOrder" th:text="#{pageSelectionPrompt}"></label>
@ -194,6 +194,29 @@
alphabetGroup.style.display = 'none'; alphabetGroup.style.display = 'none';
} }
} }
document.addEventListener('DOMContentLoaded', function() {
// Get the form by ID
const form = document.getElementById('stampFormGroup');
if (form) {
// Override the default submission behavior
form.addEventListener('submit', function(event) {
// Get the file input element (using the pattern from the fileSelector fragment)
const fileInput = document.getElementById('fileInput-input');
// Check if files are selected
if (!fileInput || fileInput.files.length === 0) {
// Prevent the form from submitting
event.preventDefault();
event.stopPropagation();
// Alert the user
alert('Please select a PDF file before submitting.');
return false;
}
return true;
}, true);
}
});
</script> </script>
</div> </div>
<th:block th:insert="~{fragments/footer.html :: footer}"></th:block> <th:block th:insert="~{fragments/footer.html :: footer}"></th:block>