sql console added to global menu and now has schema info

This commit is contained in:
zadam
2019-02-10 10:38:18 +01:00
parent e04f1cd574
commit 92fcd7b345
26 changed files with 86 additions and 22387 deletions

View File

@@ -1,4 +1,3 @@
import utils from '../services/utils.js';
import libraryLoader from '../services/library_loader.js';
import server from '../services/server.js';
import infoService from "../services/info.js";
@@ -8,6 +7,7 @@ const $query = $('#sql-console-query');
const $executeButton = $('#sql-console-execute');
const $resultHead = $('#sql-console-results thead');
const $resultBody = $('#sql-console-results tbody');
const $tables = $("#sql-console-tables");
let codeEditor;
@@ -20,6 +20,31 @@ function showDialog() {
}
async function initEditor() {
server.get('sql/schema').then(tables => {
$tables.empty();
for (const table of tables) {
const $tableLink = $('<a href="javascript:">').text(table.name);
const $columns = $("<table>");
for (const column of table.columns) {
$columns.append(
$("<tr>")
.append($("<td>").text(column.name))
.append($("<td>").text(column.type))
);
}
$tableLink
.attr("title", $columns.html())
.tooltip({ html: true })
.click(() => codeEditor.setValue("SELECT * FROM " + table.name + " LIMIT 100"));
$tables.append($tableLink).append(" ");
}
});
if (!codeEditor) {
await libraryLoader.requireLibrary(libraryLoader.CODE_MIRROR);