From 4d50319ceb5ec875acb6167e3b97bc592b97eacf Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Tue, 25 Apr 2023 02:57:35 +1000 Subject: [PATCH] implement the config filter by extension Signed-off-by: Phillip Kruger (cherry picked from commit a9d1e88aa6e30b7a23c9b473733b2a7859543a8b) --- .../devui/deployment/DevUIProcessor.java | 2 +- .../devui/deployment/extension/Extension.java | 7 ----- .../dev-ui/controller/router-controller.js | 9 ++++--- .../resources/dev-ui/qwc/qwc-configuration.js | 27 ++++++++++++++++--- .../resources/dev-ui/qwc/qwc-extension.js | 8 +++++- 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/DevUIProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/DevUIProcessor.java index e6a67155f6e51..f57d61b6f898b 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/DevUIProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/DevUIProcessor.java @@ -441,7 +441,7 @@ void getAllExtensions(List cardPageBuildItems, if (metaData.containsKey(CAPABILITIES)) { Map capabilities = (Map) metaData.get(CAPABILITIES); - extension.setConfigFilter((List) capabilities.getOrDefault(PROVIDES, null)); + extension.setProvidesCapabilities((List) capabilities.getOrDefault(PROVIDES, null)); } if (metaData.containsKey(CODESTART)) { diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/extension/Extension.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/extension/Extension.java index af1056cd1896b..a51a528f569c8 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/extension/Extension.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/extension/Extension.java @@ -8,9 +8,6 @@ import io.quarkus.devui.spi.page.Page; public class Extension { - private static final String SPACE = " "; - private static final String DASH = "-"; - private String namespace; private String artifact; private String name; @@ -59,10 +56,6 @@ public void setName(String name) { this.name = name; } - // public String getPathName() { - // return name.toLowerCase().replaceAll(SPACE, DASH); - // } - public String getShortName() { return shortName; } diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/router-controller.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/router-controller.js index a0b6070bce0c9..0b17656c7e4fa 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/router-controller.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/router-controller.js @@ -154,10 +154,11 @@ export class RouterController { RouterController.router.addRoutes(routes); } - // TODO: Pass the other parameters along ? + var currentSelection = window.location.pathname; + var currentQueryString = window.location.search; - var relocationRequest = this.getFrom(); + var relocationRequest = this.getQueryParameter("from"); if (relocationRequest) { // We know and already loaded the requested location if (relocationRequest === path) { @@ -188,10 +189,10 @@ export class RouterController { return params; } - getFrom(){ + getQueryParameter(param){ var params = this.getQueryParameters(); if(params){ - return params.from; + return params[param] || null; }else { return null; } diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-configuration.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-configuration.js index 1e41312e10339..114c84c75e924 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-configuration.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-configuration.js @@ -1,5 +1,6 @@ import { LitElement, html, css } from 'lit'; import { JsonRpc } from 'jsonrpc'; +import { RouterController } from 'router-controller'; import { until } from 'lit/directives/until.js'; import '@vaadin/grid'; import 'qui/qui-alert.js'; @@ -18,6 +19,7 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js'; import { gridRowDetailsRenderer } from '@vaadin/grid/lit.js'; import { observeState } from 'lit-element-state'; import { devuiState } from 'devui-state'; +import 'qui-badge'; /** * This component allows users to change the configuration @@ -25,6 +27,7 @@ import { devuiState } from 'devui-state'; export class QwcConfiguration extends observeState(LitElement) { jsonRpc = new JsonRpc(this); + routerController = new RouterController(this); static styles = css` .conf { @@ -87,6 +90,13 @@ export class QwcConfiguration extends observeState(LitElement) { constructor() { super(); + + this._filteredValue = this.routerController.getQueryParameter("filter"); + + if(this._filteredValue){ + this._filteredValue = this._filteredValue.replaceAll(",", " OR "); + } + this._filtered = devuiState.allConfiguration; this.jsonRpc.getAllValues().then(e => { this._values = e.result; @@ -103,10 +113,19 @@ export class QwcConfiguration extends observeState(LitElement) { if (! value) { return false; } + if(term.includes(" OR ")){ + let terms = term.split(" OR "); + for (let t of terms) { + if(value.toLowerCase().includes(t.toLowerCase())){ + return true; + } + } + return false; + } return value.toLowerCase().includes(term.toLowerCase()); } - _filter(e) { + _filterTextChanged(e) { const searchTerm = (e.detail.value || '').trim(); if (searchTerm === '') { this._filtered = devuiState.allConfiguration @@ -119,13 +138,15 @@ export class QwcConfiguration extends observeState(LitElement) { } _render() { - if (this._filtered && this._values) { + if (this._filtered && this._values) { return html`
+ @value-changed="${(e) => this._filterTextChanged(e)}"> + ${this._filtered.length} ${this._renderGrid()}
`; diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-extension.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-extension.js index 0da0c18e84e41..931ad190ec6be 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-extension.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-extension.js @@ -44,6 +44,10 @@ export class QwcExtension extends LitElement { visibility:hidden; } + .card-footer a { + color: var(--lumo-contrast-50pct); + } + .active:hover { box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); } @@ -137,7 +141,9 @@ export class QwcExtension extends LitElement { _footerTemplate() { return html` `;