minor changes
This commit is contained in:
parent
76e6a23674
commit
cd3cc15888
2 changed files with 614 additions and 603 deletions
|
@ -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 @@
|
||||||
}
|
}
|
||||||
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 @@
|
||||||
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 @@
|
||||||
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 => {
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
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');
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@
|
||||||
parameterInput = document.createElement('input');
|
parameterInput = document.createElement('input');
|
||||||
parameterInput.type = 'text';
|
parameterInput.type = 'text';
|
||||||
parameterInput.className = "form-control";
|
parameterInput.className = "form-control";
|
||||||
parameterInput.value = "FileInputPathToBeInputtedManuallyOffline";
|
parameterInput.value = "FileInputPathToBeInputtedManuallyForOffline";
|
||||||
} else {
|
} else {
|
||||||
parameterInput = document.createElement('input');
|
parameterInput = document.createElement('input');
|
||||||
parameterInput.type = 'text';
|
parameterInput.type = 'text';
|
||||||
|
@ -390,8 +390,9 @@
|
||||||
break;
|
break;
|
||||||
case 'array':
|
case 'array':
|
||||||
case 'object':
|
case 'object':
|
||||||
|
//TODO compare to doc and check if fileInput array? parameter.schema.format === 'binary'
|
||||||
parameterInput = document.createElement('textarea');
|
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";
|
parameterInput.className = "form-control";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -449,11 +450,15 @@
|
||||||
break;
|
break;
|
||||||
case 'array':
|
case 'array':
|
||||||
case 'object':
|
case 'object':
|
||||||
|
if (value === null || value === '') {
|
||||||
|
settings[parameter.name] = '';
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
settings[parameter.name] = JSON.parse(value);
|
settings[parameter.name] = JSON.parse(value);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Invalid JSON format for ${parameter.name}`);
|
console.error(`Invalid JSON format for ${parameter.name}`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
settings[parameter.name] = value;
|
settings[parameter.name] = value;
|
||||||
|
@ -464,7 +469,7 @@
|
||||||
//pipelineSettingsModal.style.display = "none";
|
//pipelineSettingsModal.style.display = "none";
|
||||||
});
|
});
|
||||||
pipelineSettingsContent.appendChild(saveButton);
|
pipelineSettingsContent.appendChild(saveButton);
|
||||||
|
saveButton.click();
|
||||||
//pipelineSettingsModal.style.display = "block";
|
//pipelineSettingsModal.style.display = "block";
|
||||||
|
|
||||||
//pipelineSettingsModal.getElementsByClassName("close")[0].onclick = function() {
|
//pipelineSettingsModal.getElementsByClassName("close")[0].onclick = function() {
|
||||||
|
@ -477,11 +482,19 @@
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
showpipelineSettingsModal(selectedOperation);
|
||||||
updateConfigInDropdown();
|
updateConfigInDropdown();
|
||||||
hideOrShowPipelineHeader();
|
hideOrShowPipelineHeader();
|
||||||
});
|
|
||||||
|
|
||||||
function updateConfigInDropdown() {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function updateConfigInDropdown() {
|
||||||
let pipelineSelect = document.getElementById('pipelineSelect');
|
let pipelineSelect = document.getElementById('pipelineSelect');
|
||||||
let selectedOption = pipelineSelect.options[pipelineSelect.selectedIndex];
|
let selectedOption = pipelineSelect.options[pipelineSelect.selectedIndex];
|
||||||
|
|
||||||
|
@ -496,18 +509,18 @@
|
||||||
// Update the value of the selected option with the new configuration
|
// Update the value of the selected option with the new configuration
|
||||||
selectedOption.value = pipelineConfigJson;
|
selectedOption.value = pipelineConfigJson;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var saveBtn = document.getElementById('savePipelineBtn');
|
var saveBtn = document.getElementById('savePipelineBtn');
|
||||||
|
|
||||||
// Remove any existing event listeners
|
// Remove any existing event listeners
|
||||||
saveBtn.removeEventListener('click', savePipeline);
|
saveBtn.removeEventListener('click', savePipeline);
|
||||||
|
|
||||||
// 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 configToJson() {
|
function configToJson() {
|
||||||
if (!validatePipeline()) {
|
if (!validatePipeline()) {
|
||||||
return null; // Return null if validation fails
|
return null; // Return null if validation fails
|
||||||
}
|
}
|
||||||
|
@ -538,11 +551,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSON.stringify(pipelineConfig, null, 2);
|
return JSON.stringify(pipelineConfig, null, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function savePipeline() {
|
function savePipeline() {
|
||||||
let pipelineConfigJson = configToJson();
|
let pipelineConfigJson = configToJson();
|
||||||
if (!pipelineConfigJson) {
|
if (!pipelineConfigJson) {
|
||||||
console.error("Failed to save pipeline: Invalid configuration");
|
console.error("Failed to save pipeline: Invalid configuration");
|
||||||
|
@ -559,11 +572,11 @@
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function processPipelineConfig(configString) {
|
async function processPipelineConfig(configString) {
|
||||||
console.log("configString",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');
|
||||||
|
|
||||||
|
@ -614,29 +627,29 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
document.getElementById('uploadPipelineBtn').addEventListener('click', function() {
|
document.getElementById('uploadPipelineBtn').addEventListener('click', function() {
|
||||||
document.getElementById('uploadPipelineInput').click();
|
document.getElementById('uploadPipelineInput').click();
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('uploadPipelineInput').addEventListener('change', function(e) {
|
document.getElementById('uploadPipelineInput').addEventListener('change', function(e) {
|
||||||
let reader = new FileReader();
|
let reader = new FileReader();
|
||||||
reader.onload = function(event) {
|
reader.onload = function(event) {
|
||||||
processPipelineConfig(event.target.result);
|
processPipelineConfig(event.target.result);
|
||||||
};
|
};
|
||||||
reader.readAsText(e.target.files[0]);
|
reader.readAsText(e.target.files[0]);
|
||||||
hideOrShowPipelineHeader();
|
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
|
let selectedPipelineJson = e.target.value; // assuming the selected value is the JSON string of the pipeline config
|
||||||
processPipelineConfig(selectedPipelineJson);
|
processPipelineConfig(selectedPipelineJson);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function hideOrShowPipelineHeader() {
|
function hideOrShowPipelineHeader() {
|
||||||
var pipelineHeader = document.getElementById('pipelineHeader');
|
var pipelineHeader = document.getElementById('pipelineHeader');
|
||||||
var pipelineList = document.getElementById('pipelineList');
|
var pipelineList = document.getElementById('pipelineList');
|
||||||
|
|
||||||
|
@ -647,4 +660,4 @@
|
||||||
// Show the pipeline header if there are items in the pipeline list
|
// Show the pipeline header if there are items in the pipeline list
|
||||||
pipelineHeader.style.display = 'block';
|
pipelineHeader.style.display = 'block';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,8 +102,6 @@
|
||||||
|
|
||||||
<h3>Todo</h3>
|
<h3>Todo</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Fix operation adding requering settings to be openned and
|
|
||||||
saved instead of saving defaults</li>
|
|
||||||
<li>Translation support</li>
|
<li>Translation support</li>
|
||||||
<li>Save to browser/Account</li>
|
<li>Save to browser/Account</li>
|
||||||
<li>offline mode checks and testing</li>
|
<li>offline mode checks and testing</li>
|
||||||
|
|
Loading…
Reference in a new issue