let currentDb = ''; let currentTable = ''; let openedDb = ''; function getCsrfToken() { return document.querySelector('meta[name="csrf-token"]')?.content || ''; } function filterTables(inp) { const q = inp.value.toLowerCase(); const body = inp.closest('.pma-accordion-body'); if (body) { body.querySelectorAll('.pma-table-item').forEach(el => { el.style.display = !q || (el.dataset.tbl || '').includes(q) ? '' : 'none'; }); } } function filterSidebar(q) { document.querySelectorAll('.pma-accordion-item').forEach(el => { el.style.display = el.textContent.toLowerCase().includes(q.toLowerCase()) ? '' : 'none'; }); } function toggleDb(db) { const item = document.querySelector(`.pma-accordion-item[data-db="${db.replace(/"/g,'\\"')}"]`); if (!item) return; const body = item.querySelector('.pma-accordion-body'); const header = item.querySelector('.pma-accordion-header'); const chevron = item.querySelector('.pma-chevron'); if (item.classList.contains('expanded')) { item.classList.remove('expanded'); body.style.maxHeight = '0'; return; } document.querySelectorAll('.pma-accordion-item.expanded').forEach(el => { el.classList.remove('expanded'); el.querySelector('.pma-accordion-body').style.maxHeight = '0'; }); item.classList.add('expanded'); currentDb = db; if (body.querySelector('.pma-table-item')) { body.style.maxHeight = body.scrollHeight + 'px'; return; } body.querySelector('.pma-loading-tables').style.display = ''; body.style.maxHeight = '60px'; fetch('/servers/' + serverId + '/database', { method: 'POST', headers: {'Content-Type':'application/x-www-form-urlencoded','X-CSRF-Token':getCsrfToken()}, body: 'action=tables&db=' + encodeURIComponent(db) + '&_csrf_token=' + encodeURIComponent(getCsrfToken()), }) .then(r => r.json()) .then(data => { body.querySelector('.pma-loading-tables').style.display = 'none'; let html = '
'; (data.tables || []).forEach(t => { html += ''+escHtml(table)+'| # | Field | Type | Collation | Null | Key | Default | Extra |
|---|---|---|---|---|---|---|---|
| '+(i+1)+' | '+escHtml(c.field)+' | '+escHtml(c.type)+' | '
+''+escHtml(c.collation)+' | '+escHtml(c.null)+' | '+escHtml(c.key)+' | ' +''+(c.default??'NULL')+' | '+escHtml(c.extra)+' |
'+escHtml(table)+'| User | Host | Databases | Expired | Actions |
|---|---|---|---|---|
| '+escHtml(u.user)+' | '+escHtml(u.host)+' | '+(dbList||'-')+' | '+escHtml(u.expired)+' | ' +'' +' ' +'' +' |
'+escHtml(user)+' @ '+escHtml(host)+''
+''
+'