-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kafka Streams Dev UI migration to v2
- Loading branch information
Showing
7 changed files
with
682 additions
and
0 deletions.
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
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
30 changes: 30 additions & 0 deletions
30
...t/src/main/java/io/quarkus/kafka/streams/deployment/devui/KafkaStreamsDevUIProcessor.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,30 @@ | ||
package io.quarkus.kafka.streams.deployment.devui; | ||
|
||
import io.quarkus.deployment.IsDevelopment; | ||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.devui.spi.JsonRPCProvidersBuildItem; | ||
import io.quarkus.devui.spi.page.CardPageBuildItem; | ||
import io.quarkus.devui.spi.page.Page; | ||
import io.quarkus.kafka.streams.runtime.devui.KafkaStreamsJsonRPCService; | ||
|
||
public class KafkaStreamsDevUIProcessor { | ||
|
||
@BuildStep(onlyIf = IsDevelopment.class) | ||
public void createPages(BuildProducer<CardPageBuildItem> cardPageProducer) { | ||
|
||
CardPageBuildItem cardPageBuildItem = new CardPageBuildItem(); | ||
|
||
cardPageBuildItem.addPage(Page.webComponentPageBuilder() | ||
.componentLink("qwc-kafka-streams-topology.js") | ||
.title("Topology") | ||
.icon("font-awesome-solid:diagram-project")); | ||
|
||
cardPageProducer.produce(cardPageBuildItem); | ||
} | ||
|
||
@BuildStep(onlyIf = IsDevelopment.class) | ||
public void createJsonRPCService(BuildProducer<JsonRPCProvidersBuildItem> jsonRPCServiceProducer) { | ||
jsonRPCServiceProducer.produce(new JsonRPCProvidersBuildItem(KafkaStreamsJsonRPCService.class)); | ||
} | ||
} |
123 changes: 123 additions & 0 deletions
123
extensions/kafka-streams/deployment/src/main/resources/dev-ui/qwc-kafka-streams-topology.js
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,123 @@ | ||
import { QwcHotReloadElement, html, css } from 'qwc-hot-reload-element'; | ||
import { unsafeHTML } from 'lit/directives/unsafe-html.js'; | ||
import { JsonRpc } from 'jsonrpc'; | ||
|
||
import { Graphviz } from "@hpcc-js/wasm/graphviz.js"; | ||
|
||
import '@vaadin/details'; | ||
import '@vaadin/tabs'; | ||
import '@vaadin/vertical-layout'; | ||
import 'qui-badge'; | ||
import 'qui-code-block'; | ||
|
||
/** | ||
* This component shows the Kafka Streams Topology | ||
*/ | ||
export class QwcKafkaStreamsTopology extends QwcHotReloadElement { | ||
|
||
jsonRpc = new JsonRpc(this); | ||
|
||
static styles = css` | ||
.codeBlock { | ||
width: 100%; | ||
height: auto; | ||
} | ||
`; | ||
|
||
static properties = { | ||
_topology: {state: true}, | ||
_graphviz: {state: true}, | ||
_tabContent: {state: true} | ||
}; | ||
|
||
constructor() { | ||
super(); | ||
this._topology = null; | ||
this._graphviz = null; | ||
this._tabContent = ''; | ||
} | ||
|
||
connectedCallback() { | ||
super.connectedCallback(); | ||
Graphviz.load().then(r => this._graphviz = r); | ||
this.hotReload() | ||
} | ||
|
||
render() { | ||
if (this._topology) { | ||
return html`<vaadin-tabs @selected-changed="${(e) => this._tabSelectedChanged(e.detail.value)}"> | ||
<vaadin-tab id="graphTab">Graph</vaadin-tab> | ||
<vaadin-tab id="detailsTab">Details</vaadin-tab> | ||
<vaadin-tab id="describeTab">Describe</vaadin-tab> | ||
<vaadin-tab id="graphvizTab">Graphviz</vaadin-tab> | ||
<vaadin-tab id="mermaidTab">Mermaid</vaadin-tab> | ||
</vaadin-tabs> | ||
<vaadin-vertical-layout theme="padding"><p>${this._tabContent}</p></vaadin-vertical-layout>`; | ||
} | ||
|
||
return html`<qwc-no-data message="You do not have any Topology." | ||
link="https://quarkus.io/guides/kafka-streams" | ||
linkText="Learn how to write Kafka Streams"> | ||
</qwc-no-data>`; | ||
} | ||
|
||
hotReload() { | ||
this._topology = null; | ||
this.jsonRpc.getTopology().then(jsonRpcResponse => { | ||
this._topology = jsonRpcResponse.result; | ||
}); | ||
} | ||
|
||
_tabSelectedChanged(n) { | ||
switch(n) { | ||
case 1 : this._selectDetailsTab(); break; | ||
case 2 : this._selectDescribeTab(); break; | ||
case 3 : this._selectGraphvizTab(); break; | ||
case 4 : this._selectMermaidTab(); break; | ||
default : this._selectGraphTab(); | ||
} | ||
} | ||
|
||
_selectGraphTab() { | ||
if (this._graphviz) { | ||
let g = this._graphviz.dot(this._topology.graphviz); | ||
this._tabContent = html`${unsafeHTML(g)}`; | ||
} else { | ||
this._tabContent = html`Graph engine not started.`; | ||
} | ||
} | ||
|
||
_selectDetailsTab() { | ||
this._tabContent = html`<table> | ||
<tr> | ||
<td>Sub-topologies</td><td><qui-badge>${this._topology.subTopologies.length}</qui-badge></td> | ||
<td>${this._topology.subTopologies.map((subTopology) => html`<qui-badge level="contrast" icon="font-awesome-solid:diagram-project" style="margin-right:5px">${subTopology}</qui-badge>`)}</td> | ||
</tr> | ||
<tr> | ||
<td>Sources</td><td><qui-badge>${this._topology.sources.length}</qui-badge></td> | ||
<td>${this._topology.sources.map((source) => html`<qui-badge level="contrast" icon="font-awesome-solid:right-to-bracket" style="margin-right:5px">${source}</qui-badge>`)}</td> | ||
</tr> | ||
<tr> | ||
<td>Sinks</td><td><qui-badge>${this._topology.sinks.length}</qui-badge></td> | ||
<td>${this._topology.sinks.map((sink) => html`<qui-badge level="contrast" icon="font-awesome-solid:right-from-bracket" style="margin-right:5px">${sink}</qui-badge>`)}</td> | ||
</tr> | ||
<tr> | ||
<td>Stores</td><td><qui-badge>${this._topology.stores.length}</qui-badge></td> | ||
<td>${this._topology.stores.map((store) => html`<qui-badge level="contrast" icon="font-awesome-solid:database" style="margin-right:5px">${store}</qui-badge>`)}</td> | ||
</tr> | ||
</table>`; | ||
} | ||
|
||
_selectDescribeTab() { | ||
this._tabContent = html`<qui-code-block mode='text' content='${this._topology.describe}' class="codeBlock"></qui-code-block>`; | ||
} | ||
|
||
_selectGraphvizTab() { | ||
this._tabContent = html`<qui-code-block mode='gv' content='${this._topology.graphviz}' class="codeBlock"></qui-code-block>`; | ||
} | ||
|
||
_selectMermaidTab() { | ||
this._tabContent = html`<qui-code-block mode='mermaid' content='${this._topology.mermaid}' class="codeBlock"></qui-code-block>`; | ||
} | ||
} | ||
customElements.define('qwc-kafka-streams-topology', QwcKafkaStreamsTopology); |
Oops, something went wrong.