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

Add new Dev UI card #242

Merged
merged 1 commit into from
Jun 21, 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
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) {

Check notice

Code scanning / CodeQL

Useless parameter

The parameter 'configuration' is never used.

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));
}
}