mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-08-06 12:11:13 +00:00
WIP SQL console
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
package tech.ailef.dbadmin.external.controller;
|
||||
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -596,6 +597,8 @@ public class DefaultDbAdminController {
|
||||
public String consoleRun(Model model, @RequestParam(required = false) String query,
|
||||
@RequestParam(required = false) String queryTitle,
|
||||
@PathVariable String queryId) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
if (!properties.isSqlConsoleEnabled()) {
|
||||
throw new DbAdminException("SQL console not enabled");
|
||||
}
|
||||
@@ -644,7 +647,9 @@ public class DefaultDbAdminController {
|
||||
model.addAttribute("error", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double elapsedTime = (System.currentTimeMillis() - startTime) / 1000.0;
|
||||
model.addAttribute("elapsedTime", new DecimalFormat("0.0#").format(elapsedTime));
|
||||
return "console";
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,7 @@
|
||||
<input type="text" class="form-control mb-3"
|
||||
name="queryTitle" th:value="${activeQuery.getTitle()}">
|
||||
<span class="text-muted fw-bold mb-1 d-inline-block">SQL</span>
|
||||
<textarea class="form-control" rows="6" name="query"
|
||||
<textarea class="form-control font-monospace" rows="6" name="query"
|
||||
th:text="${activeQuery.getSql()}"></textarea>
|
||||
<input class="ui-btn btn btn-primary mt-3" type="submit" value="Run">
|
||||
<a href="#" class="ms-4 ui-btn btn btn-danger mt-3" id="console-delete-btn">Delete</a>
|
||||
@@ -48,6 +48,9 @@
|
||||
|
||||
<div th:if="${error == null && activeQuery.getSql() != null}">
|
||||
<div class="separator mt-3 mb-3"></div>
|
||||
<span class="text-muted mb-1 d-inline-block">
|
||||
[[ ${results.size()} ]] results in [[ ${elapsedTime} ]] seconds
|
||||
</span>
|
||||
<div th:replace="~{fragments/generic_table :: table(results=${results})}"></div>
|
||||
</div>
|
||||
<div th:if="${error != null}">
|
||||
|
Reference in New Issue
Block a user