pipe
This commit is contained in:
parent
0cebe69ff8
commit
aed48ffc93
1 changed files with 227 additions and 87 deletions
|
@ -1,82 +1,109 @@
|
||||||
<!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>
|
||||||
|
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="page-container">
|
<div id="page-container">
|
||||||
<div id="content-wrap">
|
<div id="content-wrap">
|
||||||
<div th:insert="~{fragments/navbar.html :: navbar}"></div>
|
<div th:insert="~{fragments/navbar.html :: navbar}"></div>
|
||||||
<br> <br>
|
<br> <br>
|
||||||
<div class="container" id="dropContainer">
|
<div class="container" id="dropContainer">
|
||||||
<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">
|
|
||||||
<!-- Options will be dynamically populated here -->
|
|
||||||
</select>
|
|
||||||
<button id="addOperationBtn">Add operation to pipeline</button>
|
|
||||||
<h3>Pipeline:</h3>
|
|
||||||
<ol id="pipelineList">
|
|
||||||
<!-- Pipeline operations will be dynamically populated here -->
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- pipelineSettings modal -->
|
<!-- Pipeline Configuration Card Header -->
|
||||||
<div id="pipelineSettingsModal" class="modal">
|
<div class="card-header">
|
||||||
<div class="modal-content">
|
<h2 class="card-title">Pipeline Configuration</h2>
|
||||||
<div class="modal-body">
|
</div>
|
||||||
<span class="close">×</span>
|
|
||||||
<h2>Operation Settings</h2>
|
<!-- Pipeline Configuration Body -->
|
||||||
<div id="pipelineSettingsContent">
|
<div class="card-body">
|
||||||
<!-- pipelineSettings will be dynamically populated here -->
|
<div class="mb-3">
|
||||||
</div>
|
<select id="operationsDropdown" class="form-select">
|
||||||
</div>
|
<!-- Options will be dynamically populated here -->
|
||||||
</div>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<style>
|
<div class="mb-3">
|
||||||
.modal {
|
<button id="addOperationBtn" class="btn btn-primary">Add
|
||||||
display: none; /* Hidden by default */
|
operation to pipeline</button>
|
||||||
position: fixed; /* Stay in place */
|
</div>
|
||||||
z-index: 1; /* Sit on top */
|
<h3>Pipeline:</h3>
|
||||||
padding-top: 100px; /* Location of the box */
|
<ol id="pipelineList" class="list-group">
|
||||||
left: 0;
|
<!-- Pipeline operations will be dynamically populated here -->
|
||||||
top: 0;
|
</ol>
|
||||||
width: 100%; /* Full width */
|
</div>
|
||||||
height: 100%; /* Full height */
|
|
||||||
overflow: auto; /* Enable scroll if needed */
|
</div>
|
||||||
background-color: rgb(0,0,0); /* Fallback color */
|
|
||||||
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
<!-- pipelineSettings modal -->
|
||||||
|
<div id="pipelineSettingsModal" class="modal">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-body">
|
||||||
|
<span class="close">×</span>
|
||||||
|
<h2>Operation Settings</h2>
|
||||||
|
<div id="pipelineSettingsContent">
|
||||||
|
<!-- pipelineSettings will be dynamically populated here -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<style>
|
||||||
|
.modal {
|
||||||
|
display: none; /* Hidden by default */
|
||||||
|
position: fixed; /* Stay in place */
|
||||||
|
z-index: 1; /* Sit on top */
|
||||||
|
padding-top: 100px; /* Location of the box */
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
width: 100%; /* Full width */
|
||||||
|
height: 100%; /* Full height */
|
||||||
|
overflow: auto; /* Enable scroll if needed */
|
||||||
|
background-color: rgb(0, 0, 0); /* Fallback color */
|
||||||
|
background-color: rgba(0, 0, 0, 0.4); /* Black w/ opacity */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modal Content */
|
/* Modal Content */
|
||||||
.modal-content {
|
.modal-content {
|
||||||
background-color: #fefefe;
|
background-color: #fefefe;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
border: 1px solid #888;
|
border: 1px solid #888;
|
||||||
width: 50%;
|
width: 50%;
|
||||||
}
|
}
|
||||||
.btn-margin {
|
|
||||||
margin-right: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
.btn-margin {
|
||||||
|
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>
|
||||||
|
|
||||||
|
@ -270,11 +410,11 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in a new issue