diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/BuildTimeContentProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/BuildTimeContentProcessor.java index 86c18954b1cf2..26177f8ec97a8 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/BuildTimeContentProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/BuildTimeContentProcessor.java @@ -423,13 +423,14 @@ void createBuildTimeData(BuildProducer buildTimeConstPr ExtensionsBuildItem extensionsBuildItem, NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem, LaunchModeBuildItem launchModeBuildItem, - Optional effectiveIdeBuildItem) { + Optional effectiveIdeBuildItem, + DevUIConfig devUIConfig) { BuildTimeConstBuildItem internalBuildTimeData = new BuildTimeConstBuildItem(AbstractDevUIBuildItem.DEV_UI); addThemeBuildTimeData(internalBuildTimeData, themeVarsProducer); addMenuSectionBuildTimeData(internalBuildTimeData, internalPages, extensionsBuildItem); - addFooterTabBuildTimeData(internalBuildTimeData, extensionsBuildItem); + addFooterTabBuildTimeData(internalBuildTimeData, extensionsBuildItem, devUIConfig); addVersionInfoBuildTimeData(internalBuildTimeData, curateOutcomeBuildItem, nonApplicationRootPathBuildItem); addIdeBuildTimeData(internalBuildTimeData, effectiveIdeBuildItem, launchModeBuildItem); buildTimeConstProducer.produce(internalBuildTimeData); @@ -490,7 +491,7 @@ private void addMenuSectionBuildTimeData(BuildTimeConstBuildItem internalBuildTi } private void addFooterTabBuildTimeData(BuildTimeConstBuildItem internalBuildTimeData, - ExtensionsBuildItem extensionsBuildItem) { + ExtensionsBuildItem extensionsBuildItem, DevUIConfig devUIConfig) { // Add the Footer tabs @SuppressWarnings("unchecked") List footerTabs = new ArrayList(); @@ -509,7 +510,7 @@ private void addFooterTabBuildTimeData(BuildTimeConstBuildItem internalBuildTime footerTabs.add(testLog); // This is only needed when extension developers work on an extension, so we only included it if you build from source. - if (Version.getVersion().equalsIgnoreCase("999-SNAPSHOT")) { + if (Version.getVersion().equalsIgnoreCase("999-SNAPSHOT") || devUIConfig.showJsonRpcLog) { Page devUiLog = Page.webComponentPageBuilder().internal() .namespace("devui-jsonrpcstream") .title("Dev UI") diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/DevUIConfig.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/DevUIConfig.java index 9b9415a33688d..174a7e17088ff 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/DevUIConfig.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/DevUIConfig.java @@ -13,6 +13,12 @@ public class DevUIConfig { @ConfigItem(defaultValue = "50") public int historySize; + /** + * Show the JsonRPC Log. Useful for extension developers + */ + @ConfigItem(defaultValue = "false") + public boolean showJsonRpcLog; + /** * CORS configuration. */ diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/jsonrpc.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/jsonrpc.js index f17647f35c340..bfd86942f2612 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/jsonrpc.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/jsonrpc.js @@ -249,19 +249,22 @@ export class JsonRpc { JsonRpc.webSocket.onmessage = function (event) { var response = JSON.parse(event.data); var devUiResponse = response.result; - + var devUiError = response.error; if (!devUiResponse && response.error) { if (JsonRpc.promiseQueue.has(response.id)) { var saved = JsonRpc.promiseQueue.get(response.id); var promise = saved.promise; - var log = saved.log; - promise.reject_ex(response); JsonRpc.promiseQueue.delete(response.id); - if (log) { - var jsonrpcpayload = JSON.stringify(response); - JsonRpc.dispatchMessageLogEntry(Level.Error, MessageDirection.Down, jsonrpcpayload); + JsonRpc.log(saved,response); + }else if(JsonRpc.observerQueue.has(response.id)){ + var saved = JsonRpc.observerQueue.get(response.id); + var observer = saved.observer; + response.error = devUiError; + if (typeof observer.onErrorCallback === "function") { + observer.onErrorCallback(response); } + JsonRpc.log(saved,response); } return; @@ -279,16 +282,12 @@ export class JsonRpc { if (JsonRpc.promiseQueue.has(response.id)) { var saved = JsonRpc.promiseQueue.get(response.id); var promise = saved.promise; - var log = saved.log; var userData = devUiResponse.object; response.result = userData; promise.resolve_ex(response); JsonRpc.promiseQueue.delete(response.id); - if(log){ - var jsonrpcpayload = JSON.stringify(response); - JsonRpc.dispatchMessageLogEntry(Level.Info, MessageDirection.Down, jsonrpcpayload); - } + JsonRpc.log(saved,response); } else { JsonRpc.dispatchMessageLogEntry(Level.Warning, MessageDirection.Down, "Initial normal request not found [ " + devUiResponse.messageType + "], " + event.data); } @@ -296,14 +295,10 @@ export class JsonRpc { if (JsonRpc.observerQueue.has(response.id)) { var saved = JsonRpc.observerQueue.get(response.id); var observer = saved.observer; - var log = saved.log; var userData = devUiResponse.object; response.result = userData; observer.onNextCallback(response); - if(log){ - var jsonrpcpayload = JSON.stringify(response); - JsonRpc.dispatchMessageLogEntry(Level.Info, MessageDirection.Down, jsonrpcpayload); - } + JsonRpc.log(saved,response); } else { // Let's cancel as we do not have someone interested in this anymore JsonRpc.cancelSubscription(response.id); @@ -342,4 +337,12 @@ export class JsonRpc { const event = new CustomEvent('jsonRPCLogEntryEvent', {detail: logEntry}); document.dispatchEvent(event); } + + static log(o, response){ + var log = o.log; + if(log){ + var jsonrpcpayload = JSON.stringify(response); + JsonRpc.dispatchMessageLogEntry(Level.Info, MessageDirection.Down, jsonrpcpayload); + } + } } \ No newline at end of file