mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-22 13:42:12 -03:00
65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
import { modalManager } from './ModalManager.js';
|
|
import { showToast } from '../utils/uiHelpers.js';
|
|
|
|
export class SettingsManager {
|
|
constructor() {
|
|
this.initialized = false;
|
|
this.isOpen = false;
|
|
}
|
|
|
|
toggleSettings() {
|
|
if (this.isOpen) {
|
|
modalManager.closeModal('settingsModal');
|
|
} else {
|
|
modalManager.showModal('settingsModal');
|
|
}
|
|
this.isOpen = !this.isOpen;
|
|
}
|
|
|
|
/*
|
|
showSettings() {
|
|
console.log('Opening settings modal...'); // Debug log
|
|
modalManager.showModal('settingsModal');
|
|
}
|
|
*/
|
|
|
|
async saveSettings() {
|
|
const apiKey = document.getElementById('civitaiApiKey').value;
|
|
|
|
try {
|
|
const response = await fetch('/api/settings', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
civitai_api_key: apiKey
|
|
})
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Failed to save settings');
|
|
}
|
|
|
|
showToast('Settings saved successfully', 'success');
|
|
modalManager.closeModal('settingsModal');
|
|
} catch (error) {
|
|
showToast('Failed to save settings: ' + error.message, 'error');
|
|
}
|
|
}
|
|
}
|
|
|
|
// Helper function for toggling API key visibility
|
|
export function toggleApiKeyVisibility(button) {
|
|
const input = button.parentElement.querySelector('input');
|
|
const icon = button.querySelector('i');
|
|
|
|
if (input.type === 'password') {
|
|
input.type = 'text';
|
|
icon.className = 'fas fa-eye-slash';
|
|
} else {
|
|
input.type = 'password';
|
|
icon.className = 'fas fa-eye';
|
|
}
|
|
}
|