package providers import ( "fmt" "strings" "github.com/starfleetcptn/gomft/components/providers/common" "github.com/starfleetcptn/gomft/components/providers/source" "github.com/starfleetcptn/gomft/components/providers/destination" ) // Returns the form ID based on the form type and whether it's a source or destination func formID(formType string, isSource bool) string { if isSource { return "source_config_form" } return "destination_config_form" } // Returns a user-friendly display name for the provider func providerDisplayName(provider string) string { switch provider { case "sftp": return "SFTP" case "local": return "Local Filesystem" case "s3": return "Amazon S3" case "ftp": return "FTP" case "azure": return "Azure Blob Storage" default: return strings.Title(provider) } } templ ProviderForm(formType string, providers []string, isSource bool) {
} script formAlpineInit() { return { initProviderForm() { // Initialize with values if editing existing config if (window.editData && window.editData.configs) { const config = window.editData.configs.find(c => isSource ? (c.id === window.editData.source_config_id) : (c.id === window.editData.destination_config_id) ); if (config) { this[formType + 'Provider'] = config.provider; this.name = config.name; // Provider-specific fields if (config.provider === 'sftp') { this.host = config.host; this.port = config.port; this.username = config.username; this.path = config.path; if (config.key_file && config.key_file !== '') { this.authType = 'key_file'; this.keyFile = config.key_file; } else { this.authType = 'password'; // Password is not included in edit data for security } } else if (config.provider === 'local') { this.path = config.path; } else if (config.provider === 's3') { this.bucket = config.bucket; this.region = config.region; this.path = config.path; this.accessKey = config.access_key; if (config.endpoint && config.endpoint !== '') { this.useCustomEndpoint = true; this.endpoint = config.endpoint; } else { this.useCustomEndpoint = false; } } else if (config.provider === 'ftp') { this.host = config.host; this.port = config.port; this.username = config.username; this.path = config.path; this.useFTPS = config.use_ftps; } // Advanced options if (config.include_pattern) this.filePattern = config.include_pattern; if (config.exclude_pattern) this.excludePattern = config.exclude_pattern; if (isSource && config.extract_archives) { this.extractArchives = true; this.deleteArchives = config.delete_archives; } } } }, providerChanged() { console.log("Provider changed to: " + this[formType + 'Provider']); } }; }