| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| class UIHelpers {
|
| |
| |
| |
| |
| |
| |
|
|
| static showModal(modalId) {
|
| document.getElementById(modalId).classList.add('active');
|
| }
|
|
|
| |
| |
| |
| |
| |
| |
|
|
| static hideModal(modalId) {
|
| document.getElementById(modalId).classList.remove('active');
|
| }
|
|
|
| |
| |
| |
| |
| |
| |
|
|
| static showLoading(message = 'Loading...') {
|
| const overlay = document.getElementById('loadingOverlay');
|
| if (overlay) {
|
| overlay.querySelector('.loading-text').textContent = message;
|
| overlay.classList.add('active');
|
| }
|
| }
|
|
|
| |
| |
| |
| |
| |
|
|
| static hideLoading() {
|
| const overlay = document.getElementById('loadingOverlay');
|
| if (overlay) {
|
| overlay.classList.remove('active');
|
| }
|
| }
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| static showToast(type, title, message) {
|
| const container = document.getElementById('toastContainer');
|
| if (!container) return;
|
|
|
| const toast = document.createElement('div');
|
| toast.className = `toast toast-${type}`;
|
| toast.innerHTML = `
|
| <div class="toast-content">
|
| <div class="toast-title">${title}</div>
|
| <div class="toast-message">${message}</div>
|
| </div>
|
| <button class="toast-close">×</button>
|
| `;
|
|
|
| const closeBtn = toast.querySelector('.toast-close');
|
| closeBtn.addEventListener('click', () => {
|
| UIHelpers.removeToast(toast);
|
| });
|
|
|
| container.appendChild(toast);
|
|
|
|
|
| setTimeout(() => {
|
| if (toast.parentNode) {
|
| UIHelpers.removeToast(toast);
|
| }
|
| }, 5000);
|
| }
|
|
|
| static removeToast(toast) {
|
| toast.classList.add('removing');
|
| setTimeout(() => {
|
| if (toast.parentNode) {
|
| toast.parentNode.removeChild(toast);
|
| }
|
| }, 300);
|
| }
|
|
|
| static createTable(columns, rows) {
|
| const table = document.createElement('table');
|
| table.className = 'data-table';
|
|
|
|
|
| const thead = document.createElement('thead');
|
| const headerRow = document.createElement('tr');
|
|
|
| columns.forEach(column => {
|
| const th = document.createElement('th');
|
| th.textContent = column;
|
| headerRow.appendChild(th);
|
| });
|
|
|
| thead.appendChild(headerRow);
|
| table.appendChild(thead);
|
|
|
|
|
| const tbody = document.createElement('tbody');
|
|
|
| rows.forEach(row => {
|
| const tr = document.createElement('tr');
|
|
|
| row.forEach(cell => {
|
| const td = document.createElement('td');
|
| if (cell === 'NULL' || cell === null) {
|
| td.className = 'null-value';
|
| td.textContent = 'NULL';
|
| } else {
|
| td.textContent = cell;
|
| td.title = cell;
|
| }
|
| tr.appendChild(td);
|
| });
|
|
|
| tbody.appendChild(tr);
|
| });
|
|
|
| table.appendChild(tbody);
|
| return table;
|
| }
|
|
|
| static updateConnectionStatus(status, message) {
|
| const indicator = document.getElementById('statusIndicator');
|
| if (!indicator) return;
|
|
|
| const dot = indicator.querySelector('.status-dot');
|
| const text = indicator.querySelector('.status-text');
|
|
|
| if (dot) dot.className = `status-dot ${status}`;
|
| if (text) text.textContent = message;
|
| }
|
|
|
| static populateConnectionSelector(connections) {
|
| const select = document.getElementById('connectionSelect');
|
| if (!select) return;
|
|
|
| select.innerHTML = '<option value="">Select Connection...</option>';
|
|
|
| connections.forEach(conn => {
|
| const option = document.createElement('option');
|
| option.value = conn.id;
|
| option.textContent = `${conn.name} (${conn.type})`;
|
| select.appendChild(option);
|
| });
|
| }
|
|
|
| static renderDatabaseTree(structure) {
|
| const treeContainer = document.getElementById('databaseTree');
|
| if (!treeContainer) return;
|
|
|
| treeContainer.innerHTML = '';
|
|
|
| if (!structure.tables || structure.tables.length === 0) {
|
| treeContainer.innerHTML = '<div class="tree-placeholder"><p>No tables found</p></div>';
|
| return;
|
| }
|
|
|
|
|
| const tablesSection = document.createElement('div');
|
| tablesSection.className = 'tree-section';
|
|
|
| const tablesHeader = document.createElement('div');
|
| tablesHeader.className = 'tree-header';
|
| tablesHeader.innerHTML = `<strong>Tables (${structure.tables.length})</strong>`;
|
| tablesSection.appendChild(tablesHeader);
|
|
|
| structure.tables.forEach(table => {
|
| const tableItem = document.createElement('div');
|
| tableItem.className = 'tree-item';
|
| tableItem.innerHTML = `
|
| <span class="tree-icon">[TBL]</span>
|
| <span class="tree-label">${table.name}</span>
|
| <span class="tree-meta">${table.rowCount || 0} rows</span>
|
| `;
|
|
|
| tableItem.addEventListener('click', () => {
|
| UIHelpers.showToast('info', 'Table Selected', `Selected table: ${table.name}`);
|
| });
|
|
|
| tablesSection.appendChild(tableItem);
|
| });
|
|
|
| treeContainer.appendChild(tablesSection);
|
|
|
|
|
| if (structure.views && structure.views.length > 0) {
|
| const viewsSection = document.createElement('div');
|
| viewsSection.className = 'tree-section';
|
|
|
| const viewsHeader = document.createElement('div');
|
| viewsHeader.className = 'tree-header';
|
| viewsHeader.innerHTML = `<strong>Views (${structure.views.length})</strong>`;
|
| viewsSection.appendChild(viewsHeader);
|
|
|
| structure.views.forEach(view => {
|
| const viewItem = document.createElement('div');
|
| viewItem.className = 'tree-item';
|
| viewItem.innerHTML = `
|
| <span class="tree-icon">[SVC]</span>
|
| <span class="tree-label">${view.name}</span>
|
| `;
|
|
|
| viewItem.addEventListener('click', () => {
|
| UIHelpers.showToast('info', 'View Selected', `Selected view: ${view.name}`);
|
| });
|
|
|
| viewsSection.appendChild(viewItem);
|
| });
|
|
|
| treeContainer.appendChild(viewsSection);
|
| }
|
| }
|
| }
|
|
|
|
|
| if (typeof window !== 'undefined') {
|
| window.UIHelpers = UIHelpers;
|
| }
|
|
|
|
|
| function initializeHorizontalSplitter() {
|
| const splitter = document.querySelector('.splitter');
|
| const queryPanel = document.querySelector('.query-panel');
|
| const resultsPanel = document.querySelector('.results-panel');
|
| const container = document.querySelector('.horizontal-split-container');
|
|
|
| if (!splitter || !queryPanel || !resultsPanel || !container) {
|
| return;
|
| }
|
|
|
| let isResizing = false;
|
|
|
| splitter.addEventListener('mousedown', (e) => {
|
| isResizing = true;
|
| document.body.style.cursor = 'col-resize';
|
| document.body.style.userSelect = 'none';
|
| e.preventDefault();
|
| });
|
|
|
| document.addEventListener('mousemove', (e) => {
|
| if (!isResizing) return;
|
|
|
| const containerRect = container.getBoundingClientRect();
|
| const mouseX = e.clientX - containerRect.left;
|
| const containerWidth = containerRect.width;
|
|
|
|
|
| let percentage = (mouseX / containerWidth) * 100;
|
| percentage = Math.max(20, Math.min(80, percentage));
|
|
|
| queryPanel.style.width = `${percentage}%`;
|
| resultsPanel.style.width = `${100 - percentage}%`;
|
|
|
| e.preventDefault();
|
| });
|
|
|
| document.addEventListener('mouseup', () => {
|
| if (isResizing) {
|
| isResizing = false;
|
| document.body.style.cursor = '';
|
| document.body.style.userSelect = '';
|
| }
|
| });
|
|
|
|
|
| splitter.addEventListener('dblclick', () => {
|
| queryPanel.style.width = '50%';
|
| resultsPanel.style.width = '50%';
|
| });
|
| }
|
|
|
|
|
| document.addEventListener('DOMContentLoaded', function() {
|
| console.log('UI initialized');
|
| initializeHorizontalSplitter();
|
| });
|
|
|