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:
@@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.jdbc.UncategorizedSQLException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -87,6 +88,8 @@ public class DefaultDbAdminController {
|
||||
@Autowired
|
||||
private UserActionService userActionService;
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbTemplate;
|
||||
|
||||
@Autowired
|
||||
private UserSettingsRepository userSettingsRepo;
|
||||
@@ -535,6 +538,17 @@ public class DefaultDbAdminController {
|
||||
return "help";
|
||||
}
|
||||
|
||||
@GetMapping("/console")
|
||||
public String console(Model model, @RequestParam(required=false) String query) {
|
||||
model.addAttribute("activePage", "console");
|
||||
|
||||
if (query != null) {
|
||||
jdbTemplate.execute(query);
|
||||
}
|
||||
|
||||
return "console";
|
||||
}
|
||||
|
||||
@GetMapping("/settings/appearance")
|
||||
public String settingsAppearance(Model model) {
|
||||
model.addAttribute("activePage", "settings");
|
||||
|
26
src/main/resources/templates/console.html
Normal file
26
src/main/resources/templates/console.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org">
|
||||
<head th:replace="~{fragments/resources::head}">
|
||||
</head>
|
||||
<body>
|
||||
<div class="bg-light main-wrapper">
|
||||
<nav th:replace="~{fragments/resources :: navbar}"></nav>
|
||||
<div class="d-flex">
|
||||
<div th:replace="~{fragments/resources :: sidebar('console')}"></div>
|
||||
<div class="main-content bg-lighter">
|
||||
<h1 class="fw-bold mb-4"><i class="align-middle bi bi-terminal"></i><span class="align-middle"> SQL console</span></h1>
|
||||
<div class="row mt-4">
|
||||
<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">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@@ -82,9 +82,9 @@
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<!--
|
||||
|
||||
<li th:class="${#strings.equals(activePage, 'console') ? 'active' : ''}">
|
||||
<a href="/live">
|
||||
<a th:href="|/${dbadmin_baseUrl}/console|">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="menu-icon">
|
||||
<i class="bi bi-terminal"></i>
|
||||
@@ -95,6 +95,7 @@
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<!--
|
||||
<li th:class="${#strings.equals(activePage, 'ai') ? 'active' : ''}">
|
||||
<a href="/search">
|
||||
<div class="d-flex align-items-center">
|
||||
|
Reference in New Issue
Block a user