pipe
This commit is contained in:
parent
0cebe69ff8
commit
aed48ffc93
1 changed files with 227 additions and 87 deletions
|
@ -1,5 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html th:lang="${#locale.toString()}" th:lang-direction="#{language.direction}" xmlns:th="http://www.thymeleaf.org">
|
<html th:lang="${#locale.toString()}"
|
||||||
|
th:lang-direction="#{language.direction}"
|
||||||
|
xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title=#{merge.title})}"></th:block>
|
<th:block th:insert="~{fragments/common :: head(title=#{merge.title})}"></th:block>
|
||||||
|
|
||||||
|
@ -13,18 +15,43 @@
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<button id="savePipelineBtn" class="btn btn-success">Save
|
||||||
|
Pipeline Configuration</button>
|
||||||
|
<div class="btn-group">
|
||||||
|
<button id="uploadPipelineBtn" class="btn btn-primary">Upload
|
||||||
|
Pipeline Configuration</button>
|
||||||
|
<input type="file" id="uploadPipelineInput" accept=".json"
|
||||||
|
style="display: none;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="pipelineContainer">
|
<div id="pipelineContainer" class="card">
|
||||||
<select id="operationsDropdown">
|
|
||||||
|
<!-- Pipeline Configuration Card Header -->
|
||||||
|
<div class="card-header">
|
||||||
|
<h2 class="card-title">Pipeline Configuration</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Pipeline Configuration Body -->
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="mb-3">
|
||||||
|
<select id="operationsDropdown" class="form-select">
|
||||||
<!-- Options will be dynamically populated here -->
|
<!-- Options will be dynamically populated here -->
|
||||||
</select>
|
</select>
|
||||||
<button id="addOperationBtn">Add operation to pipeline</button>
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<button id="addOperationBtn" class="btn btn-primary">Add
|
||||||
|
operation to pipeline</button>
|
||||||
|
</div>
|
||||||
<h3>Pipeline:</h3>
|
<h3>Pipeline:</h3>
|
||||||
<ol id="pipelineList">
|
<ol id="pipelineList" class="list-group">
|
||||||
<!-- Pipeline operations will be dynamically populated here -->
|
<!-- Pipeline operations will be dynamically populated here -->
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- pipelineSettings modal -->
|
<!-- pipelineSettings modal -->
|
||||||
<div id="pipelineSettingsModal" class="modal">
|
<div id="pipelineSettingsModal" class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
@ -60,23 +87,23 @@
|
||||||
border: 1px solid #888;
|
border: 1px solid #888;
|
||||||
width: 50%;
|
width: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-margin {
|
.btn-margin {
|
||||||
margin-right: 2px;
|
margin-right: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.modal-body {
|
.modal-body {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
|
||||||
let apiDocs = {};
|
let apiDocs = {};
|
||||||
|
|
||||||
|
let operationSettings = {};
|
||||||
|
|
||||||
fetch('v3/api-docs')
|
fetch('v3/api-docs')
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
@ -191,6 +218,30 @@
|
||||||
parameterInput.className = "form-control";
|
parameterInput.className = "form-control";
|
||||||
}
|
}
|
||||||
parameterInput.id = parameter.name;
|
parameterInput.id = parameter.name;
|
||||||
|
|
||||||
|
// Check if there are saved settings for this operation and this parameter
|
||||||
|
if(operationSettings[operation] && operationSettings[operation][parameter.name] !== undefined) {
|
||||||
|
let savedValue = operationSettings[operation][parameter.name];
|
||||||
|
|
||||||
|
// Set the value in the input field according to the type of the parameter
|
||||||
|
switch(parameter.schema.type) {
|
||||||
|
case 'number':
|
||||||
|
case 'integer':
|
||||||
|
parameterInput.value = savedValue.toString();
|
||||||
|
break;
|
||||||
|
case 'boolean':
|
||||||
|
parameterInput.checked = savedValue;
|
||||||
|
break;
|
||||||
|
case 'array':
|
||||||
|
case 'object':
|
||||||
|
parameterInput.value = JSON.stringify(savedValue);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
parameterInput.value = savedValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
parameterDiv.appendChild(parameterInput);
|
parameterDiv.appendChild(parameterInput);
|
||||||
|
|
||||||
pipelineSettingsContent.appendChild(parameterDiv);
|
pipelineSettingsContent.appendChild(parameterDiv);
|
||||||
|
@ -225,6 +276,7 @@
|
||||||
settings[parameter.name] = value;
|
settings[parameter.name] = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
operationSettings[operation] = settings;
|
||||||
console.log(settings); // TODO: Save these settings in your desired format
|
console.log(settings); // TODO: Save these settings in your desired format
|
||||||
pipelineSettingsModal.style.display = "none";
|
pipelineSettingsModal.style.display = "none";
|
||||||
});
|
});
|
||||||
|
@ -247,6 +299,94 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
document.getElementById('savePipelineBtn').addEventListener('click', function() {
|
||||||
|
let pipelineList = document.getElementById('pipelineList').children;
|
||||||
|
let pipelineConfig = {
|
||||||
|
"name": "uniquePipelineName",
|
||||||
|
"pipeline": []
|
||||||
|
};
|
||||||
|
|
||||||
|
for(let i=0; i<pipelineList.length; i++) {
|
||||||
|
let operationName = pipelineList[i].querySelector('.operationName').textContent;
|
||||||
|
let parameters = operationSettings[operationName] || {}; // Retrieve saved parameters for this operation
|
||||||
|
|
||||||
|
pipelineConfig.pipeline.push({
|
||||||
|
"operation": operationName,
|
||||||
|
"parameters": parameters
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let a = document.createElement('a');
|
||||||
|
a.href = URL.createObjectURL(new Blob([JSON.stringify(pipelineConfig, null, 2)], {
|
||||||
|
type: 'application/json'
|
||||||
|
}));
|
||||||
|
a.download = 'pipelineConfig.json';
|
||||||
|
a.style.display = 'none';
|
||||||
|
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('uploadPipelineBtn').addEventListener('click', function() {
|
||||||
|
document.getElementById('uploadPipelineInput').click();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('uploadPipelineInput').addEventListener('change', function(e) {
|
||||||
|
let reader = new FileReader();
|
||||||
|
reader.onload = function(event) {
|
||||||
|
let pipelineConfig = JSON.parse(event.target.result);
|
||||||
|
let pipelineList = document.getElementById('pipelineList');
|
||||||
|
|
||||||
|
// clear the existing pipeline list
|
||||||
|
while(pipelineList.firstChild) {
|
||||||
|
pipelineList.removeChild(pipelineList.firstChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
// populate the pipeline list with operations from the uploaded configuration
|
||||||
|
pipelineConfig.pipeline.forEach(operationConfig => {
|
||||||
|
let operationsDropdown = document.getElementById('operationsDropdown');
|
||||||
|
operationsDropdown.value = operationConfig.operation;
|
||||||
|
operationSettings[operationConfig.operation] = operationConfig.parameters;
|
||||||
|
document.getElementById('addOperationBtn').click();
|
||||||
|
|
||||||
|
// get the last added operation
|
||||||
|
let lastOperation = pipelineList.lastChild;
|
||||||
|
|
||||||
|
// open the settings modal
|
||||||
|
lastOperation.querySelector('.pipelineSettings').click();
|
||||||
|
|
||||||
|
// set the parameters for the added operation
|
||||||
|
Object.keys(operationConfig.parameters).forEach(parameterName => {
|
||||||
|
let input = document.getElementById(parameterName);
|
||||||
|
if(input) {
|
||||||
|
switch(input.type) {
|
||||||
|
case 'checkbox':
|
||||||
|
input.checked = operationConfig.parameters[parameterName];
|
||||||
|
break;
|
||||||
|
case 'number':
|
||||||
|
input.value = operationConfig.parameters[parameterName].toString();
|
||||||
|
break;
|
||||||
|
case 'text':
|
||||||
|
case 'textarea':
|
||||||
|
default:
|
||||||
|
input.value = JSON.stringify(operationConfig.parameters[parameterName]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// save the settings
|
||||||
|
document.querySelector('#pipelineSettingsModal .btn-primary').click();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
reader.readAsText(e.target.files[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue