Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kafka Streams Dev UI migration to v2 #36706

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,110 @@
<scope>runtime</scope>
</dependency>

<!-- hpcc-js Wasm / Graphviz and dependencies -->
<dependency>
<groupId>org.mvnpm.at.hpcc-js</groupId>
<artifactId>wasm</artifactId>
<version>2.14.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>yargs</artifactId>
<version>17.7.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>cliui</artifactId>
<version>8.0.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>escalade</artifactId>
<version>3.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>get-caller-file</artifactId>
<version>2.0.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>require-directory</artifactId>
<version>2.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>string-width</artifactId>
<version>4.2.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>y18n</artifactId>
<version>5.0.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>yargs-parser</artifactId>
<version>21.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>strip-ansi</artifactId>
<version>6.0.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>wrap-ansi</artifactId>
<version>7.0.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>emoji-regex</artifactId>
<version>8.0.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>is-fullwidth-code-point</artifactId>
<version>3.0.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>ansi-regex</artifactId>
<version>5.0.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>ansi-styles</artifactId>
<version>4.3.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>color-convert</artifactId>
<version>2.0.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>color-name</artifactId>
<version>1.1.4</version>
<scope>runtime</scope>
</dependency>

<!-- Code editor -->
<dependency>
<groupId>org.mvnpm.at.vanillawc</groupId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/kafka-streams/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health-spi</artifactId>
</dependency>
<dependency>
<groupId>org.mvnpm.at.hpcc-js</groupId>
<artifactId>wasm</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
Expand Down
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));
}
}
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);
Loading
Loading