Skip to content

Commit

Permalink
Add new Dev UI card
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Kruger <[email protected]>
  • Loading branch information
phillip-kruger committed Jun 21, 2023
1 parent 31fc316 commit 9862b62
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/includes/attributes.adoc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
:quarkus-version: 3.1.0.Final
:quarkus-version: 3.1.2.Final
:quarkus-minio-version: 3.1.0.Final
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.quarkiverse.minio.client.deployment.devui;

import io.quarkiverse.minio.client.MiniosBuildTimeConfiguration;
import io.quarkiverse.minio.client.deployment.devservices.MinioBuildTimeConfig;
import io.quarkiverse.minio.client.devui.MinioJsonRPCService;
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;

public class MinioClientDevUIProcessor {

@BuildStep(onlyIf = IsDevelopment.class)
void createCard(BuildProducer<CardPageBuildItem> cardProducer, MinioBuildTimeConfig devServiceConfig,
MiniosBuildTimeConfiguration configuration) {

final CardPageBuildItem card = new CardPageBuildItem();

card.addBuildTimeData("enabled", devServiceConfig.devservices.enabled.orElse(true));

card.addPage(Page.externalPageBuilder("Min.io console")
.icon("font-awesome-solid:signs-post")
.dynamicUrlJsonRPCMethodName("getMinioConsoleUrl")
.doNotEmbed());

card.setCustomCard("qwc-minio-card.js");

cardProducer.produce(card);
}

@BuildStep(onlyIf = IsDevelopment.class)
JsonRPCProvidersBuildItem createJsonRPCServiceForCache() {
return new JsonRPCProvidersBuildItem(MinioJsonRPCService.class);
}

}
105 changes: 105 additions & 0 deletions minio-client/deployment/src/main/resources/dev-ui/qwc-minio-card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { LitElement, html, css} from 'lit';
import { pages } from 'build-time-data';
import { enabled } from 'build-time-data';
import 'qwc/qwc-extension-link.js';
import { JsonRpc } from 'jsonrpc'
import 'qui-badge';

export class QwcMinioCard extends LitElement {
jsonRpc = new JsonRpc(this);

static styles = css`
.identity {
display: flex;
justify-content: flex-start;
}
.loginDetails {
padding-top: 10px;
color: var(--lumo-contrast-70pct);
font-size: smaller;
text-align: center;
}
.description {
padding-bottom: 10px;
}
.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 = {
extensionName: {type: String},
description: {type: String},
guide: {type: String},
namespace: {type: String},
_loginDetails: {type: String}
}

constructor() {
super();
}

connectedCallback() {
super.connectedCallback();
this.jsonRpc.getLoginDetails().then(jsonRpcResponse => {
this._loginDetails = jsonRpcResponse.result;
});
}

render() {
return html`<div class="card-content" slot="content">
<div class="identity">
<div class="description">${this.description}</div>
</div>
${this._renderCardLinks()}
${this._renderLoginDetails()}
</div>
`;
}

_renderCardLinks(){
if(enabled){

return html`${pages.map(page => html`
<qwc-extension-link slot="link"
namespace="${this.namespace}"
extensionName="${this.name}"
iconName="${page.icon}"
displayName="${page.title}"
staticLabel="${page.staticLabel}"
dynamicLabel="${page.dynamicLabel}"
streamingLabel="${page.streamingLabel}"
path="${page.id}"
?embed=${page.embed}
externalUrl="${page.metadata.externalUrl}"
dynamicUrlMethodName="${page.metadata.dynamicUrlMethodName}"
webcomponent="${page.componentLink}" >
</qwc-extension-link>
`)}`;
} else {
return html`<span>Disabled</span>`;
}

}

_renderLoginDetails(){
if(this._loginDetails){
return html`<div class="loginDetails">
<span>Access Key: <qui-badge><span>${this._loginDetails.accesskey}</span></qui-badge></span><br/>
<span>Secret Key: <qui-badge><span>${this._loginDetails.secretkey}</span></qui-badge></span>
</div>`;
}
}

}
customElements.define('qwc-minio-card', QwcMinioCard);
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.quarkiverse.minio.client.devui;

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;

import io.smallrye.common.annotation.NonBlocking;
import io.vertx.core.json.JsonObject;

public class MinioJsonRPCService {

Config config = ConfigProvider.getConfig();

@NonBlocking
public String getMinioConsoleUrl() {
return config.getOptionalValue("quarkus.minio.console", String.class).orElse(null);
}

@NonBlocking
public JsonObject getLoginDetails() {
return JsonObject.of(
"accesskey", config.getOptionalValue("quarkus.minio.access-key", String.class).orElse(null),
"secretkey", config.getOptionalValue("quarkus.minio.secret-key", String.class).orElse(null));
}
}
14 changes: 14 additions & 0 deletions nbactions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>CUSTOM-skipTests</actionName>
<displayName>skipTests</displayName>
<goals>
<goal>clean</goal>
<goal>install</goal>
</goals>
<properties>
<skipTests>true</skipTests>
</properties>
</action>
</actions>

0 comments on commit 9862b62

Please sign in to comment.