diff --git a/src/main/java/tech/ailef/dbadmin/external/DbAdmin.java b/src/main/java/tech/ailef/dbadmin/external/DbAdmin.java index 1dc99f6..a5583c2 100644 --- a/src/main/java/tech/ailef/dbadmin/external/DbAdmin.java +++ b/src/main/java/tech/ailef/dbadmin/external/DbAdmin.java @@ -79,7 +79,9 @@ public class DbAdmin { private DbAdminProperties properties; - /** + private final String version = "0.1.6"; + + /** * Builds the DbAdmin instance by scanning the `@Entity` beans and loading * the schemas. * @param entityManager the entity manager @@ -112,11 +114,21 @@ public class DbAdmin { } boolean hasErrors = schemas.stream().flatMap(s -> s.getErrors().stream()).count() > 0; + logger.info("Spring Boot Database Admin initialized. Loaded " + schemas.size() + " schemas from " + modelsPackage.size() + " packages" + (hasErrors ? " (with errors)" : "")); logger.info("Spring Boot Database Admin web interface at: http://YOUR_HOST:YOUR_PORT/" + properties.getBaseUrl()); + } + /** + * Returns the current version + * @return + */ + public String getVersion() { + return version; + } + /** * Returns all the loaded schemas (i.e. entity classes) * @return the list of loaded schemas from the `@Entity` classes @@ -352,4 +364,6 @@ public class DbAdmin { throw new DbAdminException(e); } } + + } diff --git a/src/main/java/tech/ailef/dbadmin/external/controller/DefaultDbAdminController.java b/src/main/java/tech/ailef/dbadmin/external/controller/DefaultDbAdminController.java index 15ca503..8a70224 100644 --- a/src/main/java/tech/ailef/dbadmin/external/controller/DefaultDbAdminController.java +++ b/src/main/java/tech/ailef/dbadmin/external/controller/DefaultDbAdminController.java @@ -258,7 +258,6 @@ public class DefaultDbAdminController { ); }); - model.addAttribute("title", "Entities | " + schema.getJavaClass().getSimpleName() + " | " + object.getDisplayName()); model.addAttribute("object", object); model.addAttribute("activePage", "entities"); diff --git a/src/main/java/tech/ailef/dbadmin/external/controller/GlobalController.java b/src/main/java/tech/ailef/dbadmin/external/controller/GlobalController.java index cd2b11e..12b7855 100644 --- a/src/main/java/tech/ailef/dbadmin/external/controller/GlobalController.java +++ b/src/main/java/tech/ailef/dbadmin/external/controller/GlobalController.java @@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ModelAttribute; import jakarta.servlet.http.HttpServletRequest; +import tech.ailef.dbadmin.external.DbAdmin; import tech.ailef.dbadmin.external.DbAdminProperties; import tech.ailef.dbadmin.external.exceptions.DbAdminNotFoundException; import tech.ailef.dbadmin.internal.UserConfiguration; @@ -45,6 +46,9 @@ public class GlobalController { @Autowired private UserConfiguration userConf; + @Autowired + private DbAdmin dbAdmin; + @ExceptionHandler(DbAdminNotFoundException.class) public String handleNotFound(Exception e, Model model) { model.addAttribute("status", "404"); @@ -52,9 +56,15 @@ public class GlobalController { model.addAttribute("message", e.getMessage()); model.addAttribute("dbadmin_userConf", userConf); model.addAttribute("dbadmin_baseUrl", getBaseUrl()); + model.addAttribute("dbadmin_version", dbAdmin.getVersion()); return "other/error"; } + @ModelAttribute("dbadmin_version") + public String getVersion() { + return dbAdmin.getVersion(); + } + /** * A multi valued map containing the query parameters. It is used primarily * in building complex URL when performing faceted search with multiple filters. diff --git a/src/main/resources/templates/fragments/resources.html b/src/main/resources/templates/fragments/resources.html index 480c88f..91e8465 100644 --- a/src/main/resources/templates/fragments/resources.html +++ b/src/main/resources/templates/fragments/resources.html @@ -122,6 +122,7 @@
+