mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-09 05:48:20 +00:00
Added global version variable
This commit is contained in:
parent
821bbd98ef
commit
90aae69daf
@ -79,6 +79,8 @@ public class DbAdmin {
|
|||||||
|
|
||||||
private DbAdminProperties properties;
|
private DbAdminProperties properties;
|
||||||
|
|
||||||
|
private final String version = "0.1.6";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the DbAdmin instance by scanning the `@Entity` beans and loading
|
* Builds the DbAdmin instance by scanning the `@Entity` beans and loading
|
||||||
* the schemas.
|
* the schemas.
|
||||||
@ -112,9 +114,19 @@ public class DbAdmin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean hasErrors = schemas.stream().flatMap(s -> s.getErrors().stream()).count() > 0;
|
boolean hasErrors = schemas.stream().flatMap(s -> s.getErrors().stream()).count() > 0;
|
||||||
|
|
||||||
logger.info("Spring Boot Database Admin initialized. Loaded " + schemas.size()
|
logger.info("Spring Boot Database Admin initialized. Loaded " + schemas.size()
|
||||||
+ " schemas from " + modelsPackage.size() + " packages" + (hasErrors ? " (with errors)" : ""));
|
+ " schemas from " + modelsPackage.size() + " packages" + (hasErrors ? " (with errors)" : ""));
|
||||||
logger.info("Spring Boot Database Admin web interface at: http://YOUR_HOST:YOUR_PORT/" + properties.getBaseUrl());
|
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);
|
throw new DbAdminException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,6 @@ public class DefaultDbAdminController {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
model.addAttribute("title", "Entities | " + schema.getJavaClass().getSimpleName() + " | " + object.getDisplayName());
|
model.addAttribute("title", "Entities | " + schema.getJavaClass().getSimpleName() + " | " + object.getDisplayName());
|
||||||
model.addAttribute("object", object);
|
model.addAttribute("object", object);
|
||||||
model.addAttribute("activePage", "entities");
|
model.addAttribute("activePage", "entities");
|
||||||
|
@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
|||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import tech.ailef.dbadmin.external.DbAdmin;
|
||||||
import tech.ailef.dbadmin.external.DbAdminProperties;
|
import tech.ailef.dbadmin.external.DbAdminProperties;
|
||||||
import tech.ailef.dbadmin.external.exceptions.DbAdminNotFoundException;
|
import tech.ailef.dbadmin.external.exceptions.DbAdminNotFoundException;
|
||||||
import tech.ailef.dbadmin.internal.UserConfiguration;
|
import tech.ailef.dbadmin.internal.UserConfiguration;
|
||||||
@ -45,6 +46,9 @@ public class GlobalController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UserConfiguration userConf;
|
private UserConfiguration userConf;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DbAdmin dbAdmin;
|
||||||
|
|
||||||
@ExceptionHandler(DbAdminNotFoundException.class)
|
@ExceptionHandler(DbAdminNotFoundException.class)
|
||||||
public String handleNotFound(Exception e, Model model) {
|
public String handleNotFound(Exception e, Model model) {
|
||||||
model.addAttribute("status", "404");
|
model.addAttribute("status", "404");
|
||||||
@ -52,9 +56,15 @@ public class GlobalController {
|
|||||||
model.addAttribute("message", e.getMessage());
|
model.addAttribute("message", e.getMessage());
|
||||||
model.addAttribute("dbadmin_userConf", userConf);
|
model.addAttribute("dbadmin_userConf", userConf);
|
||||||
model.addAttribute("dbadmin_baseUrl", getBaseUrl());
|
model.addAttribute("dbadmin_baseUrl", getBaseUrl());
|
||||||
|
model.addAttribute("dbadmin_version", dbAdmin.getVersion());
|
||||||
return "other/error";
|
return "other/error";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ModelAttribute("dbadmin_version")
|
||||||
|
public String getVersion() {
|
||||||
|
return dbAdmin.getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A multi valued map containing the query parameters. It is used primarily
|
* A multi valued map containing the query parameters. It is used primarily
|
||||||
* in building complex URL when performing faceted search with multiple filters.
|
* in building complex URL when performing faceted search with multiple filters.
|
||||||
|
@ -122,6 +122,7 @@
|
|||||||
<div class="menu-entry-text d-none d-md-block">
|
<div class="menu-entry-text d-none d-md-block">
|
||||||
Help
|
Help
|
||||||
</div>
|
</div>
|
||||||
|
<div th:text="|v${dbadmin_version}|" class="text-muted ms-5"></div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user