-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from quarkiverse/feat/dev-console
feat: add dev ui link to dashboard
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
deployment/src/main/java/io/quarkiverse/mockserver/devservices/DevUIMockServerProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.quarkiverse.mockserver.devservices; | ||
|
||
import java.util.List; | ||
|
||
import io.quarkiverse.mockserver.runtime.MockServerConfig; | ||
import io.quarkus.deployment.IsDevelopment; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.Consume; | ||
import io.quarkus.deployment.builditem.DevServicesResultBuildItem; | ||
import io.quarkus.deployment.builditem.RuntimeConfigSetupCompleteBuildItem; | ||
import io.quarkus.devui.spi.page.CardPageBuildItem; | ||
import io.quarkus.devui.spi.page.Page; | ||
|
||
public class DevUIMockServerProcessor { | ||
|
||
@BuildStep(onlyIf = IsDevelopment.class) | ||
@Consume(RuntimeConfigSetupCompleteBuildItem.class) | ||
public CardPageBuildItem pages(List<DevServicesResultBuildItem> devServicesResultBuildItemList, | ||
MockServerBuildTimeConfig config) { | ||
|
||
CardPageBuildItem cardPageBuildItem = new CardPageBuildItem(); | ||
|
||
if (devServicesResultBuildItemList != null) { | ||
var mockServerService = devServicesResultBuildItemList.stream() | ||
.filter(x -> config.defaultDevService.devservices.serviceName.equals(x.getName())) | ||
.findFirst().orElse(null); | ||
if (mockServerService != null) { | ||
var keys = mockServerService.getConfig(); | ||
var url = String.format("http://%s:%s/mockserver/dashboard", | ||
keys.get(MockServerConfig.CLIENT_HOST), | ||
keys.get(MockServerConfig.CLIENT_PORT)); | ||
|
||
cardPageBuildItem.addPage(Page.externalPageBuilder("Dashboard") | ||
.url(url).isHtmlContent() | ||
.icon("font-awesome-solid:sliders")); | ||
|
||
cardPageBuildItem.addPage(Page.externalPageBuilder("External dashboard") | ||
.url(url, url).doNotEmbed() | ||
.icon("font-awesome-solid:share-from-square")); | ||
} | ||
} | ||
|
||
return cardPageBuildItem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters