Generate connector form based on meta-data (#62)

* Ignore volumes and exe

* Export form meta-data

* use dynamic metaform for connectors

* fix populating form
This commit is contained in:
Richard Palethorpe
2025-03-20 15:00:37 +00:00
committed by GitHub
parent 43a46ad1fb
commit d7cfa7f0b2
15 changed files with 630 additions and 78 deletions

View File

@@ -190,10 +190,16 @@
updateButton.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Updating...';
updateButton.disabled = true;
// Get the agent name from the hidden input field
const agentName = document.getElementById('name').value;
// Build a structured data object
const formData = new FormData(form);
const jsonData = AgentFormUtils.processFormData(formData);
// Ensure the name is set correctly
jsonData.name = agentName;
// Process special fields
jsonData.connectors = AgentFormUtils.processConnectors(updateButton);
if (jsonData.connectors === null) return; // Validation failed
@@ -209,7 +215,7 @@
console.log('Sending data:', jsonData);
// Send the structured data as JSON
fetch(`/api/agent/${jsonData.name}/config`, {
fetch(`/api/agent/${agentName}/config`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
@@ -360,16 +366,13 @@
// Find the added connector elements
const connectorType = document.getElementById(`connectorType${index}`);
const connectorConfig = document.getElementById(`connectorConfig${index}`);
// Set values
// Set connector type value
if (connectorType) {
AgentFormUtils.setSelectValue(connectorType, connector.type);
}
if (connectorConfig) {
// Format the config value
AgentFormUtils.formatConfigValue(connectorConfig, connector.config);
// Load the connector form with the existing config data
loadConnectorForm(index, connector.type, connector.config);
}
});
}