171 lines
6.0 KiB
HTML
171 lines
6.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ru">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Дебаг консоли AI Drawer</title>
|
|
<style>
|
|
body { font-family: Arial, sans-serif; margin: 20px; background: #f0f0f0; }
|
|
.debug-panel {
|
|
background: white;
|
|
padding: 20px;
|
|
border-radius: 10px;
|
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
margin-bottom: 20px;
|
|
}
|
|
.log-output {
|
|
background: #000;
|
|
color: #0f0;
|
|
padding: 15px;
|
|
border-radius: 5px;
|
|
font-family: monospace;
|
|
font-size: 12px;
|
|
max-height: 400px;
|
|
overflow-y: auto;
|
|
white-space: pre-wrap;
|
|
}
|
|
.button {
|
|
background: #007bff;
|
|
color: white;
|
|
padding: 10px 20px;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
margin: 5px;
|
|
}
|
|
.button:hover { background: #0056b3; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="debug-panel">
|
|
<h1>🐛 Дебаг консоли AI Drawer</h1>
|
|
<p>Эта страница перехватывает все console.log и показывает их на экране.</p>
|
|
|
|
<button class="button" onclick="testAIDrawer()">Открыть AI Drawer</button>
|
|
<button class="button" onclick="clearLogs()">Очистить логи</button>
|
|
<button class="button" onclick="testHistoryRequest()">Тест запроса истории</button>
|
|
|
|
<h3>Логи консоли:</h3>
|
|
<div id="log-output" class="log-output"></div>
|
|
</div>
|
|
|
|
<!-- Симулируем CRM окружение -->
|
|
<script>
|
|
// Симулируем CRM переменные
|
|
window._USERMETA = {
|
|
id: '8',
|
|
name: 'Тестовый пользователь',
|
|
email: 'test@example.com'
|
|
};
|
|
|
|
// Симулируем URL параметры
|
|
Object.defineProperty(window.location, 'search', {
|
|
writable: true,
|
|
value: '?module=Contacts&view=Detail&record=82823'
|
|
});
|
|
|
|
// Перехватываем console.log
|
|
const logOutput = document.getElementById('log-output');
|
|
const originalLog = console.log;
|
|
const originalError = console.error;
|
|
const originalWarn = console.warn;
|
|
|
|
function addToLog(type, args) {
|
|
const timestamp = new Date().toLocaleTimeString();
|
|
const message = `[${timestamp}] ${type.toUpperCase()}: ${args.join(' ')}\n`;
|
|
logOutput.textContent += message;
|
|
logOutput.scrollTop = logOutput.scrollHeight;
|
|
}
|
|
|
|
console.log = function(...args) {
|
|
originalLog.apply(console, args);
|
|
addToLog('log', args);
|
|
};
|
|
|
|
console.error = function(...args) {
|
|
originalError.apply(console, args);
|
|
addToLog('error', args);
|
|
};
|
|
|
|
console.warn = function(...args) {
|
|
originalWarn.apply(console, args);
|
|
addToLog('warn', args);
|
|
};
|
|
|
|
function clearLogs() {
|
|
logOutput.textContent = '';
|
|
}
|
|
|
|
function testAIDrawer() {
|
|
console.log('=== TESTING AI DRAWER ===');
|
|
if (window.aiDrawerInstance) {
|
|
console.log('AI Drawer instance exists, opening...');
|
|
window.aiDrawerInstance.open();
|
|
} else {
|
|
console.error('AI Drawer instance not found!');
|
|
}
|
|
}
|
|
|
|
async function testHistoryRequest() {
|
|
console.log('=== TESTING HISTORY REQUEST ===');
|
|
try {
|
|
const context = {
|
|
projectId: '82823',
|
|
currentModule: 'Contacts',
|
|
currentView: 'Detail',
|
|
userId: '8',
|
|
userName: 'Тестовый пользователь',
|
|
userEmail: 'test@example.com'
|
|
};
|
|
|
|
const sessionId = 'test-debug-' + Date.now();
|
|
|
|
console.log('Sending request to /get_chat_history.php');
|
|
console.log('Context:', context);
|
|
console.log('SessionId:', sessionId);
|
|
|
|
const response = await fetch('/get_chat_history.php', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
context: context,
|
|
sessionId: sessionId
|
|
})
|
|
});
|
|
|
|
console.log('Response status:', response.status, response.statusText);
|
|
|
|
if (response.ok) {
|
|
const data = await response.json();
|
|
console.log('Response data:', data);
|
|
} else {
|
|
console.error('Request failed:', response.status);
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('History request error:', error);
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<!-- Подключаем AI Drawer -->
|
|
<link rel="stylesheet" href="layouts/v7/resources/css/ai-drawer.css">
|
|
<script src="layouts/v7/resources/js/ai-drawer.js"></script>
|
|
|
|
<script>
|
|
// Инициализация AI Drawer
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
console.log('=== INITIALIZING AI DRAWER ===');
|
|
try {
|
|
window.aiDrawerInstance = new AIDrawer();
|
|
console.log('AI Drawer initialized successfully');
|
|
} catch (error) {
|
|
console.error('AI Drawer initialization failed:', error);
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|