This commit is contained in:
Francesco 2023-09-23 22:24:35 +02:00
parent 49a9d58421
commit d714b8c0a6
3 changed files with 19 additions and 3 deletions

View File

@ -35,13 +35,17 @@ import tech.ailef.dbadmin.internal.InternalDbAdminConfiguration;
@Import(InternalDbAdminConfiguration.class) @Import(InternalDbAdminConfiguration.class)
public class DbAdminAutoConfiguration { public class DbAdminAutoConfiguration {
@Autowired @Autowired
Environment env; private DbAdminProperties props;
@Bean @Bean
public DataSource internalDataSource() { public DataSource internalDataSource() {
DataSourceBuilder<?> dataSourceBuilder = DataSourceBuilder.create(); DataSourceBuilder<?> dataSourceBuilder = DataSourceBuilder.create();
dataSourceBuilder.driverClassName("org.h2.Driver"); dataSourceBuilder.driverClassName("org.h2.Driver");
if (props.isTestMode())
dataSourceBuilder.url("jdbc:h2:mem:test");
else
dataSourceBuilder.url("jdbc:h2:file:./dbadmin_internal"); dataSourceBuilder.url("jdbc:h2:file:./dbadmin_internal");
dataSourceBuilder.username("sa"); dataSourceBuilder.username("sa");
dataSourceBuilder.password("password"); dataSourceBuilder.password("password");
return dataSourceBuilder.build(); return dataSourceBuilder.build();

View File

@ -26,6 +26,8 @@ public class DbAdminProperties {
*/ */
private String modelsPackage; private String modelsPackage;
private boolean testMode = false;
public boolean isEnabled() { public boolean isEnabled() {
return enabled; return enabled;
} }
@ -50,11 +52,20 @@ public class DbAdminProperties {
this.modelsPackage = modelsPackage; this.modelsPackage = modelsPackage;
} }
public boolean isTestMode() {
return testMode;
}
public void setTestMode(boolean testMode) {
this.testMode = testMode;
}
public Map<String, String> toMap() { public Map<String, String> toMap() {
Map<String, String> conf = new HashMap<>(); Map<String, String> conf = new HashMap<>();
conf.put("enabled", enabled + ""); conf.put("enabled", enabled + "");
conf.put("baseUrl", baseUrl); conf.put("baseUrl", baseUrl);
conf.put("modelsPackage", modelsPackage); conf.put("modelsPackage", modelsPackage);
conf.put("testMode", testMode + "");
return conf; return conf;
} }

View File

@ -37,13 +37,14 @@
<option value="Any">Any</option> <option value="Any">Any</option>
<option th:each="schema : ${schemas}" <option th:each="schema : ${schemas}"
th:value="${schema.getTableName()}" th:value="${schema.getTableName()}"
th:text="${schema.getJavaClass().getSimpleName()}" th:text="${schema.getTableName()}"
th:selected="${schema.getTableName().equals(searchRequest.getTable())}"> th:selected="${schema.getTableName().equals(searchRequest.getTable())}">
</option> </option>
</select> </select>
<span class="input-group-text ms-3">Item ID</span> <span class="input-group-text ms-3">Item ID</span>
<input type="text" class="form-control" name="itemId" <input type="text" class="form-control" name="itemId"
th:value="${searchRequest.getItemId()}"> th:value="${searchRequest.getItemId()}">
<button class="ui-btn btn btn-primary ms-3">Filter</button>
</div> </div>
</form> </form>
</div> </div>