fixes bugs

This commit is contained in:
itqop 2025-12-25 12:06:02 +03:00
parent b9b15d20cd
commit dde938c91d
3 changed files with 129 additions and 2 deletions

View File

@ -22,7 +22,8 @@
"Bash(.\\\\\\\\.venv\\\\\\\\Scripts\\\\\\\\python.exe -m pytest:*)",
"Bash(..venvScriptsactivate)",
"Bash(pytest:*)",
"Bash(source:*)"
"Bash(source:*)",
"Bash(find:*)"
],
"deny": [],
"ask": []

View File

@ -133,6 +133,49 @@ function setupEventListeners() {
})
}
// App bar buttons
const menuBtn = document.getElementById('menu-btn')
if (menuBtn) {
menuBtn.addEventListener('click', toggleDrawer)
}
const newQueryBtn = document.getElementById('new-query-btn')
if (newQueryBtn) {
newQueryBtn.addEventListener('click', () => queryBuilderUI.show())
}
const exportBtn = document.getElementById('export-btn')
if (exportBtn) {
exportBtn.addEventListener('click', window.exportAnalysis)
}
const importBtn = document.getElementById('import-btn')
if (importBtn) {
importBtn.addEventListener('click', window.importAnalysis)
}
// Drawer buttons
const clearAllBtn = document.getElementById('clear-all-btn')
if (clearAllBtn) {
clearAllBtn.addEventListener('click', clearAll)
}
// Query builder file operations
const loadRequestBtn = document.getElementById('load-request-btn')
if (loadRequestBtn) {
loadRequestBtn.addEventListener('click', loadRequestFromFile)
}
const loadResponseBtn = document.getElementById('load-response-btn')
if (loadResponseBtn) {
loadResponseBtn.addEventListener('click', loadResponseFromFile)
}
const validateJsonBtn = document.getElementById('validate-json-btn')
if (validateJsonBtn) {
validateJsonBtn.addEventListener('click', () => queryBuilderUI.validateJSONMode())
}
// Setup UI component listeners
authUI.setupListeners()
settingsUI.setupListeners()
@ -165,6 +208,89 @@ function setupEventListeners() {
console.log('Event listeners setup complete')
}
// ============================================
// UI Utility Functions
// ============================================
/**
* Toggle drawer visibility (mobile)
*/
function toggleDrawer() {
const drawer = document.getElementById('drawer')
if (drawer) {
drawer.classList.toggle('collapsed')
}
}
/**
* Clear all data and reload page
*/
function clearAll() {
if (confirm('Очистить все данные и обновить страницу? Несохраненные изменения будут потеряны.')) {
window.location.reload()
}
}
/**
* Load request from JSON file
*/
function loadRequestFromFile() {
const input = document.createElement('input')
input.type = 'file'
input.accept = 'application/json'
input.onchange = async (e) => {
const file = e.target.files[0]
if (!file) return
try {
const requestBody = await queryService.loadRequestFromFile(file)
// Load into textarea
const jsonTextarea = document.getElementById('json-textarea')
if (jsonTextarea) {
jsonTextarea.value = JSON.stringify(requestBody, null, 2)
queryBuilderUI.validateJSONMode()
}
showToast(`Загружен запрос: ${requestBody.length} вопросов`, 'success')
} catch (error) {
showToast(`Ошибка загрузки запроса: ${error.message}`, 'error')
}
}
input.click()
}
/**
* Load response from JSON file
*/
function loadResponseFromFile() {
const input = document.createElement('input')
input.type = 'file'
input.accept = 'application/json'
input.onchange = async (e) => {
const file = e.target.files[0]
if (!file) return
try {
const currentEnvKey = appState.getCurrentEnvironment()
await queryService.loadResponseFromFile(file, currentEnvKey)
// Update UI
questionsListUI.render()
answerViewerUI.render(0, annotationsUI.loadForAnswer)
showToast(`Загружен ответ`, 'success')
} catch (error) {
showToast(`Ошибка загрузки ответа: ${error.message}`, 'error')
}
}
input.click()
}
// ============================================
// Export/Import Functions
// ============================================

View File

@ -253,7 +253,7 @@ export function handleApiModeChange() {
* Инициализация обработчиков событий
*/
export function setupListeners() {
const openBtn = document.getElementById('open-settings-btn')
const openBtn = document.getElementById('settings-btn')
const closeBtn = document.getElementById('close-settings-btn')
const saveBtn = document.getElementById('save-settings-btn')
const resetBtn = document.getElementById('reset-settings-btn')