From 699f323335e68cb6a008716b7aa9ae03157a3d91 Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Tue, 5 Dec 2023 10:31:26 +1100 Subject: [PATCH] clean up dev ui code Signed-off-by: Phillip Kruger --- .../main/resources/dev-ui/qwc-aiservices.js | 44 ++--------- .../resources/dev-ui/qwc-embedding-store.js | 39 ++-------- .../src/main/resources/dev-ui/qwc-tools.js | 74 ++++--------------- 3 files changed, 27 insertions(+), 130 deletions(-) diff --git a/core/deployment/src/main/resources/dev-ui/qwc-aiservices.js b/core/deployment/src/main/resources/dev-ui/qwc-aiservices.js index 5d4d11c95..12a10a29e 100644 --- a/core/deployment/src/main/resources/dev-ui/qwc-aiservices.js +++ b/core/deployment/src/main/resources/dev-ui/qwc-aiservices.js @@ -1,14 +1,5 @@ -import { LitElement, html, css} from 'lit'; -import { JsonRpc } from 'jsonrpc'; -import '@vaadin/icon'; -import '@vaadin/button'; -import '@vaadin/text-field'; -import '@vaadin/text-area'; -import '@vaadin/form-layout'; -import '@vaadin/progress-bar'; -import '@vaadin/checkbox'; +import { LitElement, html} from 'lit'; import '@vaadin/grid'; -import 'qui-alert'; import { columnBodyRenderer } from '@vaadin/grid/lit.js'; import '@vaadin/grid/vaadin-grid-sort-column.js'; @@ -17,31 +8,12 @@ import {aiservices} from 'build-time-data'; export class QwcAiservices extends LitElement { - static styles = css` - .button { - cursor: pointer; - } - .clearIcon { - color: orange; - } - .message { - padding: 15px; - text-align: center; - margin-left: 20%; - margin-right: 20%; - border: 2px solid orange; - border-radius: 10px; - font-size: large; - } - `; - static properties = { "_aiservices": {state: true}, - "_message": {state: true} } - connectedCallback() { - super.connectedCallback(); + constructor() { + super(); this._aiservices = aiservices; } @@ -49,18 +21,18 @@ export class QwcAiservices extends LitElement { if (this._aiservices) { return this._renderAiServiceTable(); } else { - return html`Loading AI services...`; + return html`No AI services found`; } } _renderAiServiceTable() { return html` - ${this._message} - - + - + diff --git a/core/deployment/src/main/resources/dev-ui/qwc-embedding-store.js b/core/deployment/src/main/resources/dev-ui/qwc-embedding-store.js index a6e3e765b..a2fe714c9 100644 --- a/core/deployment/src/main/resources/dev-ui/qwc-embedding-store.js +++ b/core/deployment/src/main/resources/dev-ui/qwc-embedding-store.js @@ -1,12 +1,8 @@ -import { LitElement, html, css} from 'lit'; +import { LitElement, html} from 'lit'; import { JsonRpc } from 'jsonrpc'; -import '@vaadin/icon'; import '@vaadin/button'; import '@vaadin/text-field'; import '@vaadin/text-area'; -import '@vaadin/form-layout'; -import '@vaadin/progress-bar'; -import '@vaadin/checkbox'; import '@vaadin/grid'; import 'qui-alert'; import { columnBodyRenderer } from '@vaadin/grid/lit.js'; @@ -17,33 +13,11 @@ export class QwcEmbeddingStore extends LitElement { jsonRpc = new JsonRpc(this); - static styles = css` - .button { - cursor: pointer; - } - .clearIcon { - color: orange; - } - .message { - padding: 15px; - text-align: center; - margin-left: 20%; - margin-right: 20%; - border: 2px solid orange; - border-radius: 10px; - font-size: large; - } - `; - static properties = { "_addEmbeddingConfirmation": {state: true}, "_relevantEmbeddingsOutput": {state: true} } - connectedCallback() { - super.connectedCallback(); - } - render() { return html`

Add a new embedding

@@ -92,11 +66,11 @@ export class QwcEmbeddingStore extends LitElement { this._relevantEmbeddingsOutput = ''; this.jsonRpc.findRelevant({text: text, limit: limit}).then(jsonRpcResponse => { this._relevantEmbeddingsOutput = html` - - - - - + + + + + `; }); @@ -115,7 +89,6 @@ export class QwcEmbeddingStore extends LitElement { } _embeddingMatchMetadataRenderer(match) { - // return html`${ match.metadata }` if (match.metadata && match.metadata.length > 0) { return html` ${match.metadata.map((entry) => diff --git a/core/deployment/src/main/resources/dev-ui/qwc-tools.js b/core/deployment/src/main/resources/dev-ui/qwc-tools.js index 4c75f9cb3..d0a31ce1d 100644 --- a/core/deployment/src/main/resources/dev-ui/qwc-tools.js +++ b/core/deployment/src/main/resources/dev-ui/qwc-tools.js @@ -1,15 +1,5 @@ -import { LitElement, html, css} from 'lit'; -import { JsonRpc } from 'jsonrpc'; -import '@vaadin/icon'; -import '@vaadin/button'; -import '@vaadin/text-field'; -import '@vaadin/text-area'; -import '@vaadin/form-layout'; -import '@vaadin/progress-bar'; -import '@vaadin/checkbox'; +import { LitElement, html} from 'lit'; import '@vaadin/grid'; -import 'qui-alert'; -import { columnBodyRenderer } from '@vaadin/grid/lit.js'; import '@vaadin/grid/vaadin-grid-sort-column.js'; import {tools} from 'build-time-data'; @@ -17,30 +7,12 @@ import {tools} from 'build-time-data'; export class QwcTools extends LitElement { - static styles = css` - .button { - cursor: pointer; - } - .clearIcon { - color: orange; - } - .message { - padding: 15px; - text-align: center; - margin-left: 20%; - margin-right: 20%; - border: 2px solid orange; - border-radius: 10px; - font-size: large; - } - `; - static properties = { "_tools": {state: true}, } - connectedCallback() { - super.connectedCallback(); + constructor() { + super(); this._tools = tools; } @@ -48,47 +20,27 @@ export class QwcTools extends LitElement { if (this._tools) { return this._renderToolTable(); } else { - return html`Loading tools...`; + return html`No tools found`; } } _renderToolTable() { return html` - + + + + path="name" + header="Tool name"> - - + path="description" + header="Description"> `; } - _actionRenderer(tool) { - return html` - this._reset(ds)} class="button"> - Reset - `; - } - - _classNameRenderer(tool) { - return html`${tool.className}`; - } - - - _nameRenderer(tool) { - return html`${tool.name}`; - } - - _descriptionRenderer(tool) { - return html`${tool.description}`; - } - } customElements.define('qwc-tools', QwcTools); \ No newline at end of file