chore(ui): Move zombie UI to old
This commit is contained in:
564
webui/old/public/js/agent-form.js
Normal file
564
webui/old/public/js/agent-form.js
Normal file
@@ -0,0 +1,564 @@
|
||||
// Common utility functions for agent forms
|
||||
const AgentFormUtils = {
|
||||
// Add dynamic component based on template
|
||||
addDynamicComponent: function(sectionId, templateFunction, dataItems) {
|
||||
const section = document.getElementById(sectionId);
|
||||
const newIndex = section.getElementsByClassName(dataItems.className).length;
|
||||
|
||||
// Generate HTML from template function
|
||||
const newHtml = templateFunction(newIndex, dataItems);
|
||||
|
||||
// Add to DOM
|
||||
section.insertAdjacentHTML('beforeend', newHtml);
|
||||
},
|
||||
|
||||
// Process form data into JSON structure
|
||||
processFormData: function(formData) {
|
||||
const jsonData = {};
|
||||
|
||||
// Process basic form fields
|
||||
for (const [key, value] of formData.entries()) {
|
||||
// Skip the array fields as they'll be processed separately
|
||||
if (!key.includes('[') && !key.includes('].')) {
|
||||
// Handle checkboxes
|
||||
if (value === 'on') {
|
||||
jsonData[key] = true;
|
||||
}
|
||||
// Handle numeric fields - specifically kb_results
|
||||
else if (key === 'kb_results') {
|
||||
// Convert to integer or default to 3 if empty
|
||||
jsonData[key] = value ? parseInt(value, 10) : 3;
|
||||
|
||||
// Check if the parse was successful
|
||||
if (isNaN(jsonData[key])) {
|
||||
showToast('Knowledge Base Results must be a number', 'error');
|
||||
return null; // Indicate validation error
|
||||
}
|
||||
}
|
||||
// Handle other numeric fields if needed
|
||||
else if (key === 'periodic_runs' && value) {
|
||||
// Try to parse as number if it looks like one
|
||||
const numValue = parseInt(value, 10);
|
||||
if (!isNaN(numValue) && String(numValue) === value) {
|
||||
jsonData[key] = numValue;
|
||||
} else {
|
||||
jsonData[key] = value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
jsonData[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return jsonData;
|
||||
},
|
||||
|
||||
// Process connectors from form
|
||||
processConnectors: function(button) {
|
||||
const connectors = [];
|
||||
const connectorElements = document.querySelectorAll('.connector');
|
||||
|
||||
for (let i = 0; i < connectorElements.length; i++) {
|
||||
const typeSelect = document.getElementById(`connectorType${i}`);
|
||||
if (!typeSelect) {
|
||||
showToast(`Error: Could not find connector type select for index ${i}`, 'error');
|
||||
button.innerHTML = button.getAttribute('data-original-text');
|
||||
button.disabled = false;
|
||||
return null; // Validation failed
|
||||
}
|
||||
|
||||
const type = typeSelect.value;
|
||||
if (!type) {
|
||||
showToast(`Please select a connector type for connector ${i+1}`, 'error');
|
||||
button.innerHTML = button.getAttribute('data-original-text');
|
||||
button.disabled = false;
|
||||
return null; // Validation failed
|
||||
}
|
||||
|
||||
// Get all config fields for this connector
|
||||
const connector = {
|
||||
type: type,
|
||||
config: {}
|
||||
};
|
||||
|
||||
// Find all config inputs for this connector
|
||||
const configInputs = document.querySelectorAll(`[name^="connectors[${i}][config]"]`);
|
||||
|
||||
// Check if we have a JSON textarea (fallback template)
|
||||
const jsonTextarea = document.getElementById(`connectorConfig${i}`);
|
||||
if (jsonTextarea && jsonTextarea.value) {
|
||||
try {
|
||||
// If it's a JSON textarea, parse it and use the result
|
||||
const jsonConfig = JSON.parse(jsonTextarea.value);
|
||||
// Convert the parsed JSON back to a string for the backend
|
||||
connector.config = JSON.stringify(jsonConfig);
|
||||
} catch (e) {
|
||||
// If it's not valid JSON, use it as is
|
||||
connector.config = jsonTextarea.value;
|
||||
}
|
||||
} else {
|
||||
// Process individual form fields
|
||||
configInputs.forEach(input => {
|
||||
// Extract the key from the name attribute
|
||||
// Format: connectors[0][config][key]
|
||||
const keyMatch = input.name.match(/\[config\]\[([^\]]+)\]/);
|
||||
if (keyMatch && keyMatch[1]) {
|
||||
const key = keyMatch[1];
|
||||
// For checkboxes, set true/false based on checked state
|
||||
if (input.type === 'checkbox') {
|
||||
connector.config[key] = input.checked ? 'true' : 'false';
|
||||
} else {
|
||||
connector.config[key] = input.value;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Convert the config object to a JSON string for the backend
|
||||
connector.config = JSON.stringify(connector.config);
|
||||
}
|
||||
|
||||
connectors.push(connector);
|
||||
}
|
||||
|
||||
return connectors;
|
||||
},
|
||||
|
||||
// Process MCP servers from form
|
||||
processMCPServers: function() {
|
||||
const mcpServers = [];
|
||||
const mcpElements = document.querySelectorAll('.mcp_server');
|
||||
|
||||
for (let i = 0; i < mcpElements.length; i++) {
|
||||
const urlInput = document.getElementById(`mcpURL${i}`);
|
||||
const tokenInput = document.getElementById(`mcpToken${i}`);
|
||||
|
||||
if (urlInput && urlInput.value) {
|
||||
const server = {
|
||||
url: urlInput.value
|
||||
};
|
||||
|
||||
// Add token if present
|
||||
if (tokenInput && tokenInput.value) {
|
||||
server.token = tokenInput.value;
|
||||
}
|
||||
|
||||
mcpServers.push(server);
|
||||
}
|
||||
}
|
||||
|
||||
return mcpServers;
|
||||
},
|
||||
|
||||
// Process actions from form
|
||||
processActions: function(button) {
|
||||
const actions = [];
|
||||
const actionElements = document.querySelectorAll('.action');
|
||||
|
||||
for (let i = 0; i < actionElements.length; i++) {
|
||||
const nameSelect = document.getElementById(`actionsName${i}`);
|
||||
const configTextarea = document.getElementById(`actionsConfig${i}`);
|
||||
|
||||
if (!nameSelect) {
|
||||
showToast(`Error: Could not find action name select for index ${i}`, 'error');
|
||||
button.innerHTML = button.getAttribute('data-original-text');
|
||||
button.disabled = false;
|
||||
return null; // Validation failed
|
||||
}
|
||||
|
||||
const name = nameSelect.value;
|
||||
if (!name) {
|
||||
showToast(`Please select an action type for action ${i+1}`, 'error');
|
||||
button.innerHTML = button.getAttribute('data-original-text');
|
||||
button.disabled = false;
|
||||
return null; // Validation failed
|
||||
}
|
||||
|
||||
let config = {};
|
||||
if (configTextarea && configTextarea.value) {
|
||||
try {
|
||||
config = JSON.parse(configTextarea.value);
|
||||
} catch (e) {
|
||||
showToast(`Invalid JSON in action ${i+1} config: ${e.message}`, 'error');
|
||||
button.innerHTML = button.getAttribute('data-original-text');
|
||||
button.disabled = false;
|
||||
return null; // Validation failed
|
||||
}
|
||||
}
|
||||
|
||||
actions.push({
|
||||
name: name,
|
||||
config: JSON.stringify(config) // Convert to JSON string for backend
|
||||
});
|
||||
}
|
||||
|
||||
return actions;
|
||||
},
|
||||
|
||||
// Process prompt blocks from form
|
||||
processPromptBlocks: function(button) {
|
||||
const promptBlocks = [];
|
||||
const promptElements = document.querySelectorAll('.prompt_block');
|
||||
|
||||
for (let i = 0; i < promptElements.length; i++) {
|
||||
const nameSelect = document.getElementById(`promptName${i}`);
|
||||
const configTextarea = document.getElementById(`promptConfig${i}`);
|
||||
|
||||
if (!nameSelect) {
|
||||
showToast(`Error: Could not find prompt block name select for index ${i}`, 'error');
|
||||
button.innerHTML = button.getAttribute('data-original-text');
|
||||
button.disabled = false;
|
||||
return null; // Validation failed
|
||||
}
|
||||
|
||||
const name = nameSelect.value;
|
||||
if (!name) {
|
||||
showToast(`Please select a prompt block type for block ${i+1}`, 'error');
|
||||
button.innerHTML = button.getAttribute('data-original-text');
|
||||
button.disabled = false;
|
||||
return null; // Validation failed
|
||||
}
|
||||
|
||||
let config = {};
|
||||
if (configTextarea && configTextarea.value) {
|
||||
try {
|
||||
config = JSON.parse(configTextarea.value);
|
||||
} catch (e) {
|
||||
showToast(`Invalid JSON in prompt block ${i+1} config: ${e.message}`, 'error');
|
||||
button.innerHTML = button.getAttribute('data-original-text');
|
||||
button.disabled = false;
|
||||
return null; // Validation failed
|
||||
}
|
||||
}
|
||||
|
||||
promptBlocks.push({
|
||||
name: name,
|
||||
config: JSON.stringify(config) // Convert to JSON string for backend
|
||||
});
|
||||
}
|
||||
|
||||
return promptBlocks;
|
||||
},
|
||||
|
||||
// Helper function to format config values (for edit form)
|
||||
formatConfigValue: function(configElement, configValue) {
|
||||
if (!configElement) return;
|
||||
|
||||
// If configValue is an object, stringify it
|
||||
if (typeof configValue === 'object' && configValue !== null) {
|
||||
try {
|
||||
configElement.value = JSON.stringify(configValue, null, 2);
|
||||
} catch (e) {
|
||||
console.error('Error stringifying config value:', e);
|
||||
configElement.value = '{}';
|
||||
}
|
||||
}
|
||||
// If it's a string that looks like JSON, try to parse and pretty print it
|
||||
else if (typeof configValue === 'string' && (configValue.startsWith('{') || configValue.startsWith('['))) {
|
||||
try {
|
||||
const parsed = JSON.parse(configValue);
|
||||
configElement.value = JSON.stringify(parsed, null, 2);
|
||||
} catch (e) {
|
||||
// If it's not valid JSON, just use the string as is
|
||||
configElement.value = configValue;
|
||||
}
|
||||
}
|
||||
// Otherwise, just use the value as is
|
||||
else {
|
||||
configElement.value = configValue || '';
|
||||
}
|
||||
},
|
||||
|
||||
// Helper function to set select value (with fallback if option doesn't exist)
|
||||
setSelectValue: function(selectElement, value) {
|
||||
if (!selectElement) return;
|
||||
|
||||
// Check if the option exists
|
||||
let optionExists = false;
|
||||
for (let i = 0; i < selectElement.options.length; i++) {
|
||||
if (selectElement.options[i].value === value) {
|
||||
optionExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the value if the option exists
|
||||
if (optionExists) {
|
||||
selectElement.value = value;
|
||||
} else if (selectElement.options.length > 0) {
|
||||
// Otherwise, select the first option
|
||||
selectElement.selectedIndex = 0;
|
||||
}
|
||||
},
|
||||
|
||||
// Render connector form based on type
|
||||
renderConnectorForm: function(index, type, config = {}) {
|
||||
const formContainer = document.getElementById(`connectorFormContainer${index}`);
|
||||
if (!formContainer) return;
|
||||
|
||||
// Clear existing form
|
||||
formContainer.innerHTML = '';
|
||||
|
||||
// Debug log to see what's happening
|
||||
console.log(`Rendering connector form for type: ${type}`);
|
||||
console.log(`Config for connector:`, config);
|
||||
console.log(`Available templates:`, ConnectorTemplates ? Object.keys(ConnectorTemplates) : 'None');
|
||||
|
||||
// Ensure config is an object
|
||||
let configObj = config;
|
||||
if (typeof config === 'string') {
|
||||
try {
|
||||
configObj = JSON.parse(config);
|
||||
} catch (e) {
|
||||
console.error('Error parsing connector config string:', e);
|
||||
configObj = {};
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a template for this connector type in the global ConnectorTemplates object
|
||||
if (ConnectorTemplates && type && ConnectorTemplates[type]) {
|
||||
console.log(`Found template for ${type}`);
|
||||
// Get the template result which contains HTML and setValues function
|
||||
const templateResult = ConnectorTemplates[type](configObj, index);
|
||||
|
||||
// Set the HTML content
|
||||
formContainer.innerHTML = templateResult.html;
|
||||
|
||||
// Call the setValues function to set input values safely
|
||||
if (typeof templateResult.setValues === 'function') {
|
||||
setTimeout(templateResult.setValues, 0);
|
||||
}
|
||||
} else {
|
||||
console.log(`No template found for ${type}, using fallback`);
|
||||
// Use the fallback template
|
||||
if (ConnectorTemplates && ConnectorTemplates.fallback) {
|
||||
const fallbackResult = ConnectorTemplates.fallback(configObj, index);
|
||||
formContainer.innerHTML = fallbackResult.html;
|
||||
|
||||
if (typeof fallbackResult.setValues === 'function') {
|
||||
setTimeout(fallbackResult.setValues, 0);
|
||||
}
|
||||
} else {
|
||||
// Fallback to generic JSON textarea if no fallback template
|
||||
formContainer.innerHTML = `
|
||||
<div class="form-group">
|
||||
<label for="connectorConfig${index}">Connector Config (JSON)</label>
|
||||
<textarea id="connectorConfig${index}"
|
||||
name="connectors[${index}][config]"
|
||||
class="form-control"
|
||||
placeholder='{"key":"value"}'></textarea>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Set the value safely after DOM is created
|
||||
setTimeout(function() {
|
||||
const configTextarea = document.getElementById(`connectorConfig${index}`);
|
||||
if (configTextarea) {
|
||||
if (typeof configObj === 'object' && configObj !== null) {
|
||||
configTextarea.value = JSON.stringify(configObj, null, 2);
|
||||
} else if (typeof config === 'string') {
|
||||
configTextarea.value = config;
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// HTML Templates for dynamic elements
|
||||
const AgentFormTemplates = {
|
||||
// Connector template
|
||||
connectorTemplate: function(index, data) {
|
||||
return `
|
||||
<div class="connector mb-4 section-box" style="margin-top: 15px; padding: 15px;">
|
||||
<h2>Connector ${index + 1}</h2>
|
||||
<div class="mb-4">
|
||||
<label for="connectorType${index}">Connector Type</label>
|
||||
<select name="connectors[${index}][type]"
|
||||
id="connectorType${index}"
|
||||
class="form-control"
|
||||
onchange="AgentFormUtils.renderConnectorForm(${index}, this.value)">
|
||||
<option value="">Select Connector Type</option>
|
||||
${data.options}
|
||||
</select>
|
||||
</div>
|
||||
<div id="connectorFormContainer${index}">
|
||||
<!-- Connector form will be dynamically inserted here -->
|
||||
<div class="form-group">
|
||||
<div class="placeholder-text">Select a connector type to configure</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="remove-btn" onclick="this.closest('.connector').remove()">
|
||||
<i class="fas fa-trash"></i> Remove Connector
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
},
|
||||
|
||||
// MCP Server template
|
||||
mcpServerTemplate: function(index, data) {
|
||||
return `
|
||||
<div class="mcp_server mb-4 section-box" style="margin-top: 15px; padding: 15px;">
|
||||
<h2>MCP Server ${index + 1}</h2>
|
||||
<div class="mb-4">
|
||||
<label for="mcpURL${index}">Server URL</label>
|
||||
<input type="text" id="mcpURL${index}" name="mcp_servers[${index}][url]" placeholder="https://example.com">
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="mcpToken${index}">API Token (Optional)</label>
|
||||
<input type="text" id="mcpToken${index}" name="mcp_servers[${index}][token]" placeholder="API token">
|
||||
</div>
|
||||
<button type="button" class="remove-btn" onclick="this.closest('.mcp_server').remove()">
|
||||
<i class="fas fa-trash"></i> Remove Server
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
},
|
||||
|
||||
// Action template
|
||||
actionTemplate: function(index, data) {
|
||||
return `
|
||||
<div class="action mb-4 section-box" style="margin-top: 15px; padding: 15px;">
|
||||
<h2>Action ${index + 1}</h2>
|
||||
<div class="mb-4">
|
||||
<label for="actionsName${index}">Action Type</label>
|
||||
<select name="actions[${index}][name]" id="actionsName${index}">
|
||||
${data.options}
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="actionsConfig${index}">Action Config (JSON)</label>
|
||||
<textarea id="actionsConfig${index}" name="actions[${index}][config]" placeholder='{"key":"value"}'>{}</textarea>
|
||||
</div>
|
||||
<button type="button" class="remove-btn" onclick="this.closest('.action').remove()">
|
||||
<i class="fas fa-trash"></i> Remove Action
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
},
|
||||
|
||||
// Prompt Block template
|
||||
promptBlockTemplate: function(index, data) {
|
||||
return `
|
||||
<div class="prompt_block mb-4 section-box" style="margin-top: 15px; padding: 15px;">
|
||||
<h2>Prompt Block ${index + 1}</h2>
|
||||
<div class="mb-4">
|
||||
<label for="promptName${index}">Prompt Block Type</label>
|
||||
<select name="promptblocks[${index}][name]" id="promptName${index}">
|
||||
${data.options}
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="promptConfig${index}">Prompt Block Config (JSON)</label>
|
||||
<textarea id="promptConfig${index}" name="promptblocks[${index}][config]" placeholder='{"key":"value"}'>{}</textarea>
|
||||
</div>
|
||||
<button type="button" class="remove-btn" onclick="this.closest('.prompt_block').remove()">
|
||||
<i class="fas fa-trash"></i> Remove Prompt Block
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize form event listeners
|
||||
function initAgentFormCommon(options = {}) {
|
||||
// Add connector button
|
||||
const addConnectorButton = document.getElementById('addConnectorButton');
|
||||
if (addConnectorButton) {
|
||||
addConnectorButton.addEventListener('click', function() {
|
||||
// Create options string
|
||||
let optionsHtml = '';
|
||||
if (options.connectors) {
|
||||
optionsHtml = options.connectors;
|
||||
}
|
||||
|
||||
// Add new connector form
|
||||
AgentFormUtils.addDynamicComponent('connectorsSection', AgentFormTemplates.connectorTemplate, {
|
||||
className: 'connector',
|
||||
options: optionsHtml
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Add MCP server button
|
||||
const addMCPButton = document.getElementById('addMCPButton');
|
||||
if (addMCPButton) {
|
||||
addMCPButton.addEventListener('click', function() {
|
||||
// Add new MCP server form
|
||||
AgentFormUtils.addDynamicComponent('mcpSection', AgentFormTemplates.mcpServerTemplate, {
|
||||
className: 'mcp_server'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Add action button
|
||||
const actionButton = document.getElementById('action_button');
|
||||
if (actionButton) {
|
||||
actionButton.addEventListener('click', function() {
|
||||
// Create options string
|
||||
let optionsHtml = '';
|
||||
if (options.actions) {
|
||||
optionsHtml = options.actions;
|
||||
}
|
||||
|
||||
// Add new action form
|
||||
AgentFormUtils.addDynamicComponent('action_box', AgentFormTemplates.actionTemplate, {
|
||||
className: 'action',
|
||||
options: optionsHtml
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Add prompt block button
|
||||
const dynamicButton = document.getElementById('dynamic_button');
|
||||
if (dynamicButton) {
|
||||
dynamicButton.addEventListener('click', function() {
|
||||
// Create options string
|
||||
let optionsHtml = '';
|
||||
if (options.promptBlocks) {
|
||||
optionsHtml = options.promptBlocks;
|
||||
}
|
||||
|
||||
// Add new prompt block form
|
||||
AgentFormUtils.addDynamicComponent('dynamic_box', AgentFormTemplates.promptBlockTemplate, {
|
||||
className: 'prompt_block',
|
||||
options: optionsHtml
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Simple toast notification function
|
||||
function showToast(message, type) {
|
||||
// Check if toast container exists, if not create it
|
||||
let toast = document.getElementById('toast');
|
||||
if (!toast) {
|
||||
toast = document.createElement('div');
|
||||
toast.id = 'toast';
|
||||
toast.className = 'toast';
|
||||
|
||||
const toastMessage = document.createElement('div');
|
||||
toastMessage.id = 'toast-message';
|
||||
toast.appendChild(toastMessage);
|
||||
|
||||
document.body.appendChild(toast);
|
||||
}
|
||||
|
||||
const toastMessage = document.getElementById('toast-message');
|
||||
|
||||
// Set message
|
||||
toastMessage.textContent = message;
|
||||
|
||||
// Set type class
|
||||
toast.className = 'toast';
|
||||
toast.classList.add(`toast-${type}`);
|
||||
|
||||
// Show toast
|
||||
toast.classList.add('show');
|
||||
|
||||
// Hide after 3 seconds
|
||||
setTimeout(() => {
|
||||
toast.classList.remove('show');
|
||||
}, 3000);
|
||||
}
|
||||
44
webui/old/public/js/common.js
Normal file
44
webui/old/public/js/common.js
Normal file
@@ -0,0 +1,44 @@
|
||||
// Function to show toast notifications with enhanced animation
|
||||
function showToast(message, type) {
|
||||
const toast = document.getElementById('toast');
|
||||
const toastMessage = document.getElementById('toast-message');
|
||||
|
||||
// Set message
|
||||
toastMessage.textContent = message;
|
||||
|
||||
// Set toast type (success/error)
|
||||
toast.className = 'toast';
|
||||
toast.classList.add(type === 'success' ? 'toast-success' : 'toast-error');
|
||||
|
||||
// Show toast with enhanced animation
|
||||
setTimeout(() => {
|
||||
toast.classList.add('toast-visible');
|
||||
}, 100);
|
||||
|
||||
// Hide toast after 3 seconds with animation
|
||||
setTimeout(() => {
|
||||
toast.classList.remove('toast-visible');
|
||||
|
||||
// Clean up after animation completes
|
||||
setTimeout(() => {
|
||||
toast.className = 'toast';
|
||||
}, 400);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// Function to create the glitch effect on headings
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const headings = document.querySelectorAll('h1');
|
||||
|
||||
headings.forEach(heading => {
|
||||
heading.addEventListener('mouseover', function() {
|
||||
this.style.animation = 'glitch 0.3s infinite';
|
||||
});
|
||||
|
||||
heading.addEventListener('mouseout', function() {
|
||||
this.style.animation = 'neonPulse 2s infinite';
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
475
webui/old/public/js/connector-templates.js
Normal file
475
webui/old/public/js/connector-templates.js
Normal file
@@ -0,0 +1,475 @@
|
||||
/**
|
||||
* Connector Templates
|
||||
*
|
||||
* This file contains templates for all connector types supported by LocalAgent.
|
||||
* Each template is a function that returns an HTML string for the connector's form.
|
||||
*
|
||||
* Note: We don't need to escape HTML in the value attributes because browsers
|
||||
* handle these values safely when setting them via DOM properties after rendering.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Connector Templates
|
||||
* Each function takes a config object and returns an HTML string
|
||||
*/
|
||||
const ConnectorTemplates = {
|
||||
/**
|
||||
* Telegram Connector Template
|
||||
* @param {Object} config - Existing configuration values
|
||||
* @param {Number} index - Connector index
|
||||
* @returns {Object} HTML template and setValues function
|
||||
*/
|
||||
telegram: function(config = {}, index) {
|
||||
// Return HTML without values in the template string
|
||||
const html = `
|
||||
<div class="form-group">
|
||||
<label for="telegramToken${index}">Telegram Bot Token</label>
|
||||
<input type="text"
|
||||
id="telegramToken${index}"
|
||||
name="connectors[${index}][config][token]"
|
||||
class="form-control"
|
||||
placeholder="123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11">
|
||||
<small class="form-text text-muted">Get this from @BotFather on Telegram</small>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Function to set values after HTML is added to DOM to avoid XSS
|
||||
const setValues = function() {
|
||||
const input = document.getElementById(`telegramToken${index}`);
|
||||
if (input) input.value = config.token || '';
|
||||
};
|
||||
|
||||
return { html, setValues };
|
||||
},
|
||||
|
||||
/**
|
||||
* Slack Connector Template
|
||||
* @param {Object} config - Existing configuration values
|
||||
* @param {Number} index - Connector index
|
||||
* @returns {Object} HTML template and setValues function
|
||||
*/
|
||||
slack: function(config = {}, index) {
|
||||
// Return HTML without values in the template string
|
||||
const html = `
|
||||
<div class="form-group">
|
||||
<label for="slackAppToken${index}">Slack App Token</label>
|
||||
<input type="text"
|
||||
id="slackAppToken${index}"
|
||||
name="connectors[${index}][config][appToken]"
|
||||
class="form-control"
|
||||
placeholder="xapp-...">
|
||||
<small class="form-text text-muted">App-level token starting with xapp-</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="slackBotToken${index}">Slack Bot Token</label>
|
||||
<input type="text"
|
||||
id="slackBotToken${index}"
|
||||
name="connectors[${index}][config][botToken]"
|
||||
class="form-control"
|
||||
placeholder="xoxb-...">
|
||||
<small class="form-text text-muted">Bot token starting with xoxb-</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="slackChannelID${index}">Slack Channel ID</label>
|
||||
<input type="text"
|
||||
id="slackChannelID${index}"
|
||||
name="connectors[${index}][config][channelID]"
|
||||
class="form-control"
|
||||
placeholder="C012345678">
|
||||
<small class="form-text text-muted">Channel ID where the bot will operate</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-check">
|
||||
<input type="checkbox"
|
||||
class="form-check-input"
|
||||
id="slackAlwaysReply${index}"
|
||||
name="connectors[${index}][config][alwaysReply]">
|
||||
<label class="form-check-label" for="slackAlwaysReply${index}">Always Reply</label>
|
||||
<small class="form-text text-muted">If checked, the bot will reply to all messages in the channel</small>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Function to set values after HTML is added to DOM to avoid XSS
|
||||
const setValues = function() {
|
||||
const appTokenInput = document.getElementById(`slackAppToken${index}`);
|
||||
const botTokenInput = document.getElementById(`slackBotToken${index}`);
|
||||
const channelIDInput = document.getElementById(`slackChannelID${index}`);
|
||||
const alwaysReplyInput = document.getElementById(`slackAlwaysReply${index}`);
|
||||
|
||||
if (appTokenInput) appTokenInput.value = config.appToken || '';
|
||||
if (botTokenInput) botTokenInput.value = config.botToken || '';
|
||||
if (channelIDInput) channelIDInput.value = config.channelID || '';
|
||||
if (alwaysReplyInput) alwaysReplyInput.checked = config.alwaysReply === 'true';
|
||||
};
|
||||
|
||||
return { html, setValues };
|
||||
},
|
||||
|
||||
/**
|
||||
* Discord Connector Template
|
||||
* @param {Object} config - Existing configuration values
|
||||
* @param {Number} index - Connector index
|
||||
* @returns {Object} HTML template and setValues function
|
||||
*/
|
||||
discord: function(config = {}, index) {
|
||||
// Return HTML without values in the template string
|
||||
const html = `
|
||||
<div class="form-group">
|
||||
<label for="discordToken${index}">Discord Bot Token</label>
|
||||
<input type="text"
|
||||
id="discordToken${index}"
|
||||
name="connectors[${index}][config][token]"
|
||||
class="form-control"
|
||||
placeholder="Bot token from Discord Developer Portal">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="discordChannelID${index}">Default Channel ID</label>
|
||||
<input type="text"
|
||||
id="discordChannelID${index}"
|
||||
name="connectors[${index}][config][defaultChannel]"
|
||||
class="form-control"
|
||||
placeholder="Channel ID where the bot will operate">
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Function to set values after HTML is added to DOM
|
||||
const setValues = function() {
|
||||
const tokenInput = document.getElementById(`discordToken${index}`);
|
||||
const channelIDInput = document.getElementById(`discordChannelID${index}`);
|
||||
|
||||
if (tokenInput) tokenInput.value = config.token || '';
|
||||
if (channelIDInput) channelIDInput.value = config.defaultChannel || '';
|
||||
};
|
||||
|
||||
return { html, setValues };
|
||||
},
|
||||
|
||||
/**
|
||||
* GitHub Issues Connector Template
|
||||
* @param {Object} config - Existing configuration values
|
||||
* @param {Number} index - Connector index
|
||||
* @returns {Object} HTML template and setValues function
|
||||
*/
|
||||
'github-issues': function(config = {}, index) {
|
||||
// Return HTML without values in the template string
|
||||
const html = `
|
||||
<div class="form-group">
|
||||
<label for="githubIssuesToken${index}">GitHub Personal Access Token</label>
|
||||
<input type="text"
|
||||
id="githubIssuesToken${index}"
|
||||
name="connectors[${index}][config][token]"
|
||||
class="form-control"
|
||||
placeholder="ghp_...">
|
||||
<small class="form-text text-muted">Needs repo and read:org permissions</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="githubIssuesOwner${index}">Repository Owner</label>
|
||||
<input type="text"
|
||||
id="githubIssuesOwner${index}"
|
||||
name="connectors[${index}][config][owner]"
|
||||
class="form-control"
|
||||
placeholder="username or organization">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="githubIssuesRepo${index}">Repository Name</label>
|
||||
<input type="text"
|
||||
id="githubIssuesRepo${index}"
|
||||
name="connectors[${index}][config][repository]"
|
||||
class="form-control"
|
||||
placeholder="repository-name">
|
||||
</div>
|
||||
|
||||
<div class="form-group form-check">
|
||||
<input type="checkbox"
|
||||
class="form-check-input"
|
||||
id="githubIssuesReplyIfNoReplies${index}"
|
||||
name="connectors[${index}][config][replyIfNoReplies]"
|
||||
value="true">
|
||||
<label class="form-check-label" for="githubIssuesReplyIfNoReplies${index}">Reply to issues with no replies</label>
|
||||
<small class="form-text text-muted">If checked, the bot will reply to issues that have no replies yet</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="githubIssuesPollInterval${index}">Poll Interval (seconds)</label>
|
||||
<input type="number"
|
||||
id="githubIssuesPollInterval${index}"
|
||||
name="connectors[${index}][config][pollInterval]"
|
||||
class="form-control"
|
||||
placeholder="60">
|
||||
<small class="form-text text-muted">How often to check for new issues (in seconds)</small>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Function to set values after HTML is added to DOM to avoid XSS
|
||||
const setValues = function() {
|
||||
const tokenInput = document.getElementById(`githubIssuesToken${index}`);
|
||||
const ownerInput = document.getElementById(`githubIssuesOwner${index}`);
|
||||
const repoInput = document.getElementById(`githubIssuesRepo${index}`);
|
||||
const replyIfNoRepliesInput = document.getElementById(`githubIssuesReplyIfNoReplies${index}`);
|
||||
const pollIntervalInput = document.getElementById(`githubIssuesPollInterval${index}`);
|
||||
|
||||
if (tokenInput) tokenInput.value = config.token || '';
|
||||
if (ownerInput) ownerInput.value = config.owner || '';
|
||||
if (repoInput) repoInput.value = config.repository || '';
|
||||
if (replyIfNoRepliesInput) replyIfNoRepliesInput.checked = config.replyIfNoReplies === 'true';
|
||||
if (pollIntervalInput) pollIntervalInput.value = config.pollInterval || '60';
|
||||
};
|
||||
|
||||
return { html, setValues };
|
||||
},
|
||||
|
||||
/**
|
||||
* GitHub PRs Connector Template
|
||||
* @param {Object} config - Existing configuration values
|
||||
* @param {Number} index - Connector index
|
||||
* @returns {Object} HTML template and setValues function
|
||||
*/
|
||||
'github-prs': function(config = {}, index) {
|
||||
// Return HTML without values in the template string
|
||||
const html = `
|
||||
<div class="form-group">
|
||||
<label for="githubPRsToken${index}">GitHub Token</label>
|
||||
<input type="text"
|
||||
id="githubPRsToken${index}"
|
||||
name="connectors[${index}][config][token]"
|
||||
class="form-control"
|
||||
placeholder="ghp_...">
|
||||
<small class="form-text text-muted">Personal Access Token with repo permissions</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="githubPRsOwner${index}">Repository Owner</label>
|
||||
<input type="text"
|
||||
id="githubPRsOwner${index}"
|
||||
name="connectors[${index}][config][owner]"
|
||||
class="form-control"
|
||||
placeholder="username or organization">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="githubPRsRepo${index}">Repository Name</label>
|
||||
<input type="text"
|
||||
id="githubPRsRepo${index}"
|
||||
name="connectors[${index}][config][repository]"
|
||||
class="form-control"
|
||||
placeholder="repository-name">
|
||||
</div>
|
||||
|
||||
<div class="form-group form-check">
|
||||
<input type="checkbox"
|
||||
class="form-check-input"
|
||||
id="githubPRsReplyIfNoReplies${index}"
|
||||
name="connectors[${index}][config][replyIfNoReplies]"
|
||||
value="true">
|
||||
<label class="form-check-label" for="githubPRsReplyIfNoReplies${index}">Reply to PRs with no replies</label>
|
||||
<small class="form-text text-muted">If checked, the bot will reply to pull requests that have no replies yet</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="githubPRsPollInterval${index}">Poll Interval (seconds)</label>
|
||||
<input type="number"
|
||||
id="githubPRsPollInterval${index}"
|
||||
name="connectors[${index}][config][pollInterval]"
|
||||
class="form-control"
|
||||
placeholder="60">
|
||||
<small class="form-text text-muted">How often to check for new pull requests (in seconds)</small>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Function to set values after HTML is added to DOM to avoid XSS
|
||||
const setValues = function() {
|
||||
const tokenInput = document.getElementById(`githubPRsToken${index}`);
|
||||
const ownerInput = document.getElementById(`githubPRsOwner${index}`);
|
||||
const repoInput = document.getElementById(`githubPRsRepo${index}`);
|
||||
const replyIfNoRepliesInput = document.getElementById(`githubPRsReplyIfNoReplies${index}`);
|
||||
const pollIntervalInput = document.getElementById(`githubPRsPollInterval${index}`);
|
||||
|
||||
if (tokenInput) tokenInput.value = config.token || '';
|
||||
if (ownerInput) ownerInput.value = config.owner || '';
|
||||
if (repoInput) repoInput.value = config.repository || '';
|
||||
if (replyIfNoRepliesInput) replyIfNoRepliesInput.checked = config.replyIfNoReplies === 'true';
|
||||
if (pollIntervalInput) pollIntervalInput.value = config.pollInterval || '60';
|
||||
};
|
||||
|
||||
return { html, setValues };
|
||||
},
|
||||
|
||||
/**
|
||||
* IRC Connector Template
|
||||
* @param {Object} config - Existing configuration values
|
||||
* @param {Number} index - Connector index
|
||||
* @returns {Object} HTML template and setValues function
|
||||
*/
|
||||
irc: function(config = {}, index) {
|
||||
// Return HTML without values in the template string
|
||||
const html = `
|
||||
<div class="form-group">
|
||||
<label for="ircServer${index}">IRC Server</label>
|
||||
<input type="text"
|
||||
id="ircServer${index}"
|
||||
name="connectors[${index}][config][server]"
|
||||
class="form-control"
|
||||
placeholder="irc.libera.chat">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="ircPort${index}">Port</label>
|
||||
<input type="text"
|
||||
id="ircPort${index}"
|
||||
name="connectors[${index}][config][port]"
|
||||
class="form-control"
|
||||
placeholder="6667">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="ircChannel${index}">Channel</label>
|
||||
<input type="text"
|
||||
id="ircChannel${index}"
|
||||
name="connectors[${index}][config][channel]"
|
||||
class="form-control"
|
||||
placeholder="#channel">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="ircNick${index}">Nickname</label>
|
||||
<input type="text"
|
||||
id="ircNick${index}"
|
||||
name="connectors[${index}][config][nickname]"
|
||||
class="form-control"
|
||||
placeholder="MyBot">
|
||||
</div>
|
||||
|
||||
<div class="form-group form-check">
|
||||
<input type="checkbox"
|
||||
class="form-check-input"
|
||||
id="ircAlwaysReply${index}"
|
||||
name="connectors[${index}][config][alwaysReply]"
|
||||
value="true">
|
||||
<label class="form-check-label" for="ircAlwaysReply${index}">Always reply to messages</label>
|
||||
<small class="form-text text-muted">If checked, the bot will always reply to messages, even if they are not directed at it</small>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Function to set values after HTML is added to DOM
|
||||
const setValues = function() {
|
||||
const serverInput = document.getElementById(`ircServer${index}`);
|
||||
const portInput = document.getElementById(`ircPort${index}`);
|
||||
const channelInput = document.getElementById(`ircChannel${index}`);
|
||||
const nickInput = document.getElementById(`ircNick${index}`);
|
||||
const alwaysReplyInput = document.getElementById(`ircAlwaysReply${index}`);
|
||||
|
||||
if (serverInput) serverInput.value = config.server || '';
|
||||
if (portInput) portInput.value = config.port || '6667';
|
||||
if (channelInput) channelInput.value = config.channel || '';
|
||||
if (nickInput) nickInput.value = config.nickname || '';
|
||||
if (alwaysReplyInput) alwaysReplyInput.checked = config.alwaysReply === 'true';
|
||||
};
|
||||
|
||||
return { html, setValues };
|
||||
},
|
||||
|
||||
/**
|
||||
* Twitter Connector Template
|
||||
* @param {Object} config - Existing configuration values
|
||||
* @param {Number} index - Connector index
|
||||
* @returns {Object} HTML template and setValues function
|
||||
*/
|
||||
twitter: function(config = {}, index) {
|
||||
// Return HTML without values in the template string
|
||||
const html = `
|
||||
<div class="form-group">
|
||||
<label for="twitterToken${index}">Twitter API Token</label>
|
||||
<input type="text"
|
||||
id="twitterToken${index}"
|
||||
name="connectors[${index}][config][token]"
|
||||
class="form-control"
|
||||
placeholder="Your Twitter API token">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="twitterBotUsername${index}">Bot Username</label>
|
||||
<input type="text"
|
||||
id="twitterBotUsername${index}"
|
||||
name="connectors[${index}][config][botUsername]"
|
||||
class="form-control"
|
||||
placeholder="@YourBotUsername">
|
||||
<small class="form-text text-muted">Username of your Twitter bot (with or without @)</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-check">
|
||||
<input type="checkbox"
|
||||
class="form-check-input"
|
||||
id="twitterNoCharLimit${index}"
|
||||
name="connectors[${index}][config][noCharacterLimit]"
|
||||
value="true">
|
||||
<label class="form-check-label" for="twitterNoCharLimit${index}">Disable character limit</label>
|
||||
<small class="form-text text-muted">If checked, the bot will not enforce Twitter's character limit</small>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Function to set values after HTML is added to DOM
|
||||
const setValues = function() {
|
||||
const tokenInput = document.getElementById(`twitterToken${index}`);
|
||||
const botUsernameInput = document.getElementById(`twitterBotUsername${index}`);
|
||||
const noCharLimitInput = document.getElementById(`twitterNoCharLimit${index}`);
|
||||
|
||||
if (tokenInput) tokenInput.value = config.token || '';
|
||||
if (botUsernameInput) botUsernameInput.value = config.botUsername || '';
|
||||
if (noCharLimitInput) noCharLimitInput.checked = config.noCharacterLimit === 'true';
|
||||
};
|
||||
|
||||
return { html, setValues };
|
||||
},
|
||||
|
||||
/**
|
||||
* Fallback template for any connector without a specific template
|
||||
* @param {Object} config - Existing configuration values
|
||||
* @param {Number} index - Connector index
|
||||
* @returns {Object} HTML template and setValues function
|
||||
*/
|
||||
fallback: function(config = {}, index) {
|
||||
// Convert config to a pretty-printed JSON string
|
||||
let configStr = '{}';
|
||||
try {
|
||||
if (typeof config === 'string') {
|
||||
// If it's already a string, try to parse it first to pretty-print
|
||||
configStr = JSON.stringify(JSON.parse(config), null, 2);
|
||||
} else if (typeof config === 'object' && config !== null) {
|
||||
configStr = JSON.stringify(config, null, 2);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error formatting config:', e);
|
||||
// If it's a string but not valid JSON, just use it as is
|
||||
if (typeof config === 'string') {
|
||||
configStr = config;
|
||||
}
|
||||
}
|
||||
|
||||
// Return HTML without values in the template string
|
||||
const html = `
|
||||
<div class="form-group">
|
||||
<label for="connectorConfig${index}">Connector Configuration (JSON)</label>
|
||||
<textarea id="connectorConfig${index}"
|
||||
name="connectors[${index}][config]"
|
||||
class="form-control"
|
||||
rows="10"
|
||||
placeholder='{"key":"value"}'>${escapeHTML(configStr)}</textarea>
|
||||
<small class="form-text text-muted">Enter the connector configuration as a JSON object</small>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Function to set values after HTML is added to DOM
|
||||
const setValues = function() {
|
||||
const configInput = document.getElementById(`connectorConfig${index}`);
|
||||
|
||||
if (configInput) configInput.value = configStr;
|
||||
};
|
||||
|
||||
return { html, setValues };
|
||||
}
|
||||
};
|
||||
139
webui/old/public/js/wizard.js
Normal file
139
webui/old/public/js/wizard.js
Normal file
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* Agent Form Wizard - Navigation and UI functionality
|
||||
*/
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Check if the wizard exists on the page
|
||||
const wizardSidebar = document.querySelector('.wizard-sidebar');
|
||||
if (!wizardSidebar) return;
|
||||
|
||||
// Get all sections and nav items
|
||||
const navItems = document.querySelectorAll('.wizard-nav-item');
|
||||
const sections = document.querySelectorAll('.form-section');
|
||||
const prevButton = document.getElementById('prevSection');
|
||||
const nextButton = document.getElementById('nextSection');
|
||||
const currentStepLabelEl = document.getElementById('currentStepLabel');
|
||||
const progressDotsContainer = document.getElementById('progressDots');
|
||||
|
||||
// Create progress dots
|
||||
const totalSteps = sections.length;
|
||||
|
||||
// Create dots for each section
|
||||
if (progressDotsContainer) {
|
||||
for (let i = 0; i < totalSteps; i++) {
|
||||
const dot = document.createElement('div');
|
||||
dot.className = 'progress-dot';
|
||||
dot.setAttribute('data-index', i);
|
||||
dot.addEventListener('click', () => setActiveSection(i));
|
||||
progressDotsContainer.appendChild(dot);
|
||||
}
|
||||
}
|
||||
|
||||
// Get all progress dots
|
||||
const progressDots = document.querySelectorAll('.progress-dot');
|
||||
|
||||
// Track current active section
|
||||
let currentSectionIndex = 0;
|
||||
|
||||
// Initialize
|
||||
updateNavigation();
|
||||
|
||||
// Add click events to nav items
|
||||
navItems.forEach((item, index) => {
|
||||
item.addEventListener('click', () => {
|
||||
setActiveSection(index);
|
||||
});
|
||||
});
|
||||
|
||||
// Add click events to prev/next buttons
|
||||
if (prevButton) {
|
||||
prevButton.addEventListener('click', () => {
|
||||
if (currentSectionIndex > 0) {
|
||||
setActiveSection(currentSectionIndex - 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (nextButton) {
|
||||
nextButton.addEventListener('click', () => {
|
||||
if (currentSectionIndex < sections.length - 1) {
|
||||
setActiveSection(currentSectionIndex + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the active section and update navigation
|
||||
*/
|
||||
function setActiveSection(index) {
|
||||
// Remove active class from all sections and nav items
|
||||
sections.forEach(section => section.classList.remove('active'));
|
||||
navItems.forEach(item => item.classList.remove('active'));
|
||||
progressDots.forEach(dot => dot.classList.remove('active'));
|
||||
|
||||
// Add active class to current section, nav item, and dot
|
||||
sections[index].classList.add('active');
|
||||
navItems[index].classList.add('active');
|
||||
if (progressDots[index]) {
|
||||
progressDots[index].classList.add('active');
|
||||
}
|
||||
|
||||
// Update current section index
|
||||
currentSectionIndex = index;
|
||||
|
||||
// Update navigation state
|
||||
updateNavigation();
|
||||
|
||||
// Scroll to top of section
|
||||
sections[index].scrollIntoView({behavior: 'smooth', block: 'start'});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update navigation buttons and progress
|
||||
*/
|
||||
function updateNavigation() {
|
||||
// Update section label
|
||||
if (currentStepLabelEl && navItems[currentSectionIndex]) {
|
||||
// Extract text content without the icon
|
||||
const navText = navItems[currentSectionIndex].textContent.trim();
|
||||
currentStepLabelEl.textContent = navText;
|
||||
}
|
||||
|
||||
// Update prev/next buttons
|
||||
if (prevButton) {
|
||||
prevButton.disabled = currentSectionIndex === 0;
|
||||
prevButton.style.opacity = currentSectionIndex === 0 ? 0.5 : 1;
|
||||
}
|
||||
|
||||
if (nextButton) {
|
||||
nextButton.disabled = currentSectionIndex === sections.length - 1;
|
||||
nextButton.style.opacity = currentSectionIndex === sections.length - 1 ? 0.5 : 1;
|
||||
|
||||
// Change text for last step
|
||||
if (currentSectionIndex === sections.length - 2) {
|
||||
nextButton.innerHTML = 'Finish <i class="fas fa-check"></i>';
|
||||
} else {
|
||||
nextButton.innerHTML = 'Next <i class="fas fa-arrow-right"></i>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to validate current section before proceeding
|
||||
function validateCurrentSection() {
|
||||
// Implement validation logic here based on the current section
|
||||
// Return true if valid, false if not
|
||||
return true;
|
||||
}
|
||||
|
||||
// Add to initAgentFormCommon function if it exists
|
||||
if (typeof window.initAgentFormCommon === 'function') {
|
||||
const originalInit = window.initAgentFormCommon;
|
||||
|
||||
window.initAgentFormCommon = function(options) {
|
||||
// Call the original initialization function
|
||||
originalInit(options);
|
||||
|
||||
// Now initialize the wizard navigation
|
||||
setActiveSection(0);
|
||||
};
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user