WIP SQL console: basic prototype working

This commit is contained in:
Francesco
2023-10-21 19:39:21 +02:00
parent 2352bdcdd7
commit 0691d17867
8 changed files with 221 additions and 20 deletions

View File

@@ -6,3 +6,4 @@
#spring.h2.console.enabled=true
#spring.jpa.show-sql=true

View File

@@ -13,9 +13,14 @@
<div class="col">
<div class="box">
<form th:action="|/${dbadmin_baseUrl}/console|" method="GET">
<textarea class="form-control" rows="6" name="query"></textarea>
<input class="ui-btn btn btn-primary" type="submit" value="Run">
<textarea class="form-control" rows="6" name="query"
th:text="${query}"></textarea>
<input class="ui-btn btn btn-primary mt-3" type="submit" value="Run">
</form>
<div class="separator mt-3 mb-3"></div>
<div th:replace="~{fragments/generic_table :: table(results=${results})}"></div>
</div>
</div>
</div>

View File

@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org">
<head></head>
<body>
<tr th:fragment="data_row(row)" class="table-data-row">
<td th:each="field : ${row.getSortedFields()}"
th:classAppend="${field.isBinary() ? 'text-center' : ''}">
<th:block th:replace="~{fragments/generic_data_row :: data_row_field(field=${field}, object=${row})}"></th:block>
</td>
</tr>
<!-- data-row-field fragment -->
<th:block th:fragment="data_row_field(field, object)">
<span th:text="${object.get(field)}"></span>
</th:block>
<!-- end data-row-field fragment -->
</body>
</html>

View File

@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org">
<head></head>
<body>
<div th:fragment="table(results)">
<div th:if="${results == null || results.isEmpty()}">
<p class="alert alert-warning">No results.</p>
</div>
<div th:if="${results != null && results.size() > 0}">
<table class="table table-striped align-middle mt-3">
<tr class="table-data-row">
<th th:each="field : ${results.getSortedFields()}">
<div class="m-0 p-0 d-flex justify-content-between">
<div class="column-title">
<span th:if="${field.isPrimaryKey()}">
<i title="Primary Key" class="bi bi-key"></i>
</span>
<span th:if="${field.isForeignKey()}">
<i title="Foreign Key" class="bi bi-link"></i>
</span>
<span class="m-0 p-0" th:text="${field.getName()}"></span>
</div>
</div>
<p class="m-0 p-0 dbfieldtype"><small th:text="${field.getType()}"></small></p>
</th>
</tr>
<th:block th:each="r : ${results.getRows()}">
<tr th:replace="~{fragments/generic_data_row :: data_row(row=${r})}">
</tr>
</th:block>
</table>
</div>
</div>
</body>
</html>