dev-ui.config-component.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of timefold-solver-quarkus-deployment Show documentation
Show all versions of timefold-solver-quarkus-deployment Show documentation
Quarkus deployment module for timefold-solver-quarkus.
The newest version!
import {css, html, LitElement} from 'lit';
import {JsonRpc} from 'jsonrpc';
import '@vaadin/icon';
import '@vaadin/button';
import {until} from 'lit/directives/until.js';
import '@vaadin/grid';
import '@vaadin/grid/vaadin-grid-sort-column.js';
import {columnBodyRenderer} from '@vaadin/grid/lit.js';
export class ConfigComponent extends LitElement {
jsonRpc = new JsonRpc("Timefold Solver");
// Component style
static styles = css`
.button {
background-color: transparent;
cursor: pointer;
}
.clearIcon {
color: orange;
}
`;
// Component properties
static properties = {
"_config": {state: true}
}
// Components callbacks
/**
* Called when displayed
*/
connectedCallback() {
super.connectedCallback();
this.jsonRpc.getConfig().then(jsonRpcResponse => {
this._config = jsonRpcResponse.result.config;
});
}
/**
* Called when it needs to render the components
* @returns {*}
*/
render() {
return html`${until(this._renderConfig(), html`Loading config...`)}`;
}
// View / Templates
_renderConfig() {
if (this._config) {
let config = this._config;
const keys = Object.keys(config);
if (keys.length === 1) {
return html`
${config[keys[0]]}
`;
} else {
return html`
`;
}
}
}
_configRenderer(key) {
let content = this._config[key];
return html`
${key}
${content}
`;
}
}
customElements.define('config-component', ConfigComponent);