-
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.
Signed-off-by: Phillip Kruger <[email protected]>
- Loading branch information
1 parent
bf53906
commit 685623a
Showing
7 changed files
with
175 additions
and
4 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
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
101 changes: 101 additions & 0 deletions
101
extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-routes.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,101 @@ | ||
import { LitElement, html, css} from 'lit'; | ||
import { basepath } from 'devui-data'; | ||
import '@vaadin/progress-bar'; | ||
import '@vaadin/grid'; | ||
import { columnBodyRenderer } from '@vaadin/grid/lit.js'; | ||
import '@vaadin/grid/vaadin-grid-sort-column.js'; | ||
|
||
/** | ||
* This component show all available routes | ||
*/ | ||
export class QwcRoutes extends LitElement { | ||
|
||
static styles = css` | ||
.infogrid { | ||
width: 99%; | ||
height: 99%; | ||
} | ||
a { | ||
cursor: pointer; | ||
color: var(--lumo-body-text-color); | ||
} | ||
a:link { | ||
text-decoration: none; | ||
color: var(--lumo-body-text-color); | ||
} | ||
a:visited { | ||
text-decoration: none; | ||
color: var(--lumo-body-text-color); | ||
} | ||
a:active { | ||
text-decoration: none; | ||
color: var(--lumo-body-text-color); | ||
} | ||
a:hover { | ||
color: var(--quarkus-red); | ||
} | ||
`; | ||
|
||
static properties = { | ||
_routes: {state: true}, | ||
} | ||
|
||
constructor() { | ||
super(); | ||
this._routes = null; | ||
} | ||
|
||
async connectedCallback() { | ||
super.connectedCallback(); | ||
await this.load(); | ||
} | ||
|
||
async load() { | ||
const response = await fetch(basepath + "/endpoints/routes.json"); | ||
const data = await response.json(); | ||
this._routes = data; | ||
} | ||
|
||
render() { | ||
if (this._routes) { | ||
return html`<vaadin-grid .items="${this._routes}" class="infogrid"> | ||
<vaadin-grid-sort-column resizable | ||
header='Handler' | ||
path="contextHandlers" | ||
${columnBodyRenderer(this._contextHandlersRenderer, [])}>> | ||
</vaadin-grid-sort-column> | ||
<vaadin-grid-sort-column resizable | ||
header="Order" | ||
path="order"> | ||
</vaadin-grid-sort-column> | ||
<vaadin-grid-sort-column resizable | ||
header="Path" | ||
path="path"> | ||
</vaadin-grid-sort-column> | ||
</vaadin-grid>`; | ||
}else{ | ||
return html` | ||
<div style="color: var(--lumo-secondary-text-color);width: 95%;" > | ||
<div>Fetching routes...</div> | ||
<vaadin-progress-bar indeterminate></vaadin-progress-bar> | ||
</div> | ||
`; | ||
} | ||
} | ||
|
||
_contextHandlersRenderer(route){ | ||
const regex1 = /([^$]+)*/; | ||
const match1 = route.contextHandlers.match(regex1); | ||
let className1 = match1 ? match1[1] : route.contextHandlers; | ||
if(className1.startsWith("[")){ | ||
className1 = className1.substring(1); | ||
} | ||
|
||
return html`<code>${className1}</code>`; | ||
} | ||
|
||
} | ||
customElements.define('qwc-routes', QwcRoutes); |
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
48 changes: 48 additions & 0 deletions
48
...ions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/VertxRouteInfoService.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,48 @@ | ||
package io.quarkus.devui.runtime; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.event.Observes; | ||
|
||
import io.vertx.core.Vertx; | ||
import io.vertx.core.json.JsonArray; | ||
import io.vertx.core.json.JsonObject; | ||
import io.vertx.ext.web.Route; | ||
import io.vertx.ext.web.Router; | ||
import io.vertx.ext.web.impl.RouteImpl; | ||
|
||
@ApplicationScoped | ||
public class VertxRouteInfoService { | ||
|
||
private Router router; | ||
|
||
public void init(@Observes Router router, Vertx vertx) { | ||
this.router = router; | ||
} | ||
|
||
public JsonArray getInfo() { | ||
JsonArray allRoutes = new JsonArray(); | ||
for (Route r : router.getRoutes()) { | ||
String ts = ((RouteImpl) r).toString(); | ||
int begin = ts.lastIndexOf("{") + 1; | ||
int end = ts.indexOf("}"); | ||
ts = ts.substring(begin, end); | ||
|
||
String fields[] = ts.split(","); | ||
Map<String, Object> routeMap = new HashMap<>(); | ||
for (String field : fields) { | ||
String kv[] = field.split("="); | ||
String key = kv[0]; | ||
String value = ""; | ||
if (kv.length > 1) { | ||
value = kv[1]; | ||
} | ||
routeMap.put(key.trim(), value.trim()); | ||
} | ||
allRoutes.add(new JsonObject(routeMap)); | ||
} | ||
return allRoutes; | ||
} | ||
} |