pipeline enhance for MI

This commit is contained in:
Anthony Stirling 2023-12-31 13:05:38 +00:00
parent eda91cc556
commit f535387ac4
3 changed files with 521 additions and 482 deletions

View file

@ -138,7 +138,7 @@ public class PipelineProcessor {
hasErrors = true; hasErrors = true;
} }
outputFiles = newOutputFiles;
} }
} else { } else {
@ -177,11 +177,13 @@ public class PipelineProcessor {
} }
} }
logPrintStream.close(); logPrintStream.close();
outputFiles = newOutputFiles;
} }
if (hasErrors) { if (hasErrors) {
logger.error("Errors occurred during processing. Log: {}", logStream.toString()); logger.error("Errors occurred during processing. Log: {}", logStream.toString());
} }
return outputFiles; return outputFiles;
} }

View file

@ -1,8 +1,8 @@
document.getElementById('validateButton').addEventListener('click', function(event) { document.getElementById('validateButton').addEventListener('click', function(event) {
event.preventDefault(); event.preventDefault();
validatePipeline(); validatePipeline();
}); });
function validatePipeline() { function validatePipeline() {
let pipelineListItems = document.getElementById('pipelineList').children; let pipelineListItems = document.getElementById('pipelineList').children;
let isValid = true; let isValid = true;
let containsAddPassword = false; let containsAddPassword = false;
@ -54,9 +54,9 @@ function validatePipeline() {
} }
updateValidateButton(isValid); updateValidateButton(isValid);
return isValid; return isValid;
} }
function updateValidateButton(isValid) { function updateValidateButton(isValid) {
var validateButton = document.getElementById('validateButton'); var validateButton = document.getElementById('validateButton');
if (isValid) { if (isValid) {
validateButton.classList.remove('btn-danger'); validateButton.classList.remove('btn-danger');
@ -65,12 +65,12 @@ function updateValidateButton(isValid) {
validateButton.classList.remove('btn-success'); validateButton.classList.remove('btn-success');
validateButton.classList.add('btn-danger'); validateButton.classList.add('btn-danger');
} }
} }
document.getElementById('submitConfigBtn').addEventListener('click', function() { document.getElementById('submitConfigBtn').addEventListener('click', function() {
if (validatePipeline() === false) { if (validatePipeline() === false) {
return; return;
@ -160,13 +160,13 @@ document.getElementById('submitConfigBtn').addEventListener('click', function()
console.error('Error:', error); console.error('Error:', error);
}); });
}); });
let apiDocs = {}; let apiDocs = {};
let apiSchemas = {}; let apiSchemas = {};
let operationSettings = {}; let operationSettings = {};
fetch('v1/api-docs') fetch('v1/api-docs')
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
@ -182,10 +182,11 @@ fetch('v1/api-docs')
// Group operations by tags // Group operations by tags
Object.keys(data.paths).forEach(operationPath => { Object.keys(data.paths).forEach(operationPath => {
let operation = data.paths[operationPath].post; let operation = data.paths[operationPath].post;
if(!operation || !operation.description) { if (!operation || !operation.description) {
console.log(operationPath); console.log(operationPath);
} }
if (operation && !ignoreOperations.includes(operationPath) && !operation.description.includes("Type:MISO")) { //!operation.description.includes("Type:MISO")
if (operation && !ignoreOperations.includes(operationPath)) {
let operationTag = operation.tags[0]; // This assumes each operation has exactly one tag let operationTag = operation.tags[0]; // This assumes each operation has exactly one tag
if (!operationsByTag[operationTag]) { if (!operationsByTag[operationTag]) {
operationsByTag[operationTag] = []; operationsByTag[operationTag] = [];
@ -209,12 +210,12 @@ fetch('v1/api-docs')
operationPathDisplay = operationPath.replace(new RegExp("api/v1/" + tag.toLowerCase() + "/", 'i'), ""); operationPathDisplay = operationPath.replace(new RegExp("api/v1/" + tag.toLowerCase() + "/", 'i'), "");
if(operationPath.includes("/convert")){ if (operationPath.includes("/convert")) {
operationPathDisplay = operationPathDisplay.replace(/^\//, '').replaceAll("/", " to "); operationPathDisplay = operationPathDisplay.replace(/^\//, '').replaceAll("/", " to ");
} else { } else {
operationPathDisplay = operationPathDisplay.replace(/\//g, ''); // Remove slashes operationPathDisplay = operationPathDisplay.replace(/\//g, ''); // Remove slashes
} }
operationPathDisplay = operationPathDisplay.replaceAll(" ","-"); 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);
@ -226,7 +227,7 @@ fetch('v1/api-docs')
}); });
document.getElementById('addOperationBtn').addEventListener('click', function() { document.getElementById('addOperationBtn').addEventListener('click', function() {
let selectedOperation = document.getElementById('operationsDropdown').value; let selectedOperation = document.getElementById('operationsDropdown').value;
let pipelineList = document.getElementById('pipelineList'); let pipelineList = document.getElementById('pipelineList');
@ -264,7 +265,7 @@ document.getElementById('addOperationBtn').addEventListener('click', function()
<button class="btn btn-danger remove ms-1"><span>X</span></button> <button class="btn btn-danger remove ms-1"><span>X</span></button>
</div> </div>
</div> </div>
`; `;
pipelineList.appendChild(listItem); pipelineList.appendChild(listItem);
@ -273,6 +274,7 @@ document.getElementById('addOperationBtn').addEventListener('click', function()
event.preventDefault(); event.preventDefault();
if (listItem.previousElementSibling) { if (listItem.previousElementSibling) {
pipelineList.insertBefore(listItem, listItem.previousElementSibling); pipelineList.insertBefore(listItem, listItem.previousElementSibling);
updateConfigInDropdown();
} }
}); });
@ -280,13 +282,16 @@ document.getElementById('addOperationBtn').addEventListener('click', function()
event.preventDefault(); event.preventDefault();
if (listItem.nextElementSibling) { if (listItem.nextElementSibling) {
pipelineList.insertBefore(listItem.nextElementSibling, listItem); pipelineList.insertBefore(listItem.nextElementSibling, listItem);
updateConfigInDropdown();
} }
}); });
listItem.querySelector('.remove').addEventListener('click', function(event) { listItem.querySelector('.remove').addEventListener('click', function(event) {
event.preventDefault(); event.preventDefault();
pipelineList.removeChild(listItem); pipelineList.removeChild(listItem);
hideOrShowPipelineHeader(); hideOrShowPipelineHeader();
updateConfigInDropdown();
}); });
listItem.querySelector('.pipelineSettings').addEventListener('click', function(event) { listItem.querySelector('.pipelineSettings').addEventListener('click', function(event) {
@ -426,7 +431,7 @@ document.getElementById('addOperationBtn').addEventListener('click', function()
event.preventDefault(); event.preventDefault();
let settings = {}; let settings = {};
operationData.forEach(parameter => { operationData.forEach(parameter => {
if(parameter.name !== "fileInput"){ if (parameter.name !== "fileInput") {
let value = document.getElementById(parameter.name).value; let value = document.getElementById(parameter.name).value;
switch (parameter.schema.type) { switch (parameter.schema.type) {
case 'number': case 'number':
@ -466,10 +471,26 @@ document.getElementById('addOperationBtn').addEventListener('click', function()
// } // }
//} //}
} }
updateConfigInDropdown();
hideOrShowPipelineHeader(); hideOrShowPipelineHeader();
}); });
function updateConfigInDropdown() {
let pipelineSelect = document.getElementById('pipelineSelect');
let selectedOption = pipelineSelect.options[pipelineSelect.selectedIndex];
// Get the current configuration as JSON
let pipelineConfigJson = configToJson();
console.log("pipelineConfigJson", pipelineConfigJson);
if (!pipelineConfigJson) {
console.error("Failed to update configuration: Invalid configuration");
return;
}
// Update the value of the selected option with the new configuration
selectedOption.value = pipelineConfigJson;
}
var saveBtn = document.getElementById('savePipelineBtn'); var saveBtn = document.getElementById('savePipelineBtn');
@ -479,10 +500,10 @@ document.getElementById('addOperationBtn').addEventListener('click', function()
// Add the event listener // Add the event listener
saveBtn.addEventListener('click', savePipeline); saveBtn.addEventListener('click', savePipeline);
console.log("saveBtn", saveBtn) console.log("saveBtn", saveBtn)
function savePipeline() {
if (validatePipeline() === false) { function configToJson() {
return; if (!validatePipeline()) {
return null; // Return null if validation fails
} }
var pipelineName = document.getElementById('pipelineName').value; var pipelineName = document.getElementById('pipelineName').value;
@ -509,11 +530,23 @@ document.getElementById('addOperationBtn').addEventListener('click', function()
"parameters": parameters "parameters": parameters
}); });
} }
console.log("Downloading..");
return JSON.stringify(pipelineConfig, null, 2);
}
function savePipeline() {
let pipelineConfigJson = configToJson();
if (!pipelineConfigJson) {
console.error("Failed to save pipeline: Invalid configuration");
return;
}
let pipelineName = document.getElementById('pipelineName').value;
console.log("Downloading...");
let a = document.createElement('a'); let a = document.createElement('a');
a.href = URL.createObjectURL(new Blob([JSON.stringify(pipelineConfig, null, 2)], { a.href = URL.createObjectURL(new Blob([pipelineConfigJson], { type: 'application/json' }));
type: 'application/json'
}));
a.download = pipelineName + '.json'; a.download = pipelineName + '.json';
a.style.display = 'none'; a.style.display = 'none';
@ -522,7 +555,9 @@ document.getElementById('addOperationBtn').addEventListener('click', function()
document.body.removeChild(a); document.body.removeChild(a);
} }
async function processPipelineConfig(configString) { async function processPipelineConfig(configString) {
console.log("configString",configString);
let pipelineConfig = JSON.parse(configString); let pipelineConfig = JSON.parse(configString);
let pipelineList = document.getElementById('pipelineList'); let pipelineList = document.getElementById('pipelineList');

View file

@ -48,6 +48,8 @@
<div class="center-element"> <div class="center-element">
<div class="element-margin"> <div class="element-margin">
<select id="pipelineSelect" class="custom-select"> <select id="pipelineSelect" class="custom-select">
<option value="{&quot;name&quot;:&quot;Custom&quot;,&quot;pipeline&quot;:[],&quot;_examples&quot;:{&quot;outputDir&quot;:&quot;{outputFolder}/{folderName}&quot;,&quot;outputFileName&quot;:&quot;{filename}-{pipelineName}-{date}-{time}&quot;},&quot;outputDir&quot;:&quot;{outputFolder}&quot;,&quot;outputFileName&quot;:&quot;{filename}&quot;}" th:text="Custom"></option>
<th:block th:each="config : ${pipelineConfigsWithNames}"> <th:block th:each="config : ${pipelineConfigsWithNames}">
<option th:value="${config.json}" th:text="${config.name}"></option> <option th:value="${config.json}" th:text="${config.name}"></option>
</th:block> </th:block>