minor changes

This commit is contained in:
Anthony Stirling 2024-01-01 13:46:09 +00:00
parent 76e6a23674
commit cd3cc15888
2 changed files with 614 additions and 603 deletions

View file

@ -1,8 +1,8 @@
document.getElementById('validateButton').addEventListener('click', function(event) {
document.getElementById('validateButton').addEventListener('click', function(event) {
event.preventDefault();
validatePipeline();
});
function validatePipeline() {
});
function validatePipeline() {
let pipelineListItems = document.getElementById('pipelineList').children;
let isValid = true;
let containsAddPassword = false;
@ -54,9 +54,9 @@
}
updateValidateButton(isValid);
return isValid;
}
}
function updateValidateButton(isValid) {
function updateValidateButton(isValid) {
var validateButton = document.getElementById('validateButton');
if (isValid) {
validateButton.classList.remove('btn-danger');
@ -65,12 +65,12 @@
validateButton.classList.remove('btn-success');
validateButton.classList.add('btn-danger');
}
}
}
document.getElementById('submitConfigBtn').addEventListener('click', function() {
document.getElementById('submitConfigBtn').addEventListener('click', function() {
if (validatePipeline() === false) {
return;
@ -160,13 +160,13 @@
console.error('Error:', error);
});
});
});
let apiDocs = {};
let apiSchemas = {};
let operationSettings = {};
let apiDocs = {};
let apiSchemas = {};
let operationSettings = {};
fetch('v1/api-docs')
fetch('v1/api-docs')
.then(response => response.json())
.then(data => {
@ -233,7 +233,7 @@
});
document.getElementById('addOperationBtn').addEventListener('click', function() {
document.getElementById('addOperationBtn').addEventListener('click', function() {
let selectedOperation = document.getElementById('operationsDropdown').value;
let pipelineList = document.getElementById('pipelineList');
@ -368,7 +368,7 @@
parameterInput = document.createElement('input');
parameterInput.type = 'text';
parameterInput.className = "form-control";
parameterInput.value = "FileInputPathToBeInputtedManuallyOffline";
parameterInput.value = "FileInputPathToBeInputtedManuallyForOffline";
} else {
parameterInput = document.createElement('input');
parameterInput.type = 'text';
@ -390,8 +390,9 @@
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}`;
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:
@ -449,11 +450,15 @@
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;
default:
settings[parameter.name] = value;
@ -464,7 +469,7 @@
//pipelineSettingsModal.style.display = "none";
});
pipelineSettingsContent.appendChild(saveButton);
saveButton.click();
//pipelineSettingsModal.style.display = "block";
//pipelineSettingsModal.getElementsByClassName("close")[0].onclick = function() {
@ -477,11 +482,19 @@
// }
//}
}
showpipelineSettingsModal(selectedOperation);
updateConfigInDropdown();
hideOrShowPipelineHeader();
});
function updateConfigInDropdown() {
});
function updateConfigInDropdown() {
let pipelineSelect = document.getElementById('pipelineSelect');
let selectedOption = pipelineSelect.options[pipelineSelect.selectedIndex];
@ -496,18 +509,18 @@
// Update the value of the selected option with the new configuration
selectedOption.value = pipelineConfigJson;
}
}
var saveBtn = document.getElementById('savePipelineBtn');
var saveBtn = document.getElementById('savePipelineBtn');
// Remove any existing event listeners
saveBtn.removeEventListener('click', savePipeline);
// Remove any existing event listeners
saveBtn.removeEventListener('click', savePipeline);
// Add the event listener
saveBtn.addEventListener('click', savePipeline);
console.log("saveBtn", saveBtn)
// Add the event listener
saveBtn.addEventListener('click', savePipeline);
console.log("saveBtn", saveBtn)
function configToJson() {
function configToJson() {
if (!validatePipeline()) {
return null; // Return null if validation fails
}
@ -538,11 +551,11 @@
}
return JSON.stringify(pipelineConfig, null, 2);
}
}
function savePipeline() {
function savePipeline() {
let pipelineConfigJson = configToJson();
if (!pipelineConfigJson) {
console.error("Failed to save pipeline: Invalid configuration");
@ -559,11 +572,11 @@
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
}
async function processPipelineConfig(configString) {
console.log("configString",configString);
async function processPipelineConfig(configString) {
console.log("configString", configString);
let pipelineConfig = JSON.parse(configString);
let pipelineList = document.getElementById('pipelineList');
@ -614,29 +627,29 @@
});
}
}
}
document.getElementById('uploadPipelineBtn').addEventListener('click', function() {
document.getElementById('uploadPipelineBtn').addEventListener('click', function() {
document.getElementById('uploadPipelineInput').click();
});
});
document.getElementById('uploadPipelineInput').addEventListener('change', function(e) {
document.getElementById('uploadPipelineInput').addEventListener('change', function(e) {
let reader = new FileReader();
reader.onload = function(event) {
processPipelineConfig(event.target.result);
};
reader.readAsText(e.target.files[0]);
hideOrShowPipelineHeader();
});
});
document.getElementById('pipelineSelect').addEventListener('change', function(e) {
document.getElementById('pipelineSelect').addEventListener('change', function(e) {
let selectedPipelineJson = e.target.value; // assuming the selected value is the JSON string of the pipeline config
processPipelineConfig(selectedPipelineJson);
});
});
function hideOrShowPipelineHeader() {
function hideOrShowPipelineHeader() {
var pipelineHeader = document.getElementById('pipelineHeader');
var pipelineList = document.getElementById('pipelineList');
@ -647,4 +660,4 @@
// Show the pipeline header if there are items in the pipeline list
pipelineHeader.style.display = 'block';
}
}
}

View file

@ -102,8 +102,6 @@
<h3>Todo</h3>
<ul>
<li>Fix operation adding requering settings to be openned and
saved instead of saving defaults</li>
<li>Translation support</li>
<li>Save to browser/Account</li>
<li>offline mode checks and testing</li>