mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-09-13 12:15:29 +02:00
# Description of Changes Previously, the dropdown menu in the pipeline configuration displayed all endpoints, including disabled ones, and allowed API calls to them. Changes: - Updated EndpointInterceptor to correctly parse request URIs and match them to corresponding endpoint names in settings.yml, ensuring disabled endpoints are blocked. - Added a new API endpoint in SettingsController to expose the endpointStatus map, allowing the frontend to check which endpoints are disabled. - Updated pipeline.js to use this new API and hide disabled endpoints from the dropdown menu. Tests: - Created a new Docker Compose setup using a custom settings.yml where all endpoints are disabled. - Implemented a test script to run this setup, send API requests to disabled endpoints, and verify they are correctly blocked. [Bug Fix Video](https://youtu.be/L1z3jZh8z8E) Closes #2881 --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [x] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing) for more details. --------- Co-authored-by: Anthony Stirling <[email protected]>
This commit is contained in:
co-authored by
Anthony Stirling
parent
4e63a684b5
commit
7f8e3d676d
@@ -153,22 +153,32 @@ document.getElementById("submitConfigBtn").addEventListener("click", function ()
|
||||
let apiDocs = {};
|
||||
let apiSchemas = {};
|
||||
let operationSettings = {};
|
||||
let operationStatus = {};
|
||||
|
||||
fetchWithCsrf("v1/api-docs")
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
apiDocs = data.paths;
|
||||
apiSchemas = data.components.schemas;
|
||||
let operationsDropdown = document.getElementById("operationsDropdown");
|
||||
return fetchWithCsrf("api/v1/settings/get-endpoints-status")
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
operationStatus = data;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error:", error);
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
const ignoreOperations = ["/api/v1/pipeline/handleData", "/api/v1/pipeline/operationToIgnore"]; // Add the operations you want to ignore here
|
||||
|
||||
let operationsDropdown = document.getElementById("operationsDropdown");
|
||||
operationsDropdown.innerHTML = "";
|
||||
|
||||
let operationsByTag = {};
|
||||
|
||||
// Group operations by tags
|
||||
Object.keys(data.paths).forEach((operationPath) => {
|
||||
let operation = data.paths[operationPath].post;
|
||||
Object.keys(apiDocs).forEach((operationPath) => {
|
||||
let operation = apiDocs[operationPath].post;
|
||||
if (!operation || !operation.description) {
|
||||
console.log(operationPath);
|
||||
}
|
||||
@@ -209,13 +219,19 @@ fetchWithCsrf("v1/api-docs")
|
||||
}
|
||||
operationPathDisplay = operationPathDisplay.replaceAll(" ", "-");
|
||||
option.textContent = operationPathDisplay;
|
||||
option.value = operationPath; // Keep the value with slashes for querying
|
||||
group.appendChild(option);
|
||||
|
||||
if (!(operationPathDisplay in operationStatus)) {
|
||||
option.value = operationPath; // Keep the value with slashes for querying
|
||||
group.appendChild(option);
|
||||
}
|
||||
});
|
||||
|
||||
operationsDropdown.appendChild(group);
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error:", error);
|
||||
});
|
||||
|
||||
document.getElementById('deletePipelineBtn').addEventListener('click', function(event) {
|
||||
|
||||
Reference in New Issue
Block a user