WIP SQL console: edit tab names

This commit is contained in:
Francesco 2023-10-22 14:43:38 +02:00
parent 0ec0f63359
commit d0fa9a0dc6
2 changed files with 15 additions and 5 deletions

View File

@ -574,7 +574,9 @@ public class DefaultDbAdminController {
} }
@GetMapping("/console/run/{queryId}") @GetMapping("/console/run/{queryId}")
public String consoleRun(Model model, @RequestParam(required = false) String query, @PathVariable String queryId) { public String consoleRun(Model model, @RequestParam(required = false) String query,
@RequestParam(required = false) String queryTitle,
@PathVariable String queryId) {
ConsoleQuery activeQuery = consoleQueryRepository.findById(queryId).orElseThrow(() -> { ConsoleQuery activeQuery = consoleQueryRepository.findById(queryId).orElseThrow(() -> {
return new DbAdminNotFoundException("Query with ID " + queryId + " not found."); return new DbAdminNotFoundException("Query with ID " + queryId + " not found.");
}); });
@ -582,6 +584,9 @@ public class DefaultDbAdminController {
if (query != null && !query.isBlank()) { if (query != null && !query.isBlank()) {
activeQuery.setSql(query); activeQuery.setSql(query);
} }
if (queryTitle != null && !queryTitle.isBlank()) {
activeQuery.setTitle(queryTitle);
}
activeQuery.setUpdatedAt(LocalDateTime.now()); activeQuery.setUpdatedAt(LocalDateTime.now());
consoleQueryRepository.save(activeQuery); consoleQueryRepository.save(activeQuery);

View File

@ -16,8 +16,8 @@
class="d-inline-block" class="d-inline-block"
th:classAppend="${query.getId() == activeQuery.getId() ? 'active' : ''}"> th:classAppend="${query.getId() == activeQuery.getId() ? 'active' : ''}">
<div class="ui-tab ps-5 pe-5 p-3"> <div class="ui-tab ps-5 pe-5 p-3">
<i class="bi bi-filetype-sql pe-2"></i> Untitled Query <i class="bi bi-filetype-sql pe-2"></i>
<span th:text="${query.getTitle()}"></span>
</div> </div>
</a> </a>
<div class="inner-navigation-border flex-grow-1 align-items-center d-flex"> <div class="inner-navigation-border flex-grow-1 align-items-center d-flex">
@ -30,16 +30,21 @@
</div> </div>
<div class="box with-navigation"> <div class="box with-navigation">
<form th:action="|/${dbadmin_baseUrl}/console/run/${activeQuery.getId()}|" method="GET"> <form th:action="|/${dbadmin_baseUrl}/console/run/${activeQuery.getId()}|" method="GET">
<input type="text" class="form-control mb-3"
name="queryTitle" th:value="${activeQuery.getTitle()}">
<textarea class="form-control" rows="6" name="query" <textarea class="form-control" rows="6" name="query"
th:text="${activeQuery.getSql()}"></textarea> th:text="${activeQuery.getSql()}"></textarea>
<input class="ui-btn btn btn-primary mt-3" type="submit" value="Run"> <input class="ui-btn btn btn-primary mt-3" type="submit" value="Run">
</form> </form>
<div th:if="${error == null}"> <div th:if="${error == null && activeQuery.getSql() != null}">
<div class="separator mt-3 mb-3"></div> <div class="separator mt-3 mb-3"></div>
<div th:replace="~{fragments/generic_table :: table(results=${results})}"></div> <div th:replace="~{fragments/generic_table :: table(results=${results})}"></div>
</div> </div>
<th:block th:replace="~{fragments/resources :: alerts}"></th:block> <div th:if="${error != null}">
<div class="separator mt-3 mb-3"></div>
<th:block th:replace="~{fragments/resources :: alerts}"></th:block>
</div>
</div> </div>
</div> </div>
</div> </div>