Skip to content

Commit

Permalink
Add a Dev UI Screen for Agroal (DB)
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Kruger <phillip.kruger@gmail.com>
  • Loading branch information
phillip-kruger committed Dec 11, 2024
1 parent fc237a6 commit bedb8c5
Show file tree
Hide file tree
Showing 11 changed files with 1,276 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,11 @@
<artifactId>quarkus-agroal</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-agroal-dev</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-agroal-deployment</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions extensions/agroal/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-agroal</artifactId>
</dependency>
<!-- This is for Dev Mode only runtime code, example Dev UI JsonRPC.
It needs to be compile so that other extensions that depends on this extension can still compile and run their tests
If we make this optional it does not get pulled in transitivly. Since this is deployment module it still does not end up
in a prod mode build-->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-agroal-dev</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-agroal-spi</artifactId>
Expand Down Expand Up @@ -87,6 +95,11 @@
<artifactId>quarkus-smallrye-health-deployment</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-dev-ui-tests</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.quarkus.agroal.deployment.devui;

import io.quarkus.agroal.runtime.DataSourcesJdbcBuildTimeConfig;
import io.quarkus.agroal.runtime.dev.ui.DatabaseInspector;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.BuildSteps;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.dev.spi.DevModeType;
import io.quarkus.devui.spi.JsonRPCProvidersBuildItem;
import io.quarkus.devui.spi.page.CardPageBuildItem;
import io.quarkus.devui.spi.page.Page;

@BuildSteps(onlyIf = IsDevelopment.class)
class AgroalDevUIProcessor {

@BuildStep
void devUI(DataSourcesJdbcBuildTimeConfig config,
BuildProducer<CardPageBuildItem> cardPageProducer,
BuildProducer<JsonRPCProvidersBuildItem> jsonRPCProviderProducer,
LaunchModeBuildItem launchMode) {

if (launchMode.getDevModeType().isPresent() && launchMode.getDevModeType().get().equals(DevModeType.LOCAL)) {
if (config.devui().enabled()) {
CardPageBuildItem cardPageBuildItem = new CardPageBuildItem();

cardPageBuildItem.addPage(Page.webComponentPageBuilder()
.icon("font-awesome-solid:database")
.title("Database view")
.componentLink("qwc-agroal-datasource.js")
.metadata("allowSql", String.valueOf(config.devui().allowSql()))
.metadata("appendSql", config.devui().appendToDefaultSelect().orElse(""))
.metadata("allowedHost", config.devui().allowedDBHost().orElse(null)));

cardPageProducer.produce(cardPageBuildItem);
jsonRPCProviderProducer.produce(new JsonRPCProvidersBuildItem(DatabaseInspector.class));
}
}
}
}
Loading

0 comments on commit bedb8c5

Please sign in to comment.