From f905bcc424cce8ca51ea053c27b60e3a5e6b34a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Wilmsmann?= Date: Wed, 21 Dec 2022 20:05:26 +0100 Subject: [PATCH] UI improvements --- pom.xml | 2 +- .../bjoernkw/schematic/IndexController.java | 15 ++++++ .../java/com/bjoernkw/schematic/Table.java | 10 ++-- .../bjoernkw/schematic/TablesController.java | 2 +- src/main/resources/static/css/styles.css | 12 +++++ .../resources/templates/fragments/header.html | 2 +- .../resources/templates/fragments/tables.html | 48 ++++++++++++------- src/main/resources/templates/index.html | 6 +-- 8 files changed, 68 insertions(+), 29 deletions(-) create mode 100644 src/main/java/com/bjoernkw/schematic/IndexController.java diff --git a/pom.xml b/pom.xml index a3ca328..f495f7f 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.bjoernkw schematic - 0.0.7-SNAPSHOT + 0.0.7 Schematic Database management UI for Spring Boot diff --git a/src/main/java/com/bjoernkw/schematic/IndexController.java b/src/main/java/com/bjoernkw/schematic/IndexController.java new file mode 100644 index 0000000..4f8d45e --- /dev/null +++ b/src/main/java/com/bjoernkw/schematic/IndexController.java @@ -0,0 +1,15 @@ +package com.bjoernkw.schematic; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping("/") +public class IndexController { + + @GetMapping + public String redirect() { + return "redirect:/schematic/tables"; + } +} diff --git a/src/main/java/com/bjoernkw/schematic/Table.java b/src/main/java/com/bjoernkw/schematic/Table.java index 47e1574..1893c01 100644 --- a/src/main/java/com/bjoernkw/schematic/Table.java +++ b/src/main/java/com/bjoernkw/schematic/Table.java @@ -9,7 +9,7 @@ class Table { List columns; - List> entries; + List> rows; public String getTableName() { return tableName; @@ -27,11 +27,11 @@ public void setColumns(List columns) { this.columns = columns; } - public List> getEntries() { - return entries; + public List> getRows() { + return rows; } - public void setEntries(List> entries) { - this.entries = entries; + public void setRows(List> rows) { + this.rows = rows; } } diff --git a/src/main/java/com/bjoernkw/schematic/TablesController.java b/src/main/java/com/bjoernkw/schematic/TablesController.java index 8960652..ce3e602 100644 --- a/src/main/java/com/bjoernkw/schematic/TablesController.java +++ b/src/main/java/com/bjoernkw/schematic/TablesController.java @@ -79,7 +79,7 @@ private List getTables() { table.getTableName() ) ); - table.setEntries(jdbcTemplate.queryForList("SELECT * FROM " + table.getTableName())); + table.setRows(jdbcTemplate.queryForList("SELECT * FROM " + table.getTableName() + " FETCH FIRST 10 ROWS ONLY")); }); return tables; diff --git a/src/main/resources/static/css/styles.css b/src/main/resources/static/css/styles.css index 4b5c1c7..8934d3c 100644 --- a/src/main/resources/static/css/styles.css +++ b/src/main/resources/static/css/styles.css @@ -5,3 +5,15 @@ h1.app-title { #tables { overflow-x: scroll; } + +.show-table-icon, .hide-table-icon { + display: none; +} + +button.collapsed .show-table-icon { + display: inline-block; +} + +button:not(.collapsed) .hide-table-icon { + display: inline-block; +} diff --git a/src/main/resources/templates/fragments/header.html b/src/main/resources/templates/fragments/header.html index 18a46fa..c79e2a7 100644 --- a/src/main/resources/templates/fragments/header.html +++ b/src/main/resources/templates/fragments/header.html @@ -4,7 +4,7 @@ -
+
+ - + @@ -34,14 +46,14 @@
showing the first 10 rows here
[[${column.columnName}]] ([[${column.dataType}]])
[[${entry.get(column.columnName)}]]