From 5357ded921a97e5006f6fb6078c3ad885bb8a426 Mon Sep 17 00:00:00 2001 From: melloware Date: Mon, 13 Mar 2023 12:49:37 -0400 Subject: [PATCH] Fix #46: Add new Dev UI --- deployment/pom.xml | 4 + .../devui/QuinoaDevUIProcessor.java | 60 +++++++++++++ .../dev-ui/quinoa/qwc-quinoa-card.js | 84 +++++++++++++++++++ .../ROOT/pages/includes/attributes.adoc | 2 +- pom.xml | 2 +- 5 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 deployment/src/main/java/io/quarkiverse/quinoa/deployment/devui/QuinoaDevUIProcessor.java create mode 100644 deployment/src/main/resources/dev-ui/quinoa/qwc-quinoa-card.js diff --git a/deployment/pom.xml b/deployment/pom.xml index d2b95715..1ee1d962 100644 --- a/deployment/pom.xml +++ b/deployment/pom.xml @@ -17,6 +17,10 @@ io.quarkus quarkus-resteasy-reactive-server-spi-deployment + + io.quarkus + quarkus-vertx-http-dev-ui-spi + com.github.eirslett frontend-plugin-core diff --git a/deployment/src/main/java/io/quarkiverse/quinoa/deployment/devui/QuinoaDevUIProcessor.java b/deployment/src/main/java/io/quarkiverse/quinoa/deployment/devui/QuinoaDevUIProcessor.java new file mode 100644 index 00000000..538bbc8f --- /dev/null +++ b/deployment/src/main/java/io/quarkiverse/quinoa/deployment/devui/QuinoaDevUIProcessor.java @@ -0,0 +1,60 @@ +package io.quarkiverse.quinoa.deployment.devui; + +import java.util.Optional; +import java.util.OptionalInt; + +import io.netty.util.internal.StringUtil; +import io.quarkiverse.quinoa.deployment.QuinoaConfig; +import io.quarkus.deployment.IsDevelopment; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.devui.spi.page.CardPageBuildItem; +import io.quarkus.devui.spi.page.Page; +import io.quarkus.devui.spi.page.PageBuilder; + +/** + * Dev UI card for displaying important details such as the Node.js version. + */ +public class QuinoaDevUIProcessor { + + @BuildStep(onlyIf = IsDevelopment.class) + void createCard(BuildProducer cardPageBuildItemBuildProducer, QuinoaConfig quinoaConfig) { + final CardPageBuildItem card = new CardPageBuildItem("Quinoa"); + + final Optional node = quinoaConfig.packageManagerInstall.nodeVersion; + if (node.isPresent() && !node.isEmpty()) { + final String nodeVersion = node.get(); + final PageBuilder nodejsPage = Page.externalPageBuilder("Node.js") + .icon("font-awesome-brands:square-js") + .url("https://nodejs.org/") + .isHtmlContent() + .staticLabel(nodeVersion); + card.addPage(nodejsPage); + } + + final String npmVersion = quinoaConfig.packageManagerInstall.npmVersion; + if (!StringUtil.isNullOrEmpty(npmVersion)) { + final PageBuilder nodejsPage = Page.externalPageBuilder("NPM") + .icon("font-awesome-brands:square-js") + .url("https://www.npmjs.com/") + .isHtmlContent() + .staticLabel(npmVersion); + card.addPage(nodejsPage); + } + + final OptionalInt port = quinoaConfig.devServer.port; + if (port.isPresent() && port.getAsInt() > 0) { + final PageBuilder portPage = Page.externalPageBuilder("Port") + .icon("font-awesome-solid:plug") + .url(String.format("https://localhost:%d", port.getAsInt())) + .doNotEmbed() + .staticLabel(String.valueOf(port.getAsInt())); + card.addPage(portPage); + } + + card.setCustomCard("qwc-quinoa-card.js"); + + cardPageBuildItemBuildProducer.produce(card); + } + +} diff --git a/deployment/src/main/resources/dev-ui/quinoa/qwc-quinoa-card.js b/deployment/src/main/resources/dev-ui/quinoa/qwc-quinoa-card.js new file mode 100644 index 00000000..bcf6edaf --- /dev/null +++ b/deployment/src/main/resources/dev-ui/quinoa/qwc-quinoa-card.js @@ -0,0 +1,84 @@ +import { LitElement, html, css} from 'lit'; +import { pages } from 'quinoa-data'; +import 'qwc/qwc-extension-link.js'; + +const NAME = "Quinoa"; +const DESCRIPTION = "Quinoa serves single page applications or web components (built with NodeJS: React, Angular, Vue, Lit, …)"; +export class QwcQuinoaCard extends LitElement { + static styles = css` + .identity { + display: flex; + justify-content: flex-start; + } + + .description { + padding-bottom: 10px; + } + + .logo { + padding-bottom: 10px; + margin-right: 5px; + } + + .card-content { + color: var(--lumo-contrast-90pct); + display: flex; + flex-direction: column; + justify-content: flex-start; + padding: 10px 10px; + height: 100%; + } + + .card-content slot { + display: flex; + flex-flow: column wrap; + padding-top: 5px; + } + `; + + static properties = { + description: {type: String} + }; + + constructor() { + super(); + } + + connectedCallback() { + super.connectedCallback(); + } + + render() { + return html`
+
+ +
${DESCRIPTION}
+
+ ${this._renderCardLinks()} +
+ `; + } + + _renderCardLinks(){ + return html`${pages.map(page => html` + + + `)}`; + } + +} +customElements.define('qwc-quinoa-card', QwcQuinoaCard); \ No newline at end of file diff --git a/docs/modules/ROOT/pages/includes/attributes.adoc b/docs/modules/ROOT/pages/includes/attributes.adoc index d5bd6d6f..e56c8ed4 100644 --- a/docs/modules/ROOT/pages/includes/attributes.adoc +++ b/docs/modules/ROOT/pages/includes/attributes.adoc @@ -1,4 +1,4 @@ -:quarkus-version: 3.0.0.Alpha4 +:quarkus-version: 3.0.0.Alpha5 :quarkus-quinoa-version: 1.2.5 :maven-version: 3.8.1+ diff --git a/pom.xml b/pom.xml index 55535172..1ac2edb6 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ 11 UTF-8 UTF-8 - 3.0.0.Alpha4 + 3.0.0.Alpha6 1.31.0 3.24.2 1.12.1