Skip to content

Commit

Permalink
Merge pull request #43618 from phillip-kruger/dev-ui-db
Browse files Browse the repository at this point in the history
Add a Dev UI Screen for Agroal (DB)
  • Loading branch information
phillip-kruger authored Dec 12, 2024
2 parents e91073f + bedb8c5 commit 50371bb
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 50371bb

Please sign in to comment.