Added global version variable

This commit is contained in:
Francesco 2023-10-11 11:34:51 +02:00
parent 821bbd98ef
commit 90aae69daf
4 changed files with 26 additions and 2 deletions

View File

@ -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,9 +114,19 @@ 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;
}
/**
@ -352,4 +364,6 @@ public class DbAdmin {
throw new DbAdminException(e);
}
}
}

View File

@ -258,7 +258,6 @@ public class DefaultDbAdminController {
);
});
model.addAttribute("title", "Entities | " + schema.getJavaClass().getSimpleName() + " | " + object.getDisplayName());
model.addAttribute("object", object);
model.addAttribute("activePage", "entities");

View File

@ -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.

View File

@ -122,6 +122,7 @@
<div class="menu-entry-text d-none d-md-block">
Help
</div>
<div th:text="|v${dbadmin_version}|" class="text-muted ms-5"></div>
</div>
</a>
</li>