From 468fcf14eefccb4ac27a532eabba626e1cb39084 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Wed, 29 Mar 2023 18:20:57 +0200 Subject: [PATCH 1/8] Dev UI - Add a dot at the end of a sentence --- .../src/main/resources/dev-ui/qwc/qwc-dev-services.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-dev-services.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-dev-services.js index 203dafdd97a0c..3465ac29931fc 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-dev-services.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-dev-services.js @@ -72,7 +72,7 @@ export class QwcDevServices extends LitElement { return html`${items}`; } else { return html`

- You do not have any Dev Services running + You do not have any Dev Services running. Read more about Dev Services

` From 790f75911d50fe2c7b4d34b69bdcf9b110d26b9d Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Wed, 29 Mar 2023 18:21:21 +0200 Subject: [PATCH 2/8] Dev UI - Rename ConfigJsonRpcService for consistency --- .../deployment/devmode/console/ConfigEditorProcessor.java | 4 ++-- .../{ConfigJsonRpcService.java => ConfigJsonRPCService.java} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/config/{ConfigJsonRpcService.java => ConfigJsonRPCService.java} (95%) diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/ConfigEditorProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/ConfigEditorProcessor.java index e2ecf0eda4509..9c3110356f54f 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/ConfigEditorProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/ConfigEditorProcessor.java @@ -44,7 +44,7 @@ import io.quarkus.devconsole.runtime.spi.DevConsolePostHandler; import io.quarkus.devconsole.spi.DevConsoleRouteBuildItem; import io.quarkus.devconsole.spi.DevConsoleRuntimeTemplateInfoBuildItem; -import io.quarkus.devui.runtime.config.ConfigJsonRpcService; +import io.quarkus.devui.runtime.config.ConfigJsonRPCService; import io.quarkus.devui.spi.JsonRPCProvidersBuildItem; import io.quarkus.vertx.http.runtime.devmode.ConfigDescription; import io.quarkus.vertx.http.runtime.devmode.ConfigDescriptionsManager; @@ -161,7 +161,7 @@ JsonRPCProvidersBuildItem registerJsonRpcService() { updateConfig(values); return null; }); - return new JsonRPCProvidersBuildItem("configuration", ConfigJsonRpcService.class); + return new JsonRPCProvidersBuildItem("configuration", ConfigJsonRPCService.class); } private Map filterAndApplyProfile(Map autoconfig, List configFilter, diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/config/ConfigJsonRpcService.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/config/ConfigJsonRPCService.java similarity index 95% rename from extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/config/ConfigJsonRpcService.java rename to extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/config/ConfigJsonRPCService.java index 0369cb62db578..bd00385cf577d 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/config/ConfigJsonRpcService.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/config/ConfigJsonRPCService.java @@ -11,7 +11,7 @@ import io.vertx.core.json.JsonObject; @ApplicationScoped -public class ConfigJsonRpcService { +public class ConfigJsonRPCService { public boolean updateProperty(String name, String value) { DevConsoleManager.invoke("config-update-property", Map.of("name", name, "value", value)); From d7cec4a424c6e8eb1515282817f15342eb107658 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 30 Mar 2023 10:50:47 +0200 Subject: [PATCH 3/8] Dev UI - First version of the Build Steps It is missing all the fancy graph features from the original Dev UI but it should be OK for now. --- .../deployment/BuildTimeContentProcessor.java | 1 - .../build/BuildStepsDevUIProcessor.java | 40 +++ .../BuildMetricsDevConsoleProcessor.java | 1 + .../resources/dev-ui/qwc/qwc-build-steps.js | 128 ++++++- .../build/BuildStepsDevUIController.java | 327 ++++++++++++++++++ .../build/BuildStepsDevUIRecorder.java | 13 + .../build/BuildStepsJsonRPCService.java | 13 + 7 files changed, 511 insertions(+), 12 deletions(-) create mode 100644 extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/BuildStepsDevUIProcessor.java create mode 100644 extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsDevUIController.java create mode 100644 extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsDevUIRecorder.java create mode 100644 extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsJsonRPCService.java 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 8db1c3e46edb7..a52a3d0b8d440 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 @@ -365,7 +365,6 @@ void createBuildTimeData(BuildProducer buildTimeConstPr .title("Build Steps") .icon("font-awesome-solid:hammer") .componentLink("qwc-build-steps.js").build(); - internalBuildTimeData.addBuildTimeData("buildSteps", "TODO: Build Steps"); Page buildItems = Page.webComponentPageBuilder().internal() .namespace("devui-build-information") diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/BuildStepsDevUIProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/BuildStepsDevUIProcessor.java new file mode 100644 index 0000000000000..93c8988b60e46 --- /dev/null +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/BuildStepsDevUIProcessor.java @@ -0,0 +1,40 @@ +package io.quarkus.devui.deployment.build; + +import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT; + +import io.quarkus.arc.deployment.AdditionalBeanBuildItem; +import io.quarkus.arc.processor.DotNames; +import io.quarkus.deployment.IsDevelopment; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.BuildSteps; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.deployment.pkg.builditem.BuildSystemTargetBuildItem; +import io.quarkus.devui.runtime.build.BuildStepsDevUIRecorder; +import io.quarkus.devui.runtime.build.BuildStepsJsonRPCService; +import io.quarkus.devui.spi.JsonRPCProvidersBuildItem; + +@BuildSteps(onlyIf = { IsDevelopment.class }) +public class BuildStepsDevUIProcessor { + + @BuildStep + @Record(RUNTIME_INIT) + public void create(BuildStepsDevUIRecorder recorder, + BuildSystemTargetBuildItem buildSystemTarget) { + recorder.setBuildMetricsPath(buildSystemTarget.getOutputDirectory().resolve("build-metrics.json").toString()); + } + + @BuildStep + AdditionalBeanBuildItem additionalBeans() { + return AdditionalBeanBuildItem + .builder() + .addBeanClass(BuildStepsJsonRPCService.class) + .setUnremovable() + .setDefaultScope(DotNames.APPLICATION_SCOPED) + .build(); + } + + @BuildStep + JsonRPCProvidersBuildItem createJsonRPCService() { + return new JsonRPCProvidersBuildItem("build-steps", BuildStepsJsonRPCService.class); + } +} diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/BuildMetricsDevConsoleProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/BuildMetricsDevConsoleProcessor.java index b72d13bff79af..a244accd8224e 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/BuildMetricsDevConsoleProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/BuildMetricsDevConsoleProcessor.java @@ -30,6 +30,7 @@ import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; +@Deprecated(forRemoval = true) public class BuildMetricsDevConsoleProcessor { private static final Logger LOG = Logger.getLogger(BuildMetricsDevConsoleProcessor.class.getName()); diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js index 1d1950651d6cf..52dfe9ccb0665 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js @@ -1,29 +1,135 @@ -import { LitElement, html, css} from 'lit'; -import { buildSteps } from 'devui-data'; +import { LitElement, html, css } from 'lit'; + +import { JsonRpc } from 'jsonrpc'; +import { until } from 'lit/directives/until.js'; +import '@vaadin/grid'; +import { columnBodyRenderer } from '@vaadin/grid/lit.js'; +import '@vaadin/grid/vaadin-grid-sort-column.js'; +import '@vaadin/icon'; +import '@vaadin/text-field'; +import '@vaadin/vertical-layout'; +import '@vaadin/horizontal-layout'; /** * This component shows the Build Steps */ export class QwcBuildSteps extends LitElement { + + jsonRpc = new JsonRpc(this); + static styles = css` - .todo { - padding-left: 10px; - height: 100%; - }`; + .build-steps { + height: 100%; + display: flex; + flex-direction: column; + overflow: hidden; + } + + vaadin-grid { + height: 100%; + } + + vaadin-grid-cell-content { + vertical-align: top; + width: 100%; + } + + .summary { + margin-bottom: 15px; + }`; static properties = { - _steps: {state: true} + _buildStepsMetrics: { state: true }, + _filtered: {state: true, type: Array} }; - + constructor() { super(); - this._steps = buildSteps; + this.jsonRpc.getBuildStepsMetrics().then(e => { + this._buildStepsMetrics = e.result; + this._filtered = this._buildStepsMetrics.records; + }); } render() { - if(this._steps){ - return html`
${this._steps}
`; + return html`${until(this._render(), html`Loading build steps...`)}`; + } + + _match(value, term) { + if (!value) { + return false; } + return value.toLowerCase().includes(term.toLowerCase()); + } + + _filter(e) { + const searchTerm = (e.detail.value || '').trim(); + if (searchTerm === '') { + this._filtered = this._buildStepsMetrics.records; + return; + } + + this._filtered = this._buildStepsMetrics.records.filter((record) => { + return this._match(record.stepId, searchTerm); + }); + } + + _render() { + if (this._buildStepsMetrics && this._filtered) { + return html`
+
Executed ${this._buildStepsMetrics.records.length} build steps on ${Object.keys(this._buildStepsMetrics.threadSlotRecords).length} threads in ${this._buildStepsMetrics.duration} ms.
+ + + + + + + + + + + + + + + +
`; + } + } + + _stepIdRenderer(record) { + return html`${record.stepId}`; + } + + _startedRenderer(record) { + return html`${record.started}`; + } + + _durationRenderer(record) { + return html`${record.duration}`; + } + + _threadRenderer(record) { + return html`${record.thread}`; } } customElements.define('qwc-build-steps', QwcBuildSteps); \ No newline at end of file diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsDevUIController.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsDevUIController.java new file mode 100644 index 0000000000000..94e66fd607ee0 --- /dev/null +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsDevUIController.java @@ -0,0 +1,327 @@ +package io.quarkus.devui.runtime.build; + +import java.io.IOException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import org.jboss.logging.Logger; + +import io.quarkus.devui.runtime.build.BuildStepsDevUIController.DependencyGraph.Link; +import io.quarkus.devui.runtime.build.BuildStepsDevUIController.DependencyGraph.Node; +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; + +public class BuildStepsDevUIController { + + private static final Logger LOG = Logger.getLogger(BuildStepsDevUIController.class.getName()); + + private static final BuildStepsDevUIController INSTANCE = new BuildStepsDevUIController(); + + public static BuildStepsDevUIController get() { + return INSTANCE; + } + + private Path buildMetricsPath; + + private volatile Map buildStepsMetrics; + + private BuildStepsDevUIController() { + } + + void setBuildMetricsPath(Path buildMetricsPath) { + this.buildMetricsPath = buildMetricsPath; + } + + Map getBuildStepsMetrics() { + if (buildStepsMetrics != null) { + return buildStepsMetrics; + } + + synchronized (this) { + if (buildStepsMetrics != null) { + return buildStepsMetrics; + } + + buildStepsMetrics = prepareBuildStepsMetrics(); + return buildStepsMetrics; + } + } + + public Map prepareBuildStepsMetrics() { + Map metrics = new HashMap<>(); + Map stepIdToRecord = new HashMap<>(); + Map recordIdToRecord = new HashMap<>(); + Map> threadToRecords = new HashMap<>(); + long buildDuration = 0; + LocalTime buildStarted = null; + + if (Files.isReadable(buildMetricsPath)) { + try { + JsonObject data = new JsonObject(Files.readString(buildMetricsPath)); + buildDuration = data.getLong("duration"); + buildStarted = LocalDateTime + .parse(data.getString("started"), DateTimeFormatter.ISO_LOCAL_DATE_TIME).toLocalTime(); + + JsonArray records = data.getJsonArray("records"); + for (Object record : records) { + JsonObject recordObj = (JsonObject) record; + recordObj.put("encodedStepId", URLEncoder.encode(recordObj.getString("stepId"), + StandardCharsets.UTF_8.toString())); + String thread = recordObj.getString("thread"); + stepIdToRecord.put(recordObj.getString("stepId"), recordObj); + recordIdToRecord.put(recordObj.getInteger("id"), recordObj); + List steps = threadToRecords.get(thread); + if (steps == null) { + steps = new ArrayList<>(); + threadToRecords.put(thread, steps); + } + steps.add(recordObj); + } + + metrics.put("records", records); + metrics.put("items", data.getJsonArray("items")); + metrics.put("itemsCount", data.getInteger("itemsCount")); + metrics.put("duration", buildDuration); + } catch (IOException e) { + LOG.error(e); + } + } + + // Build dependency graphs + Map dependencyGraphs = new HashMap<>(); + for (Map.Entry e : stepIdToRecord.entrySet()) { + dependencyGraphs.put(e.getKey(), + buildDependencyGraph(e.getValue(), stepIdToRecord, recordIdToRecord).toJson()); + } + metrics.put("dependencyGraphs", dependencyGraphs); + + // Time slots + long slotDuration = Math.max(10, buildDuration / 100); + List slots = new ArrayList<>(); + long currentSlot = slotDuration; + while (currentSlot < buildDuration) { + slots.add(currentSlot); + currentSlot += slotDuration; + } + if (currentSlot != buildDuration) { + slots.add(buildDuration); + } + metrics.put("slots", slots); + + Map>> threadToSlotRecords = new HashMap<>(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss.SSS"); + + for (Map.Entry> entry : threadToRecords.entrySet()) { + String thread = entry.getKey(); + List records = entry.getValue(); + List> threadSlots = new ArrayList<>(); + + for (Long slot : slots) { + List slotRecords = new ArrayList<>(); + for (JsonObject record : records) { + LocalTime started = LocalTime.parse(record.getString("started"), formatter); + long startAt = Duration.between(buildStarted, started).toMillis(); + if (startAt < slot && (slot - slotDuration) < (startAt + record.getLong("duration"))) { + slotRecords.add(record.getString("stepId")); + } + } + threadSlots.add(slotRecords); + } + threadToSlotRecords.put(thread, threadSlots); + } + metrics.put("threadSlotRecords", threadToSlotRecords); + + return metrics; + } + + DependencyGraph buildDependencyGraph(JsonObject step, Map stepIdToRecord, + Map recordIdToRecord) { + Set nodes = new HashSet<>(); + Set links = new HashSet<>(); + + addNodesDependents(step, nodes, links, step, stepIdToRecord, recordIdToRecord); + addNodeDependencies(step, nodes, links, step, stepIdToRecord, recordIdToRecord); + return new DependencyGraph(nodes, links); + } + + void addNodesDependents(JsonObject root, Set nodes, Set links, JsonObject record, + Map stepIdToRecord, Map recordIdToRecord) { + String stepId = record.getString("stepId"); + nodes.add(new Node(stepId, record.getString("encodedStepId"))); + for (Object dependentRecordId : record.getJsonArray("dependents")) { + int recordId = (int) dependentRecordId; + if (recordId != record.getInteger("id")) { + JsonObject dependentRecord = recordIdToRecord.get(recordId); + String dependentStepId = dependentRecord.getString("stepId"); + links.add(Link.dependent(root.equals(record), dependentStepId, stepId)); + nodes.add(new Node(dependentStepId, dependentRecord.getString("encodedStepId"))); + // NOTE: we do not fetch transient dependencies yet because the UI is not ready to show so many nodes + // if (added) { + // addNodesDependents(root, nodes, links, dependentRecord, stepIdToRecord, recordIdToRecord); + // } + } + } + } + + void addNodeDependencies(JsonObject root, Set nodes, Set links, JsonObject record, + Map stepIdToRecord, Map recordIdToRecord) { + for (Map.Entry entry : stepIdToRecord.entrySet()) { + for (Object dependentRecordId : entry.getValue().getJsonArray("dependents")) { + int recordId = (int) dependentRecordId; + if (record.getInteger("id") == recordId) { + links.add(Link.dependency(root.equals(record), + record.getString("stepId"), entry.getValue().getString("stepId"))); + nodes.add(new Node(entry.getValue().getString("stepId"), entry.getValue().getString("encodedStepId"))); + // NOTE: we do not fetch transient dependencies yet because the UI is not ready to show so many nodes + // if (added) { + // addNodeDependencies(root, nodes, links, entry.getValue(), stepIdToRecord, recordIdToRecord); + // } + } + } + } + } + + public static class DependencyGraph { + + public final Set nodes; + public final Set links; + + public DependencyGraph(Set nodes, Set links) { + this.nodes = nodes; + this.links = links; + } + + public JsonObject toJson() { + JsonObject dependencyGraph = new JsonObject(); + JsonArray nodes = new JsonArray(); + JsonArray links = new JsonArray(); + for (Node node : this.nodes) { + nodes.add(node.toJson()); + } + for (Link link : this.links) { + links.add(link.toJson()); + } + dependencyGraph.put("nodes", nodes); + dependencyGraph.put("links", links); + + return dependencyGraph; + } + + public static class Node { + + public final String stepId; + public final String simpleName; + public final String encodedStepId; + + public Node(String stepId, String encodedStepId) { + this.stepId = stepId; + this.encodedStepId = encodedStepId; + int lastDot = stepId.lastIndexOf('.'); + String simple = lastDot > 0 ? stepId.substring(lastDot + 1) : stepId; + int hash = simple.indexOf('#'); + if (hash > 0) { + StringBuilder sb = new StringBuilder(); + char[] chars = simple.substring(0, hash).toCharArray(); + for (char c : chars) { + if (Character.isUpperCase(c)) { + sb.append(c); + } + } + simple = sb + simple.substring(hash); + } + this.simpleName = simple; + } + + public JsonObject toJson() { + JsonObject node = new JsonObject(); + node.put("stepId", stepId); + node.put("simpleName", simpleName); + node.put("encodedStepId", encodedStepId); + return node; + } + + @Override + public int hashCode() { + return Objects.hash(stepId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Node other = (Node) obj; + return Objects.equals(stepId, other.stepId); + } + + } + + public static class Link { + + static Link dependent(boolean direct, String source, String target) { + return new Link(source, target, direct ? "directDependent" : "dependency"); + } + + static Link dependency(boolean direct, String source, String target) { + return new Link(source, target, direct ? "directDependency" : "dependency"); + } + + public final String source; + public final String target; + public final String type; + + public Link(String source, String target, String type) { + this.source = source; + this.target = target; + this.type = type; + } + + public JsonObject toJson() { + JsonObject link = new JsonObject(); + link.put("source", source); + link.put("target", target); + link.put("type", type); + return link; + } + + @Override + public int hashCode() { + return Objects.hash(source, target); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Link other = (Link) obj; + return Objects.equals(source, other.source) && Objects.equals(target, other.target); + } + } + } +} diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsDevUIRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsDevUIRecorder.java new file mode 100644 index 0000000000000..07820f4d3e91e --- /dev/null +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsDevUIRecorder.java @@ -0,0 +1,13 @@ +package io.quarkus.devui.runtime.build; + +import java.nio.file.Path; + +import io.quarkus.runtime.annotations.Recorder; + +@Recorder +public class BuildStepsDevUIRecorder { + + public void setBuildMetricsPath(String buildMetricsPath) { + BuildStepsDevUIController.get().setBuildMetricsPath(Path.of(buildMetricsPath)); + } +} diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsJsonRPCService.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsJsonRPCService.java new file mode 100644 index 0000000000000..6e5c897a39c73 --- /dev/null +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsJsonRPCService.java @@ -0,0 +1,13 @@ +package io.quarkus.devui.runtime.build; + +import java.util.Map; + +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class BuildStepsJsonRPCService { + + public Map getBuildStepsMetrics() { + return BuildStepsDevUIController.get().getBuildStepsMetrics(); + } +} From e387f5adfb7147feb4053397d8986d90dc714f52 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 30 Mar 2023 13:47:48 +0200 Subject: [PATCH 4/8] Dev UI - Do not append namespace with custom service identifier in JSON RPC --- .../src/main/resources/dev-ui/controller/jsonrpc.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 5d0502f68df54..11d3c9b1648f6 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 @@ -86,7 +86,7 @@ export class JsonRpc { _extensionName; _logTraffic; - + /** * * @param {type} host the component using this. @@ -96,7 +96,7 @@ export class JsonRpc { * Again serviceIdentifier can allow multiple backends * In the case of cards or logs, the namespace will be passed in as an attribute (as this component is not registered with the router) * Again serviceIdentifier can allow multiple backends - * @param {type} logTraffic - if traffic should be logged in the Dev UI Log (json-prc log) + * @param {type} logTraffic - if traffic should be logged in the Dev UI Log (json-rpc log) * @param {type} serviceIdentifier - if needed, a backend service identifier * @returns {Proxy} */ @@ -205,7 +205,7 @@ export class JsonRpc { _setExtensionName(discoveredNamespace, serviceIdentifier){ if(serviceIdentifier){ - this._extensionName = discoveredNamespace + "-" + serviceIdentifier; + this._extensionName = serviceIdentifier; }else { this._extensionName = discoveredNamespace; } From 2292366b5de820eddafdc6c90ce463e0c22ba280 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 30 Mar 2023 13:48:09 +0200 Subject: [PATCH 5/8] Dev UI - First version of the Build Items page --- .../deployment/BuildTimeContentProcessor.java | 4 +- ...r.java => BuildMetricsDevUIProcessor.java} | 12 +- .../resources/dev-ui/qwc/qwc-build-items.js | 106 ++++++++++++++++-- .../resources/dev-ui/qwc/qwc-build-steps.js | 2 +- ....java => BuildMetricsDevUIController.java} | 14 +-- ...er.java => BuildMetricsDevUIRecorder.java} | 4 +- ...e.java => BuildMetricsJsonRPCService.java} | 4 +- 7 files changed, 114 insertions(+), 32 deletions(-) rename extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/{BuildStepsDevUIProcessor.java => BuildMetricsDevUIProcessor.java} (74%) rename extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/{BuildStepsDevUIController.java => BuildMetricsDevUIController.java} (95%) rename extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/{BuildStepsDevUIRecorder.java => BuildMetricsDevUIRecorder.java} (60%) rename extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/{BuildStepsJsonRPCService.java => BuildMetricsJsonRPCService.java} (63%) 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 a52a3d0b8d440..73dd106ae0093 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 @@ -371,11 +371,9 @@ void createBuildTimeData(BuildProducer buildTimeConstPr .title("Build Items") .icon("font-awesome-solid:trowel") .componentLink("qwc-build-items.js").build(); - internalBuildTimeData.addBuildTimeData("buildItems", "TODO: Build Items"); // Add default menu items - @SuppressWarnings("unchecked") - List sectionMenu = new ArrayList( + List sectionMenu = new ArrayList<>( List.of(extensions, configuration, configurationSourceEditor, continuousTesting, devServices, buildSteps, buildItems)); diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/BuildStepsDevUIProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/BuildMetricsDevUIProcessor.java similarity index 74% rename from extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/BuildStepsDevUIProcessor.java rename to extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/BuildMetricsDevUIProcessor.java index 93c8988b60e46..7be931b37aa32 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/BuildStepsDevUIProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/BuildMetricsDevUIProcessor.java @@ -9,16 +9,16 @@ import io.quarkus.deployment.annotations.BuildSteps; import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.pkg.builditem.BuildSystemTargetBuildItem; -import io.quarkus.devui.runtime.build.BuildStepsDevUIRecorder; -import io.quarkus.devui.runtime.build.BuildStepsJsonRPCService; +import io.quarkus.devui.runtime.build.BuildMetricsDevUIRecorder; +import io.quarkus.devui.runtime.build.BuildMetricsJsonRPCService; import io.quarkus.devui.spi.JsonRPCProvidersBuildItem; @BuildSteps(onlyIf = { IsDevelopment.class }) -public class BuildStepsDevUIProcessor { +public class BuildMetricsDevUIProcessor { @BuildStep @Record(RUNTIME_INIT) - public void create(BuildStepsDevUIRecorder recorder, + public void create(BuildMetricsDevUIRecorder recorder, BuildSystemTargetBuildItem buildSystemTarget) { recorder.setBuildMetricsPath(buildSystemTarget.getOutputDirectory().resolve("build-metrics.json").toString()); } @@ -27,7 +27,7 @@ public void create(BuildStepsDevUIRecorder recorder, AdditionalBeanBuildItem additionalBeans() { return AdditionalBeanBuildItem .builder() - .addBeanClass(BuildStepsJsonRPCService.class) + .addBeanClass(BuildMetricsJsonRPCService.class) .setUnremovable() .setDefaultScope(DotNames.APPLICATION_SCOPED) .build(); @@ -35,6 +35,6 @@ AdditionalBeanBuildItem additionalBeans() { @BuildStep JsonRPCProvidersBuildItem createJsonRPCService() { - return new JsonRPCProvidersBuildItem("build-steps", BuildStepsJsonRPCService.class); + return new JsonRPCProvidersBuildItem("build-metrics", BuildMetricsJsonRPCService.class); } } diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-items.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-items.js index 448a341fd74c4..967f1245e4680 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-items.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-items.js @@ -1,29 +1,113 @@ -import { LitElement, html, css} from 'lit'; -import { buildItems } from 'devui-data'; +import { LitElement, html, css } from 'lit'; + +import { JsonRpc } from 'jsonrpc'; +import { until } from 'lit/directives/until.js'; +import '@vaadin/grid'; +import { columnBodyRenderer } from '@vaadin/grid/lit.js'; +import '@vaadin/grid/vaadin-grid-sort-column.js'; +import '@vaadin/icon'; +import '@vaadin/text-field'; +import '@vaadin/vertical-layout'; +import '@vaadin/horizontal-layout'; /** * This component shows the Build Items */ export class QwcBuildItems extends LitElement { + + jsonRpc = new JsonRpc(this, true, 'build-metrics'); + static styles = css` - .todo { - padding-left: 10px; - height: 100%; - }`; + .build-items { + height: 100%; + display: flex; + flex-direction: column; + overflow: hidden; + } + + vaadin-grid { + height: 100%; + } + + vaadin-grid-cell-content { + vertical-align: top; + width: 100%; + } + + .summary { + margin-bottom: 15px; + }`; static properties = { - _items: {state: true} + _buildStepsMetrics: { state: true }, + _filtered: {state: true, type: Array} }; - + constructor() { super(); - this._items = buildItems; + this.jsonRpc.getBuildStepsMetrics().then(e => { + this._buildStepsMetrics = e.result; + this._filtered = this._buildStepsMetrics.items; + }); } render() { - if(this._items){ - return html`
${this._items}
`; + return html`${until(this._render(), html`Loading build items...`)}`; + } + + _match(value, term) { + if (!value) { + return false; } + return value.toLowerCase().includes(term.toLowerCase()); + } + + _filter(e) { + const searchTerm = (e.detail.value || '').trim(); + if (searchTerm === '') { + this._filtered = this._buildStepsMetrics.items; + return; + } + + this._filtered = this._buildStepsMetrics.items.filter((item) => { + return this._match(item.class, searchTerm); + }); + } + + _render() { + if (this._buildStepsMetrics && this._filtered) { + return html`
+
Produced ${this._buildStepsMetrics.itemsCount} build items.
+ + + + + + + + + +
`; + } + } + + _classRenderer(item) { + return html`${item.class}`; + } + + _countRenderer(item) { + return html`${item.count}`; } } customElements.define('qwc-build-items', QwcBuildItems); \ No newline at end of file diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js index 52dfe9ccb0665..b6720fb1ec85b 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js @@ -15,7 +15,7 @@ import '@vaadin/horizontal-layout'; */ export class QwcBuildSteps extends LitElement { - jsonRpc = new JsonRpc(this); + jsonRpc = new JsonRpc(this, true, 'build-metrics'); static styles = css` .build-steps { diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsDevUIController.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildMetricsDevUIController.java similarity index 95% rename from extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsDevUIController.java rename to extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildMetricsDevUIController.java index 94e66fd607ee0..93b9db1160cbd 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsDevUIController.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildMetricsDevUIController.java @@ -19,18 +19,18 @@ import org.jboss.logging.Logger; -import io.quarkus.devui.runtime.build.BuildStepsDevUIController.DependencyGraph.Link; -import io.quarkus.devui.runtime.build.BuildStepsDevUIController.DependencyGraph.Node; +import io.quarkus.devui.runtime.build.BuildMetricsDevUIController.DependencyGraph.Link; +import io.quarkus.devui.runtime.build.BuildMetricsDevUIController.DependencyGraph.Node; import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; -public class BuildStepsDevUIController { +public class BuildMetricsDevUIController { - private static final Logger LOG = Logger.getLogger(BuildStepsDevUIController.class.getName()); + private static final Logger LOG = Logger.getLogger(BuildMetricsDevUIController.class.getName()); - private static final BuildStepsDevUIController INSTANCE = new BuildStepsDevUIController(); + private static final BuildMetricsDevUIController INSTANCE = new BuildMetricsDevUIController(); - public static BuildStepsDevUIController get() { + public static BuildMetricsDevUIController get() { return INSTANCE; } @@ -38,7 +38,7 @@ public static BuildStepsDevUIController get() { private volatile Map buildStepsMetrics; - private BuildStepsDevUIController() { + private BuildMetricsDevUIController() { } void setBuildMetricsPath(Path buildMetricsPath) { diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsDevUIRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildMetricsDevUIRecorder.java similarity index 60% rename from extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsDevUIRecorder.java rename to extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildMetricsDevUIRecorder.java index 07820f4d3e91e..0511015bc8f3b 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsDevUIRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildMetricsDevUIRecorder.java @@ -5,9 +5,9 @@ import io.quarkus.runtime.annotations.Recorder; @Recorder -public class BuildStepsDevUIRecorder { +public class BuildMetricsDevUIRecorder { public void setBuildMetricsPath(String buildMetricsPath) { - BuildStepsDevUIController.get().setBuildMetricsPath(Path.of(buildMetricsPath)); + BuildMetricsDevUIController.get().setBuildMetricsPath(Path.of(buildMetricsPath)); } } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsJsonRPCService.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildMetricsJsonRPCService.java similarity index 63% rename from extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsJsonRPCService.java rename to extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildMetricsJsonRPCService.java index 6e5c897a39c73..b46f6ffa6d994 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildStepsJsonRPCService.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildMetricsJsonRPCService.java @@ -5,9 +5,9 @@ import jakarta.enterprise.context.ApplicationScoped; @ApplicationScoped -public class BuildStepsJsonRPCService { +public class BuildMetricsJsonRPCService { public Map getBuildStepsMetrics() { - return BuildStepsDevUIController.get().getBuildStepsMetrics(); + return BuildMetricsDevUIController.get().getBuildStepsMetrics(); } } From dbe8b8aa31f93726db5ac851720a27356f2e726b Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 30 Mar 2023 14:29:07 +0200 Subject: [PATCH 6/8] Dev UI - Make BuildMetricsJsonRPCService reactive --- .../devui/runtime/build/BuildMetricsJsonRPCService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildMetricsJsonRPCService.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildMetricsJsonRPCService.java index b46f6ffa6d994..1698e90cf9fab 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildMetricsJsonRPCService.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/build/BuildMetricsJsonRPCService.java @@ -4,10 +4,14 @@ import jakarta.enterprise.context.ApplicationScoped; +import io.smallrye.mutiny.Uni; +import io.smallrye.mutiny.infrastructure.Infrastructure; + @ApplicationScoped public class BuildMetricsJsonRPCService { - public Map getBuildStepsMetrics() { - return BuildMetricsDevUIController.get().getBuildStepsMetrics(); + public Uni> getBuildStepsMetrics() { + return Uni.createFrom().item(() -> BuildMetricsDevUIController.get().getBuildStepsMetrics()) + .runSubscriptionOn(Infrastructure.getDefaultWorkerPool()); } } From 0036999ce7714cfe7b24e93d687a5d5a0eefe5e1 Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Sun, 2 Apr 2023 12:48:41 +1000 Subject: [PATCH 7/8] custom namespace for build metrics Signed-off-by: Phillip Kruger --- .../deployment/BuildTimeContentProcessor.java | 4 ++-- .../build/BuildMetricsDevUIProcessor.java | 2 +- .../resources/dev-ui/controller/jsonrpc.js | 2 +- .../resources/dev-ui/qwc/qwc-build-items.js | 21 ++++++++++++------- .../resources/dev-ui/qwc/qwc-build-steps.js | 19 +++++++++++------ 5 files changed, 31 insertions(+), 17 deletions(-) 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 73dd106ae0093..5d14fbf251791 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 @@ -361,13 +361,13 @@ void createBuildTimeData(BuildProducer buildTimeConstPr internalBuildTimeData.addBuildTimeData("devServices", devServiceDescriptions); Page buildSteps = Page.webComponentPageBuilder().internal() - .namespace("devui-build-information") + .namespace("devui-build-metrics") .title("Build Steps") .icon("font-awesome-solid:hammer") .componentLink("qwc-build-steps.js").build(); Page buildItems = Page.webComponentPageBuilder().internal() - .namespace("devui-build-information") + .namespace("devui-build-metrics") .title("Build Items") .icon("font-awesome-solid:trowel") .componentLink("qwc-build-items.js").build(); diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/BuildMetricsDevUIProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/BuildMetricsDevUIProcessor.java index 7be931b37aa32..606357d79d335 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/BuildMetricsDevUIProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/build/BuildMetricsDevUIProcessor.java @@ -35,6 +35,6 @@ AdditionalBeanBuildItem additionalBeans() { @BuildStep JsonRPCProvidersBuildItem createJsonRPCService() { - return new JsonRPCProvidersBuildItem("build-metrics", BuildMetricsJsonRPCService.class); + return new JsonRPCProvidersBuildItem("devui-build-metrics", BuildMetricsJsonRPCService.class); } } 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 11d3c9b1648f6..29e0c6de3fc16 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 @@ -205,7 +205,7 @@ export class JsonRpc { _setExtensionName(discoveredNamespace, serviceIdentifier){ if(serviceIdentifier){ - this._extensionName = serviceIdentifier; + this._extensionName = discoveredNamespace + "-" + serviceIdentifier; }else { this._extensionName = discoveredNamespace; } diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-items.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-items.js index 967f1245e4680..ee8deb81cc8d3 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-items.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-items.js @@ -15,11 +15,12 @@ import '@vaadin/horizontal-layout'; */ export class QwcBuildItems extends LitElement { - jsonRpc = new JsonRpc(this, true, 'build-metrics'); + jsonRpc = new JsonRpc("devui-build-metrics", true); static styles = css` .build-items { height: 100%; + width: 100%; display: flex; flex-direction: column; overflow: hidden; @@ -36,6 +37,10 @@ export class QwcBuildItems extends LitElement { .summary { margin-bottom: 15px; + } + + .datatable { + width: 100%; }`; static properties = { @@ -52,7 +57,11 @@ export class QwcBuildItems extends LitElement { } render() { - return html`${until(this._render(), html`Loading build items...`)}`; + if (this._buildStepsMetrics && this._filtered) { + return this._render(); + }else { + return html`Loading build items...`; + } } _match(value, term) { @@ -75,8 +84,7 @@ export class QwcBuildItems extends LitElement { } _render() { - if (this._buildStepsMetrics && this._filtered) { - return html`
+ return html`
Produced ${this._buildStepsMetrics.itemsCount} build items.
- - +
`; - } } _classRenderer(item) { diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js index b6720fb1ec85b..ec2cb21b48c62 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js @@ -15,11 +15,12 @@ import '@vaadin/horizontal-layout'; */ export class QwcBuildSteps extends LitElement { - jsonRpc = new JsonRpc(this, true, 'build-metrics'); + jsonRpc = new JsonRpc("devui-build-metrics", true); static styles = css` .build-steps { height: 100%; + width: 100%; display: flex; flex-direction: column; overflow: hidden; @@ -36,6 +37,10 @@ export class QwcBuildSteps extends LitElement { .summary { margin-bottom: 15px; + } + + .datatable { + width: 100%; }`; static properties = { @@ -52,7 +57,11 @@ export class QwcBuildSteps extends LitElement { } render() { - return html`${until(this._render(), html`Loading build steps...`)}`; + if (this._buildStepsMetrics && this._filtered) { + return this._render(); + }else { + return html`Loading build steps...`; + } } _match(value, term) { @@ -75,7 +84,6 @@ export class QwcBuildSteps extends LitElement { } _render() { - if (this._buildStepsMetrics && this._filtered) { return html`
Executed ${this._buildStepsMetrics.records.length} build steps on ${Object.keys(this._buildStepsMetrics.threadSlotRecords).length} threads in ${this._buildStepsMetrics.duration} ms.
- - +
`; - } } _stepIdRenderer(record) { From bb8003b2838804fc57b618937bfdbf85984dbd12 Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Mon, 3 Apr 2023 11:01:43 +1000 Subject: [PATCH 8/8] Make sure to reload on a hot reload Signed-off-by: Phillip Kruger --- .../resources/dev-ui/qwc/qwc-build-items.js | 25 +++++------ .../resources/dev-ui/qwc/qwc-build-steps.js | 45 ++++++------------- 2 files changed, 24 insertions(+), 46 deletions(-) diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-items.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-items.js index ee8deb81cc8d3..9c0ee32b70e38 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-items.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-items.js @@ -1,7 +1,6 @@ -import { LitElement, html, css } from 'lit'; +import { QwcHotReloadElement, html, css} from 'qwc-hot-reload-element'; import { JsonRpc } from 'jsonrpc'; -import { until } from 'lit/directives/until.js'; import '@vaadin/grid'; import { columnBodyRenderer } from '@vaadin/grid/lit.js'; import '@vaadin/grid/vaadin-grid-sort-column.js'; @@ -13,7 +12,7 @@ import '@vaadin/horizontal-layout'; /** * This component shows the Build Items */ -export class QwcBuildItems extends LitElement { +export class QwcBuildItems extends QwcHotReloadElement { jsonRpc = new JsonRpc("devui-build-metrics", true); @@ -30,9 +29,8 @@ export class QwcBuildItems extends LitElement { height: 100%; } - vaadin-grid-cell-content { - vertical-align: top; - width: 100%; + vaadin-grid-sort-column { + color: red; } .summary { @@ -50,11 +48,15 @@ export class QwcBuildItems extends LitElement { constructor() { super(); + this.hotReload(); + } + + hotReload(){ this.jsonRpc.getBuildStepsMetrics().then(e => { this._buildStepsMetrics = e.result; this._filtered = this._buildStepsMetrics.items; }); - } + } render() { if (this._buildStepsMetrics && this._filtered) { @@ -96,15 +98,12 @@ export class QwcBuildItems extends LitElement { + path="count">
`; } @@ -112,9 +111,5 @@ export class QwcBuildItems extends LitElement { _classRenderer(item) { return html`${item.class}`; } - - _countRenderer(item) { - return html`${item.count}`; - } } customElements.define('qwc-build-items', QwcBuildItems); \ No newline at end of file diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js index ec2cb21b48c62..5514264401c8e 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-build-steps.js @@ -1,7 +1,6 @@ -import { LitElement, html, css } from 'lit'; +import { QwcHotReloadElement, html, css} from 'qwc-hot-reload-element'; import { JsonRpc } from 'jsonrpc'; -import { until } from 'lit/directives/until.js'; import '@vaadin/grid'; import { columnBodyRenderer } from '@vaadin/grid/lit.js'; import '@vaadin/grid/vaadin-grid-sort-column.js'; @@ -13,7 +12,7 @@ import '@vaadin/horizontal-layout'; /** * This component shows the Build Steps */ -export class QwcBuildSteps extends LitElement { +export class QwcBuildSteps extends QwcHotReloadElement { jsonRpc = new JsonRpc("devui-build-metrics", true); @@ -30,9 +29,8 @@ export class QwcBuildSteps extends LitElement { height: 100%; } - vaadin-grid-cell-content { - vertical-align: top; - width: 100%; + vaadin-grid-sort-column { + color: red; } .summary { @@ -50,11 +48,15 @@ export class QwcBuildSteps extends LitElement { constructor() { super(); + this.hotReload(); + } + + hotReload(){ this.jsonRpc.getBuildStepsMetrics().then(e => { this._buildStepsMetrics = e.result; this._filtered = this._buildStepsMetrics.records; }); - } + } render() { if (this._buildStepsMetrics && this._filtered) { @@ -96,47 +98,28 @@ export class QwcBuildSteps extends LitElement { + path="started"> + path="duration"> - - + path="thread"> + `; } _stepIdRenderer(record) { return html`${record.stepId}`; } - - _startedRenderer(record) { - return html`${record.started}`; - } - - _durationRenderer(record) { - return html`${record.duration}`; - } - - _threadRenderer(record) { - return html`${record.thread}`; - } } customElements.define('qwc-build-steps', QwcBuildSteps); \ No newline at end of file